Skip to content

Commit c90b2ff

Browse files
committed
Remove SOL transfer funding in cli unwrap lamports unfunded case
1 parent 210d576 commit c90b2ff

2 files changed

Lines changed: 5 additions & 45 deletions

File tree

clients/cli/src/command.rs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ use {
3131
program_option::COption,
3232
pubkey::Pubkey,
3333
signature::{Keypair, Signer},
34-
transaction::Transaction,
3534
},
36-
solana_system_interface::{instruction::transfer, program as system_program},
35+
solana_system_interface::program as system_program,
3736
spl_associated_token_account_interface::address::get_associated_token_address_with_program_id,
3837
spl_pod::optional_keys::OptionalNonZeroPubkey,
3938
spl_token_2022::extension::confidential_transfer::account_info::{
@@ -2155,34 +2154,7 @@ async fn command_unwrap_lamports(
21552154

21562155
if config.rpc_client.get_balance(&destination_account).await? == 0 {
21572156
// if it doesn't exist, we gate transfer with a different flag
2158-
if allow_unfunded_recipient {
2159-
println_display(
2160-
config,
2161-
format!("Funding recipient: {}", destination_account,),
2162-
);
2163-
2164-
let rent_exempt_lamports = config
2165-
.rpc_client
2166-
.get_minimum_balance_for_rent_exemption(0)
2167-
.await?;
2168-
let fee_payer = config.fee_payer()?;
2169-
let instruction = transfer(
2170-
&fee_payer.pubkey(),
2171-
&destination_account,
2172-
rent_exempt_lamports,
2173-
);
2174-
let recent_blockhash = config.rpc_client.get_latest_blockhash().await?;
2175-
let transaction = Transaction::new_signed_with_payer(
2176-
&[instruction],
2177-
Some(&fee_payer.pubkey()),
2178-
&[fee_payer],
2179-
recent_blockhash,
2180-
);
2181-
config
2182-
.rpc_client
2183-
.send_and_confirm_transaction(&transaction)
2184-
.await?;
2185-
} else {
2157+
if !allow_unfunded_recipient {
21862158
return Err("Error: The recipient address is not funded. \
21872159
Add `--allow-unfunded-recipient` to complete the transfer."
21882160
.into());

clients/cli/tests/command.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -918,13 +918,9 @@ async fn unwrap_lamports(test_validator: &TestValidator, payer: &Keypair) {
918918
.get_minimum_balance_for_rent_exemption(account_space)
919919
.await
920920
.unwrap();
921-
let zero_space_rent_exempt_lamports = config
922-
.rpc_client
923-
.get_minimum_balance_for_rent_exemption(0)
924-
.await
925-
.unwrap();
921+
926922
let balance = config.rpc_client.get_balance(&new_address).await.unwrap();
927-
assert_eq!(balance, amount + zero_space_rent_exempt_lamports); // we fund the recipient first
923+
assert_eq!(balance, amount);
928924

929925
let wrapped_account = config
930926
.rpc_client
@@ -1115,16 +1111,8 @@ async fn multisig_unwrap_lamports(test_validator: &TestValidator, payer: &Keypai
11151111
.get_minimum_balance_for_rent_exemption(account_space)
11161112
.await
11171113
.unwrap();
1118-
let zero_space_rent_exempt_lamports = config
1119-
.rpc_client
1120-
.get_minimum_balance_for_rent_exemption(0)
1121-
.await
1122-
.unwrap();
11231114
let new_account_balance = config.rpc_client.get_balance(&new_address).await.unwrap();
1124-
assert_eq!(
1125-
new_account_balance,
1126-
amount + zero_space_rent_exempt_lamports // we fund the account before the unwrap
1127-
);
1115+
assert_eq!(new_account_balance, amount);
11281116
let wrapped_account = config
11291117
.rpc_client
11301118
.get_account(&multisig_wrapped_address)

0 commit comments

Comments
 (0)