Skip to content

Commit 718a9a2

Browse files
authored
Use repatriate_reserved instead of unreserve + transfer (paritytech#195)
* Use repatriate_reserved instead of unreserve + transfer * Remove deprecated stuffs * Split out xp-assets-registrar Use impl-trait-for-tuples crate * Add some docs * . * Avoid allocation * Add some docs * Fix the vesting offset FIXME * Add a test for vesting migration offset * . * Remove currently unused files in rpc * Fix a bunch of clippy warnings * Nits
1 parent f9609bb commit 718a9a2

File tree

35 files changed

+194
-506
lines changed

35 files changed

+194
-506
lines changed

Cargo.lock

Lines changed: 10 additions & 0 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
@@ -21,6 +21,7 @@ members = [
2121
"primitives/runtime",
2222
"primitives/mining/common",
2323
"primitives/mining/staking",
24+
"primitives/assets-registrar",
2425
"rpc",
2526

2627
"frame/balances",

Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,3 @@ format: pre-format
4848

4949
clean:
5050
@cargo clean
51-
52-
upgrade:
53-
@echo "Upgrading substrate under native..."
54-
cargo update -p srml-system
55-
@echo
56-
@echo "Upgrading substrate under wasm..."
57-
cd runtime/wasm && cargo update -p srml-system

cli/src/chain_spec.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ fn testnet_genesis(
358358

359359
// PCX only reserves the native asset id in assets module,
360360
// the actual native fund management is handled by pallet_balances.
361-
let mut assets_endowed = endowed.clone();
361+
let mut assets_endowed = endowed;
362362
assets_endowed.remove(&xpallet_protocol::PCX);
363363

364364
let validators = initial_authorities
@@ -471,7 +471,6 @@ fn testnet_genesis(
471471
100000,
472472
true,
473473
)],
474-
..Default::default()
475474
}),
476475
xpallet_contracts: Some(XContractsConfig {
477476
current_schedule: ContractsSchedule {

cli/src/config.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ fn read_config_file(path: &Path) -> Result<HashMap<String, Value>, Box<dyn std::
88
let mut bytes = Vec::new();
99
File::open(path)?.read_to_end(&mut bytes)?;
1010

11-
Ok(serde_json::from_slice(&bytes).expect(&format!(
12-
"JSON was not well-formatted, please ensure {} is a valid JSON file.",
13-
path.display()
14-
)))
11+
Ok(serde_json::from_slice(&bytes).unwrap_or_else(|_| {
12+
panic!(
13+
"JSON was not well-formatted, please ensure {} is a valid JSON file.",
14+
path.display()
15+
)
16+
}))
1517
}
1618

1719
/// Extends the origin cli arg list with the options from the config file.
@@ -83,7 +85,7 @@ pub fn preprocess_cli_args(cli_args: Vec<String>) -> Vec<String> {
8385
.expect("The argument '--config <PATH>' requires a value but none was supplied");
8486
config_path = Some(path.to_string());
8587
} else if arg.starts_with("--config=") {
86-
config_path = arg.split('=').skip(1).next().map(|s| s.to_string());
88+
config_path = arg.split('=').nth(1).map(|s| s.to_string());
8789
assert!(config_path.is_some(), "missing PATH in --config=<PATH>");
8890
}
8991
}

cli/src/logger.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn parse_log_filters(log_filters: &str) -> (Vec<Directive>, Option<LevelFilter>)
4242
return (directives, None);
4343
}
4444

45-
mods.map(|m| {
45+
if let Some(m) = mods {
4646
let print_warning =
4747
|v: &str| eprintln!("warning: invalid log_filters value '{}', ignoring it", v);
4848

@@ -79,7 +79,7 @@ fn parse_log_filters(log_filters: &str) -> (Vec<Directive>, Option<LevelFilter>)
7979
level: log_level,
8080
});
8181
}
82-
});
82+
}
8383

8484
let mut filter_level = LevelFilter::Off;
8585
for d in directives.iter() {

polkadotjs.md

Lines changed: 0 additions & 202 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "xp-assets-registrar"
3+
version = "0.1.0"
4+
authors = ["ChainX community <https://www.chainx.org>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
impl-trait-for-tuples = "0.1.3"
9+
10+
frame-support = { version = "2.0.0-rc5", default-features = false }
11+
12+
chainx-primitives = { path = "../../primitives", default-features = false }
13+
14+
[features]
15+
default = ["std"]
16+
std = [
17+
"frame-support/std",
18+
"chainx-primitives/std",
19+
]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![cfg_attr(not(feature = "std"), no_std)]
2+
3+
use chainx_primitives::AssetId;
4+
use frame_support::dispatch::DispatchResult;
5+
6+
/// Trait for doing some stuff on the registration/deregistration of a foreign asset.
7+
pub trait RegistrarHandler {
8+
/// Called when a new asset is added or a deregistered asset is recovered.
9+
fn on_register(_asset_id: &AssetId, _has_mining_rights: bool) -> DispatchResult {
10+
Ok(())
11+
}
12+
13+
/// Called when an asset is deregistered.
14+
fn on_deregister(_asset_id: &AssetId) -> DispatchResult {
15+
Ok(())
16+
}
17+
}
18+
19+
#[impl_trait_for_tuples::impl_for_tuples(30)]
20+
impl RegistrarHandler for Tuple {
21+
fn on_register(asset_id: &AssetId, has_mining_rights: bool) -> DispatchResult {
22+
for_tuples!( #( Tuple::on_register(asset_id, has_mining_rights)?; )* );
23+
Ok(())
24+
}
25+
26+
fn on_deregister(asset_id: &AssetId) -> DispatchResult {
27+
for_tuples!( #( Tuple::on_deregister(asset_id)?; )* );
28+
Ok(())
29+
}
30+
}

rpc/src/apis.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

rpc/src/errors.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)