1
1
import { BaseWallet } from '@cardano-sdk/wallet' ;
2
- import { Cardano , StakePoolProvider } from '@cardano-sdk/core' ;
2
+ import { Cardano , Serialization , StakePoolProvider } from '@cardano-sdk/core' ;
3
3
import { buildSharedWallets } from '../wallet_epoch_0/SharedWallet/utils' ;
4
4
import { filter , firstValueFrom , map , take } from 'rxjs' ;
5
5
import {
@@ -20,11 +20,15 @@ const env = getEnv(walletVariables);
20
20
21
21
const submitDelegationTx = async ( alice : BaseWallet , bob : BaseWallet , charlotte : BaseWallet , pool : Cardano . PoolId ) => {
22
22
logger . info ( `Creating delegation tx at epoch #${ ( await firstValueFrom ( alice . currentEpoch$ ) ) . epochNo } ` ) ;
23
- let tx = ( await alice . createTxBuilder ( ) . delegateFirstStakeCredential ( pool ) . build ( ) . sign ( ) ) . tx ;
23
+ const tx = ( await alice . createTxBuilder ( ) . delegateFirstStakeCredential ( pool ) . build ( ) . sign ( ) ) . tx ;
24
24
25
- tx = await bob . updateWitness ( { sender : { id : 'e2e' } , tx } ) ;
26
- tx = await charlotte . updateWitness ( { sender : { id : 'e2e' } , tx } ) ;
27
- await alice . submitTx ( tx ) ;
25
+ // Serialize and transmit TX...
26
+ let serializedTx = Serialization . Transaction . fromCore ( tx ) . toCbor ( ) ;
27
+
28
+ serializedTx = await bob . addSignatures ( { sender : { id : 'e2e' } , tx : serializedTx } ) ;
29
+ serializedTx = await charlotte . addSignatures ( { sender : { id : 'e2e' } , tx : serializedTx } ) ;
30
+
31
+ await alice . submitTx ( serializedTx ) ;
28
32
29
33
const { epochNo } = await firstValueFrom ( alice . currentEpoch$ ) ;
30
34
logger . info ( `Delegation tx ${ tx . id } submitted at epoch #${ epochNo } ` ) ;
@@ -61,15 +65,18 @@ const buildSpendRewardTx = async (
61
65
const { body } = await tx . inspect ( ) ;
62
66
logger . debug ( 'Body of tx before sign' ) ;
63
67
logger . debug ( body ) ;
64
- let signedTx = ( await tx . sign ( ) ) . tx ;
68
+ const signedTx = ( await tx . sign ( ) ) . tx ;
69
+
70
+ // Serialize and transmit TX...
71
+ let serializedTx = Serialization . Transaction . fromCore ( signedTx ) . toCbor ( ) ;
65
72
66
- signedTx = await bob . updateWitness ( { sender : { id : 'e2e' } , tx : signedTx } ) ;
67
- signedTx = await charlotte . updateWitness ( { sender : { id : 'e2e' } , tx : signedTx } ) ;
73
+ serializedTx = await bob . addSignatures ( { sender : { id : 'e2e' } , tx : serializedTx } ) ;
74
+ serializedTx = await charlotte . addSignatures ( { sender : { id : 'e2e' } , tx : serializedTx } ) ;
68
75
69
76
logger . debug ( 'Body of tx after sign' ) ;
70
77
logger . debug ( signedTx . body ) ;
71
78
72
- return signedTx ;
79
+ return serializedTx ;
73
80
} ;
74
81
75
82
const getPoolIds = async ( stakePoolProvider : StakePoolProvider , count : number ) => {
@@ -187,13 +194,11 @@ describe('shared wallet delegation rewards', () => {
187
194
logger . info ( `Generated rewards: ${ rewards } tLovelace` ) ;
188
195
189
196
// Spend reward
190
- const spendRewardTx = await buildSpendRewardTx (
191
- aliceMultiSigWallet ,
192
- bobMultiSigWallet ,
193
- charlotteMultiSigWallet ,
194
- faucetWallet
195
- ) ;
196
- expect ( spendRewardTx . body . withdrawals ?. length ) . toBeGreaterThan ( 0 ) ;
197
- await submitAndConfirm ( aliceMultiSigWallet , spendRewardTx ) ;
197
+ const spendRewardsTx = Serialization . Transaction . fromCbor (
198
+ await buildSpendRewardTx ( aliceMultiSigWallet , bobMultiSigWallet , charlotteMultiSigWallet , faucetWallet )
199
+ ) . toCore ( ) ;
200
+
201
+ expect ( spendRewardsTx . body . withdrawals ?. length ) . toBeGreaterThan ( 0 ) ;
202
+ await submitAndConfirm ( aliceMultiSigWallet , spendRewardsTx ) ;
198
203
} ) ;
199
204
} ) ;
0 commit comments