Skip to content

Commit

Permalink
Merge pull request #21 from Odrin/master
Browse files Browse the repository at this point in the history
refactor: update TonWallet to support multiple gifts in transfers
  • Loading branch information
Rexagon authored Feb 25, 2025
2 parents d70cf9e + 41a8e9e commit 516bc1a
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/core/ton_wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,17 @@ impl TonWallet {
&mut self,
current_state: &ton_block::AccountStuff,
public_key: &PublicKey,
gift: Gift,
gifts: Vec<Gift>,
expiration: Expiration,
) -> Result<TransferAction> {
match self.wallet_type {
WalletType::Multisig(multisig_type) => {
anyhow::ensure!(
gifts.len() == 1,
"Multiple outgoing messages are not supported by multisig contract"
);
let gift = gifts.into_iter().next().unwrap();

match &current_state.storage.state {
ton_block::AccountState::AccountFrozen { .. } => {
return Err(TonWalletError::AccountIsFrozen.into())
Expand Down Expand Up @@ -337,15 +343,15 @@ impl TonWallet {
public_key,
current_state,
0,
vec![gift],
gifts,
expiration,
),
WalletType::WalletV4R1 => wallet_v4::prepare_transfer(
self.clock.as_ref(),
public_key,
current_state,
0,
vec![gift],
gifts,
expiration,
wallet_v4::WalletV4Version::R1,
),
Expand All @@ -354,7 +360,7 @@ impl TonWallet {
public_key,
current_state,
0,
vec![gift],
gifts,
expiration,
wallet_v4::WalletV4Version::R2,
),
Expand All @@ -363,22 +369,22 @@ impl TonWallet {
public_key,
current_state,
0,
vec![gift],
gifts,
expiration,
),
WalletType::EverWallet => ever_wallet::prepare_transfer(
self.clock.as_ref(),
public_key,
current_state,
self.address().clone(),
vec![gift],
gifts,
expiration,
),
WalletType::HighloadWalletV2 => highload_wallet_v2::prepare_transfer(
self.clock.as_ref(),
public_key,
current_state,
vec![gift],
gifts,
expiration,
),
}
Expand Down Expand Up @@ -792,19 +798,16 @@ impl InternalMessageSender for TonWallet {
return Err(InternalMessageSenderError::InvalidSender.into());
}

self.prepare_transfer(
current_state,
public_key,
Gift {
flags: MessageFlags::default().into(),
bounce: message.bounce,
destination: message.destination,
amount: message.amount,
body: Some(message.body),
state_init: None,
},
expiration,
)
let gift = Gift {
flags: MessageFlags::default().into(),
bounce: message.bounce,
destination: message.destination,
amount: message.amount,
body: Some(message.body),
state_init: None,
};

self.prepare_transfer(current_state, public_key, vec![gift], expiration)
}
}

Expand Down

0 comments on commit 516bc1a

Please sign in to comment.