Skip to content

Commit 7e05827

Browse files
wangjj9219xlczjb0807
authored
impl rate limit for xtokens (#854)
* poc * add RateLimiter for xtokens * impl new pallet orml-rate-limit * add unit tests * add comment * add weight * update * use explicit call index * fix features * update Cargo.toml --------- Co-authored-by: Bryan Chen <[email protected]> Co-authored-by: zjb0807 <[email protected]>
1 parent d26b0b1 commit 7e05827

File tree

15 files changed

+1758
-4
lines changed

15 files changed

+1758
-4
lines changed

Cargo.dev.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ members = [
1212
"oracle/runtime-api",
1313
"parameters",
1414
"payments",
15+
"rate-limit",
1516
"rewards",
1617
"tokens",
1718
"tokens/runtime-api",
@@ -47,6 +48,7 @@ pallet-message-queue = { version = "32.0.0", default-features = false }
4748
pallet-preimage = { version = "29.0.0", default-features = false }
4849
pallet-root-testing = { version = "5.0.0", default-features = false }
4950
pallet-scheduler = { version = "30.0.0", default-features = false }
51+
pallet-timestamp = { version = "28.0.0", default-features = false }
5052
pallet-treasury = { version = "28.0.0", default-features = false }
5153
pallet-xcm = { version = "8.0.0", default-features = false }
5254
polkadot-parachain-primitives = { version = "7.0.0", default-features = false }

asset-registry/src/mock/para.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ impl orml_xtokens::Config for Runtime {
325325
type UniversalLocation = UniversalLocation;
326326
type MaxAssetsForTransfer = MaxAssetsForTransfer;
327327
type ReserveProvider = RelativeReserveProvider;
328+
type RateLimiter = ();
329+
type RateLimiterId = ();
328330
}
329331

330332
impl orml_xcm::Config for Runtime {

rate-limit/Cargo.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[package]
2+
name = "orml-rate-limit"
3+
description = "Provides way to config rate limiter for limit some operation."
4+
repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rate-limit"
5+
license = "Apache-2.0"
6+
version = "0.7.0"
7+
authors = ["Laminar Developers <[email protected]>"]
8+
edition = "2021"
9+
10+
[dependencies]
11+
parity-scale-codec = { workspace = true }
12+
scale-info = { workspace = true }
13+
serde = { workspace = true, optional = true }
14+
15+
frame-support = { workspace = true }
16+
frame-system = { workspace = true }
17+
sp-core = { workspace = true }
18+
sp-io = { workspace = true }
19+
sp-runtime = { workspace = true }
20+
sp-std = { workspace = true }
21+
22+
orml-traits = { path = "../traits", version = "0.7.0", default-features = false }
23+
orml-utilities = { path = "../utilities", version = "0.7.0", default-features = false }
24+
25+
[dev-dependencies]
26+
pallet-timestamp = { workspace = true, features = ["std"] }
27+
28+
[features]
29+
default = [ "std" ]
30+
std = [
31+
"frame-support/std",
32+
"frame-system/std",
33+
"orml-traits/std",
34+
"orml-utilities/std",
35+
"parity-scale-codec/std",
36+
"scale-info/std",
37+
"serde",
38+
"sp-core/std",
39+
"sp-io/std",
40+
"sp-runtime/std",
41+
"sp-std/std",
42+
]
43+
runtime-benchmarks = [
44+
"frame-support/runtime-benchmarks",
45+
"frame-system/runtime-benchmarks",
46+
"sp-runtime/runtime-benchmarks",
47+
]
48+
try-runtime = [
49+
"frame-support/try-runtime",
50+
"frame-system/try-runtime",
51+
"sp-runtime/try-runtime",
52+
]

0 commit comments

Comments
 (0)