Skip to content

Commit

Permalink
make parameters default
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Jan 14, 2025
1 parent 361c60d commit 8490979
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
11 changes: 10 additions & 1 deletion control/preimage/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ pub fn force_set_metadata(params: &UpdateAssetArgs) -> AssetHubRuntimeCall {
}

pub fn register_ether(params: &RegisterEtherArgs) -> (AssetHubRuntimeCall, AssetHubRuntimeCall) {
use subxt::utils::AccountId32;
let chain_id = crate::bridge_hub_runtime::CHAIN_ID;
#[cfg(feature = "paseo")]
use asset_hub_paseo_types::*;
Expand All @@ -346,7 +347,15 @@ pub fn register_ether(params: &RegisterEtherArgs) -> (AssetHubRuntimeCall, Asset
use asset_hub_westend_types::*;

let asset_id = get_ether_id(chain_id);
let owner = GlobalConsensusEthereumConvertsFor::<[u8; 32]>::from_chain_id(&chain_id);

let force_register =
AssetHubRuntimeCall::ForeignAssets(pallet_assets::pallet::Call2::force_create {
id: asset_id.clone(),
min_balance: params.ether_min_balance,
is_sufficient: true,
owner: MultiAddress::<AccountId32, ()>::Id(owner.into()),
});
let metadata =
AssetHubRuntimeCall::ForeignAssets(pallet_assets::pallet::Call2::force_set_metadata {
id: asset_id,
Expand All @@ -356,5 +365,5 @@ pub fn register_ether(params: &RegisterEtherArgs) -> (AssetHubRuntimeCall, Asset
is_frozen: false,
});

return (metadata.clone(), metadata);
return (force_register, metadata);
}
13 changes: 1 addition & 12 deletions control/preimage/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,8 @@ pub struct TreasuryProposal2024Args {
#[derive(Debug, Args)]
pub struct RegisterEtherArgs {
/// The minimum balance of the Ether asset that users are allowed to hold
#[arg(long, value_name = "WEI", value_parser = parse_units_wei, default_value_t = 1u128)]
#[arg(long, value_name = "WEI", default_value_t = 1u128)]
ether_min_balance: u128,
/// Make Ether asset sufficient
#[arg(long, default_value_t = true)]
ether_sufficient: bool,
/// The Ether asset owner. This should be the Gateway Proxy Address sovereign account
#[arg(long, value_name = "ADDRESS", value_parser=parse_hex_bytes32)]
ether_owner: FixedBytes<32>,
/// The Ether asset display name
#[arg(long, value_name = "ASSET_DISPLAY_NAME", default_value_t = String::from("Ether"))]
ether_name: String,
Expand Down Expand Up @@ -281,11 +275,6 @@ fn parse_units_polkadot(v: &str) -> Result<U128, String> {
Ok(amount)
}

fn parse_units_wei(v: &str) -> Result<U256, String> {
let amount = parse_units(v, "wei").map_err(|e| format!("{e}"))?;
Ok(amount.into())
}

fn parse_units_gwei(v: &str) -> Result<U256, String> {
let amount = parse_units(v, "gwei").map_err(|e| format!("{e}"))?;
Ok(amount.into())
Expand Down

0 comments on commit 8490979

Please sign in to comment.