@@ -747,6 +747,7 @@ describe('TSS Ecdsa Utils:', async function () {
747747 backupNShare : backupKeyShare . nShares [ 1 ] ,
748748 } ) ,
749749 reqId,
750+ txParams : { recipients : [ { address : '0xrecipient' , amount : '1000' } ] } ,
750751 } ) ;
751752 signedTxRequest . unsignedTxs . should . deepEqual ( txRequest . unsignedTxs ) ;
752753 const userGpgActual = sendShareSpy . getCalls ( ) [ 0 ] . args [ 10 ] as string ;
@@ -764,12 +765,125 @@ describe('TSS Ecdsa Utils:', async function () {
764765 backupNShare : backupKeyShare . nShares [ 1 ] ,
765766 } ) ,
766767 reqId,
768+ txParams : { recipients : [ { address : '0xrecipient' , amount : '1000' } ] } ,
767769 } ) ;
768770 signedTxRequest . unsignedTxs . should . deepEqual ( txRequest . unsignedTxs ) ;
769771 const userGpgActual = sendShareSpy . getCalls ( ) [ 0 ] . args [ 10 ] as string ;
770772 userGpgActual . should . startWith ( '-----BEGIN PGP PUBLIC KEY BLOCK-----' ) ;
771773 } ) ;
772774
775+ it ( 'signTxRequest should fail when txParams is missing' , async function ( ) {
776+ await tssUtils
777+ . signTxRequest ( {
778+ txRequest,
779+ prv : JSON . stringify ( {
780+ pShare : userKeyShare . pShare ,
781+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
782+ backupNShare : backupKeyShare . nShares [ 1 ] ,
783+ } ) ,
784+ reqId,
785+ } )
786+ . should . be . rejectedWith (
787+ 'Recipient details are required to verify this transaction before signing. Pass txParams with at least one recipient.'
788+ ) ;
789+ } ) ;
790+
791+ it ( 'signTxRequest should fail when txParams has empty recipients' , async function ( ) {
792+ await tssUtils
793+ . signTxRequest ( {
794+ txRequest,
795+ prv : JSON . stringify ( {
796+ pShare : userKeyShare . pShare ,
797+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
798+ backupNShare : backupKeyShare . nShares [ 1 ] ,
799+ } ) ,
800+ reqId,
801+ txParams : { recipients : [ ] } ,
802+ } )
803+ . should . be . rejectedWith (
804+ 'Recipient details are required to verify this transaction before signing. Pass txParams with at least one recipient.'
805+ ) ;
806+ } ) ;
807+
808+ it ( 'signTxRequest should succeed when recipients are only in intent (smart contract interaction)' , async function ( ) {
809+ await setupSignTxRequestNocks ( false , userSignShare , aShare , dShare , enterpriseData ) ;
810+ const txRequestWithIntentRecipients = {
811+ ...txRequest ,
812+ intent : {
813+ intentType : 'contractCall' ,
814+ recipients : [
815+ {
816+ address : { address : '0xrecipient' } ,
817+ amount : { value : '1000' , symbol : 'hteth' } ,
818+ } ,
819+ ] ,
820+ } ,
821+ } ;
822+ const signedTxRequest = await tssUtils . signTxRequest ( {
823+ txRequest : txRequestWithIntentRecipients ,
824+ prv : JSON . stringify ( {
825+ pShare : userKeyShare . pShare ,
826+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
827+ backupNShare : backupKeyShare . nShares [ 1 ] ,
828+ } ) ,
829+ reqId,
830+ // no txParams.recipients — should fall back to intent.recipients
831+ } ) ;
832+ signedTxRequest . unsignedTxs . should . deepEqual ( txRequest . unsignedTxs ) ;
833+ } ) ;
834+
835+ it ( 'signTxRequest should succeed for no-recipient tx types (tokenApproval)' , async function ( ) {
836+ await setupSignTxRequestNocks ( false , userSignShare , aShare , dShare , enterpriseData ) ;
837+ const signedTxRequest = await tssUtils . signTxRequest ( {
838+ txRequest,
839+ prv : JSON . stringify ( {
840+ pShare : userKeyShare . pShare ,
841+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
842+ backupNShare : backupKeyShare . nShares [ 1 ] ,
843+ } ) ,
844+ reqId,
845+ txParams : { type : 'tokenApproval' } ,
846+ } ) ;
847+ signedTxRequest . unsignedTxs . should . deepEqual ( txRequest . unsignedTxs ) ;
848+ } ) ;
849+
850+ it ( 'signTxRequest should succeed for no-recipient tx types (acceleration)' , async function ( ) {
851+ await setupSignTxRequestNocks ( false , userSignShare , aShare , dShare , enterpriseData ) ;
852+ const signedTxRequest = await tssUtils . signTxRequest ( {
853+ txRequest,
854+ prv : JSON . stringify ( {
855+ pShare : userKeyShare . pShare ,
856+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
857+ backupNShare : backupKeyShare . nShares [ 1 ] ,
858+ } ) ,
859+ reqId,
860+ txParams : { type : 'acceleration' } ,
861+ } ) ;
862+ signedTxRequest . unsignedTxs . should . deepEqual ( txRequest . unsignedTxs ) ;
863+ } ) ;
864+
865+ it ( 'signTxRequest should prefer txParams.recipients over intent.recipients when both are present' , async function ( ) {
866+ await setupSignTxRequestNocks ( false , userSignShare , aShare , dShare , enterpriseData ) ;
867+ const txRequestWithBothRecipients = {
868+ ...txRequest ,
869+ intent : {
870+ intentType : 'contractCall' ,
871+ recipients : [ { address : { address : '0xintentRecipient' } , amount : { value : '9999' , symbol : 'hteth' } } ] ,
872+ } ,
873+ } ;
874+ const signedTxRequest = await tssUtils . signTxRequest ( {
875+ txRequest : txRequestWithBothRecipients ,
876+ prv : JSON . stringify ( {
877+ pShare : userKeyShare . pShare ,
878+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
879+ backupNShare : backupKeyShare . nShares [ 1 ] ,
880+ } ) ,
881+ reqId,
882+ txParams : { recipients : [ { address : '0xrecipient' , amount : '1000' } ] } ,
883+ } ) ;
884+ signedTxRequest . unsignedTxs . should . deepEqual ( txRequest . unsignedTxs ) ;
885+ } ) ;
886+
773887 it ( 'signTxRequest should fail with wrong recipient' , async function ( ) {
774888 // To generate these Hex values, we used the bitgo-ui to create a transaction and then
775889 // used the `signableHex` and `serializedTxHex` values from the prebuild.
0 commit comments