Skip to content

Commit 478d5e1

Browse files
feat: call route handler on eve client for recovery
1 parent acc36e2 commit 478d5e1

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

src/api/enclaved/recoveryMultisigTransaction.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// TODO: based on the original signMultisigTransaction.ts file.
2-
// Added this one because things like verify transaction doesn't seems to be present during recovery (in my limited experience)
3-
// But I want to commit something that could be fused later on with the normal signing
4-
51
import { SignFinalOptions } from '@bitgo/abstract-eth';
62
import { MethodNotImplementedError } from 'bitgo';
73
import { EnclavedApiSpecRouteRequest } from '../../enclavedBitgoExpress/routers/enclavedApiSpec';

src/masterBitgoExpress/enclavedExpressClient.ts

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import superagent from 'superagent';
2-
import https from 'https';
3-
import debug from 'debug';
4-
import { MasterExpressConfig } from '../types';
5-
import { TlsMode } from '../types';
61
import { SignedTransaction, TransactionPrebuild } from '@bitgo/sdk-core';
2+
import debug from 'debug';
3+
import https from 'https';
4+
import superagent from 'superagent';
5+
import { MasterExpressConfig, TlsMode } from '../types';
76

87
const debugLogger = debug('bitgo:express:enclavedExpressClient');
98

@@ -29,6 +28,18 @@ interface SignMultisigOptions {
2928
pub: string;
3029
}
3130

31+
interface RecoveryMultisigOptions {
32+
userPub: string;
33+
backupPub: string;
34+
walletContractAddress: string;
35+
recoveryDestinationAddress: string;
36+
apiKey: string;
37+
recoveryParams?: {
38+
bitgoPub?: string;
39+
ignoreAddressTypes: string[];
40+
};
41+
}
42+
3243
export class EnclavedExpressClient {
3344
private readonly baseUrl: string;
3445
private readonly enclavedExpressCert: string;
@@ -134,6 +145,27 @@ export class EnclavedExpressClient {
134145
throw err;
135146
}
136147
}
148+
149+
/**
150+
* Recovery a multisig transaction
151+
*/
152+
async recoveryMultisig(params: RecoveryMultisigOptions): Promise<SignedTransaction> {
153+
if (!this.coin) {
154+
throw new Error('Coin must be specified to recovery a multisig');
155+
}
156+
157+
try {
158+
const res = await this.configureRequest(
159+
superagent.post(`${this.baseUrl}/api/${this.coin}/multisig/recovery`).type('json'),
160+
).send(params);
161+
162+
return res.body;
163+
} catch (error) {
164+
const err = error as Error;
165+
debugLogger('Failed to recover multisig: %s', err.message);
166+
throw err;
167+
}
168+
}
137169
}
138170

139171
/**

src/masterBitgoExpress/recoveryWallet.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ export async function handleRecoveryWalletOnPrem(
2828
} = req.body;
2929

3030
try {
31-
const fullSignedRecoveryTx = await enclavedExpressClient.multisigRecovery({
32-
coin,
31+
const fullSignedRecoveryTx = await enclavedExpressClient.recoveryMultisig({
3332
userPub,
3433
backupPub,
3534
walletContractAddress,
36-
recoveryDestination: recoveryDestinationAddress,
35+
recoveryDestinationAddress,
3736
apiKey,
3837
recoveryParams,
3938
});

0 commit comments

Comments
 (0)