@@ -34,7 +34,14 @@ export class AdaService extends Service {
3434 walletAddress : string ,
3535 options ?: AdaStakeOptions ,
3636 ) : Promise < Transaction > {
37+ const poolHash = this . testnet ? '3496527c1e1b20d56cc9d4e5615c76ba2421ad3f13e2561a1ad4d6c6' : '78da8fa2f5089964963a0ab7ad1402e8c656f203bef622cf9f5ee3c6' ;
38+ const wasmWalletAddress = CardanoWasm . Address . from_bech32 ( walletAddress ) ;
39+ const baseWalletAddress = CardanoWasm . BaseAddress . from_address ( wasmWalletAddress ) ;
3740
41+ if ( ! baseWalletAddress ) {
42+ throw new Error ( 'Could not generate base wallet address' ) ;
43+
44+ }
3845 let utxo : UTXO = [ ] ;
3946 try {
4047 utxo = await this . client . addressesUtxosAll ( walletAddress ) ;
@@ -75,13 +82,17 @@ export class AdaService extends Service {
7582 const ttl = currentSlot + 7200 ;
7683 txBuilder . set_ttl ( ttl ) ;
7784
85+ const addresses = await this . client . addresses ( walletAddress ) ;
86+
87+ // Add output
88+ txBuilder . add_output (
89+ CardanoWasm . TransactionOutput . new (
90+ wasmWalletAddress ,
91+ CardanoWasm . Value . new ( CardanoWasm . BigNum . from_str ( addresses . amount [ 0 ] . quantity . toString ( ) ) ) ,
92+ ) ,
93+ ) ;
94+
7895 // Add delegation (stake registration + stake delegation certificates)
79- const poolHash = this . testnet ? '3496527c1e1b20d56cc9d4e5615c76ba2421ad3f13e2561a1ad4d6c6' : '78da8fa2f5089964963a0ab7ad1402e8c656f203bef622cf9f5ee3c6' ;
80- const wasmWalletAddress = CardanoWasm . Address . from_bech32 ( walletAddress ) ;
81- const baseWalletAddress = CardanoWasm . BaseAddress . from_address ( wasmWalletAddress ) ;
82- if ( ! baseWalletAddress ) {
83- throw new Error ( 'Could not generate base wallet address' ) ;
84- }
8596 const poolKeyHash = CardanoWasm . Ed25519KeyHash . from_hex ( poolHash ) ;
8697 const stakeCredentials = baseWalletAddress . stake_cred ( ) ;
8798 const certificates = CardanoWasm . Certificates . new ( ) ;
0 commit comments