@@ -10,6 +10,7 @@ import { OfflineVaultTxInfo, optionalDeps, SignTransactionOptions } from '@bitgo
1010import { Opeth , Topeth , TransactionBuilder , TransferBuilder } from '../../src/index' ;
1111import * as mockData from '../fixtures/opeth' ;
1212import { getBuilder } from '../getBuilder' ;
13+ import { EthereumNetwork } from '@bitgo/statics' ;
1314
1415nock . enableNetConnect ( ) ;
1516
@@ -578,6 +579,105 @@ describe('Optimism', function () {
578579 . verifyTransaction ( { txParams, txPrebuild, wallet, verification } )
579580 . should . be . rejectedWith ( 'coin in txPrebuild did not match that in txParams supplied by client' ) ;
580581 } ) ;
582+
583+ it ( 'should verify a txPrebuild with more than one recipient in case of token batch transfer' , async function ( ) {
584+ const wallet = new Wallet ( bitgo , basecoin , { } ) ;
585+
586+ const txParams = {
587+ tokenName : 'topeth:terc18dp' ,
588+ recipients : [
589+ { amount : '1' , address : address1 } ,
590+ { amount : '2' , address : address2 } ,
591+ { amount : '3' , address : address2 } ,
592+ ] ,
593+ wallet : wallet ,
594+ walletPassphrase : 'fakeWalletPassphrase' ,
595+ } ;
596+
597+ const txPrebuild = {
598+ recipients : [
599+ { amount : '0' , address : ( basecoin ?. staticsCoin ?. network as EthereumNetwork ) . batcherContractAddress } ,
600+ ] ,
601+ nextContractSequenceId : 0 ,
602+ gasPrice : 20000000000 ,
603+ gasLimit : 500000 ,
604+ isBatch : true ,
605+ coin : 'topeth' ,
606+ walletId : 'fakeWalletId' ,
607+ walletContractAddress : 'fakeWalletContractAddress' ,
608+ } ;
609+
610+ const verification = { } ;
611+
612+ const isTransactionVerified = await basecoin . verifyTransaction ( { txParams, txPrebuild, wallet, verification } ) ;
613+ isTransactionVerified . should . equal ( true ) ;
614+ } ) ;
615+
616+ it ( 'should reject a txPrebuild with more than one recipient in case of token batch transfer with wrong amount' , async function ( ) {
617+ const wallet = new Wallet ( bitgo , basecoin , { } ) ;
618+
619+ const txParams = {
620+ tokenName : 'topeth:terc18dp' ,
621+ recipients : [
622+ { amount : '1' , address : address1 } ,
623+ { amount : '2' , address : address2 } ,
624+ { amount : '3' , address : address2 } ,
625+ ] ,
626+ wallet : wallet ,
627+ walletPassphrase : 'fakeWalletPassphrase' ,
628+ } ;
629+
630+ const txPrebuild = {
631+ recipients : [
632+ { amount : '6' , address : ( basecoin ?. staticsCoin ?. network as EthereumNetwork ) . batcherContractAddress } ,
633+ ] ,
634+ nextContractSequenceId : 0 ,
635+ gasPrice : 20000000000 ,
636+ gasLimit : 500000 ,
637+ isBatch : true ,
638+ coin : 'topeth' ,
639+ walletId : 'fakeWalletId' ,
640+ walletContractAddress : 'fakeWalletContractAddress' ,
641+ } ;
642+
643+ const verification = { } ;
644+
645+ await basecoin
646+ . verifyTransaction ( { txParams, txPrebuild, wallet, verification } )
647+ . should . be . rejectedWith ( `batch token transaction amount in txPrebuild should be zero for token transfers` ) ;
648+ } ) ;
649+
650+ it ( 'should reject a txPrebuild with more than one recipient in case of token batch transfer with wrong batcher contract address' , async function ( ) {
651+ const wallet = new Wallet ( bitgo , basecoin , { } ) ;
652+
653+ const txParams = {
654+ tokenName : 'topeth:terc18dp' ,
655+ recipients : [
656+ { amount : '1' , address : address1 } ,
657+ { amount : '2' , address : address2 } ,
658+ { amount : '3' , address : address2 } ,
659+ ] ,
660+ wallet : wallet ,
661+ walletPassphrase : 'fakeWalletPassphrase' ,
662+ } ;
663+
664+ const txPrebuild = {
665+ recipients : [ { amount : '0' , address : 'fakeContractAddress' } ] ,
666+ nextContractSequenceId : 0 ,
667+ gasPrice : 20000000000 ,
668+ gasLimit : 500000 ,
669+ isBatch : true ,
670+ coin : 'topeth' ,
671+ walletId : 'fakeWalletId' ,
672+ walletContractAddress : 'fakeWalletContractAddress' ,
673+ } ;
674+
675+ const verification = { } ;
676+
677+ await basecoin
678+ . verifyTransaction ( { txParams, txPrebuild, wallet, verification } )
679+ . should . be . rejectedWith ( `recipient address of txPrebuild does not match batcher address` ) ;
680+ } ) ;
581681 } ) ;
582682
583683 describe ( 'Recover transaction:' , function ( ) {
0 commit comments