Add command to create genesis accounts (#5343)

This commit is contained in:
Jack May
2019-07-30 23:43:12 -07:00
committed by GitHub
parent bd7e269280
commit 6d7cb23c61
10 changed files with 402 additions and 279 deletions

View File

@@ -18,11 +18,36 @@ use solana_runtime::loader_utils::load_program;
use solana_sdk::account::KeyedAccount;
use solana_sdk::client::Client;
use solana_sdk::instruction::InstructionError;
use solana_sdk::message::Message;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Keypair;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_instruction;
use types::account_address::AccountAddress;
pub fn create_genesis<T: Client>(from_key: &Keypair, client: &T, amount: u64) -> Keypair {
let libra_genesis_key = Keypair::new();
let instruction = system_instruction::create_account(
&from_key.pubkey(),
&libra_genesis_key.pubkey(),
1,
bincode::serialize(&LibraAccountState::create_genesis(1))
.unwrap()
.len() as u64,
&solana_move_loader_api::id(),
);
client.send_instruction(&from_key, instruction).unwrap();
let instruction = librapay_instruction::genesis(&libra_genesis_key.pubkey(), amount);
let message = Message::new_with_payer(vec![instruction], Some(&from_key.pubkey()));
client
.send_message(&[from_key, &libra_genesis_key], message)
.unwrap();
libra_genesis_key
}
pub fn upload_move_program<T: Client>(from: &Keypair, client: &T, code: &str) -> Pubkey {
let address = AccountAddress::default();
let account_state = LibraAccountState::create_program(&address, code, vec![]);