Skip to content

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

Merged
merged 1 commit into from
Apr 21, 2025
Merged

feat: send digital asset #5988

merged 1 commit into from
Apr 21, 2025

Conversation

bhavidhingra
Copy link
Contributor

@bhavidhingra bhavidhingra commented Apr 17, 2025

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:

Error handling and transaction logic:

Additional enhancements:

@bhavidhingra bhavidhingra requested review from a team as code owners April 17, 2025 15:44
@bhavidhingra bhavidhingra requested a review from a team as a code owner April 17, 2025 15:53
Copy link
Contributor

@mullapudipruthvik mullapudipruthvik left a 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 '';
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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 ?

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

case 'Digital Asset': {
this.validateNftEntries(sendNftOptions.entries, nftBalance, sendNftOptions);

const recipients = _.map(sendNftOptions.entries, (entry) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const recipients = _.map(sendNftOptions.entries, (entry) => {
const recipients = sendNftOptions.entries.map( (entry) => {

Copy link
Contributor

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 ?

Copy link
Contributor Author

@bhavidhingra bhavidhingra Apr 21, 2025

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,
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

@bhavidhingra bhavidhingra force-pushed the coin-3820-send-nft branch 3 times, most recently from 07f355b to 4acdae2 Compare April 21, 2025 07:20
@baltiyal baltiyal requested a review from Copilot April 21, 2025 08:35
Copy link

@Copilot Copilot AI left a 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',

@bhavidhingra bhavidhingra requested a review from a team as a code owner April 21, 2025 11:51
@bhavidhingra bhavidhingra force-pushed the coin-3820-send-nft branch 4 times, most recently from cb86fbe to 4c7614b Compare April 21, 2025 11:58
@bhavidhingra bhavidhingra merged commit 2acd35d into master Apr 21, 2025
12 checks passed
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