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) {
|
if !(account_data.owner == system_program::id() && system_account_ok) {
|
||||||
return Err(format!("Error: Account already exists: {}", account).into());
|
return Err(format!("Error: Account already exists: {}", account).into());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Some((
|
Ok(Some((
|
||||||
minimum_balance_for_rent_exemption,
|
minimum_balance_for_rent_exemption,
|
||||||
|
@ -448,7 +453,11 @@ fn command_transfer(
|
||||||
let mut recipient_token_account = recipient;
|
let mut recipient_token_account = recipient;
|
||||||
let mut minimum_balance_for_rent_exemption = 0;
|
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() {
|
if account_data.owner == system_program::id() {
|
||||||
recipient_token_account = get_associated_token_address(&recipient, &mint_pubkey);
|
recipient_token_account = get_associated_token_address(&recipient, &mint_pubkey);
|
||||||
println!(
|
println!(
|
||||||
|
@ -458,7 +467,10 @@ fn command_transfer(
|
||||||
|
|
||||||
let needs_funding = if let Some(recipient_token_account_data) = config
|
let needs_funding = if let Some(recipient_token_account_data) = config
|
||||||
.rpc_client
|
.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
|
.value
|
||||||
{
|
{
|
||||||
if recipient_token_account_data.owner == system_program::id() {
|
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() {
|
} else if recipient_token_account_data.owner == spl_token::id() {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
return Err(format!("Error: Unsupported recipient address: {}", recipient).into());
|
return Err(
|
||||||
|
format!("Error: Unsupported recipient address: {}", recipient).into(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
|
@ -498,6 +512,9 @@ fn command_transfer(
|
||||||
} else if account_data.owner != spl_token::id() {
|
} else if account_data.owner != spl_token::id() {
|
||||||
return Err(format!("Error: Unsupported recipient address: {}", recipient).into());
|
return Err(format!("Error: Unsupported recipient address: {}", recipient).into());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return Err(format!("Error: Recipient does not exist: {}", recipient).into());
|
||||||
|
}
|
||||||
|
|
||||||
instructions.push(transfer_checked(
|
instructions.push(transfer_checked(
|
||||||
&spl_token::id(),
|
&spl_token::id(),
|
||||||
|
|
Loading…
Reference in New Issue