@@ -3072,10 +3072,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
30723072 async verifyTssTransaction ( params : VerifyEthTransactionOptions ) : Promise < boolean > {
30733073 const { txParams, txPrebuild, wallet } = params ;
30743074
3075- const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
3076-
30773075 // Helper to throw TxIntentMismatchRecipientError with recipient details
3078- const throwRecipientMismatch = ( message : string , mismatchedRecipients : Recipient [ ] ) : never => {
3076+ const throwRecipientMismatch = async ( message : string , mismatchedRecipients : Recipient [ ] ) : Promise < never > => {
3077+ const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
30793078 throw new TxIntentMismatchRecipientError (
30803079 message ,
30813080 undefined ,
@@ -3114,12 +3113,13 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
31143113 const txJson = tx . toJson ( ) ;
31153114 if ( txJson . data === '0x' ) {
31163115 if ( expectedAmount !== txJson . value ) {
3117- throwRecipientMismatch ( 'the transaction amount in txPrebuild does not match the value given by client' , [
3118- { address : txJson . to , amount : txJson . value } ,
3119- ] ) ;
3116+ await throwRecipientMismatch (
3117+ 'the transaction amount in txPrebuild does not match the value given by client' ,
3118+ [ { address : txJson . to , amount : txJson . value } ]
3119+ ) ;
31203120 }
31213121 if ( expectedDestination . toLowerCase ( ) !== txJson . to . toLowerCase ( ) ) {
3122- throwRecipientMismatch ( 'destination address does not match with the recipient address' , [
3122+ await throwRecipientMismatch ( 'destination address does not match with the recipient address' , [
31233123 { address : txJson . to , amount : txJson . value } ,
31243124 ] ) ;
31253125 }
@@ -3149,13 +3149,14 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
31493149 }
31503150
31513151 if ( expectedTokenAmount !== amount . toString ( ) ) {
3152- throwRecipientMismatch ( 'the transaction amount in txPrebuild does not match the value given by client' , [
3153- { address : addHexPrefix ( recipientAddress . toString ( ) ) , amount : amount . toString ( ) } ,
3154- ] ) ;
3152+ await throwRecipientMismatch (
3153+ 'the transaction amount in txPrebuild does not match the value given by client' ,
3154+ [ { address : addHexPrefix ( recipientAddress . toString ( ) ) , amount : amount . toString ( ) } ]
3155+ ) ;
31553156 }
31563157
31573158 if ( expectedRecipientAddress !== addHexPrefix ( recipientAddress . toString ( ) ) . toLowerCase ( ) ) {
3158- throwRecipientMismatch ( 'destination address does not match with the recipient address' , [
3159+ await throwRecipientMismatch ( 'destination address does not match with the recipient address' , [
31593160 { address : addHexPrefix ( recipientAddress . toString ( ) ) , amount : amount . toString ( ) } ,
31603161 ] ) ;
31613162 }
@@ -3185,10 +3186,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
31853186 return this . verifyTssTransaction ( params ) ;
31863187 }
31873188
3188- const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
3189-
31903189 // Helper to throw TxIntentMismatchRecipientError with recipient details
3191- const throwRecipientMismatch = ( message : string , mismatchedRecipients : Recipient [ ] ) : never => {
3190+ const throwRecipientMismatch = async ( message : string , mismatchedRecipients : Recipient [ ] ) : Promise < never > => {
3191+ const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
31923192 throw new TxIntentMismatchRecipientError (
31933193 message ,
31943194 undefined ,
@@ -3226,7 +3226,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
32263226 const expectedHopAddress = optionalDeps . ethUtil . stripHexPrefix ( decodedHopTx . getSenderAddress ( ) . toString ( ) ) ;
32273227 const actualHopAddress = optionalDeps . ethUtil . stripHexPrefix ( txPrebuild . recipients [ 0 ] . address ) ;
32283228 if ( expectedHopAddress . toLowerCase ( ) !== actualHopAddress . toLowerCase ( ) ) {
3229- throwRecipientMismatch ( 'recipient address of txPrebuild does not match hop address' , [
3229+ await throwRecipientMismatch ( 'recipient address of txPrebuild does not match hop address' , [
32303230 { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ,
32313231 ] ) ;
32323232 }
@@ -3246,17 +3246,18 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
32463246 if ( txParams . tokenName ) {
32473247 const expectedTotalAmount = new BigNumber ( 0 ) ;
32483248 if ( ! expectedTotalAmount . isEqualTo ( txPrebuild . recipients [ 0 ] . amount ) ) {
3249- throwRecipientMismatch ( 'batch token transaction amount in txPrebuild should be zero for token transfers' , [
3250- { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ,
3251- ] ) ;
3249+ await throwRecipientMismatch (
3250+ 'batch token transaction amount in txPrebuild should be zero for token transfers' ,
3251+ [ { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ]
3252+ ) ;
32523253 }
32533254 } else {
32543255 let expectedTotalAmount = new BigNumber ( 0 ) ;
32553256 for ( let i = 0 ; i < recipients . length ; i ++ ) {
32563257 expectedTotalAmount = expectedTotalAmount . plus ( recipients [ i ] . amount ) ;
32573258 }
32583259 if ( ! expectedTotalAmount . isEqualTo ( txPrebuild . recipients [ 0 ] . amount ) ) {
3259- throwRecipientMismatch (
3260+ await throwRecipientMismatch (
32603261 'batch transaction amount in txPrebuild received from BitGo servers does not match txParams supplied by client' ,
32613262 [ { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ]
32623263 ) ;
@@ -3269,7 +3270,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
32693270 ! batcherContractAddress ||
32703271 batcherContractAddress . toLowerCase ( ) !== txPrebuild . recipients [ 0 ] . address . toLowerCase ( )
32713272 ) {
3272- throwRecipientMismatch ( 'recipient address of txPrebuild does not match batcher address' , [
3273+ await throwRecipientMismatch ( 'recipient address of txPrebuild does not match batcher address' , [
32733274 { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ,
32743275 ] ) ;
32753276 }
@@ -3280,20 +3281,21 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
32803281 }
32813282 const expectedAmount = new BigNumber ( recipients [ 0 ] . amount ) ;
32823283 if ( ! expectedAmount . isEqualTo ( txPrebuild . recipients [ 0 ] . amount ) ) {
3283- throwRecipientMismatch (
3284+ await throwRecipientMismatch (
32843285 'normal transaction amount in txPrebuild received from BitGo servers does not match txParams supplied by client' ,
32853286 [ { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ]
32863287 ) ;
32873288 }
32883289 if ( this . isETHAddress ( recipients [ 0 ] . address ) && recipients [ 0 ] . address !== txPrebuild . recipients [ 0 ] . address ) {
3289- throwRecipientMismatch (
3290+ await throwRecipientMismatch (
32903291 'destination address in normal txPrebuild does not match that in txParams supplied by client' ,
32913292 [ { address : txPrebuild . recipients [ 0 ] . address , amount : txPrebuild . recipients [ 0 ] . amount . toString ( ) } ]
32923293 ) ;
32933294 }
32943295 }
32953296 // Check coin is correct for all transaction types
32963297 if ( ! this . verifyCoin ( txPrebuild ) ) {
3298+ const txExplanation = await this . getTxExplanation ( txPrebuild ) ;
32973299 throw new TxIntentMismatchError (
32983300 'coin in txPrebuild did not match that in txParams supplied by client' ,
32993301 undefined ,
0 commit comments