Skip to content

Commit 0b883e1

Browse files
authored
Merge pull request #36 from BitGo/WP-4769
feat: improved typing for recovery musig
2 parents fccaff0 + d5f2f5a commit 0b883e1

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/api/enclaved/recoveryMultisigTransaction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { MethodNotImplementedError } from 'bitgo';
33
import { EnclavedApiSpecRouteRequest } from '../../enclavedBitgoExpress/routers/enclavedApiSpec';
44
import logger from '../../logger';
55
import { isEthLikeCoin } from '../../shared/coinUtils';
6+
import { HalfSignedEthLikeRecoveryTx } from '../../types/transaction';
67
import { retrieveKmsKey } from './utils';
78

89
export async function recoveryMultisigTransaction(
@@ -36,7 +37,7 @@ export async function recoveryMultisigTransaction(
3637
walletContractAddress,
3738
});
3839

39-
const { halfSigned } = halfSignedTx as any;
40+
const { halfSigned } = halfSignedTx as HalfSignedEthLikeRecoveryTx;
4041
const fullSignedTx = await coin.signTransaction({
4142
isLastSignature: true,
4243
prv: backupPrv,

src/enclavedBitgoExpress/routers/enclavedApiSpec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ const RecoveryMultisigRequest = {
5858
userPub: t.string,
5959
backupPub: t.string,
6060
apiKey: t.string,
61-
// TODO: best typing for this, they come from sdk TS types
6261
unsignedSweepPrebuildTx: t.any,
62+
walletContractAddress: t.string,
6363
coinSpecificParams: t.union([
6464
t.undefined,
6565
t.partial({
@@ -71,8 +71,9 @@ const RecoveryMultisigRequest = {
7171

7272
// Response type for /multisig/recovery endpoint
7373
const RecoveryMultisigResponse: HttpResponse = {
74-
// TODO: Define proper response type for recovery multisig transaction
75-
200: t.any, // the full signed tx
74+
200: t.type({
75+
txHex: t.string,
76+
}), // the full signed tx
7677
500: t.type({
7778
error: t.string,
7879
details: t.string,

src/masterBitgoExpress/routers/masterApiSpec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export const SendManyResponse: HttpResponse = {
9090
// Response type for /recovery endpoint
9191
const RecoveryWalletResponse: HttpResponse = {
9292
// TODO: Get type from public types repo
93-
200: t.any,
93+
200: t.type({
94+
txHex: t.string, // the full signed transaction hex
95+
}),
9496
500: t.type({
9597
error: t.string,
9698
details: t.string,

src/types/transaction.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { type Recipient, type SignedTransaction } from 'bitgo';
2+
3+
export type HalfSignedEthLikeRecoveryTx = SignedTransaction & {
4+
halfSigned: {
5+
signatures?: string;
6+
recipients?: Recipient[];
7+
signingKeyNonce?: number;
8+
backupKeyNonce?: number;
9+
};
10+
};

0 commit comments

Comments
 (0)