Skip to content
Draft
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
12 changes: 6 additions & 6 deletions modules/bitgo/test/v2/unit/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4199,12 +4199,12 @@ describe('V2 Wallet:', function () {
prebuildAndSignTransaction.calledOnceWithExactly(sendManyInput);

const sendTxRequest = sandbox.stub(TssUtils.prototype, 'sendTxRequest');
sendTxRequest.resolves('sendTxResponse');
sendTxRequest.resolves(undefined);
// TODO(BG-59686): this is not doing anything if we don't check the return value, we should also move this check to happen after we invoke sendMany
sendTxRequest.calledOnceWithExactly(signedTransaction.txRequestId);

const sendMany = await tssSolWallet.sendMany(sendManyInput);
sendMany.should.deepEqual('sendTxResponse');
sendMany.should.deepEqual(undefined);
});

it('should send many and call setRequestTracer', async function () {
Expand All @@ -4217,14 +4217,14 @@ describe('V2 Wallet:', function () {
prebuildAndSignTransaction.calledOnceWithExactly(sendManyInput);

const sendTxRequest = sandbox.stub(TssUtils.prototype, 'sendTxRequest');
sendTxRequest.resolves('sendTxResponse');
sendTxRequest.resolves(undefined);
sendTxRequest.calledOnceWithExactly(signedTransaction.txRequestId);

const setRequestTracerSpy = sinon.spy(bitgo, 'setRequestTracer');
setRequestTracerSpy.withArgs(sendManyInput.reqId);

const sendMany = await tssSolWallet.sendMany(sendManyInput);
sendMany.should.deepEqual('sendTxResponse');
sendMany.should.deepEqual(undefined);
sinon.assert.calledOnce(setRequestTracerSpy);
setRequestTracerSpy.restore();
});
Expand Down Expand Up @@ -5040,7 +5040,7 @@ describe('V2 Wallet:', function () {
// stub all steps after txrequest creation
sinon.stub(adaWallet.baseCoin, 'verifyTransaction').resolves(true);
sinon.stub(adaWallet, 'signTransaction').resolves({ txRequestId: 'txRequestId' });
sinon.stub(BaseTssUtils.default.prototype, 'sendTxRequest').resolves('sendTxResponse');
sinon.stub(BaseTssUtils.default.prototype, 'sendTxRequest').resolves(undefined);
await adaWallet.sendMany(sendManyParams);
});

Expand Down Expand Up @@ -5081,7 +5081,7 @@ describe('V2 Wallet:', function () {

sinon.stub(adaWallet.baseCoin, 'verifyTransaction').resolves(true);
sinon.stub(adaWallet, 'signTransaction').resolves({ txRequestId: 'txRequestId' });
sinon.stub(BaseTssUtils.default.prototype, 'sendTxRequest').resolves('sendTxResponse');
sinon.stub(BaseTssUtils.default.prototype, 'sendTxRequest').resolves(undefined);
await adaWallet.sendMany(sendManyParams).should.be.resolved();
});
});
Expand Down
9 changes: 6 additions & 3 deletions modules/sdk-core/src/bitgo/utils/tss/baseTSSUtils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { IRequestTracer } from '../../../api';
import * as openpgp from 'openpgp';
import * as _ from 'lodash';

import { type TxSendResponse } from '@bitgo/public-types';

