From a7bfc4a4808304121ff7d1788448f9aa2033d85f Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Wed, 18 Jan 2023 20:21:11 +0800 Subject: [PATCH] Readable address (#224) --- Cargo.lock | 3 ++- pallet/account-migration/Cargo.toml | 5 +++-- pallet/account-migration/src/lib.rs | 2 +- pallet/account-migration/src/tests.rs | 2 +- pallet/message-transact/Cargo.toml | 15 +++++++-------- pallet/message-transact/src/tests/eip1559.rs | 4 +--- pallet/message-transact/src/tests/eip2930.rs | 4 +--- pallet/message-transact/src/tests/legacy.rs | 4 +--- 8 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c0162090..1f3a97d3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2282,6 +2282,7 @@ dependencies = [ name = "darwinia-account-migration" version = "6.0.0" dependencies = [ + "array-bytes 6.0.0", "darwinia-deposit", "darwinia-staking", "dc-primitives", @@ -2380,7 +2381,7 @@ dependencies = [ name = "darwinia-message-transact" version = "6.0.0" dependencies = [ - "array-bytes 4.2.0", + "array-bytes 6.0.0", "bp-message-dispatch", "bp-runtime", "ethereum", diff --git a/pallet/account-migration/Cargo.toml b/pallet/account-migration/Cargo.toml index 5afad954b..2cc84449b 100644 --- a/pallet/account-migration/Cargo.toml +++ b/pallet/account-migration/Cargo.toml @@ -11,8 +11,9 @@ version = "6.0.0" [dependencies] # crates.io -codec = { package = "parity-scale-codec", version = "3.2", default-features = false, features = ["derive"] } -scale-info = { version = "2.3", default-features = false, features = ["derive"] } +array-bytes = { version = "6.0" } +codec = { package = "parity-scale-codec", version = "3.2", default-features = false, features = ["derive"] } +scale-info = { version = "2.3", default-features = false, features = ["derive"] } # darwinia darwinia-deposit = { default-features = false, path = "../deposit" } diff --git a/pallet/account-migration/src/lib.rs b/pallet/account-migration/src/lib.rs index 74770c3e8..fa3f2bee3 100644 --- a/pallet/account-migration/src/lib.rs +++ b/pallet/account-migration/src/lib.rs @@ -335,7 +335,7 @@ pub enum ExistenceReason { pub fn sr25519_signable_message(spec_name: &[u8], account_id_20: &AccountId20) -> Vec { [ b"I authorize the migration to ", - account_id_20.0.as_slice(), + array_bytes::bytes2hex("0x", account_id_20.0).as_bytes(), b", an unused address on ", spec_name, b". Sign this message to authorize using the Substrate key associated with the account on ", diff --git a/pallet/account-migration/src/tests.rs b/pallet/account-migration/src/tests.rs index 849820ca8..d8eb1842a 100644 --- a/pallet/account-migration/src/tests.rs +++ b/pallet/account-migration/src/tests.rs @@ -28,7 +28,7 @@ fn sr25519_signable_message_should_work() { sr25519_signable_message(s.as_bytes(), &Default::default()), format!( "I authorize the migration to {}, an unused address on {}. Sign this message to authorize using the Substrate key associated with the account on {} that you wish to migrate.", - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", + "0x0000000000000000000000000000000000000000", s, &s[..s.len() - 1], ).as_bytes() diff --git a/pallet/message-transact/Cargo.toml b/pallet/message-transact/Cargo.toml index b2552c3f2..57d5ceadb 100644 --- a/pallet/message-transact/Cargo.toml +++ b/pallet/message-transact/Cargo.toml @@ -11,16 +11,16 @@ version = "6.0.0" [dependencies] # crates.io -codec = { default-features = false, package = "parity-scale-codec", version = "3.2", features = ["derive"] } -ethereum = { default-features = false, version = "0.14.0", features = ["with-codec"] } -scale-info = { default-features = false, version = "2.3.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2", default-features = false, features = ["derive"] } +ethereum = { version = "0.14", default-features = false, features = ["with-codec"] } +scale-info = { version = "2.3", default-features = false, features = ["derive"] } # frontier fp-ethereum = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.33" } fp-evm = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.33" } pallet-evm = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.33" } -# paritytech +# substrate frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33" } frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33" } sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33" } @@ -28,7 +28,7 @@ sp-runtime = { default-features = false, git = "https://github.com/paritytech sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33" } [dev-dependencies] -array-bytes = { version = "4.1" } +array-bytes = { version = "6.0" } libsecp256k1 = { version = "0.5", features = ["static-context", "hmac"] } rlp = { version = "0.5" } sha3 = { version = "0.9" } @@ -40,13 +40,13 @@ pallet-bridge-dispatch = { git = "https://github.com/darwinia-network/darwinia-m # frontier fp-self-contained = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.33" } +pallet-ethereum = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.33" } # moonbeam precompile-utils = { git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.33", features = ["testing"] } # substrate pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33" } -pallet-ethereum = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.33" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33" } sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33" } @@ -62,9 +62,8 @@ std = [ "fp-evm/std", "fp-ethereum/std", "pallet-evm/std", - "pallet-ethereum/std", - # paritytech + # substrate "frame-support/std", "frame-system/std", "sp-core/std", diff --git a/pallet/message-transact/src/tests/eip1559.rs b/pallet/message-transact/src/tests/eip1559.rs index 6ea902e3a..ce3de2d0e 100644 --- a/pallet/message-transact/src/tests/eip1559.rs +++ b/pallet/message-transact/src/tests/eip1559.rs @@ -16,8 +16,6 @@ // You should have received a copy of the GNU General Public License // along with Darwinia. If not, see . -// crates -use array_bytes::hex2bytes; // darwinia use crate::{mock::*, tests::*}; // frontier @@ -35,7 +33,7 @@ pub fn eip1559_erc20_creation_unsigned_transaction() -> EIP1559UnsignedTransacti gas_limit: U256::from(1_000_000), action: ethereum::TransactionAction::Create, value: U256::zero(), - input: hex2bytes(ERC20_CONTRACT_BYTECODE).unwrap(), + input: array_bytes::hex2bytes_unchecked(ERC20_CONTRACT_BYTECODE), } } diff --git a/pallet/message-transact/src/tests/eip2930.rs b/pallet/message-transact/src/tests/eip2930.rs index fefef528b..a599a615f 100644 --- a/pallet/message-transact/src/tests/eip2930.rs +++ b/pallet/message-transact/src/tests/eip2930.rs @@ -16,8 +16,6 @@ // You should have received a copy of the GNU General Public License // along with Darwinia. If not, see . -// crates.io -use array_bytes::hex2bytes; // darwinia use crate::{mock::*, tests::*}; // frontier @@ -34,7 +32,7 @@ fn eip2930_erc20_creation_unsigned_transaction() -> EIP2930UnsignedTransaction { gas_limit: U256::from(1_000_000), action: ethereum::TransactionAction::Create, value: U256::zero(), - input: hex2bytes(ERC20_CONTRACT_BYTECODE).unwrap(), + input: array_bytes::hex2bytes_unchecked(ERC20_CONTRACT_BYTECODE), } } diff --git a/pallet/message-transact/src/tests/legacy.rs b/pallet/message-transact/src/tests/legacy.rs index 3e730759a..c3488b380 100644 --- a/pallet/message-transact/src/tests/legacy.rs +++ b/pallet/message-transact/src/tests/legacy.rs @@ -16,8 +16,6 @@ // You should have received a copy of the GNU General Public License // along with Darwinia. If not, see . -// crates.io -use array_bytes::hex2bytes; // darwinia use crate::{mock::*, tests::*}; // frontier @@ -34,7 +32,7 @@ pub fn legacy_erc20_creation_unsigned_transaction() -> LegacyUnsignedTransaction gas_limit: U256::from(1_000_000), action: ethereum::TransactionAction::Create, value: U256::zero(), - input: hex2bytes(ERC20_CONTRACT_BYTECODE).unwrap(), + input: array_bytes::hex2bytes_unchecked(ERC20_CONTRACT_BYTECODE), } }