Skip to content

Commit

Permalink
Fix/shadow dot (paritytech#276)
Browse files Browse the repository at this point in the history
* Change xdot to sdot

* add sdot

* format code

* For testnet

* ChainX version
  • Loading branch information
gguoss authored Feb 18, 2019
1 parent 3e715dc commit 090d63c
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 66 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainx"
version = "0.3.0"
version = "0.9.0"
build = "build.rs"
authors = ["Chainpool <https://www.chainx.org>"]

Expand Down Expand Up @@ -62,7 +62,7 @@ members = [
"xrml/xmining/staking",
"xrml/xmining/tokens",
"xrml/xbridge/bitcoin",
"xrml/xbridge/xdot",
"xrml/xbridge/sdot",
]

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn local_testnet_genesis() -> GenesisConfig {
/// Local testnet config (multivalidator Alice + Bob)
pub fn local_testnet_config() -> ChainSpec {
ChainSpec::from_genesis(
"ChainX Testnet",
"ChainX V0.9.0",
"chainx_testnet",
local_testnet_genesis,
vec![],
Expand Down
20 changes: 10 additions & 10 deletions cli/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use chainx_runtime::{
use chainx_runtime::{
BalancesConfig, ConsensusConfig, GenesisConfig, IndicesConfig, Params, SessionConfig,
SudoConfig, TimestampConfig, XAssetsConfig, XAssetsProcessConfig, XBridgeOfBTCConfig,
XBridgeOfXDOTConfig, XFeeManagerConfig, XSpotConfig, XStakingConfig, XSystemConfig,
XBridgeOfSDOTConfig, XFeeManagerConfig, XSpotConfig, XStakingConfig, XSystemConfig,
XTokensConfig,
};

Expand Down Expand Up @@ -89,12 +89,12 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
// )
// .unwrap();

let xdot_asset = Asset::new(
b"XDOT".to_vec(), // token
b"XDOT".to_vec(),
let sdot_asset = Asset::new(
b"SDOT".to_vec(), // token
b"SDOT".to_vec(),
Chain::Ethereum,
3, // precision
b"XDOT ChainX".to_vec(),
b"SDOT ChainX".to_vec(),
)
.unwrap();

Expand Down Expand Up @@ -203,11 +203,11 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
asset_list: vec![
(btc_asset.clone(), true, vec![(Keyring::Alice.to_raw_public().into(), 100_000),(Keyring::Bob.to_raw_public().into(), 100_000)]),
// (dot_asset.clone(), false, vec![(Keyring::Alice.to_raw_public().into(), 1_000_000_000),(Keyring::Bob.to_raw_public().into(), 1_000_000_000)]),
(xdot_asset.clone(), true, vec![(Keyring::Alice.to_raw_public().into(), 10_000),(Keyring::Bob.to_raw_public().into(), 10_000)])
(sdot_asset.clone(), true, vec![(Keyring::Alice.to_raw_public().into(), 10_000),(Keyring::Bob.to_raw_public().into(), 10_000)])
],
}),
xprocess: Some(XAssetsProcessConfig {
token_black_list: vec![xdot_asset.token()],
token_black_list: vec![sdot_asset.token()],
_genesis_phantom_data: Default::default(),
}),
xstaking: Some(XStakingConfig {
Expand All @@ -230,18 +230,18 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
token_discount: Permill::from_percent(30),
endowed_users: vec![
(btc_asset.token(), vec![(Keyring::Alice.to_raw_public().into(), 100_000),(Keyring::Bob.to_raw_public().into(), 100_000)]),
(xdot_asset.token(), vec![(Keyring::Alice.to_raw_public().into(), 10_000),(Keyring::Bob.to_raw_public().into(), 10_000)])
(sdot_asset.token(), vec![(Keyring::Alice.to_raw_public().into(), 10_000),(Keyring::Bob.to_raw_public().into(), 10_000)])
],
}),
xspot: Some(XSpotConfig {
pair_list: vec![
(xassets::Module::<Runtime>::TOKEN.to_vec(), bitcoin::Module::<Runtime>::TOKEN.to_vec(), 9, 2, 100000, true),
// (<xassets::Module<Runtime> as ChainT>::TOKEN.to_vec(),dot_asset.token().to_vec(),7,2,100000,false),
(xdot_asset.token(), xassets::Module::<Runtime>::TOKEN.to_vec(), 4, 2, 100000, true)
(sdot_asset.token(), xassets::Module::<Runtime>::TOKEN.to_vec(), 4, 2, 100000, true)
],
price_volatility: 10,
}),
xdot: Some(XBridgeOfXDOTConfig {
sdot: Some(XBridgeOfSDOTConfig {
claims: vec![(eth_address, 1_000_000),],
}),
bitcoin: Some(XBridgeOfBTCConfig {
Expand Down
4 changes: 2 additions & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ xrml-mining-staking = { path = "../xrml/xmining/staking", default-features = fal
xrml-mining-tokens = { path = "../xrml/xmining/tokens", default-features = false }
# bridge
xrml-bridge-bitcoin = {path = "../xrml/xbridge/bitcoin", default-features = false }
xrml-bridge-xdot = {path = "../xrml/xbridge/xdot", default-features = false }
xrml-bridge-sdot = {path = "../xrml/xbridge/sdot", default-features = false }
# dex
xrml-xdex-spot = { path = "../xrml/xdex/spot", default-features = false }

Expand Down Expand Up @@ -116,7 +116,7 @@ std = [
"xrml-mining-tokens/std",
# bridge
"xrml-bridge-bitcoin/std",
"xrml-bridge-xdot/std",
"xrml-bridge-sdot/std",
# dex
"xrml-xdex-spot/std",
]
6 changes: 3 additions & 3 deletions runtime/src/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

//use balances::Call as BalancesCall;
use bitcoin::Call as BitcoinCall;
use sdot::Call as SdotCall;
use sudo::Call as SudoCall;
use xassets::Call as XAssetsCall;
use xdot::Call as XdotCall;
use xprocess::Call as XAssetsProcessCall;
use xspot::Call as XSpotCall;
use xstaking::Call as XStakingCall;
Expand Down Expand Up @@ -69,8 +69,8 @@ impl CheckFee for Call {
SudoCall::set_key(_) => Some(1),
_ => None,
},
Call::XBridgeOfXDOT(call) => match call {
XdotCall::claim(_, _, _) => Some(1),
Call::XBridgeOfSDOT(call) => match call {
SdotCall::claim(_, _, _) => Some(1),
_ => None,
},
_ => None,
Expand Down
6 changes: 3 additions & 3 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub extern crate xrml_xassets_process as xprocess;
pub extern crate xrml_xassets_records as xrecords;
// bridge
pub extern crate xrml_bridge_bitcoin as bitcoin;
pub extern crate xrml_bridge_xdot as xdot;
pub extern crate xrml_bridge_sdot as sdot;
// staking
pub extern crate xrml_mining_staking as xstaking;
pub extern crate xrml_mining_tokens as xtokens;
Expand Down Expand Up @@ -201,7 +201,7 @@ impl bitcoin::Trait for Runtime {
type Event = Event;
}

impl xdot::Trait for Runtime {
impl sdot::Trait for Runtime {
type Event = Event;
}

Expand Down Expand Up @@ -321,7 +321,7 @@ construct_runtime!(
XSpot: xspot,
// bridge
XBridgeOfBTC: bitcoin::{Module, Call, Storage, Config<T>, Event<T>},
XBridgeOfXDOT: xdot::{Module, Call, Storage, Config<T>, Event<T>},
XBridgeOfSDOT: sdot::{Module, Call, Storage, Config<T>, Event<T>},
}
);

Expand Down
18 changes: 9 additions & 9 deletions runtime/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
2 changes: 1 addition & 1 deletion xrml/xbridge/bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xrml-bridge-bitcoin"
version = "0.4.0"
version = "0.9.0"
authors = ["Chainpool <http://chainx.org>"]

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions xrml/xbridge/xdot/Cargo.toml → xrml/xbridge/sdot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xrml-bridge-xdot"
version = "0.6.0"
name = "xrml-bridge-sdot"
version = "0.9.0"
authors = ["Chainpool <http://chainx.org>"]

[dependencies]
Expand Down
11 changes: 7 additions & 4 deletions xrml/xbridge/xdot/src/lib.rs → xrml/xbridge/sdot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern crate xr_primitives;

use codec::Encode;
use rstd::prelude::*;
use sr_primitives::traits::As;
#[cfg(feature = "std")]
use sr_primitives::traits::Zero;
use srml_support::dispatch::Result;
Expand All @@ -33,7 +34,7 @@ use xr_primitives::generic::Extracter;
use xr_primitives::traits::Extractable;

impl<T: Trait> ChainT for Module<T> {
const TOKEN: &'static [u8] = b"XDOT";
const TOKEN: &'static [u8] = b"SDOT";

fn chain() -> ChainDef {
ChainDef::Ethereum
Expand Down Expand Up @@ -69,7 +70,7 @@ decl_event!(
);

decl_storage! {
trait Store for Module<T: Trait> as XBridgeOfXDOT {
trait Store for Module<T: Trait> as XBridgeOfSDOT {
pub Claims get(claims) build(|config: &GenesisConfig<T>| {
config.claims.iter().map(|(a, b)| (a.clone(), b.clone())).collect::<Vec<_>>()
}): map EthereumAddress => Option<T::Balance>;
Expand Down Expand Up @@ -133,14 +134,16 @@ decl_module! {

let signer = eth_recover(&ethereum_signature, &sign_data).ok_or("Invalid Ethereum signature")?;

let balance_due = <Claims<T>>::take(&signer)
/*let balance_due = <Claims<T>>::take(&signer)
.ok_or("Ethereum address has no claim")?;
<Total<T>>::mutate(|t| if *t < balance_due {
panic!("Logic error: Pot less than the total of claims!")
} else {
*t -= balance_due
});
});*/
// only for test.
let balance_due = <T as balances::Trait>::Balance::sa(5_000);
deposit_token::<T>(&who, balance_due);

xaccounts::apply_update_binding::<T>(who, signer.to_vec(), node_name, ChainDef::Ethereum);
Expand Down
Loading

0 comments on commit 090d63c

Please sign in to comment.