Skip to content

Commit

Permalink
xcmp xtokens transfer (#117)
Browse files Browse the repository at this point in the history
* xtokens

* xcmp and xtokens for JIT works

* change native token to WND

* clean code

* xcmp

* cmd
  • Loading branch information
zqhxuyuan authored Aug 12, 2021
1 parent 597e4e6 commit e8d6ca5
Show file tree
Hide file tree
Showing 16 changed files with 1,713 additions and 364 deletions.
402 changes: 278 additions & 124 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"pallets/poa",
"pallets/poa/rpc",
"pallets/poa/rpc/runtime-api",
"pallets/currencies",
"rpc",
]
exclude = ["vendor/substrate"]
Expand Down
24 changes: 12 additions & 12 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sc-chain-spec = { version = "3.0.0", git = "https://github.com/paritytech/substr
sc-telemetry = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }

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

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

# Cumulus dependencies
cumulus-client-cli = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
cumulus-client-consensus-relay-chain = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
cumulus-client-collator = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
cumulus-client-service = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
cumulus-client-network = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
cumulus-primitives-core = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
cumulus-primitives-parachain-inherent = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-098"}
cumulus-client-cli = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
cumulus-client-consensus-relay-chain = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
cumulus-client-collator = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
cumulus-client-service = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
cumulus-client-network = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
cumulus-primitives-core = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}
cumulus-primitives-parachain-inherent = { git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp"}

# Polkadot dependencies
polkadot-primitives = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-098"}
polkadot-service = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-098"}
polkadot-cli = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-098"}
polkadot-parachain = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-098"}
polkadot-primitives = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-xcmp"}
polkadot-service = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-xcmp"}
polkadot-cli = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-xcmp"}
polkadot-parachain = { git = "https://github.com/patractlabs/polkadot", branch = "patract-sandbox-xcmp"}

# Jupiter
jupiter-io = { path = "../../../primitives/io" }
Expand Down
76 changes: 40 additions & 36 deletions bin/node/cli/res/jupiter-westend-patract.json

Large diffs are not rendered by default.

277 changes: 139 additions & 138 deletions bin/node/cli/res/westend-patract.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions bin/node/cli/src/chain_spec/jupiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use jupiter_runtime::{
SudoConfig,
SystemConfig, //ContractsConfig,
};
use jupiter_runtime_common::constants::jupiter_currency::DOTS;
use sc_service::config::TelemetryEndpoints;

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

/// Jupiter Development Chain Config
pub fn development_config(id: ParaId, relay_chain: &str) -> Result<ChainSpec, String> {
pub fn development_config(id: ParaId, relay_chain: &str, token: &str) -> Result<ChainSpec, String> {
Ok(ChainSpec::from_genesis(
// Name
"Development",
Expand Down Expand Up @@ -109,8 +110,8 @@ pub fn development_config(id: ParaId, relay_chain: &str) -> Result<ChainSpec, St
Some(
json!({
"ss58Format": jupiter_runtime_common::SS58Prefix::get(),
"tokenDecimals": 10,
"tokenSymbol": "DOT"
"tokenDecimals": 12,
"tokenSymbol": token.to_string()
})
.as_object()
.expect("network properties generation can not fail; qed")
Expand Down Expand Up @@ -191,6 +192,8 @@ fn testnet_genesis(
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> GenesisConfig {
const ENDOWMENT: u128 = 10_000 * DOTS;

GenesisConfig {
system: SystemConfig {
// Add Wasm runtime to storage.
Expand All @@ -204,7 +207,7 @@ fn testnet_genesis(
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, 1 << 100))
.map(|k| (k, ENDOWMENT))
.collect(),
},
// indices: IndicesConfig { indices: vec![] },
Expand Down Expand Up @@ -236,9 +239,6 @@ fn testnet_genesis(
.collect(),
},
aura: Default::default(),
// aura: jupiter_runtime::AuraConfig {
// authorities: initial_authorities,
// },
aura_ext: Default::default(),
parachain_system: Default::default(),
}
Expand Down
1 change: 1 addition & 0 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn load_spec(
// "jupiter-dev" => Box::new(chain_spec::jupiter::development_config(
// para_id,
// "westend-local",
// "WND",
// )?),
// "jupiter-staging" => Box::new(chain_spec::jupiter::staging_config(para_id)?),
// "" | "jupiter" => Box::new(chain_spec::jupiter::jupiter_config()?),
Expand Down
44 changes: 44 additions & 0 deletions pallets/currencies/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "currencies"
version = "1.2.1"
authors = ["Acala Developers"]
edition = "2018"

[dependencies]
serde = { version = "1.0.124", optional = true }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }

frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }

orml-traits = { git = 'https://github.com/patractlabs/open-runtime-module-library', branch = 'patract-sandbox-xcmp', default-features = false }
orml-utilities = { git = 'https://github.com/patractlabs/open-runtime-module-library', branch = 'patract-sandbox-xcmp', default-features = false }

jupiter-primitives = { path = "../../primitives", default-features = false }

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
tokens = { package = "orml-tokens", git = 'https://github.com/patractlabs/open-runtime-module-library', branch = 'patract-sandbox-xcmp' }

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"sp-io/std",
"frame-support/std",
"frame-system/std",
"orml-traits/std",
"orml-utilities/std",
"jupiter-primitives/std",
]
try-runtime = ["frame-support/try-runtime"]
9 changes: 9 additions & 0 deletions pallets/currencies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Currencies Module

## Overview

The currencies module provides a mixed currencies system, by configuring a native currency which implements `BasicCurrencyExtended`, and a multi-currency which implements `MultiCurrency`.

It also provides an adapter, to adapt `frame_support::traits::Currency` implementations into `BasicCurrencyExtended`.

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.
Loading

0 comments on commit e8d6ca5

Please sign in to comment.