@@ -498,16 +498,18 @@ describe('GenericTxBuilder', () => {
498
498
} ) ;
499
499
500
500
it ( 'can add a custom fields which are accounted for by input selector' , async ( ) => {
501
- txBuilder . addOutput ( mocks . utxo [ 0 ] [ 1 ] ) ;
502
- txBuilder . customize ( ( txBody ) => {
503
- const outputs = [ ...txBody . outputs , { ...mocks . utxo [ 1 ] [ 1 ] , value : { coins : 100n } } ] ;
504
- return {
505
- ...txBody ,
506
- outputs,
507
- withdrawals : [ ...( txBody . withdrawals || [ ] ) , { quantity : 13n , stakeAddress : mocks . rewardAccount } ]
508
- } ;
509
- } ) ;
510
- const txProps = await txBuilder . build ( ) . inspect ( ) ;
501
+ const txProps = await txBuilder
502
+ . addOutput ( mocks . utxo [ 0 ] [ 1 ] )
503
+ . customize ( ( { txBody } ) => {
504
+ const outputs = [ ...txBody . outputs , { ...mocks . utxo [ 1 ] [ 1 ] , value : { coins : 100n } } ] ;
505
+ return {
506
+ ...txBody ,
507
+ outputs,
508
+ withdrawals : [ ...( txBody . withdrawals || [ ] ) , { quantity : 13n , stakeAddress : mocks . rewardAccount } ]
509
+ } ;
510
+ } )
511
+ . build ( )
512
+ . inspect ( ) ;
511
513
512
514
// Check if the custom fields were included the built transaction
513
515
expect ( txProps . body . outputs . filter ( ( { value : { coins } } ) => coins === 100n ) . length ) . toBe ( 1 ) ;
@@ -536,11 +538,14 @@ describe('GenericTxBuilder', () => {
536
538
type : Cardano . CredentialType . KeyHash
537
539
}
538
540
} ;
539
- txBuilder . customize ( ( txBody ) => {
540
- const certificates = [ ...( txBody . certificates || [ ] ) , stakeVoteRegDelegCert ] ;
541
- return { ...txBody , certificates } ;
542
- } ) ;
543
- const txProps = await txBuilder . build ( ) . inspect ( ) ;
541
+ const txProps = await txBuilder
542
+ . customize ( ( { txBody } ) => {
543
+ const certificates = [ ...( txBody . certificates || [ ] ) , stakeVoteRegDelegCert ] ;
544
+ return { ...txBody , certificates } ;
545
+ } )
546
+ . build ( )
547
+ . inspect ( ) ;
548
+
544
549
expect ( txProps . body . certificates ?. length ) . toEqual ( 1 ) ;
545
550
expect ( txProps . body . certificates ! [ 0 ] ) . toEqual ( stakeVoteRegDelegCert ) ;
546
551
} ) ;
@@ -556,12 +561,14 @@ describe('GenericTxBuilder', () => {
556
561
}
557
562
} ;
558
563
559
- txBuilder . customize ( ( txBody ) => {
560
- const certificates = [ ...( txBody . certificates || [ ] ) , stakeRegDelegCert ] ;
561
- return { ...txBody , certificates } ;
562
- } ) ;
564
+ const txProps = await txBuilder
565
+ . customize ( ( { txBody } ) => {
566
+ const certificates = [ ...( txBody . certificates || [ ] ) , stakeRegDelegCert ] ;
567
+ return { ...txBody , certificates } ;
568
+ } )
569
+ . build ( )
570
+ . inspect ( ) ;
563
571
564
- const txProps = await txBuilder . build ( ) . inspect ( ) ;
565
572
expect ( txProps . body . certificates ?. length ) . toEqual ( 1 ) ;
566
573
expect ( txProps . body . certificates ! [ 0 ] ) . toEqual ( stakeRegDelegCert ) ;
567
574
@@ -596,15 +603,17 @@ describe('GenericTxBuilder', () => {
596
603
]
597
604
} ;
598
605
599
- txBuilder . customize ( ( txBody ) => {
600
- const votingProcedures : Cardano . TxBody [ 'votingProcedures' ] = [
601
- ...( txBody . votingProcedures || [ ] ) ,
602
- votingProcedure
603
- ] ;
604
- return { ...txBody , votingProcedures } ;
605
- } ) ;
606
+ const txProps = await txBuilder
607
+ . customize ( ( { txBody } ) => {
608
+ const votingProcedures : Cardano . TxBody [ 'votingProcedures' ] = [
609
+ ...( txBody . votingProcedures || [ ] ) ,
610
+ votingProcedure
611
+ ] ;
612
+ return { ...txBody , votingProcedures } ;
613
+ } )
614
+ . build ( )
615
+ . inspect ( ) ;
606
616
607
- const txProps = await txBuilder . build ( ) . inspect ( ) ;
608
617
expect ( txProps . body . votingProcedures ?. length ) . toBe ( 1 ) ;
609
618
expect ( txProps . body . votingProcedures ! [ 0 ] ) . toEqual ( votingProcedure ) ;
610
619
} ) ;
0 commit comments