Compare commits

...

2 Commits

3 changed files with 29 additions and 31 deletions

View File

@ -175,8 +175,6 @@ pub struct GetTokenInfo {
#[derive(Serialize, Deserialize, Debug)]
pub struct CreateNonceAccountAndSigningKey {
authorization_address: String,
from_account: Option<String>,
from_address: String,
}
#[derive(Serialize, Deserialize, Debug)]
@ -226,7 +224,7 @@ pub struct TransferToken {
pub struct Compile {
#[serde(flatten)]
hashable: Hashable,
derivation_accounts: Vec<u32>,
derivation_accounts: Option<Vec<u32>>,
instructions: Vec<solana_sdk::instruction::Instruction>,
}
@ -671,8 +669,6 @@ impl Module for Solana {
}
Operation::CreateNonceAccountAndSigningKey(CreateNonceAccountAndSigningKey {
authorization_address,
from_account,
from_address,
}) => {
// NOTE: Since this transaction is meant to be run on an online system with a
// freshly generated mnemonic, only designed to live to make the nonce account, we
@ -685,16 +681,12 @@ impl Module for Solana {
// this uses OsRng, which sources from getrandom() if available, which pulls from
// /dev/urandom, or sources from `/dev/urandom` directly.
let keypair = Keypair::new();
let payer_keypair = Keypair::new();
let from_pk = Pubkey::from_str(&from_address).unwrap();
let authorization_pk = Pubkey::from_str(&authorization_address).unwrap();
if from_account.is_some() {
unimplemented!("alternative derivation accounts are not yet implemented");
}
let instructions = system_instruction::create_nonce_account(
&from_pk,
&payer_keypair.pubkey(),
&keypair.pubkey(),
&authorization_pk,
// just above the approximate rent necessary for a nonce account
@ -706,8 +698,13 @@ impl Module for Solana {
"blob": {
"nonce_pubkey": keypair.pubkey().to_string(),
"nonce_privkey": [keypair.secret().to_bytes()],
"payer_pubkey": payer_keypair.pubkey().to_string(),
"payer_privkey": [payer_keypair.secret().to_bytes()],
"privkeys": [
keypair.secret().to_bytes(),
payer_keypair.secret().to_bytes()
],
"transaction": instructions,
"derivation_accounts": [0u32 | 1 << 31],
},
}))
}
@ -1016,7 +1013,7 @@ impl Module for Solana {
"hash": hash,
"instructions": instructions,
},
"derivation_accounts": derivation_accounts,
"derivation_accounts": derivation_accounts.as_deref().unwrap_or(&[]),
}))
}
Operation::Inspect(Inspect { transaction }) => {
@ -1081,7 +1078,7 @@ impl Module for Solana {
"status": "simulate_transaction",
"error": err.to_string(),
}
}))
}));
}
let response = client.send_and_confirm_transaction(&transaction);
let cluster_suffix = {

View File

@ -124,15 +124,20 @@ fn load_inputs<'a>(
.and_then(|f| serde_json::from_reader(f).ok());
for input in inputs {
let identifier = &input.name;
match matches.get_one::<String>(&input.name) {
match matches.get_one::<String>(identifier) {
Some(value) => {
map.insert(identifier.clone(), value.clone());
continue;
}
None => {
if let Some(value) = input_file.as_ref().and_then(|f| f.get(identifier)) {
map.insert(identifier.clone(), value.clone());
continue;
for aliasable_identifier in input.identifiers() {
if let Some(value) = input_file
.as_ref()
.and_then(|f| f.get(aliasable_identifier))
{
map.insert(identifier.clone(), value.clone());
continue;
}
}
}
}

View File

@ -16,20 +16,11 @@ inputs:
authorization address is often the principal address - the one performing
the transaction.
aliases:
- address
- primary_address
- principal_address
- pubkey
step:
- type: "sol-generate-wallet"
- type: "sol-get-wallet-address"
outputs:
pubkey: "wallet_pubkey"
- type: "sol-await-funds"
inputs:
address: "wallet_pubkey"
cluster: "cluster"
values:
lamports: "1510000"
- type: "sol-get-blockhash"
inputs:
cluster: "cluster"
@ -37,13 +28,18 @@ step:
blockhash: "blockhash"
- type: "sol-create-nonce-account-and-signing-key"
inputs:
from_address: "wallet_pubkey"
authorization_address: "authorization_address"
outputs:
transaction: "instructions"
nonce_pubkey: "nonce_pubkey"
nonce_privkey: "private_keys"
derivation_accounts: "derivation_accounts"
payer_pubkey: "payer_pubkey"
privkeys: "private_keys"
- type: "sol-await-funds"
inputs:
address: "payer_pubkey"
cluster: "cluster"
values:
lamports: "1510000"
- type: "sol-compile"
inputs:
instructions: "instructions"