Skip to content

Commit

Permalink
Add non-zero stub balance for workchains
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWad3r committed Jan 19, 2025
1 parent 397a02d commit 1dc92ca
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/core/token_wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ impl TokenWallet {
.saturating_add(100_000_000u64.saturating_mul(storage_fees)))
}

fn stub_balance(address: &MsgAddressInt) -> u64 {
if address.is_masterchain() {
1000
} else {
1
}
}

pub async fn prepare_transfer(
&self,
destination: TransferRecipient,
Expand All @@ -239,19 +247,22 @@ impl TokenWallet {
payload: ton_types::Cell,
mut attached_amount: u64,
) -> Result<InternalMessage> {
let mut initial_balance: u64 = 0;

match &destination {
TransferRecipient::TokenWallet(address) => {
let initial_balance = match &destination {
TransferRecipient::OwnerWallet(address) => {
let transport = self.contract_subscription.transport();
let config = transport
.get_blockchain_config(self.clock.as_ref(), true)
.await?;
initial_balance = self.calculate_initial_balance(&config, address)?;
attached_amount += initial_balance

let initial_balance = match self.calculate_initial_balance(&config, address) {
Ok(value) => value + Self::stub_balance(address),
Err(_) => Self::stub_balance(address),
};
attached_amount += initial_balance;
initial_balance
}
_ => (),
}
TransferRecipient::TokenWallet(address) => Self::stub_balance(address),
};

let (function, input) = match self.version {
TokenWalletVersion::OldTip3v4 => {
Expand Down

0 comments on commit 1dc92ca

Please sign in to comment.