diff --git a/substrate/core/primitives/src/crypto.rs b/substrate/core/primitives/src/crypto.rs index 0adf50e160..5887866735 100644 --- a/substrate/core/primitives/src/crypto.rs +++ b/substrate/core/primitives/src/crypto.rs @@ -261,6 +261,9 @@ pub trait Ss58Codec: Sized { Self::from_ss58check_with_version(s) .and_then(|(r, v)| match v { Ss58AddressFormat::SubstrateAccountDirect => Ok(r), + Ss58AddressFormat::PolkadotAccountDirect => Ok(r), + Ss58AddressFormat::KusamaAccountDirect => Ok(r), + Ss58AddressFormat::DothereumAccountDirect => Ok(r), v if v == *DEFAULT_VERSION.lock() => Ok(r), _ => Err(PublicError::UnknownVersion), }) @@ -273,6 +276,9 @@ pub trait Ss58Codec: Sized { Self::from_string_with_version(s) .and_then(|(r, v)| match v { Ss58AddressFormat::SubstrateAccountDirect => Ok(r), + Ss58AddressFormat::PolkadotAccountDirect => Ok(r), + Ss58AddressFormat::KusamaAccountDirect => Ok(r), + Ss58AddressFormat::DothereumAccountDirect => Ok(r), v if v == *DEFAULT_VERSION.lock() => Ok(r), _ => Err(PublicError::UnknownVersion), }) @@ -327,6 +333,8 @@ pub enum Ss58AddressFormat { PolkadotAccountDirect, /// Kusama Relay-chain, direct checksum, standard account (*25519). KusamaAccountDirect, + /// Dothereum Para-chain, direct checksum, standard account (*25519). + DothereumAccountDirect, /// Use a manually provided numeric value. Custom(u8), } @@ -338,6 +346,7 @@ impl From for u8 { Ss58AddressFormat::SubstrateAccountDirect => 42, Ss58AddressFormat::PolkadotAccountDirect => 0, Ss58AddressFormat::KusamaAccountDirect => 2, + Ss58AddressFormat::DothereumAccountDirect => 20, Ss58AddressFormat::Custom(n) => n, } } @@ -351,6 +360,7 @@ impl TryFrom for Ss58AddressFormat { 42 => Ok(Ss58AddressFormat::SubstrateAccountDirect), 0 => Ok(Ss58AddressFormat::PolkadotAccountDirect), 2 => Ok(Ss58AddressFormat::KusamaAccountDirect), + 20 => Ok(Ss58AddressFormat::DothereumAccountDirect), _ => Err(()), } } @@ -364,6 +374,7 @@ impl<'a> TryFrom<&'a str> for Ss58AddressFormat { "substrate" => Ok(Ss58AddressFormat::SubstrateAccountDirect), "polkadot" => Ok(Ss58AddressFormat::PolkadotAccountDirect), "kusama" => Ok(Ss58AddressFormat::KusamaAccountDirect), + "dothereum" => Ok(Ss58AddressFormat::DothereumAccountDirect), a => a.parse::().map(Ss58AddressFormat::Custom).map_err(|_| ()), } } @@ -376,6 +387,7 @@ impl From for String { Ss58AddressFormat::SubstrateAccountDirect => "substrate".into(), Ss58AddressFormat::PolkadotAccountDirect => "polkadot".into(), Ss58AddressFormat::KusamaAccountDirect => "kusama".into(), + Ss58AddressFormat::DothereumAccountDirect => "dothereum".into(), Ss58AddressFormat::Custom(x) => x.to_string(), } } @@ -387,7 +399,8 @@ impl From for String { /// /// Current known "versions" are: /// - 0 direct (payload) checksum for 32-byte *25519 Polkadot addresses. -/// - 2 direct (payload) checksum for 32-byte *25519 Polkadot Milestone 'K' addresses. +/// - 2 direct (payload) checksum for 32-byte *25519 Kusama addresses. +/// - 20 direct (payload) checksum for 32-byte *25519 Dothereum addresses. /// - 42 direct (payload) checksum for 32-byte *25519 addresses on any Substrate-based network. #[cfg(feature = "std")] pub fn set_default_ss58_version(version: Ss58AddressFormat) { diff --git a/substrate/subkey/src/cli.yml b/substrate/subkey/src/cli.yml index b4f99f8743..aa6c6d4a57 100644 --- a/substrate/subkey/src/cli.yml +++ b/substrate/subkey/src/cli.yml @@ -23,7 +23,7 @@ args: long: network takes_value: true required: false - help: Specify a network. One of substrate (default), polkadot and kusama. + help: Specify a network. One of substrate (default), polkadot, kusama, or dothereum. subcommands: - generate: about: Generate a random account diff --git a/substrate/subkey/src/main.rs b/substrate/subkey/src/main.rs index c112dfa1b4..973502b3d6 100644 --- a/substrate/subkey/src/main.rs +++ b/substrate/subkey/src/main.rs @@ -140,7 +140,7 @@ where let maybe_network: Option = matches.value_of("network").map(|network| { network .try_into() - .expect("Invalid network name: must be polkadot/substrate/kusama") + .expect("Invalid network name: must be polkadot/substrate/kusama/dothereum") }); if let Some(network) = maybe_network { set_default_ss58_version(network); @@ -382,7 +382,7 @@ fn create_extrinsic( ); let signature = raw_payload.using_encoded(|payload| signer.sign(payload)); let (function, extra, _) = raw_payload.deconstruct(); - + UncheckedExtrinsic::new_signed( function, signer.public().into(),