From 917dcb1dfeaab5ebe7d3120c04b798a43464bb94 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 27 Jan 2021 04:00:33 -0400 Subject: [PATCH] Use Extensible Multiaddress in all Polkadot Runtimes (#2126) * Use extensible multiaddress * copy pasta --- runtime/kusama/src/lib.rs | 10 ++++++---- runtime/polkadot/src/lib.rs | 10 ++++++---- runtime/rococo/src/lib.rs | 10 ++++++---- runtime/test-runtime/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 10 ++++++---- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 1fa7878dbb99..a2ecbbc53226 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -43,7 +43,7 @@ use sp_runtime::{ transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority}, curve::PiecewiseLinear, traits::{ - BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup, + BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup, Extrinsic as ExtrinsicT, SaturatedConversion, Verify, }, }; @@ -138,7 +138,7 @@ impl frame_system::Config for Runtime { type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; + type Lookup = AccountIdLookup; type Header = generic::Header; type Event = Event; type BlockHashCount = BlockHashCount; @@ -662,6 +662,7 @@ impl frame_system::offchain::CreateSignedTransaction for R account: AccountId, nonce: ::Index, ) -> Option<(Call, ::SignaturePayload)> { + use sp_runtime::traits::StaticLookup; // take the biggest period possible. let period = BlockHashCount::get() .checked_next_power_of_two() @@ -690,7 +691,8 @@ impl frame_system::offchain::CreateSignedTransaction for R C::sign(payload, public) })?; let (call, extra, _) = raw_payload.deconstruct(); - Some((call, (account, signature, extra))) + let address = ::Lookup::unlookup(account); + Some((call, (address, signature, extra))) } } @@ -1031,7 +1033,7 @@ construct_runtime! { } /// The address format for describing accounts. -pub type Address = AccountId; +pub type Address = sp_runtime::MultiAddress; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime. diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 9535189d0182..b97d454ec6a0 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -43,7 +43,7 @@ use sp_runtime::{ KeyTypeId, Percent, Permill, Perbill, curve::PiecewiseLinear, transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority}, traits::{ - BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup, + BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup, Extrinsic as ExtrinsicT, SaturatedConversion, Verify, }, }; @@ -152,7 +152,7 @@ impl frame_system::Config for Runtime { type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; + type Lookup = AccountIdLookup; type Header = generic::Header; type Event = Event; type BlockHashCount = BlockHashCount; @@ -707,6 +707,7 @@ impl frame_system::offchain::CreateSignedTransaction for R account: AccountId, nonce: ::Index, ) -> Option<(Call, ::SignaturePayload)> { + use sp_runtime::traits::StaticLookup; // take the biggest period possible. let period = BlockHashCount::get() .checked_next_power_of_two() @@ -736,7 +737,8 @@ impl frame_system::offchain::CreateSignedTransaction for R C::sign(payload, public) })?; let (call, extra, _) = raw_payload.deconstruct(); - Some((call, (account, signature, extra))) + let address = ::Lookup::unlookup(account); + Some((call, (address, signature, extra))) } } @@ -1026,7 +1028,7 @@ construct_runtime! { } /// The address format for describing accounts. -pub type Address = AccountId; +pub type Address = sp_runtime::MultiAddress; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime. diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index f6b72dce86e3..b52b7cb8c49e 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -46,7 +46,7 @@ use sp_runtime::{ ApplyExtrinsicResult, KeyTypeId, Perbill, transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority}, traits::{ - BlakeTwo256, Block as BlockT, OpaqueKeys, IdentityLookup, + BlakeTwo256, Block as BlockT, OpaqueKeys, AccountIdLookup, Extrinsic as ExtrinsicT, SaturatedConversion, Verify, }, }; @@ -119,7 +119,7 @@ pub fn native_version() -> NativeVersion { } /// The address format for describing accounts. -pub type Address = AccountId; +pub type Address = sp_runtime::MultiAddress; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime. @@ -232,7 +232,7 @@ impl frame_system::Config for Runtime { type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; + type Lookup = AccountIdLookup; type Header = generic::Header; type Event = Event; type BlockHashCount = BlockHashCount; @@ -264,6 +264,7 @@ impl frame_system::offchain::CreateSignedTransaction for R account: AccountId, nonce: ::Index, ) -> Option<(Call, ::SignaturePayload)> { + use sp_runtime::traits::StaticLookup; // take the biggest period possible. let period = BlockHashCount::get() .checked_next_power_of_two() @@ -292,7 +293,8 @@ impl frame_system::offchain::CreateSignedTransaction for R C::sign(payload, public) })?; let (call, extra, _) = raw_payload.deconstruct(); - Some((call, (account, signature, extra))) + let address = ::Lookup::unlookup(account); + Some((call, (address, signature, extra))) } } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index f24725715485..1d6d0675c8bf 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -528,7 +528,7 @@ construct_runtime! { } /// The address format for describing accounts. -pub type Address = ::Source; +pub type Address = sp_runtime::MultiAddress; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime. diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 14cb5b512de5..0e6c047e9e06 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -41,7 +41,7 @@ use sp_runtime::{ ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear, transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority}, traits::{ - BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup, + BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup, Extrinsic as ExtrinsicT, SaturatedConversion, Verify, }, }; @@ -129,7 +129,7 @@ impl frame_system::Config for Runtime { type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; + type Lookup = AccountIdLookup; type Header = generic::Header; type Event = Event; type BlockHashCount = BlockHashCount; @@ -442,6 +442,7 @@ impl frame_system::offchain::CreateSignedTransaction for R account: AccountId, nonce: ::Index, ) -> Option<(Call, ::SignaturePayload)> { + use sp_runtime::traits::StaticLookup; // take the biggest period possible. let period = BlockHashCount::get() .checked_next_power_of_two() @@ -470,7 +471,8 @@ impl frame_system::offchain::CreateSignedTransaction for R C::sign(payload, public) })?; let (call, extra, _) = raw_payload.deconstruct(); - Some((call, (account, signature, extra))) + let address = ::Lookup::unlookup(account); + Some((call, (address, signature, extra))) } } @@ -724,7 +726,7 @@ construct_runtime! { } /// The address format for describing accounts. -pub type Address = AccountId; +pub type Address = sp_runtime::MultiAddress; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime.