Skip to content

Commit 35b7953

Browse files
author
Karan
committed
feat: pass custodianTransaction and messageId
Ticket: BG-59497
1 parent b517867 commit 35b7953

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

modules/bitgo/test/v2/unit/wallet.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,31 @@ describe('V2 Wallet:', function () {
19211921
intent.isTss!.should.equal(true);
19221922
intent.intentType.should.equal('fillNonce');
19231923
});
1924+
1925+
it('should populate intent with custodianTransactionId', async function () {
1926+
const mpcUtils = new ECDSAUtils.EcdsaUtils(bitgo, bitgo.coin('gteth'));
1927+
const feeOptions = {
1928+
maxFeePerGas: 3000000000,
1929+
maxPriorityFeePerGas: 2000000000,
1930+
};
1931+
const nonce = '1';
1932+
1933+
const intent = mpcUtils.populateIntent(bitgo.coin('gteth'), {
1934+
custodianTransactionId: 'unittest',
1935+
reqId,
1936+
intentType: 'fillNonce',
1937+
nonce,
1938+
feeOptions,
1939+
isTss: true,
1940+
});
1941+
1942+
intent.custodianTransactionId!.should.equal('unittest');
1943+
intent.should.have.property('recipients', undefined);
1944+
intent.feeOptions!.should.deepEqual(feeOptions);
1945+
intent.nonce!.should.equal(nonce);
1946+
intent.isTss!.should.equal(true);
1947+
intent.intentType.should.equal('fillNonce');
1948+
});
19241949
});
19251950

19261951
describe('Transaction signing', function () {
@@ -1946,6 +1971,7 @@ describe('V2 Wallet:', function () {
19461971
});
19471972
});
19481973

1974+
19491975
it('should fail to sign transaction without txRequestId', async function () {
19501976
const txPrebuild = {
19511977
walletId: tssWallet.id(),
@@ -1965,7 +1991,7 @@ describe('V2 Wallet:', function () {
19651991
txRequestId: 'id',
19661992
transactions: [],
19671993
intent: {
1968-
intentType: 'payment',
1994+
intentType: 'signMessage',
19691995
},
19701996
date: new Date().toISOString(),
19711997
latest: true,
@@ -2020,6 +2046,23 @@ describe('V2 Wallet:', function () {
20202046
actualArg.messagePrebuild.message.should.equal(`\u0019Ethereum Signed Message:\\n${message.length}${message}`);
20212047
});
20222048

2049+
it('should sign message when custodianMessageId is provided', async function () {
2050+
const signMessageTssSpy = sinon.spy(tssEthWallet, 'signMessageTss' as any);
2051+
nock(bgUrl)
2052+
.post(`/api/v2/wallet/${tssEthWallet.id()}/txrequests`)
2053+
.reply(200, txRequestForMessageSigning);
2054+
2055+
const signMessage = await tssEthWallet.signMessage({
2056+
custodianMessageId: 'unittest',
2057+
reqId,
2058+
messagePrebuild: { message },
2059+
prv: 'secretKey',
2060+
});
2061+
signMessage.should.deepEqual({ txRequestId } );
2062+
const actualArg = signMessageTssSpy.getCalls()[0].args[0];
2063+
actualArg.messagePrebuild.message.should.equal(`\u0019Ethereum Signed Message:\\n${message.length}${message}`);
2064+
});
2065+
20232066
it('should sign message when txRequestId not provided', async function () {
20242067
const signMessageTssSpy = sinon.spy(tssEthWallet, 'signMessageTss' as any);
20252068
nock(bgUrl)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export abstract class MpcUtils {
143143
hopParams: params.hopParams,
144144
isTss: params.isTss,
145145
nonce: params.nonce,
146+
custodianTransactionId: params.custodianTransactionId,
146147
};
147148
case 'acceleration':
148149
return {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ export interface IntentOptionsBase {
6363
isTss?: boolean;
6464
comment?: string;
6565
memo?: Memo;
66+
custodianTransactionId?: string;
67+
custodianMessageId?: string;
6668
}
69+
6770
export interface PrebuildTransactionWithIntentOptions extends IntentOptionsBase {
6871
recipients?: {
6972
address: string;
@@ -107,6 +110,8 @@ export interface PopulatedIntent extends PopulatedIntentBase {
107110
feeOptions?: FeeOption | EIP1559FeeOptions;
108111
hopParams?: HopParams;
109112
txid?: string;
113+
custodianTransactionId?: string;
114+
custodianMessageId?: string;
110115
}
111116

112117
export type TxRequestState =

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export interface PrebuildTransactionOptions {
103103
gasLimit?: number;
104104
lowFeeTxid?: string;
105105
isTss?: boolean;
106+
custodianTransactionId?: string;
106107
}
107108

108109
export interface PrebuildAndSignTransactionOptions extends PrebuildTransactionOptions, WalletSignTransactionOptions {
@@ -147,6 +148,7 @@ export interface WalletSignTransactionOptions extends WalletSignBaseOptions {
147148

148149
export interface WalletSignMessageOptions extends WalletSignBaseOptions {
149150
messagePrebuild?: MessagePrebuild;
151+
custodianMessageId?: string;
150152
}
151153

152154
export interface GetUserPrvOptions {
@@ -441,6 +443,7 @@ export interface SendManyOptions extends PrebuildAndSignTransactionOptions {
441443
[index: string]: unknown;
442444
eip1559?: EIP1559;
443445
gasLimit?: number;
446+
custodianTransactionId?: string;
444447
}
445448

446449
export type WalletType = 'backing' | 'cold' | 'custodial' | 'custodialPaired' | 'hot' | 'trading';

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ export class Wallet implements IWallet {
15681568
}
15691569

15701570
/**
1571-
* Sign a message using TSS (not implemented for hot wallets)
1571+
* Sign a message using TSS
15721572
* @param params
15731573
* - messagePrebuild
15741574
* - [keychain / key] (object) or prv (string)
@@ -2684,6 +2684,7 @@ export class Wallet implements IWallet {
26842684
assert(params.messagePrebuild);
26852685
if (!params.messagePrebuild.txRequestId) {
26862686
const intentOption: IntentOptionsBase = {
2687+
custodianMessageId: params.custodianMessageId,
26872688
reqId: params.reqId,
26882689
intentType: 'signmessage',
26892690
isTss: true,

0 commit comments

Comments
 (0)