Add create with seed to cli (#7713)

* Add create with seed to cli

* nonce and vote, too
This commit is contained in:
Rob Walker
2020-01-09 15:22:48 -08:00
committed by GitHub
parent 719785a8d3
commit 6775e83420
8 changed files with 376 additions and 62 deletions

View File

@ -161,9 +161,11 @@ pub fn create_account(
)
}
// we accept `to` as a parameter so that callers do their own error handling when
// calling create_address_with_seed()
pub fn create_account_with_seed(
from_pubkey: &Pubkey,
to_pubkey: &Pubkey,
to_pubkey: &Pubkey, // must match create_address_with_seed(base, seed, program_id)
base: &Pubkey,
seed: &str,
lamports: u64,
@ -173,7 +175,8 @@ pub fn create_account_with_seed(
let account_metas = vec![
AccountMeta::new(*from_pubkey, true),
AccountMeta::new(*to_pubkey, false),
];
]
.with_signer(base);
Instruction::new(
system_program::id(),
@ -233,6 +236,36 @@ pub fn create_address_with_seed(
))
}
pub fn create_nonce_account_with_seed(
from_pubkey: &Pubkey,
nonce_pubkey: &Pubkey,
base: &Pubkey,
seed: &str,
authority: &Pubkey,
lamports: u64,
) -> Vec<Instruction> {
vec![
create_account_with_seed(
from_pubkey,
nonce_pubkey,
base,
seed,
lamports,
NonceState::size() as u64,
&system_program::id(),
),
Instruction::new(
system_program::id(),
&SystemInstruction::NonceInitialize(*authority),
vec![
AccountMeta::new(*nonce_pubkey, false),
AccountMeta::new_readonly(recent_blockhashes::id(), false),
AccountMeta::new_readonly(rent::id(), false),
],
),
]
}
pub fn create_nonce_account(
from_pubkey: &Pubkey,
nonce_pubkey: &Pubkey,