Skip to content

Commit

Permalink
Merge pull request #1557 from oasisprotocol/kostko/fix/accounts-skip-…
Browse files Browse the repository at this point in the history
…zero-fee-xfer-event

runtime-sdk: Don't emit events for zero fee remainder transfers
  • Loading branch information
kostko authored Nov 10, 2023
2 parents a0e0a47 + 63f89de commit 04e8918
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions runtime-sdk/src/modules/accounts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,10 @@ impl module::BlockHandler for Module {

// Transfer remainder to a common pool account.
for (denom, remainder) in previous_fees.into_iter() {
if remainder.is_zero() {
continue;
}

let amount = token::BaseUnits::new(remainder, denom);
Self::add_amount(*ADDRESS_COMMON_POOL, &amount)
.expect("add_amount must succeed for transfer to common pool");
Expand Down
13 changes: 13 additions & 0 deletions runtime-sdk/src/modules/accounts/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1457,3 +1457,16 @@ fn test_fee_refund_subcall() {
assert_eq!(events.len(), 1);
assert_eq!(events[0].amount, 11_000);
}

#[test]
fn test_pool_addresses() {
assert_eq!(
ADDRESS_COMMON_POOL.to_bech32(),
"oasis1qz78phkdan64g040cvqvqpwkplfqf6tj6uwcsh30"
);

assert_eq!(
ADDRESS_FEE_ACCUMULATOR.to_bech32(),
"oasis1qp3r8hgsnphajmfzfuaa8fhjag7e0yt35cjxq0u4"
);
}

0 comments on commit 04e8918

Please sign in to comment.