Skip to content

Commit

Permalink
use transfer_allow_death instead of kee_alive
Browse files Browse the repository at this point in the history
  • Loading branch information
akildemir committed Sep 23, 2023
1 parent 187ef15 commit 859b4cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions substrate/in-instructions/pallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub mod pallet {
half,
1, // minimum out, so we accept whatever we get.
IN_INSTRUCTION_EXECUTOR.into(),
true,
false,
)?;

// get how much we got for our swap
Expand Down Expand Up @@ -152,17 +152,12 @@ pub mod pallet {
BalancesPallet::<T>::free_balance(PublicKey::from(IN_INSTRUCTION_EXECUTOR));

if coin_balance != 0 {
Tokens::<T>::transfer_keep_alive(
origin.clone().into(),
coin,
address,
coin_balance,
)?;
Tokens::<T>::transfer(origin.clone().into(), coin, address, coin_balance)?;
}
if sri_balance != 0 {
// unwrap here. First, it doesn't panic for full amount,
// second we should empty IIE account anyway.
BalancesPallet::<T>::transfer_keep_alive(origin.into(), address, sri_balance)
BalancesPallet::<T>::transfer_allow_death(origin.into(), address, sri_balance)
.unwrap();
}
}
Expand Down Expand Up @@ -202,7 +197,7 @@ pub mod pallet {
instruction.balance.amount.0,
out_balance.amount.0,
send_to.into(),
true,
false,
)?;

// burn the received coins so that they sent back to the user
Expand Down
9 changes: 0 additions & 9 deletions substrate/tokens/pallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@ pub mod pallet {
) -> DispatchResult {
AssetsPallet::<T>::transfer(origin, coin, target, amount)
}

pub fn transfer_keep_alive(
origin: OriginFor<T>,
coin: Coin,
target: SeraiAddress,
amount: SubstrateAmount,
) -> DispatchResult {
AssetsPallet::<T>::transfer_keep_alive(origin, coin, target, amount)
}
}

#[pallet::call]
Expand Down

0 comments on commit 859b4cd

Please sign in to comment.