Skip to content

Commit

Permalink
Bump (#2336)
Browse files Browse the repository at this point in the history
* bump

* update currencies
  • Loading branch information
xlc authored Sep 5, 2022
1 parent 090f68e commit 528a213
Show file tree
Hide file tree
Showing 57 changed files with 234 additions and 106 deletions.
102 changes: 51 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ecosystem-modules/compound-cash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ecosystem-compound-cash"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion ecosystem-modules/ren/renvm-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ecosystem-renvm-bridge"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion ecosystem-modules/starport/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ecosystem-starport"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion inspect/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "acala-inspect"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/aggregated-dex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-aggregated-dex"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-asset-registry"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/auction-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-auction-manager"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/cdp-engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-cdp-engine"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/cdp-treasury/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-cdp-treasury"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/collator-selection/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'module-collator-selection'
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/currencies/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-currencies"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
31 changes: 31 additions & 0 deletions modules/currencies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,37 @@ pub mod module {
}
Ok(())
}

/// Set lock by lock_id
///
/// The dispatch origin of this call must be _Root_.
#[pallet::weight(T::WeightInfo::update_balance_non_native_currency())]
pub fn force_set_lock(
origin: OriginFor<T>,
who: <T::Lookup as StaticLookup>::Source,
currency_id: CurrencyId,
#[pallet::compact] amount: BalanceOf<T>,
lock_id: LockIdentifier,
) -> DispatchResult {
ensure_root(origin)?;
let who = T::Lookup::lookup(who)?;
<Self as MultiLockableCurrency<T::AccountId>>::set_lock(lock_id, currency_id, &who, amount)
}

/// Remove lock by lock_id
///
/// The dispatch origin of this call must be _Root_.
#[pallet::weight(T::WeightInfo::update_balance_non_native_currency())]
pub fn force_remove_lock(
origin: OriginFor<T>,
who: <T::Lookup as StaticLookup>::Source,
currency_id: CurrencyId,
lock_id: LockIdentifier,
) -> DispatchResult {
ensure_root(origin)?;
let who = T::Lookup::lookup(who)?;
<Self as MultiLockableCurrency<T::AccountId>>::remove_lock(lock_id, currency_id, &who)
}
}
}

Expand Down
99 changes: 98 additions & 1 deletion modules/currencies/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use super::*;
use crate::mock::Erc20HoldingAccount;
use frame_support::{assert_noop, assert_ok, weights::GetDispatchInfo};
use frame_support::{assert_noop, assert_ok, traits::WithdrawReasons, weights::GetDispatchInfo};
use mock::{
alice, bob, deploy_contracts, erc20_address, eva, AccountId, AdaptedBasicCurrency, CouncilAccount, Currencies,
DustAccount, Event, ExtBuilder, NativeCurrency, Origin, PalletBalances, Runtime, System, Tokens, ALICE_BALANCE,
Expand All @@ -36,6 +36,103 @@ use sp_runtime::{
use support::mocks::MockAddressMapping;
use support::EVM as EVMTrait;

#[test]
fn force_set_lock_and_force_remove_lock_should_work() {
ExtBuilder::default()
.one_hundred_for_alice_n_bob()
.build()
.execute_with(|| {
assert_noop!(
Currencies::force_set_lock(Some(bob()).into(), alice(), DOT, 100, ID_1,),
BadOrigin
);

assert_eq!(Tokens::locks(&alice(), DOT).len(), 0);
assert_eq!(PalletBalances::locks(&alice()).len(), 0);

assert_ok!(Currencies::force_set_lock(Origin::root(), alice(), DOT, 100, ID_1,));
assert_ok!(Currencies::force_set_lock(
Origin::root(),
alice(),
NATIVE_CURRENCY_ID,
1000,
ID_1,
));

assert_eq!(
Tokens::locks(&alice(), DOT)[0],
tokens::BalanceLock { id: ID_1, amount: 100 }
);
assert_eq!(
PalletBalances::locks(&alice())[0],
pallet_balances::BalanceLock {
id: ID_1,
amount: 1000,
reasons: WithdrawReasons::all().into(),
}
);

assert_ok!(Currencies::force_set_lock(Origin::root(), alice(), DOT, 10, ID_1,));
assert_ok!(Currencies::force_set_lock(
Origin::root(),
alice(),
NATIVE_CURRENCY_ID,
100,
ID_1,
));
assert_eq!(
Tokens::locks(&alice(), DOT)[0],
tokens::BalanceLock { id: ID_1, amount: 10 }
);
assert_eq!(
PalletBalances::locks(&alice())[0],
pallet_balances::BalanceLock {
id: ID_1,
amount: 100,
reasons: WithdrawReasons::all().into(),
}
);

// do nothing
assert_ok!(Currencies::force_set_lock(Origin::root(), alice(), DOT, 0, ID_1,));
assert_ok!(Currencies::force_set_lock(
Origin::root(),
alice(),
NATIVE_CURRENCY_ID,
0,
ID_1,
));
assert_eq!(
Tokens::locks(&alice(), DOT)[0],
tokens::BalanceLock { id: ID_1, amount: 10 }
);
assert_eq!(
PalletBalances::locks(&alice())[0],
pallet_balances::BalanceLock {
id: ID_1,
amount: 100,
reasons: WithdrawReasons::all().into(),
}
);

// remove lock
assert_noop!(
Currencies::force_remove_lock(Some(bob()).into(), alice(), DOT, ID_1,),
BadOrigin
);

assert_ok!(Currencies::force_remove_lock(Origin::root(), alice(), DOT, ID_1,));
assert_ok!(Currencies::force_remove_lock(
Origin::root(),
alice(),
NATIVE_CURRENCY_ID,
ID_1,
));
assert_eq!(Tokens::locks(&alice(), DOT).len(), 0);
assert_eq!(PalletBalances::locks(&alice()).len(), 0);
});
}

#[test]
fn multi_lockable_currency_should_work() {
ExtBuilder::default()
Expand Down
2 changes: 1 addition & 1 deletion modules/dex-oracle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-dex-oracle"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/dex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-dex"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/earning/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-earning"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/emergency-shutdown/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-emergency-shutdown"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm-accounts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-accounts"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-bridge"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm-utility/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-utility"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm-utility/macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-utility-macro"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "evm-rpc"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm/rpc/runtime_api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-rpc-runtime-api"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-example"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/homa-lite/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-homa-lite"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/homa-validator-list/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-homa-validator-list"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/homa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-homa"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/honzon-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-honzon-bridge"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/honzon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-honzon"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/idle-scheduler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-idle-scheduler"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/incentives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-incentives"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion modules/loans/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-loans"
version = "2.9.2"
version = "2.9.3"
authors = ["Acala Developers"]
edition = "2021"

Expand Down
Loading

0 comments on commit 528a213

Please sign in to comment.