@@ -2839,10 +2839,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
28392839 async verifyTssTransaction ( params : VerifyEthTransactionOptions ) : Promise < boolean > {
28402840 const { txParams, txPrebuild, wallet } = params ;
28412841
2842- const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
2843-
28442842 // Helper to throw TxIntentMismatchRecipientError with recipient details
2845- const throwRecipientMismatch = ( message : string , mismatchedRecipients : Recipient [ ] ) : never => {
2843+ const throwRecipientMismatch = async ( message : string , mismatchedRecipients : Recipient [ ] ) : Promise < never > => {
2844+ const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
28462845 throw new TxIntentMismatchRecipientError (
28472846 message ,
28482847 undefined ,
@@ -2881,12 +2880,13 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
28812880 const txJson = tx . toJson ( ) ;
28822881 if ( txJson . data === '0x' ) {
28832882 if ( expectedAmount !== txJson . value ) {
2884- throwRecipientMismatch ( 'the transaction amount in txPrebuild does not match the value given by client' , [
2885- { address : txJson . to , amount : txJson . value } ,
2886- ] ) ;
2883+ await throwRecipientMismatch (
2884+ 'the transaction amount in txPrebuild does not match the value given by client' ,
2885+ [ { address : txJson . to , amount : txJson . value } ]
2886+ ) ;
28872887 }
28882888 if ( expectedDestination . toLowerCase ( ) !== txJson . to . toLowerCase ( ) ) {
2889- throwRecipientMismatch ( 'destination address does not match with the recipient address' , [
2889+ await throwRecipientMismatch ( 'destination address does not match with the recipient address' , [
28902890 { address : txJson . to , amount : txJson . value } ,
28912891 ] ) ;
28922892 }
@@ -2916,13 +2916,14 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
29162916 }
29172917
29182918 if ( expectedTokenAmount !== amount . toString ( ) ) {
2919- throwRecipientMismatch ( 'the transaction amount in txPrebuild does not match the value given by client' , [
2920- { address : addHexPrefix ( recipientAddress . toString ( ) ) , amount : amount . toString ( ) } ,
2921- ] ) ;
2919+ await throwRecipientMismatch (
2920+ 'the transaction amount in txPrebuild does not match the value given by client' ,
2921+ [ { address : addHexPrefix ( recipientAddress . toString ( ) ) , amount : amount . toString ( ) } ]
2922+ ) ;
29222923 }
29232924
29242925 if ( expectedRecipientAddress !== addHexPrefix ( recipientAddress . toString ( ) ) . toLowerCase ( ) ) {
2925- throwRecipientMismatch ( 'destination address does not match with the recipient address' , [
2926+ await throwRecipientMismatch ( 'destination address does not match with the recipient address' , [
29262927 { address : addHexPrefix ( recipientAddress . toString ( ) ) , amount : amount . toString ( ) } ,
29272928 ] ) ;
29282929 }
@@ -2952,10 +2953,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
29522953 return this . verifyTssTransaction ( params ) ;
29532954 }
29542955
2955- const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
2956-
29572956 // Helper to throw TxIntentMismatchRecipientError with recipient details
2958- const throwRecipientMismatch = ( message : string , mismatchedRecipients : Recipient [ ] ) : never => {
2957+ const throwRecipientMismatch = async ( message : string , mismatchedRecipients : Recipient [ ] ) : Promise < never > => {
2958+ const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
29592959 throw new TxIntentMismatchRecipientError (
29602960 message ,
29612961 undefined ,
@@ -2993,7 +2993,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
29932993 const expectedHopAddress = optionalDeps . ethUtil . stripHexPrefix ( decodedHopTx . getSenderAddress ( ) . toString ( ) ) ;
29942994 const actualHopAddress = optionalDeps . ethUtil . stripHexPrefix ( txPrebuild . recipients [ 0 ] . address ) ;
29952995 if ( expectedHopAddress . toLowerCase ( ) !== actualHopAddress . toLowerCase ( ) ) {
2996- throwRecipientMismatch ( 'recipient address of txPrebuild does not match hop address' , [
2996+ await throwRecipientMismatch ( 'recipient address of txPrebuild does not match hop address' , [
29972997 { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ,
29982998 ] ) ;
29992999 }
@@ -3013,17 +3013,18 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
30133013 if ( txParams . tokenName ) {
30143014 const expectedTotalAmount = new BigNumber ( 0 ) ;
30153015 if ( ! expectedTotalAmount . isEqualTo ( txPrebuild . recipients [ 0 ] . amount ) ) {
3016- throwRecipientMismatch ( 'batch token transaction amount in txPrebuild should be zero for token transfers' , [
3017- { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ,
3018- ] ) ;
3016+ await throwRecipientMismatch (
3017+ 'batch token transaction amount in txPrebuild should be zero for token transfers' ,
3018+ [ { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ]
3019+ ) ;
30193020 }
30203021 } else {
30213022 let expectedTotalAmount = new BigNumber ( 0 ) ;
30223023 for ( let i = 0 ; i < recipients . length ; i ++ ) {
30233024 expectedTotalAmount = expectedTotalAmount . plus ( recipients [ i ] . amount ) ;
30243025 }
30253026 if ( ! expectedTotalAmount . isEqualTo ( txPrebuild . recipients [ 0 ] . amount ) ) {
3026- throwRecipientMismatch (
3027+ await throwRecipientMismatch (
30273028 'batch transaction amount in txPrebuild received from BitGo servers does not match txParams supplied by client' ,
30283029 [ { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ]
30293030 ) ;
@@ -3036,7 +3037,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
30363037 ! batcherContractAddress ||
30373038 batcherContractAddress . toLowerCase ( ) !== txPrebuild . recipients [ 0 ] . address . toLowerCase ( )
30383039 ) {
3039- throwRecipientMismatch ( 'recipient address of txPrebuild does not match batcher address' , [
3040+ await throwRecipientMismatch ( 'recipient address of txPrebuild does not match batcher address' , [
30403041 { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ,
30413042 ] ) ;
30423043 }
@@ -3047,20 +3048,21 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
30473048 }
30483049 const expectedAmount = new BigNumber ( recipients [ 0 ] . amount ) ;
30493050 if ( ! expectedAmount . isEqualTo ( txPrebuild . recipients [ 0 ] . amount ) ) {
3050- throwRecipientMismatch (
3051+ await throwRecipientMismatch (
30513052 'normal transaction amount in txPrebuild received from BitGo servers does not match txParams supplied by client' ,
30523053 [ { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ]
30533054 ) ;
30543055 }
30553056 if ( this . isETHAddress ( recipients [ 0 ] . address ) && recipients [ 0 ] . address !== txPrebuild . recipients [ 0 ] . address ) {
3056- throwRecipientMismatch (
3057+ await throwRecipientMismatch (
30573058 'destination address in normal txPrebuild does not match that in txParams supplied by client' ,
30583059 [ { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ]
30593060 ) ;
30603061 }
30613062 }
30623063 // Check coin is correct for all transaction types
30633064 if ( ! this . verifyCoin ( txPrebuild ) ) {
3065+ const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
30643066 throw new TxIntentMismatchError (
30653067 'coin in txPrebuild did not match that in txParams supplied by client' ,
30663068 undefined ,
0 commit comments