Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions modules/sdk-coin-canton/src/canton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
VerifyTransactionOptions,
TransactionExplanation as BaseTransactionExplanation,
BaseTransaction,
PopulatedIntent,
PrebuildTransactionWithIntentOptions,
} from '@bitgo/sdk-core';
import { auditEddsaPrivateKey } from '@bitgo/sdk-lib-mpc';
import { BaseCoin as StaticsBaseCoin, coins } from '@bitgo/statics';
Expand Down Expand Up @@ -173,4 +175,11 @@ export class Canton extends BaseCoin {
}
auditEddsaPrivateKey(prv, publicKey ?? '');
}

/** @inheritDoc */
setCoinSpecificFieldsInIntent(intent: PopulatedIntent, params: PrebuildTransactionWithIntentOptions): void {
if (params.txRequestId) {
intent.txRequestId = params.txRequestId;
}
}
}
16 changes: 15 additions & 1 deletion modules/sdk-core/src/bitgo/utils/mpcUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,21 @@ export abstract class MpcUtils {
);
}

if (!['acceleration', 'fillNonce', 'transferToken', 'tokenApproval', 'customTx'].includes(params.intentType)) {
if (['transferAccept', 'transferReject'].includes(params.intentType) && baseCoin.getFamily() === 'canton') {
assert(params.txRequestId, `'txRequestId' is required parameter for ${params.intentType} intent`);
}

if (
![
'acceleration',
'fillNonce',
'transferToken',
'tokenApproval',
'customTx',
'transferAccept',
'transferReject',
].includes(params.intentType)
) {
assert(params.recipients, `'recipients' is a required parameter for ${params.intentType} intent`);
}
const intentRecipients = params.recipients?.map((recipient) => {
Expand Down
2 changes: 2 additions & 0 deletions modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export interface PrebuildTransactionWithIntentOptions extends IntentOptionsBase
functionArguments?: any[];
abi?: any;
};
txRequestId?: string;
}
export interface IntentRecipient {
address: {
Expand Down Expand Up @@ -336,6 +337,7 @@ export interface PopulatedIntent extends PopulatedIntentBase {
* Custom Aptos transaction for use with the customTx intent type.
*/
aptosCustomTransactionParams?: aptosCustomTransactionParams;
txRequestId?: string;
}

export type TxRequestState =
Expand Down
1 change: 1 addition & 0 deletions modules/sdk-core/src/bitgo/wallet/iWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export interface PrebuildTransactionOptions {
functionArguments?: any[];
abi?: any;
};
txRequestId?: string;
}

export interface PrebuildAndSignTransactionOptions extends PrebuildTransactionOptions, WalletSignTransactionOptions {
Expand Down
24 changes: 24 additions & 0 deletions modules/sdk-core/src/bitgo/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3499,6 +3499,30 @@ export class Wallet implements IWallet {
params.preview
);
break;
case 'transferAccept': {
txRequest = await this.tssUtils!.prebuildTxWithIntent(
{
reqId,
intentType: 'transferAccept',
txRequestId: params.txRequestId,
},
apiVersion,
params.preview
);
break;
}
case 'transferReject': {
txRequest = await this.tssUtils!.prebuildTxWithIntent(
{
reqId,
intentType: 'transferReject',
txRequestId: params.txRequestId,
},
apiVersion,
params.preview
);
break;
}
case 'customTx':
txRequest = await this.tssUtils!.prebuildTxWithIntent(
{
Expand Down