|
1 | 1 | import { BaseCoin, BitGoBase, common, MPCAlgorithm, MultisigType, multisigTypes } from '@bitgo/sdk-core'; |
2 | 2 | import { BaseCoin as StaticsBaseCoin, coins } from '@bitgo/statics'; |
3 | | -import { AbstractEthLikeNewCoins, recoveryBlockchainExplorerQuery } from '@bitgo/abstract-eth'; |
| 3 | +import { |
| 4 | + AbstractEthLikeNewCoins, |
| 5 | + recoveryBlockchainExplorerQuery, |
| 6 | + VerifyEthTransactionOptions, |
| 7 | +} from '@bitgo/abstract-eth'; |
4 | 8 | import { TransactionBuilder } from './lib'; |
5 | 9 |
|
6 | 10 | export class Bsc extends AbstractEthLikeNewCoins { |
@@ -41,4 +45,34 @@ export class Bsc extends AbstractEthLikeNewCoins { |
41 | 45 | const explorerUrl = common.Environments[this.bitgo.getEnv()].bscscanBaseUrl; |
42 | 46 | return await recoveryBlockchainExplorerQuery(query, explorerUrl as string, apiToken); |
43 | 47 | } |
| 48 | + |
| 49 | + /** |
| 50 | + * Verify if a tss transaction is valid |
| 51 | + * |
| 52 | + * @param {VerifyEthTransactionOptions} params |
| 53 | + * @param {TransactionParams} params.txParams - params object passed to send |
| 54 | + * @param {TransactionPrebuild} params.txPrebuild - prebuild object returned by server |
| 55 | + * @param {Wallet} params.wallet - Wallet object to obtain keys to verify against |
| 56 | + * @returns {boolean} |
| 57 | + */ |
| 58 | + async verifyTssTransaction(params: VerifyEthTransactionOptions): Promise<boolean> { |
| 59 | + const { txParams, txPrebuild, wallet } = params; |
| 60 | + if ( |
| 61 | + !txParams?.recipients && |
| 62 | + !( |
| 63 | + txParams.prebuildTx?.consolidateId || |
| 64 | + (txParams.type && ['acceleration', 'fillNonce', 'transferToken'].includes(txParams.type)) |
| 65 | + ) |
| 66 | + ) { |
| 67 | + throw new Error(`missing txParams`); |
| 68 | + } |
| 69 | + if (!wallet || !txPrebuild) { |
| 70 | + throw new Error(`missing params`); |
| 71 | + } |
| 72 | + if (txParams.hop && txParams.recipients && txParams.recipients.length > 1) { |
| 73 | + throw new Error(`tx cannot be both a batch and hop transaction`); |
| 74 | + } |
| 75 | + |
| 76 | + return true; |
| 77 | + } |
44 | 78 | } |
0 commit comments