Skip to content

Commit e8d6ca5

Browse files
authored
xcmp xtokens transfer (#117)
* xtokens * xcmp and xtokens for JIT works * change native token to WND * clean code * xcmp * cmd
1 parent 597e4e6 commit e8d6ca5

16 files changed

Lines changed: 1713 additions & 364 deletions

File tree

Cargo.lock

Lines changed: 278 additions & 124 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ members = [
1717
"pallets/poa",
1818
"pallets/poa/rpc",
1919
"pallets/poa/rpc/runtime-api",
20+
"pallets/currencies",
2021
"rpc",
2122
]
2223
exclude = ["vendor/substrate"]

bin/node/cli/Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ sc-chain-spec = { version = "3.0.0", git = "https://github.com/paritytech/substr
3333
sc-telemetry = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
3434

3535
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
36-
cumulus-client-consensus-aura = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098" }
36+
cumulus-client-consensus-aura = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp" }
3737

3838
sp-core = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8"}
3939
sp-inherents = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8"}
@@ -56,19 +56,19 @@ sc-tracing = { version = "3.0.0", git = "https://github.com/paritytech/substrate
5656
pallet-contracts = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
5757

5858
# Cumulus dependencies
59-
cumulus-client-cli = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
60-
cumulus-client-consensus-relay-chain = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
61-
cumulus-client-collator = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
62-
cumulus-client-service = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
63-
cumulus-client-network = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
64-
cumulus-primitives-core = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
65-
cumulus-primitives-parachain-inherent = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
59+
cumulus-client-cli = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
60+
cumulus-client-consensus-relay-chain = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
61+
cumulus-client-collator = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
62+
cumulus-client-service = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
63+
cumulus-client-network = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
64+
cumulus-primitives-core = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
65+
cumulus-primitives-parachain-inherent = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
6666

6767
# Polkadot dependencies
68-
polkadot-primitives = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-098"}
69-
polkadot-service = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-098"}
70-
polkadot-cli = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-098"}
71-
polkadot-parachain = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-098"}
68+
polkadot-primitives = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-xcmp"}
69+
polkadot-service = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-xcmp"}
70+
polkadot-cli = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-xcmp"}
71+
polkadot-parachain = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-xcmp"}
7272

7373
# Jupiter
7474
jupiter-io = { path = "../../../primitives/io" }

bin/node/cli/res/jupiter-westend-patract.json

Lines changed: 40 additions & 36 deletions
Large diffs are not rendered by default.

bin/node/cli/res/westend-patract.json

Lines changed: 139 additions & 138 deletions
Large diffs are not rendered by default.

bin/node/cli/src/chain_spec/jupiter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use jupiter_runtime::{
1717
SudoConfig,
1818
SystemConfig, //ContractsConfig,
1919
};
20+
use jupiter_runtime_common::constants::jupiter_currency::DOTS;
2021
use sc_service::config::TelemetryEndpoints;
2122

2223
// The URL for the telemetry server.
@@ -68,7 +69,7 @@ pub fn session_keys(keys: AuraId) -> jupiter_runtime::opaque::SessionKeys {
6869
}
6970

7071
/// Jupiter Development Chain Config
71-
pub fn development_config(id: ParaId, relay_chain: &str) -> Result<ChainSpec, String> {
72+
pub fn development_config(id: ParaId, relay_chain: &str, token: &str) -> Result<ChainSpec, String> {
7273
Ok(ChainSpec::from_genesis(
7374
// Name
7475
"Development",
@@ -109,8 +110,8 @@ pub fn development_config(id: ParaId, relay_chain: &str) -> Result<ChainSpec, St
109110
Some(
110111
json!({
111112
"ss58Format": jupiter_runtime_common::SS58Prefix::get(),
112-
"tokenDecimals": 10,
113-
"tokenSymbol": "DOT"
113+
"tokenDecimals": 12,
114+
"tokenSymbol": token.to_string()
114115
})
115116
.as_object()
116117
.expect("network properties generation can not fail; qed")
@@ -191,6 +192,8 @@ fn testnet_genesis(
191192
endowed_accounts: Vec<AccountId>,
192193
id: ParaId,
193194
) -> GenesisConfig {
195+
const ENDOWMENT: u128 = 10_000 * DOTS;
196+
194197
GenesisConfig {
195198
system: SystemConfig {
196199
// Add Wasm runtime to storage.
@@ -204,7 +207,7 @@ fn testnet_genesis(
204207
balances: endowed_accounts
205208
.iter()
206209
.cloned()
207-
.map(|k| (k, 1 << 100))
210+
.map(|k| (k, ENDOWMENT))
208211
.collect(),
209212
},
210213
// indices: IndicesConfig { indices: vec![] },
@@ -236,9 +239,6 @@ fn testnet_genesis(
236239
.collect(),
237240
},
238241
aura: Default::default(),
239-
// aura: jupiter_runtime::AuraConfig {
240-
// authorities: initial_authorities,
241-
// },
242242
aura_ext: Default::default(),
243243
parachain_system: Default::default(),
244244
}

bin/node/cli/src/command.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fn load_spec(
2828
// "jupiter-dev" => Box::new(chain_spec::jupiter::development_config(
2929
// para_id,
3030
// "westend-local",
31+
// "WND",
3132
// )?),
3233
// "jupiter-staging" => Box::new(chain_spec::jupiter::staging_config(para_id)?),
3334
// "" | "jupiter" => Box::new(chain_spec::jupiter::jupiter_config()?),

pallets/currencies/Cargo.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[package]
2+
name = "currencies"
3+
version = "1.2.1"
4+
authors = ["Acala Developers"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
serde = { version = "1.0.124", optional = true }
9+
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
10+
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
11+
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
12+
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
13+
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
14+
15+
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
16+
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
17+
18+
orml-traits = { git = 'https://github.com/patractlabs/open-runtime-module-library', branch = 'patract-sandbox-xcmp', default-features = false }
19+
orml-utilities = { git = 'https://github.com/patractlabs/open-runtime-module-library', branch = 'patract-sandbox-xcmp', default-features = false }
20+
21+
jupiter-primitives = { path = "../../primitives", default-features = false }
22+
23+
[dev-dependencies]
24+
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
25+
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
26+
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
27+
tokens = { package = "orml-tokens", git = 'https://github.com/patractlabs/open-runtime-module-library', branch = 'patract-sandbox-xcmp' }
28+
29+
[features]
30+
default = ["std"]
31+
std = [
32+
"serde",
33+
"codec/std",
34+
"sp-core/std",
35+
"sp-runtime/std",
36+
"sp-std/std",
37+
"sp-io/std",
38+
"frame-support/std",
39+
"frame-system/std",
40+
"orml-traits/std",
41+
"orml-utilities/std",
42+
"jupiter-primitives/std",
43+
]
44+
try-runtime = ["frame-support/try-runtime"]

pallets/currencies/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Currencies Module
2+
3+
## Overview
4+
5+
The currencies module provides a mixed currencies system, by configuring a native currency which implements `BasicCurrencyExtended`, and a multi-currency which implements `MultiCurrency`.
6+
7+
It also provides an adapter, to adapt `frame_support::traits::Currency` implementations into `BasicCurrencyExtended`.
8+
9+
The currencies module provides functionality of both `MultiCurrencyExtended` and `BasicCurrencyExtended`, via unified interfaces, and all calls would be delegated to the underlying multi-currency and base currency system. A native currency ID could be set by `Trait::GetNativeCurrencyId`, to identify the native currency.

0 commit comments

Comments
 (0)