Skip to content

Commit e806070

Browse files
authored
Merge pull request #6000 from BitGo/COIN-3815-build-rpc-call-fix
2 parents 8018bd7 + b98a353 commit e806070

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

modules/sdk-coin-apt/src/lib/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ export const DIGITAL_ASSET_TRANSFER_FUNCTION = '0x1::object::transfer';
1919
export const APTOS_COIN = '0x1::aptos_coin::AptosCoin';
2020
export const FUNGIBLE_ASSET_TYPE_ARGUMENT = '0x1::fungible_asset::Metadata';
2121
export const DIGITAL_ASSET_TYPE_ARGUMENT = '0x4::token::Token';
22+
23+
export const FUNBIGLE_ASSET_TYPE_TAG = '0x1::object::Object';
24+
export const BATCH_FUNGIBLE_ASSET_TYPE_TAG = '0x1::object::Object<0x1::fungible_asset::Metadata>';

modules/sdk-coin-apt/src/lib/transaction/digitalAssetTransfer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,17 @@ export class DigitalAssetTransfer extends Transaction {
4747
protected getTransactionPayloadData(): InputGenerateTransactionPayloadData {
4848
const recipientAddress = AccountAddress.fromString(this.recipients[0].address);
4949
const digitalAssetAddress = AccountAddress.fromString(this._assetId);
50-
const transferDigitalAssetAbi: EntryFunctionABI = {
51-
typeParameters: [{ constraints: [MoveAbility.KEY] }],
52-
parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))), new TypeTagAddress()],
53-
};
5450

5551
return {
5652
function: DIGITAL_ASSET_TRANSFER_FUNCTION,
5753
typeArguments: [DIGITAL_ASSET_TYPE_ARGUMENT],
5854
functionArguments: [digitalAssetAddress, recipientAddress],
59-
abi: transferDigitalAssetAbi,
55+
abi: this.transferDigitalAssetAbi,
6056
};
6157
}
58+
59+
private transferDigitalAssetAbi: EntryFunctionABI = {
60+
typeParameters: [{ constraints: [MoveAbility.KEY] }],
61+
parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))), new TypeTagAddress()],
62+
};
6263
}

modules/sdk-coin-apt/src/lib/transaction/fungibleAssetTransfer.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import {
88
TransactionPayloadEntryFunction,
99
TypeTagAddress,
1010
TypeTagU64,
11+
TypeTagVector,
1112
} from '@aptos-labs/ts-sdk';
1213
import { InvalidTransactionError, TransactionType } from '@bitgo/sdk-core';
1314
import { BaseCoin as CoinConfig } from '@bitgo/statics';
1415
import {
1516
FUNGIBLE_ASSET_TYPE_ARGUMENT,
1617
FUNGIBLE_ASSET_TRANSFER_FUNCTION,
1718
FUNGIBLE_ASSET_BATCH_TRANSFER_FUNCTION,
19+
FUNBIGLE_ASSET_TYPE_TAG,
20+
BATCH_FUNGIBLE_ASSET_TYPE_TAG,
1821
} from '../constants';
1922
import utils from '../utils';
2023

@@ -37,10 +40,6 @@ export class FungibleAssetTransfer extends Transaction {
3740

3841
protected getTransactionPayloadData(): InputGenerateTransactionPayloadData {
3942
const fungibleTokenAddress = this._assetId;
40-
const faTransferAbi: EntryFunctionABI = {
41-
typeParameters: [{ constraints: [] }],
42-
parameters: [parseTypeTag('0x1::object::Object'), new TypeTagAddress(), new TypeTagU64()],
43-
};
4443

4544
if (this.recipients.length > 1) {
4645
return {
@@ -51,6 +50,7 @@ export class FungibleAssetTransfer extends Transaction {
5150
this.recipients.map((recipient) => AccountAddress.fromString(recipient.address)),
5251
this.recipients.map((recipient) => recipient.amount),
5352
],
53+
abi: this.batchFaTransferAbi,
5454
};
5555
}
5656
return {
@@ -61,7 +61,7 @@ export class FungibleAssetTransfer extends Transaction {
6161
AccountAddress.fromString(this.recipients[0].address),
6262
this.recipients[0].amount,
6363
],
64-
abi: faTransferAbi,
64+
abi: this.faTransferAbi,
6565
};
6666
}
6767

@@ -74,4 +74,17 @@ export class FungibleAssetTransfer extends Transaction {
7474
FUNGIBLE_ASSET_TYPE_ARGUMENT === payload.entryFunction.type_args[0].toString()))
7575
);
7676
}
77+
private faTransferAbi: EntryFunctionABI = {
78+
typeParameters: [{ constraints: [] }],
79+
parameters: [parseTypeTag(FUNBIGLE_ASSET_TYPE_TAG), new TypeTagAddress(), new TypeTagU64()],
80+
};
81+
82+
private batchFaTransferAbi: EntryFunctionABI = {
83+
typeParameters: [],
84+
parameters: [
85+
parseTypeTag(BATCH_FUNGIBLE_ASSET_TYPE_TAG),
86+
new TypeTagVector(new TypeTagAddress()),
87+
new TypeTagVector(new TypeTagU64()),
88+
],
89+
};
7790
}

modules/sdk-coin-apt/src/lib/transaction/transferTransaction.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import { Transaction } from './transaction';
22
import { InvalidTransactionError, TransactionType } from '@bitgo/sdk-core';
33
import {
44
AccountAddress,
5+
EntryFunctionABI,
56
InputGenerateTransactionPayloadData,
67
TransactionPayload,
78
TransactionPayloadEntryFunction,
9+
TypeTagAddress,
10+
TypeTagU64,
11+
TypeTagVector,
812
} from '@aptos-labs/ts-sdk';
913

1014
import { BaseCoin as CoinConfig } from '@bitgo/statics';
@@ -38,12 +42,14 @@ export class TransferTransaction extends Transaction {
3842
this.recipients.map((recipient) => AccountAddress.fromString(recipient.address)),
3943
this.recipients.map((recipient) => recipient.amount),
4044
],
45+
abi: this.batchCoinTransferAbi,
4146
};
4247
}
4348
return {
4449
function: COIN_TRANSFER_FUNCTION,
4550
typeArguments: [this.assetId],
4651
functionArguments: [AccountAddress.fromString(this.recipients[0].address), this.recipients[0].amount],
52+
abi: this.coinTransferAbi,
4753
};
4854
}
4955

@@ -55,4 +61,14 @@ export class TransferTransaction extends Transaction {
5561
payload.entryFunction.type_args[0].toString().length > 0
5662
);
5763
}
64+
65+
private coinTransferAbi: EntryFunctionABI = {
66+
typeParameters: [{ constraints: [] }],
67+
parameters: [new TypeTagAddress(), new TypeTagU64()],
68+
};
69+
70+
private batchCoinTransferAbi: EntryFunctionABI = {
71+
typeParameters: [{ constraints: [] }],
72+
parameters: [new TypeTagVector(new TypeTagAddress()), new TypeTagVector(new TypeTagU64())],
73+
};
5874
}

0 commit comments

Comments
 (0)