Skip to content

Commit

Permalink
Feature/fix bug of same receipt (#75)
Browse files Browse the repository at this point in the history
* fix bug: when from and to are the same

* bump version 162

---------

Co-authored-by: Cyberaurora <[email protected]>
  • Loading branch information
kb1ns and kb1ns authored May 29, 2023
1 parent 8ddd988 commit 76b2ec5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v0.9.30-mainnet.162

- fix bug of `Token` pallet: when `from` and `to` are the same

# v0.9.30-mainnet.161

- migrate trading rewards to marketing rewards
Expand Down
3 changes: 3 additions & 0 deletions pallets/token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ pub mod pallet {
if amount.is_zero() {
return Ok(amount);
}
if origin == target {
return Ok(amount);
}
if token == Self::native_token_id() {
return <pallet_balances::Pallet<T> as Currency<T::AccountId>>::transfer(
origin,
Expand Down
14 changes: 13 additions & 1 deletion pallets/token/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,19 @@ fn issuing_token_and_transfer_should_work() {
reserved: Zero::zero(),
}
);

assert_ok!(Token::transfer(
RuntimeOrigin::signed(ferdie.clone()),
id.clone(),
MultiAddress::Id(ferdie.clone()),
1000000000000000000
));
assert_eq!(
Token::get_token_balance((&id, &ferdie)),
TokenAccountData {
free: 1000000000000000000,
reserved: Zero::zero(),
}
);
assert_ok!(Token::transfer(
RuntimeOrigin::signed(ferdie.clone()),
id.clone(),
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 161,
spec_version: 162,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 3,
Expand Down

0 comments on commit 76b2ec5

Please sign in to comment.