Skip to content

refactor: wallet generation handler to use new sdk callback#234

Merged
danielpeng1 merged 2 commits into
masterfrom
WCN-684/wallet-generation-with-callback
Jun 12, 2026
Merged

refactor: wallet generation handler to use new sdk callback#234
danielpeng1 merged 2 commits into
masterfrom
WCN-684/wallet-generation-with-callback

Conversation

@danielpeng1

Copy link
Copy Markdown
Contributor

Refactored onchain wallet generation to delegate key creation to the SDK via createKeychainCallback

  • Added createOnchainKeyGenCallback wrapping AWM createIndependentKeychain for user/backup keys
  • Replaced manual key orchestration in handleGenerateOnChainWallet with generateWallet({ createKeychainCallback })
  • Updated generateWallet.test.ts nocks for SDK behaviour. generateWallet.integ.test.ts as well. Tests all pass (npm test, npm run docker:test:integration)
  • Updated versions of @bitgo-beta/sdk-api and @bitgo-beta/sdk-core to include the sdk callback support change.

Ticket: WCN-684

@danielpeng1 danielpeng1 self-assigned this Jun 11, 2026
@linear-code

linear-code Bot commented Jun 11, 2026

Copy link
Copy Markdown

WCN-684

@danielpeng1 danielpeng1 force-pushed the WCN-684/wallet-generation-with-callback branch from d50953c to a02f341 Compare June 11, 2026 16:07
@danielpeng1 danielpeng1 force-pushed the WCN-684/wallet-generation-with-callback branch from a02f341 to c74f277 Compare June 11, 2026 16:17
@danielpeng1 danielpeng1 marked this pull request as ready for review June 11, 2026 16:31
@danielpeng1 danielpeng1 requested review from a team as code owners June 11, 2026 16:31
n: 3,
keys: [],
type: 'advanced',
type: 'advanced' as 'cold',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is 'advanced' cast to 'cold' -- does generateWallet not accept 'advanced' in its type union?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah SDK types allow type?: 'hot' | 'cold' | 'custodial' | 'trading' while our API expects type: 'advanced'

would adding advanced to the sdk types be more preferred?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would adding advanced to the sdk types be more preferred

yeah, imo, we should add it, as it's a valid wallet type now! 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumped sdk here includes this change

awmBackupClient: AdvancedWalletManagerClient,
): CreateKeychainCallback {
return async ({ source, coin }) => {
const client = source === 'user' ? awmUserClient : awmBackupClient;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any non-'user' source (including 'bitgo') silently routes to the backup client -- should this throw on unexpected sources?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the generateWalletWithExternalSigner i created the sdk only invokes the callback for user and backup keys; although you're right that I think this is still worth an explicit guard to throw

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throwing on any other source now

awmBackupClient: AdvancedWalletManagerClient,
): CreateKeychainCallback {
return async ({ source, coin }) => {
const client = source === 'user' ? awmUserClient : awmBackupClient;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use KeySource.USER here, we have a lot of those hard coded things from the past, but we can do better going forward 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done; maybe we can change them all sometime

@danielpeng1 danielpeng1 Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a short test file for just wallet gen callbacks, avoids clogging up generateWallet.test.ts

@pranishnepal pranishnepal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me ✅

@danielpeng1 danielpeng1 merged commit 5c2c744 into master Jun 12, 2026
21 checks passed
@danielpeng1 danielpeng1 deleted the WCN-684/wallet-generation-with-callback branch June 12, 2026 16:32
pranishnepal added a commit that referenced this pull request Jun 12, 2026
Remove all conflict markers and keep both approaches:
- Callback approach from PR #234 for sync onchain path
- getBaseWalletParams for TSS and worker paths

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants