Avoid RpcClient::get_account() in some cases
This commit is contained in:
parent
7abf8bd9cf
commit
7e3115fb25
|
@ -298,10 +298,15 @@ fn command_create_account(
|
|||
)
|
||||
};
|
||||
|
||||
let account_data = config.rpc_client.get_account(&account)?;
|
||||
if let Some(account_data) = config
|
||||
.rpc_client
|
||||
.get_account_with_commitment(&account, config.rpc_client.commitment())?
|
||||
.value
|
||||
{
|
||||
if !(account_data.owner == system_program::id() && system_account_ok) {
|
||||
return Err(format!("Error: Account already exists: {}", account).into());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Some((
|
||||
minimum_balance_for_rent_exemption,
|
||||
|
@ -448,7 +453,11 @@ fn command_transfer(
|
|||
let mut recipient_token_account = recipient;
|
||||
let mut minimum_balance_for_rent_exemption = 0;
|
||||
|
||||
let account_data = config.rpc_client.get_account(&recipient)?;
|
||||
if let Some(account_data) = config
|
||||
.rpc_client
|
||||
.get_account_with_commitment(&recipient, config.rpc_client.commitment())?
|
||||
.value
|
||||
{
|
||||
if account_data.owner == system_program::id() {
|
||||
recipient_token_account = get_associated_token_address(&recipient, &mint_pubkey);
|
||||
println!(
|
||||
|
@ -458,7 +467,10 @@ fn command_transfer(
|
|||
|
||||
let needs_funding = if let Some(recipient_token_account_data) = config
|
||||
.rpc_client
|
||||
.get_account_with_commitment(&recipient_token_account, config.rpc_client.commitment())?
|
||||
.get_account_with_commitment(
|
||||
&recipient_token_account,
|
||||
config.rpc_client.commitment(),
|
||||
)?
|
||||
.value
|
||||
{
|
||||
if recipient_token_account_data.owner == system_program::id() {
|
||||
|
@ -466,7 +478,9 @@ fn command_transfer(
|
|||
} else if recipient_token_account_data.owner == spl_token::id() {
|
||||
false
|
||||
} else {
|
||||
return Err(format!("Error: Unsupported recipient address: {}", recipient).into());
|
||||
return Err(
|
||||
format!("Error: Unsupported recipient address: {}", recipient).into(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
true
|
||||
|
@ -498,6 +512,9 @@ fn command_transfer(
|
|||
} else if account_data.owner != spl_token::id() {
|
||||
return Err(format!("Error: Unsupported recipient address: {}", recipient).into());
|
||||
}
|
||||
} else {
|
||||
return Err(format!("Error: Recipient does not exist: {}", recipient).into());
|
||||
}
|
||||
|
||||
instructions.push(transfer_checked(
|
||||
&spl_token::id(),
|
||||
|
|
Loading…
Reference in New Issue