Skip to content

Commit 0f9d886

Browse files
authored
Merge pull request #6095 from BitGo/coin-3872-nft-consolidation-script
feat: add NFT consolidation script
2 parents e8694a6 + 9a37718 commit 0f9d886

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { BitGo, Wallet } from 'bitgo';
2+
3+
// change this to env: 'production' when you are ready for production
4+
const bitgo = new BitGo({ env: 'test' });
5+
6+
// this can be retrieved by logging into app.bitgo-test.com (app.bitgo.com for production)
7+
// and going to: User > User Settings > Access Tokens > (+ icon)
8+
// the token will need Spender permission
9+
const accessToken = '';
10+
11+
// change this to 'apt' when you are ready for production
12+
const coin = 'tapt';
13+
const walletId = '';
14+
const walletPassphrase = '';
15+
16+
// this will need to be a real OTP code on production
17+
const otp = '000000';
18+
19+
async function main() {
20+
bitgo.authenticateWithAccessToken({ accessToken });
21+
22+
const wallet: Wallet = await bitgo.coin(coin).wallets().get({ id: walletId });
23+
if (!wallet) {
24+
throw new Error('Failed to retrieve wallet');
25+
}
26+
27+
// we have to unlock this session since we're sending funds
28+
const unlock = await bitgo.unlock({ otp, duration: 3600 });
29+
if (!unlock) {
30+
throw new Error('Unlock failed');
31+
}
32+
33+
const sendConsolidations = await wallet.sendAccountConsolidations({
34+
walletPassphrase,
35+
consolidateAddresses: [''],
36+
nftCollectionId: '',
37+
nftId: '',
38+
});
39+
console.dir(sendConsolidations, { depth: 6 });
40+
}
41+
42+
main().catch((e) => console.error(e));

modules/sdk-core/src/bitgo/wallet/iWallet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ export interface PrebuildTransactionOptions {
145145
comment?: string;
146146
[index: string]: unknown;
147147
tokenName?: string;
148+
nftCollectionId?: string;
149+
nftId?: string;
148150
enableTokens?: TokenEnablement[];
149151
nonce?: string;
150152
preview?: boolean;

modules/sdk-core/src/bitgo/wallet/wallet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ export class Wallet implements IWallet {
216216
prebuildConsolidateAccountParams(): string[] {
217217
return [
218218
'consolidateAddresses',
219+
'nftCollectionId',
220+
'nftId',
219221
'feeRate',
220222
'maxFeeRate',
221223
'memo',

0 commit comments

Comments
 (0)