import { IRequestTracer } from '../../../api';
import { Key, readKey, SerializedKeyPair } from 'openpgp';
import { IBaseCoin, KeychainsTriplet } from '../../baseCoin';
import { BitGoBase } from '../../bitgoBase';
import { Keychain, KeyIndices } from '../../keychain';
import { getTxRequest } from '../../tss';
import { IWallet } from '../../wallet';
import { MpcUtils } from '../mpcUtils';
import * as _ from 'lodash';
import {
BitgoGPGPublicKey,
BitgoHeldBackupKeyShare,
Expand Down Expand Up @@ -514,7 +517,7 @@ export default class BaseTssUtils<KeyShare> extends MpcUtils implements ITssUtil
* @returns {Promise<any>}
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async sendTxRequest(txRequestId: string, reqId?: IRequestTracer): Promise<any> {
async sendTxRequest(txRequestId: string, reqId?: IRequestTracer): Promise<TxSendResponse | undefined> {
const reqTracer = reqId || new RequestTracer();
this.bitgo.setRequestTracer(reqTracer);
return this.bitgo
Expand Down
22 changes: 21 additions & 1 deletion modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { Key, SerializedKeyPair } from 'openpgp';

import { type TxSendResponse } from '@bitgo/public-types';
import { type EcdsaTypes } from '@bitgo/sdk-lib-mpc';

import { IRequestTracer } from '../../../api';
import { KeychainsTriplet, ParsedTransaction, TransactionParams } from '../../baseCoin';
import { ApiKeyShare, Keychain } from '../../keychain';
import { ApiVersion, Memo, WalletType } from '../../wallet';
import { EDDSA, GShare, Signature, SignShare } from '../../../account-lib/mpc/tss';
import { Signature as EcdsaSignature } from '../../../account-lib/mpc/tss/ecdsa/types';
import { KeyShare } from './ecdsa';
import { EcdsaTypes } from '@bitgo/sdk-lib-mpc';
import { TssEcdsaStep1ReturnMessage, TssEcdsaStep2ReturnMessage, TxRequestChallengeResponse } from '../../tss/types';
import { AShare, DShare, SShare } from '../../tss/ecdsa/types';
import { MessageStandardType } from '../messageTypes';
import { PendingApprovalData } from '../../pendingApproval';

export type TxRequestVersion = 'full' | 'lite';
export interface HopParams {
Expand Down Expand Up @@ -368,6 +372,22 @@ export type SignedTx = {
signature?: string;
};

export type TxRequestTransfer = { state: string; pendingApproval?: string; txid?: string };

export type SendManyTxRequestResponse =
| {
txRequest: TxRequest;
pendingApproval: PendingApprovalData;
}
| {
transfer: TxRequestTransfer;
txRequest: TxRequest;
txid?: SignedTx['id'];
tx?: SignedTx['tx'];
status: TxRequestTransfer['state'];
}
| TxSendResponse;

export type TxRequest = {
txRequestId: string;
walletId: string;
Expand Down
6 changes: 4 additions & 2 deletions modules/sdk-core/src/bitgo/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ import {
IntentOptionsForTypedData,
RequestTracer,
RequestType,
SendManyTxRequestResponse,
TokenTransferRecipientParams,
TokenType,
TxRequest,
TxRequestTransfer,
} from '../utils';
import {
AccelerateTransactionOptions,
Expand Down Expand Up @@ -3807,7 +3809,7 @@ export class Wallet implements IWallet {
*
* @param params send options
*/
private async sendManyTxRequests(params: SendManyOptions = {}): Promise<any> {
private async sendManyTxRequests(params: SendManyOptions = {}): Promise<SendManyTxRequestResponse | undefined> {
params.apiVersion = getTxRequestApiVersion(this, params.apiVersion);

const signedTransaction = (await this.prebuildAndSignTransaction(params)) as SignedTransactionRequest;
Expand All @@ -3819,7 +3821,7 @@ export class Wallet implements IWallet {
const latestTxRequest = await getTxRequest(this.bitgo, this.id(), signedTransaction.txRequestId, params.reqId);
const reqId = params.reqId || new RequestTracer();
this.bitgo.setRequestTracer(reqId);
const transfer: { state: string; pendingApproval?: string; txid?: string } = await this.bitgo
const transfer: TxRequestTransfer = await this.bitgo
.post(
this.bitgo.url(
'/wallet/' + this._wallet.id + '/txrequests/' + signedTransaction.txRequestId + '/transfers',
Expand Down
Loading