Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit e5d4b82

Browse files
committed
token-cli: remove unnecessary fetch for memo transfers
1 parent 8528f92 commit e5d4b82

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

token/cli/src/main.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,22 +1902,11 @@ async fn command_required_transfer_memos(
19021902
if config.sign_only {
19031903
panic!("Config can not be sign only for enabling/disabling required transfer memos.");
19041904
}
1905-
let account_fetch = config
1906-
.rpc_client
1907-
.get_account(&token_account_address)
1908-
.await
1909-
.map_err(|err| {
1910-
format!(
1911-
"Token account {} does not exist: {}",
1912-
token_account_address, err
1913-
)
1914-
})?;
1915-
let program_id = config.program_id;
1916-
config.get_account_checked(&token_account_address).await?;
1905+
let account = config.get_account_checked(&token_account_address).await?;
19171906
let mut instructions: Vec<Instruction> = Vec::new();
19181907
// Reallocation (if needed)
1919-
let current_account_len = account_fetch.data.len();
1920-
let state_with_extension = StateWithExtensionsOwned::<Account>::unpack(account_fetch.data)?;
1908+
let current_account_len = account.data.len();
1909+
let state_with_extension = StateWithExtensionsOwned::<Account>::unpack(account.data)?;
19211910
let mut existing_extensions: Vec<ExtensionType> = state_with_extension.get_extension_types()?;
19221911
if existing_extensions.contains(&ExtensionType::MemoTransfer) {
19231912
let extension_data: bool = state_with_extension
@@ -1939,7 +1928,7 @@ async fn command_required_transfer_memos(
19391928
let needed_account_len = ExtensionType::get_account_len::<Account>(&existing_extensions);
19401929
if needed_account_len > current_account_len {
19411930
instructions.push(reallocate(
1942-
&program_id,
1931+
&config.program_id,
19431932
&token_account_address,
19441933
&config.fee_payer.pubkey(),
19451934
&owner,
@@ -1951,7 +1940,7 @@ async fn command_required_transfer_memos(
19511940
if enable_memos {
19521941
instructions.push(
19531942
spl_token_2022::extension::memo_transfer::instruction::enable_required_transfer_memos(
1954-
&program_id,
1943+
&config.program_id,
19551944
&token_account_address,
19561945
&owner,
19571946
&config.multisigner_pubkeys,
@@ -1960,7 +1949,7 @@ async fn command_required_transfer_memos(
19601949
} else {
19611950
instructions.push(
19621951
spl_token_2022::extension::memo_transfer::instruction::disable_required_transfer_memos(
1963-
&program_id,
1952+
&config.program_id,
19641953
&token_account_address,
19651954
&owner,
19661955
&config.multisigner_pubkeys,

0 commit comments

Comments
 (0)