Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 03e419d

Browse files
committed
Fix creation to create second transaction *after* sending first one
1 parent 317c375 commit 03e419d

File tree

1 file changed

+40
-45
lines changed

1 file changed

+40
-45
lines changed

stake-pool/cli/src/main.rs

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -405,56 +405,51 @@ fn command_create_pool(
405405
max_validators,
406406
),
407407
];
408-
let mut setup_signers = vec![config.fee_payer.as_ref(), &mint_keypair, &reserve_keypair];
409-
unique_signers!(setup_signers);
410-
let setup_transaction =
411-
checked_transaction_with_signers(config, &setup_instructions, &setup_signers)?;
412-
let mut initialize_signers = vec![
413-
config.fee_payer.as_ref(),
414-
&stake_pool_keypair,
415-
&validator_list_keypair,
416-
config.manager.as_ref(),
417-
];
418-
let initialize_transaction = if let Some(deposit_authority) = deposit_authority {
408+
409+
{
410+
let mut setup_signers = vec![config.fee_payer.as_ref(), &mint_keypair, &reserve_keypair];
411+
unique_signers!(setup_signers);
412+
413+
let setup_transaction =
414+
checked_transaction_with_signers(config, &setup_instructions, &setup_signers)?;
415+
419416
println!(
420-
"Deposits will be restricted to {} only, this can be changed using the set-funding-authority command.",
421-
deposit_authority.pubkey()
417+
"Setting up required accounts for stake pool: reserve stake {} and mint {}",
418+
reserve_keypair.pubkey(),
419+
mint_keypair.pubkey()
422420
);
423-
let mut initialize_signers = initialize_signers.clone();
424-
initialize_signers.push(&deposit_authority);
425-
unique_signers!(initialize_signers);
426-
checked_transaction_with_signers(config, initialize_instructions, &initialize_signers)?
427-
} else {
428-
unique_signers!(initialize_signers);
429-
checked_transaction_with_signers(config, initialize_instructions, &initialize_signers)?
430-
};
421+
send_transaction(config, setup_transaction)?;
422+
}
431423

432-
// Fee checks were done on the individual transactions, but this is to make
433-
// sure the wallet can cover both in sequence
434-
check_fee_payer_balance(
435-
config,
436-
total_rent_free_balances
437-
+ config
438-
.rpc_client
439-
.get_fee_for_message(&setup_transaction.message)?
440-
+ config
441-
.rpc_client
442-
.get_fee_for_message(&initialize_transaction.message)?,
443-
)?;
424+
{
425+
let mut initialize_signers = vec![
426+
config.fee_payer.as_ref(),
427+
&stake_pool_keypair,
428+
&validator_list_keypair,
429+
config.manager.as_ref(),
430+
];
431+
let initialize_transaction = if let Some(deposit_authority) = deposit_authority {
432+
println!(
433+
"Deposits will be restricted to {} only, this can be changed using the set-funding-authority command.",
434+
deposit_authority.pubkey()
435+
);
436+
let mut initialize_signers = initialize_signers.clone();
437+
initialize_signers.push(&deposit_authority);
438+
unique_signers!(initialize_signers);
439+
checked_transaction_with_signers(config, initialize_instructions, &initialize_signers)?
440+
} else {
441+
unique_signers!(initialize_signers);
442+
checked_transaction_with_signers(config, initialize_instructions, &initialize_signers)?
443+
};
444444

445-
println!(
446-
"Setting up required accounts for stake pool: reserve stake {} and mint {}",
447-
reserve_keypair.pubkey(),
448-
mint_keypair.pubkey()
449-
);
450-
send_transaction(config, setup_transaction)?;
445+
println!(
446+
"Creating stake pool {} with validator list {}",
447+
stake_pool_keypair.pubkey(),
448+
validator_list_keypair.pubkey()
449+
);
450+
send_transaction(config, initialize_transaction)?;
451+
}
451452

452-
println!(
453-
"Creating stake pool {} with validator list {}",
454-
stake_pool_keypair.pubkey(),
455-
validator_list_keypair.pubkey()
456-
);
457-
send_transaction(config, initialize_transaction)?;
458453
Ok(())
459454
}
460455

0 commit comments

Comments
 (0)