-
Notifications
You must be signed in to change notification settings - Fork 300
refactor: migrated generateWallet to typed routes #7052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
refactor: migrated generateWallet to typed routes #7052
Conversation
16a0cd0
to
96dd8d5
Compare
const coin = bitgo.coin(req.decoded.coin); | ||
const result = await coin.wallets().generateWallet(req.body); | ||
if (req.query.includeKeychains === 'false') { | ||
if ((req.decoded.includeKeychains as any) === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we casting to any here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because includeKeychains
is type BooleanFromString
which has output type string so statically it is typed as a string but during runtime it is actually a boolean. I think this is because of how we setup the decoder.
Also includeKeychains
is a parameter in the request and httpRequest
requires that params
are of type string
fb1254e
to
678e891
Compare
/** If absent, BitGo uses the default wallet type for the asset */ | ||
multisigType: multisigType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command and the codec here seem to conflict. The codec makes this a required field. The comment says this should be optional.
/** The type of wallet, defined by key management and signing protocols. 'hot' and 'cold' are both self-managed wallets. If absent, defaults to 'hot' */ | ||
type: walletType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
/** Wallet label */ | ||
label: t.string, | ||
/** Enterprise id. This is required for Ethereum wallets since they can only be created as part of an enterprise */ | ||
enterprise: t.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enterprise is optional in GenerateWalletOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might actually be required, but to avoid introducing a breaking change for this change we should map the codec to what GenerateWalletOptions
defines.
added keychain codecs to a general codec file, as I assume that these codecs could be reused (but not sure if they will). refactored the UT that covered generateWallet to ensure that encoding and decoding works e2e.
TICKET: WP-5415