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
40 changes: 40 additions & 0 deletions modules/bitgo/test/v2/unit/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4420,6 +4420,27 @@ describe('V2 Wallet:', function () {
txRequest.should.deepEqual(txRequestForMessageSigning);
});

it('should include preparedTransaction in the msgrequests body when provided', async function () {
const preparedTransaction = 'base64-prepared-transaction-bytes';
let capturedBody: any;
nock(bgUrl)
.post(`/api/v2/wallet/${tssEthWallet.id()}/msgrequests`, (body) => {
capturedBody = body;
return true;
})
.reply(200, txRequestForMessageSigning);

await tssEthWallet.buildSignMessageRequest({
message: {
messageRaw,
messageStandardType: MessageStandardType.EIP191,
preparedTransaction,
},
});

capturedBody.intent.preparedTransaction.should.equal(preparedTransaction);
});

it(`[${coinName}] should sign message`, async function () {
const signMessageTssSpy = sinon.spy(tssEthWallet, 'signMessageTss' as any);
nock(bgUrl)
Expand Down Expand Up @@ -4475,6 +4496,25 @@ describe('V2 Wallet:', function () {
);
});

it(`[${coinName}] should include preparedTransaction when signing a fresh message request`, async function () {
const preparedTransaction = 'base64-prepared-transaction-bytes';
let capturedBody: any;
nock(bgUrl)
.post(`/api/v2/wallet/${tssEthWallet.id()}/msgrequests`, (body) => {
capturedBody = body;
return true;
})
.reply(200, txRequestForMessageSigning);

await tssEthWallet.signMessage({
reqId,
message: { messageRaw, messageStandardType: MessageStandardType.EIP191, preparedTransaction },
prv: 'secretKey',
});

capturedBody.intent.preparedTransaction.should.equal(preparedTransaction);
});

it('should fail to sign message with empty prv', async function () {
await tssEthWallet
.signMessage({
Expand Down
2 changes: 2 additions & 0 deletions modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ export interface Message extends BaseSignable {
messageEncoded?: string;
messageStandardType?: MessageStandardType;
signerAddress?: string;
/** Base64-encoded prepared transaction bytes required by Canton message signing. */
preparedTransaction?: string;
}

export interface MessageTypeProperty {
Expand Down
1 change: 1 addition & 0 deletions modules/sdk-core/src/bitgo/utils/tss/baseTSSUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ export default class BaseTssUtils<KeyShare> extends MpcUtils implements ITssUtil
messageStandardType: params.messageStandardType ?? MessageStandardType.UNKNOWN,
messageEncoded: params.messageEncoded ?? '',
signerAddress: params.signerAddress,
preparedTransaction: params.preparedTransaction,
};

return this.buildSignMessageRequestBase(intent, apiVersion, params.reqId);
Expand Down
4 changes: 4 additions & 0 deletions modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ export interface IntentOptionsForMessage extends IntentOptionsBase {
messageEncoded?: string;
messageStandardType?: MessageStandardType;
signerAddress?: string;
/** Base64-encoded prepared transaction bytes required by Canton message signing. */
preparedTransaction?: string;
}

export interface IntentOptionsForTypedData extends IntentOptionsBase {
Expand Down Expand Up @@ -417,6 +419,8 @@ export interface PopulatedIntentForMessageSigning extends PopulatedIntentBase {
custodianMessageId?: string;
messageStandardType?: MessageStandardType;
signerAddress?: string;
/** Base64-encoded prepared transaction bytes required by Canton message signing. */
preparedTransaction?: string;
}

export interface PopulatedIntentForTypedDataSigning extends PopulatedIntentBase {
Expand Down
2 changes: 2 additions & 0 deletions modules/sdk-core/src/bitgo/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,7 @@ export class Wallet implements IWallet {
messageRaw,
messageStandardType,
signerAddress: params.message.signerAddress,
preparedTransaction: params.message.preparedTransaction,
};

if (!this.tssUtils) {
Expand Down Expand Up @@ -5143,6 +5144,7 @@ export class Wallet implements IWallet {
messageRaw,
messageStandardType: params.message.messageStandardType,
signerAddress: params.message.signerAddress,
preparedTransaction: params.message.preparedTransaction,
};
txRequest = await this.tssUtils!.buildSignMessageRequest(intentOption);
params.message.txRequestId = txRequest.txRequestId;
Expand Down
Loading