Skip to content

Commit 090d63c

Browse files
authored
Fix/shadow dot (paritytech#276)
* Change xdot to sdot * add sdot * format code * For testnet * ChainX version
1 parent 3e715dc commit 090d63c

File tree

13 files changed

+79
-66
lines changed

13 files changed

+79
-66
lines changed

Cargo.lock

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chainx"
3-
version = "0.3.0"
3+
version = "0.9.0"
44
build = "build.rs"
55
authors = ["Chainpool <https://www.chainx.org>"]
66

@@ -62,7 +62,7 @@ members = [
6262
"xrml/xmining/staking",
6363
"xrml/xmining/tokens",
6464
"xrml/xbridge/bitcoin",
65-
"xrml/xbridge/xdot",
65+
"xrml/xbridge/sdot",
6666
]
6767

6868
[build-dependencies]

cli/src/chain_spec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn local_testnet_genesis() -> GenesisConfig {
5353
/// Local testnet config (multivalidator Alice + Bob)
5454
pub fn local_testnet_config() -> ChainSpec {
5555
ChainSpec::from_genesis(
56-
"ChainX Testnet",
56+
"ChainX V0.9.0",
5757
"chainx_testnet",
5858
local_testnet_genesis,
5959
vec![],

cli/src/genesis_config.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use chainx_runtime::{
1818
use chainx_runtime::{
1919
BalancesConfig, ConsensusConfig, GenesisConfig, IndicesConfig, Params, SessionConfig,
2020
SudoConfig, TimestampConfig, XAssetsConfig, XAssetsProcessConfig, XBridgeOfBTCConfig,
21-
XBridgeOfXDOTConfig, XFeeManagerConfig, XSpotConfig, XStakingConfig, XSystemConfig,
21+
XBridgeOfSDOTConfig, XFeeManagerConfig, XSpotConfig, XStakingConfig, XSystemConfig,
2222
XTokensConfig,
2323
};
2424

@@ -89,12 +89,12 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
8989
// )
9090
// .unwrap();
9191

92-
let xdot_asset = Asset::new(
93-
b"XDOT".to_vec(), // token
94-
b"XDOT".to_vec(),
92+
let sdot_asset = Asset::new(
93+
b"SDOT".to_vec(), // token
94+
b"SDOT".to_vec(),
9595
Chain::Ethereum,
9696
3, // precision
97-
b"XDOT ChainX".to_vec(),
97+
b"SDOT ChainX".to_vec(),
9898
)
9999
.unwrap();
100100

@@ -203,11 +203,11 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
203203
asset_list: vec![
204204
(btc_asset.clone(), true, vec![(Keyring::Alice.to_raw_public().into(), 100_000),(Keyring::Bob.to_raw_public().into(), 100_000)]),
205205
// (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)]),
206-
(xdot_asset.clone(), true, vec![(Keyring::Alice.to_raw_public().into(), 10_000),(Keyring::Bob.to_raw_public().into(), 10_000)])
206+
(sdot_asset.clone(), true, vec![(Keyring::Alice.to_raw_public().into(), 10_000),(Keyring::Bob.to_raw_public().into(), 10_000)])
207207
],
208208
}),
209209
xprocess: Some(XAssetsProcessConfig {
210-
token_black_list: vec![xdot_asset.token()],
210+
token_black_list: vec![sdot_asset.token()],
211211
_genesis_phantom_data: Default::default(),
212212
}),
213213
xstaking: Some(XStakingConfig {
@@ -230,18 +230,18 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
230230
token_discount: Permill::from_percent(30),
231231
endowed_users: vec![
232232
(btc_asset.token(), vec![(Keyring::Alice.to_raw_public().into(), 100_000),(Keyring::Bob.to_raw_public().into(), 100_000)]),
233-
(xdot_asset.token(), vec![(Keyring::Alice.to_raw_public().into(), 10_000),(Keyring::Bob.to_raw_public().into(), 10_000)])
233+
(sdot_asset.token(), vec![(Keyring::Alice.to_raw_public().into(), 10_000),(Keyring::Bob.to_raw_public().into(), 10_000)])
234234
],
235235
}),
236236
xspot: Some(XSpotConfig {
237237
pair_list: vec![
238238
(xassets::Module::<Runtime>::TOKEN.to_vec(), bitcoin::Module::<Runtime>::TOKEN.to_vec(), 9, 2, 100000, true),
239239
// (<xassets::Module<Runtime> as ChainT>::TOKEN.to_vec(),dot_asset.token().to_vec(),7,2,100000,false),
240-
(xdot_asset.token(), xassets::Module::<Runtime>::TOKEN.to_vec(), 4, 2, 100000, true)
240+
(sdot_asset.token(), xassets::Module::<Runtime>::TOKEN.to_vec(), 4, 2, 100000, true)
241241
],
242242
price_volatility: 10,
243243
}),
244-
xdot: Some(XBridgeOfXDOTConfig {
244+
sdot: Some(XBridgeOfSDOTConfig {
245245
claims: vec![(eth_address, 1_000_000),],
246246
}),
247247
bitcoin: Some(XBridgeOfBTCConfig {

runtime/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ xrml-mining-staking = { path = "../xrml/xmining/staking", default-features = fal
5757
xrml-mining-tokens = { path = "../xrml/xmining/tokens", default-features = false }
5858
# bridge
5959
xrml-bridge-bitcoin = {path = "../xrml/xbridge/bitcoin", default-features = false }
60-
xrml-bridge-xdot = {path = "../xrml/xbridge/xdot", default-features = false }
60+
xrml-bridge-sdot = {path = "../xrml/xbridge/sdot", default-features = false }
6161
# dex
6262
xrml-xdex-spot = { path = "../xrml/xdex/spot", default-features = false }
6363

@@ -116,7 +116,7 @@ std = [
116116
"xrml-mining-tokens/std",
117117
# bridge
118118
"xrml-bridge-bitcoin/std",
119-
"xrml-bridge-xdot/std",
119+
"xrml-bridge-sdot/std",
120120
# dex
121121
"xrml-xdex-spot/std",
122122
]

runtime/src/fee.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
//use balances::Call as BalancesCall;
44
use bitcoin::Call as BitcoinCall;
5+
use sdot::Call as SdotCall;
56
use sudo::Call as SudoCall;
67
use xassets::Call as XAssetsCall;
7-
use xdot::Call as XdotCall;
88
use xprocess::Call as XAssetsProcessCall;
99
use xspot::Call as XSpotCall;
1010
use xstaking::Call as XStakingCall;
@@ -69,8 +69,8 @@ impl CheckFee for Call {
6969
SudoCall::set_key(_) => Some(1),
7070
_ => None,
7171
},
72-
Call::XBridgeOfXDOT(call) => match call {
73-
XdotCall::claim(_, _, _) => Some(1),
72+
Call::XBridgeOfSDOT(call) => match call {
73+
SdotCall::claim(_, _, _) => Some(1),
7474
_ => None,
7575
},
7676
_ => None,

runtime/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub extern crate xrml_xassets_process as xprocess;
6565
pub extern crate xrml_xassets_records as xrecords;
6666
// bridge
6767
pub extern crate xrml_bridge_bitcoin as bitcoin;
68-
pub extern crate xrml_bridge_xdot as xdot;
68+
pub extern crate xrml_bridge_sdot as sdot;
6969
// staking
7070
pub extern crate xrml_mining_staking as xstaking;
7171
pub extern crate xrml_mining_tokens as xtokens;
@@ -201,7 +201,7 @@ impl bitcoin::Trait for Runtime {
201201
type Event = Event;
202202
}
203203

204-
impl xdot::Trait for Runtime {
204+
impl sdot::Trait for Runtime {
205205
type Event = Event;
206206
}
207207

@@ -321,7 +321,7 @@ construct_runtime!(
321321
XSpot: xspot,
322322
// bridge
323323
XBridgeOfBTC: bitcoin::{Module, Call, Storage, Config<T>, Event<T>},
324-
XBridgeOfXDOT: xdot::{Module, Call, Storage, Config<T>, Event<T>},
324+
XBridgeOfSDOT: sdot::{Module, Call, Storage, Config<T>, Event<T>},
325325
}
326326
);
327327

runtime/wasm/Cargo.lock

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xrml/xbridge/bitcoin/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "xrml-bridge-bitcoin"
3-
version = "0.4.0"
3+
version = "0.9.0"
44
authors = ["Chainpool <http://chainx.org>"]
55

66
[dependencies]

xrml/xbridge/xdot/Cargo.toml xrml/xbridge/sdot/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "xrml-bridge-xdot"
3-
version = "0.6.0"
2+
name = "xrml-bridge-sdot"
3+
version = "0.9.0"
44
authors = ["Chainpool <http://chainx.org>"]
55

66
[dependencies]

xrml/xbridge/xdot/src/lib.rs xrml/xbridge/sdot/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern crate xr_primitives;
2222

2323
use codec::Encode;
2424
use rstd::prelude::*;
25+
use sr_primitives::traits::As;
2526
#[cfg(feature = "std")]
2627
use sr_primitives::traits::Zero;
2728
use srml_support::dispatch::Result;
@@ -33,7 +34,7 @@ use xr_primitives::generic::Extracter;
3334
use xr_primitives::traits::Extractable;
3435

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

3839
fn chain() -> ChainDef {
3940
ChainDef::Ethereum
@@ -69,7 +70,7 @@ decl_event!(
6970
);
7071

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

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

136-
let balance_due = <Claims<T>>::take(&signer)
137+
/*let balance_due = <Claims<T>>::take(&signer)
137138
.ok_or("Ethereum address has no claim")?;
138139
139140
<Total<T>>::mutate(|t| if *t < balance_due {
140141
panic!("Logic error: Pot less than the total of claims!")
141142
} else {
142143
*t -= balance_due
143-
});
144+
});*/
145+
// only for test.
146+
let balance_due = <T as balances::Trait>::Balance::sa(5_000);
144147
deposit_token::<T>(&who, balance_due);
145148

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

0 commit comments

Comments
 (0)