Skip to content

Commit 99915c4

Browse files
committed
fix: fund forwarders script
TICKET: COIN-3571
1 parent 7d5fa6d commit 99915c4

File tree

5 files changed

+72
-5
lines changed

5 files changed

+72
-5
lines changed

CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
/modules/sdk-coin-xtz/ @BitGo/ethalt-team
8686
/modules/sdk-coin-zketh/ @BitGo/ethalt-team
8787

88+
# Examples
89+
/examples/ @BitGo/ethalt-team
90+
8891
# Trade
8992
/modules/sdk-core/src/bitgo/address-book/ @BitGo/prime
9093
/modules/sdk-core/src/bitgo/trading/ @BitGo/prime

examples/ts/apt/fund-forwarders.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Send funds from a gas tank to a BitGo wallet's receive address.
3+
*
4+
* Copyright 2025, BitGo, Inc. All Rights Reserved.
5+
*/
6+
import { BitGoAPI } from '@bitgo/sdk-api';
7+
import { Tapt } from '@bitgo/sdk-coin-apt';
8+
import { FundForwarderParams } from '@bitgo/sdk-core';
9+
10+
const bitgo = new BitGoAPI({
11+
accessToken: '<access token>',
12+
env: 'test',
13+
});
14+
15+
const coin = 'tapt';
16+
bitgo.register(coin, Tapt.createInstance);
17+
18+
const walletId = '<wallet id>';
19+
20+
async function main() {
21+
bitgo.unlock({ otp: '000000' });
22+
const walletInstance = await bitgo.coin(coin).wallets().get({ id: walletId });
23+
24+
const fundForwarderParams: FundForwarderParams = {
25+
forwarders: [
26+
{
27+
forwarderAddress: '<forwarder address>',
28+
amount: '<amount>' // optional field
29+
},
30+
],
31+
}
32+
33+
const response = await walletInstance.fundForwarders(fundForwarderParams);
34+
console.log('Response', response);
35+
}
36+
37+
main().catch((e) => console.error(e));

examples/ts/eth/fund-forwarder.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { FundForwarderParams } from "@bitgo/sdk-core";
2+
13
/**
24
* Send funds from a fee address to a forwarder.
35
*
@@ -28,12 +30,16 @@ async function fundForwarder() {
2830
bitgo.authenticateWithAccessToken({ accessToken });
2931
const wallet = await bitgo.coin(coin).wallets().get({ id: walletId });
3032

31-
const fundForwarderOptions = {
32-
forwarderAddress: forwarderAddress,
33-
amount: amount,
34-
};
33+
const fundForwarderParams: FundForwarderParams = {
34+
forwarders: [
35+
{
36+
forwarderAddress,
37+
amount, // optional field
38+
},
39+
],
40+
}
3541

36-
const response = await wallet.fundForwarder(fundForwarderOptions);
42+
const response = await wallet.fundForwarders(fundForwarderParams);
3743
console.log('Response', response);
3844
}
3945

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ export interface FundForwardersOptions {
433433
amount?: string;
434434
}
435435

436+
export interface FundForwarderParams {
437+
forwarders: FundForwardersOptions[];
438+
}
439+
436440
export interface FlushForwarderTokenOptions {
437441
address?: string;
438442
id?: string;

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import {
9999
BulkWalletShareKeychain,
100100
ManageUnspentReservationOptions,
101101
SignAndSendTxRequestOptions,
102+
FundForwarderParams,
102103
} from './iWallet';
103104
import { GoStakingWallet, StakingWallet } from '../staking';
104105
import { Lightning } from '../lightning/custodial';
@@ -3640,6 +3641,22 @@ export class Wallet implements IWallet {
36403641
return this._wallet;
36413642
}
36423643

3644+
/**
3645+
* Send funds from a fee address to a forwarder.
3646+
*
3647+
* @param {Object} params - parameters object
3648+
* @param {List} params.forwarders - list of fund forwarder options
3649+
* @returns {*}
3650+
*/
3651+
public async fundForwarders(params: FundForwarderParams): Promise<any> {
3652+
if (_.isUndefined(params.forwarders) || params.forwarders.length == 0) {
3653+
throw new Error('fund forwarder options required');
3654+
}
3655+
const url = this.url('/fundforwarders');
3656+
this._wallet = await this.bitgo.post(url).send(params).result();
3657+
return this._wallet;
3658+
}
3659+
36433660
/**
36443661
* Gets forwarder's balance
36453662
* @param params - optional query parameters

0 commit comments

Comments
 (0)