-
Notifications
You must be signed in to change notification settings - Fork 292
feat: send digital asset #5988
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
feat: send digital asset #5988
Conversation
c4c95df
to
c3836ce
Compare
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.
please add tests for the change
@@ -2729,6 +2729,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin { | |||
return transferBuilder.build(); | |||
} | |||
} | |||
return ''; |
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.
shouldn't we throw an error here ?
Ideally we should have done it when we introduced this change
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.
Yes, I was going to do this today, thanks.
@@ -646,6 +646,7 @@ export interface SendManyOptions extends PrebuildAndSignTransactionOptions { | |||
feeLimit?: string; | |||
data?: string; | |||
tokenName?: string; | |||
tokenData?: TokenTransferRecipientParams; |
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.
what is the difference between data and tokenData ?
isn't it confusing for the user ?
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.
data
field is being populated internally here.
tokenData
field of type TokenTransferRecipientParams
is less confusing for the users than the data
field of type string. The data
field is being used specifically for eth
-like coins.
@@ -2405,7 +2407,7 @@ export class Wallet implements IWallet { | |||
if (!this.baseCoin.isValidAddress(recipientAddress)) { | |||
throw new Error(`Invalid recipient address ${recipientAddress}`); | |||
} | |||
const baseAddress = this.coinSpecific()?.baseAddress; | |||
const baseAddress = this.coinSpecific()?.baseAddress || this.coinSpecific()?.rootAddress; |
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.
can we do this.baseCoin.getBaseAddress
?
abstract the coinSpecific things
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.
case 'Digital Asset': { | ||
this.validateNftEntries(sendNftOptions.entries, nftBalance, sendNftOptions); | ||
|
||
const recipients = _.map(sendNftOptions.entries, (entry) => { |
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.
const recipients = _.map(sendNftOptions.entries, (entry) => { | |
const recipients = sendNftOptions.entries.map( (entry) => { |
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.
also what does entries mean 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.
entries: https://github.com/BitGo/BitGoJS/blob/master/modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts#L457
it denotes a list of NFT IDs and their quantity for ERC1155
type NFTs.
I'm not using entries for Aptos NFTs now.
}); | ||
return this.sendMany({ | ||
...sendOptions, | ||
recipients, |
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.
can the recipients be > 1 ?
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.
no, right now there will be just 1 recipient, using a single recipient now.
07f355b
to
4acdae2
Compare
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.
Pull Request Overview
This PR adds support for sending digital assets by extending the existing NFT transfer functionality. Key changes include:
- Extending the NFT transfer options (iBaseCoin and wallet interfaces) to include a new "Digital Asset" type.
- Adding a new case in the wallet implementation to handle digital asset transfers.
- Updating tokens and error handling logic to accommodate the new digital asset type.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
modules/sdk-core/src/bitgo/wallet/wallet.ts | Adds digital asset transfer flow and updates base address fallback logic. |
modules/sdk-core/src/bitgo/wallet/iWallet.ts | Updates SendManyOptions to include an optional tokenData field. |
modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts | Adds DIGITAL_ASSET to the TokenType enum and updates token transfer parameters. |
modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts | Expands NFT transfer types to include "Digital Asset". |
modules/abstract-eth/src/abstractEthLikeNewCoins.ts | Introduces a default case that throws an error for unsupported NFT types. |
Comments suppressed due to low confidence (2)
modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts:452
- Consider using the DIGITAL_ASSET enum value (TokenType.DIGITAL_ASSET) for consistency instead of the hardcoded string literal 'Digital Asset'.
type: 'ERC721' | 'Digital Asset';
modules/sdk-core/src/bitgo/wallet/wallet.ts:2477
- [nitpick] If digital asset transfers always use a quantity of 1, consider adding a clarifying comment or making this behavior configurable to avoid future confusion.
tokenQuantity: '1',
4acdae2
to
c40b9b8
Compare
cb86fbe
to
4c7614b
Compare
TICKET: COIN-3820
4c7614b
to
e4f9135
Compare
TICKET: COIN-3819
This pull request introduces support for a new NFT type, "Digital Asset," across the SDK. The changes include updates to type definitions, error handling, and transaction logic to accommodate this new token type.
Support for "Digital Asset" NFT type:
modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts
: UpdatedNFTTransferOptions
to include the new type,'Digital Asset'
, alongside existing NFT types.modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts
: AddedDIGITAL_ASSET
to theTokenType
enum to represent the new token type.Error handling and transaction logic:
modules/abstract-eth/src/abstractEthLikeNewCoins.ts
: Added a default case to handle unsupported NFT types, throwing an error if an unrecognized type is encountered.modules/sdk-core/src/bitgo/wallet/wallet.ts
: Enhanced theWallet
class to handle "Digital Asset" NFTs, including validation for token existence and spendable balance, and added logic to process transactions with the new type.Additional enhancements:
modules/sdk-core/src/bitgo/wallet/iWallet.ts
: Introduced a new property,tokenData
, inSendManyOptions
to support token transfer details for recipients.modules/sdk-core/src/bitgo/wallet/wallet.ts
: Updated thebaseAddress
fallback logic to includerootAddress
ifbaseAddress
is unavailable, ensuring compatibility with different wallet configurations.