Skip to content

Commit 40efbfd

Browse files
chore: support tokenApproval for MPC
Ticket: COIN-4071
1 parent 9662833 commit 40efbfd

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

modules/abstract-eth/src/abstractEthLikeNewCoins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2531,7 +2531,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
25312531
!txParams?.recipients &&
25322532
!(
25332533
txParams.prebuildTx?.consolidateId ||
2534-
(txParams.type && ['acceleration', 'fillNonce', 'transferToken'].includes(txParams.type))
2534+
(txParams.type && ['acceleration', 'fillNonce', 'transferToken', 'tokenApproval'].includes(txParams.type))
25352535
)
25362536
) {
25372537
throw new Error(`missing txParams`);

modules/sdk-core/src/bitgo/utils/mpcUtils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export abstract class MpcUtils {
117117
populateIntent(baseCoin: IBaseCoin, params: PrebuildTransactionWithIntentOptions): PopulatedIntent {
118118
const chain = this.baseCoin.getChain();
119119

120-
if (!['acceleration', 'fillNonce', 'transferToken'].includes(params.intentType)) {
120+
if (!['acceleration', 'fillNonce', 'transferToken', 'tokenApproval'].includes(params.intentType)) {
121121
assert(params.recipients, `'recipients' is a required parameter for ${params.intentType} intent`);
122122
}
123123
const intentRecipients = params.recipients?.map((recipient) => {
@@ -153,6 +153,7 @@ export abstract class MpcUtils {
153153
comment: params.comment,
154154
nonce: params.nonce,
155155
recipients: intentRecipients,
156+
tokenName: params.tokenName,
156157
};
157158

158159
if (baseCoin.getFamily() === 'eth' || baseCoin.getFamily() === 'polygon' || baseCoin.getFamily() === 'bsc') {
@@ -177,6 +178,12 @@ export abstract class MpcUtils {
177178
receiveAddress: params.receiveAddress,
178179
feeOptions: params.feeOptions,
179180
};
181+
case 'tokenApproval':
182+
return {
183+
...baseIntent,
184+
tokenName: params.tokenName,
185+
feeOptions: params.feeOptions,
186+
};
180187
default:
181188
throw new Error(`Unsupported intent type ${params.intentType}`);
182189
}

modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export interface PopulatedIntent extends PopulatedIntentBase {
253253
receiveAddress?: string;
254254
custodianTransactionId?: string;
255255
custodianMessageId?: string;
256+
tokenName?: string;
256257
}
257258

258259
export type TxRequestState =

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,6 +3285,17 @@ export class Wallet implements IWallet {
32853285
params.preview
32863286
);
32873287
break;
3288+
case 'tokenApproval':
3289+
txRequest = await this.tssUtils!.prebuildTxWithIntent(
3290+
{
3291+
reqId,
3292+
intentType: 'tokenApproval',
3293+
tokenName: params.tokenName,
3294+
},
3295+
apiVersion,
3296+
params.preview
3297+
);
3298+
break;
32883299
default:
32893300
throw new Error(`transaction type not supported: ${params.type}`);
32903301
}

0 commit comments

Comments
 (0)