Skip to content

Commit 11848da

Browse files
feat(mbe): fix comments
1 parent 8aff26f commit 11848da

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/api/master/handlers/recoveryConsolidationsWallet.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { MasterApiSpecRouteRequest } from '../routers/masterApiSpec';
22
import logger from '../../../logger';
3-
import { isSolCoin, isTrxCoin } from '../../../shared/coinUtils';
4-
import { MPCSweepTxs, MPCTx, MPCTxs } from 'bitgo';
3+
import { isSolCoin } from '../../../shared/coinUtils';
4+
import { MPCTx } from 'bitgo';
55
import { RecoveryTransaction } from '@bitgo/sdk-coin-trx';
66

77
// Handler for recovery from receive addresses (consolidation sweeps)
@@ -16,34 +16,32 @@ export async function handleRecoveryConsolidationsOnPrem(
1616

1717
const sdkCoin = bitgo.coin(coin);
1818
let txs: MPCTx[] | RecoveryTransaction[] = [];
19-
20-
logger.debug(
21-
`${isSolCoin(sdkCoin) ? 'Solana' : isTrxCoin(sdkCoin) ? 'Tron' : 'Unknown'} recovery`,
22-
);
23-
2419
// 1. Build unsigned consolidations
25-
if (isSolCoin(sdkCoin)) {
26-
const result = await sdkCoin.recoverConsolidations({
27-
...req.decoded,
28-
userKey: userPub,
29-
backupKey: backupPub,
30-
bitgoKey,
31-
durableNonces: req.decoded.durableNonces!,
32-
});
20+
if (isSolCoin(sdkCoin) && !req.decoded.durableNonces) {
21+
throw new Error('durableNonces is required for Solana consolidation recovery');
22+
}
23+
24+
if (typeof (sdkCoin as any).recoverConsolidations !== 'function') {
25+
throw new Error(`recoverConsolidations is not supported for coin: ${coin}`);
26+
}
3327

34-
txs = (result as MPCTxs).transactions || (result as MPCSweepTxs).txRequests || [];
35-
} else if (isTrxCoin(sdkCoin)) {
36-
const result = await sdkCoin.recoverConsolidations({
37-
...req.decoded,
38-
userKey: userPub,
39-
backupKey: backupPub,
40-
bitgoKey,
41-
});
28+
// Use type assertion to access recoverConsolidations
29+
const result = await (sdkCoin as any).recoverConsolidations({
30+
...req.decoded,
31+
userKey: userPub,
32+
backupKey: backupPub,
33+
bitgoKey,
34+
durableNonces: req.decoded.durableNonces,
35+
});
4236

37+
if ('transactions' in result) {
4338
txs = result.transactions;
39+
} else if ('txRequests' in result) {
40+
txs = result.txRequests;
41+
} else {
42+
throw new Error('recoverConsolidations did not return expected transactions');
4443
}
4544

46-
console.log(txs);
4745
logger.debug(`Found ${txs.length} unsigned consolidation transactions`);
4846

4947
// 2. For each unsigned sweep, get it signed by EBE (using recoveryMultisig)

src/api/master/routers/masterApiSpec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ export const MasterApiSpec = apiSpec({
306306
}),
307307
response: RecoveryConsolidationsResponse,
308308
description: 'Recover consolidations from receive addresses',
309-
})
310-
}
309+
}),
310+
},
311311
});
312312

313313
export type MasterApiSpec = typeof MasterApiSpec;

0 commit comments

Comments
 (0)