Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 917dcb1

Browse files
authored
Use Extensible Multiaddress in all Polkadot Runtimes (#2126)
* Use extensible multiaddress * copy pasta
1 parent 0fb3d76 commit 917dcb1

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

runtime/kusama/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use sp_runtime::{
4343
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
4444
curve::PiecewiseLinear,
4545
traits::{
46-
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
46+
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
4747
Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
4848
},
4949
};
@@ -138,7 +138,7 @@ impl frame_system::Config for Runtime {
138138
type Hash = Hash;
139139
type Hashing = BlakeTwo256;
140140
type AccountId = AccountId;
141-
type Lookup = IdentityLookup<Self::AccountId>;
141+
type Lookup = AccountIdLookup<AccountId, ()>;
142142
type Header = generic::Header<BlockNumber, BlakeTwo256>;
143143
type Event = Event;
144144
type BlockHashCount = BlockHashCount;
@@ -662,6 +662,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
662662
account: AccountId,
663663
nonce: <Runtime as frame_system::Config>::Index,
664664
) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
665+
use sp_runtime::traits::StaticLookup;
665666
// take the biggest period possible.
666667
let period = BlockHashCount::get()
667668
.checked_next_power_of_two()
@@ -690,7 +691,8 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
690691
C::sign(payload, public)
691692
})?;
692693
let (call, extra, _) = raw_payload.deconstruct();
693-
Some((call, (account, signature, extra)))
694+
let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
695+
Some((call, (address, signature, extra)))
694696
}
695697
}
696698

@@ -1031,7 +1033,7 @@ construct_runtime! {
10311033
}
10321034

10331035
/// The address format for describing accounts.
1034-
pub type Address = AccountId;
1036+
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
10351037
/// Block header type as expected by this runtime.
10361038
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
10371039
/// Block type as expected by this runtime.

runtime/polkadot/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use sp_runtime::{
4343
KeyTypeId, Percent, Permill, Perbill, curve::PiecewiseLinear,
4444
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
4545
traits::{
46-
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
46+
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
4747
Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
4848
},
4949
};
@@ -152,7 +152,7 @@ impl frame_system::Config for Runtime {
152152
type Hash = Hash;
153153
type Hashing = BlakeTwo256;
154154
type AccountId = AccountId;
155-
type Lookup = IdentityLookup<AccountId>;
155+
type Lookup = AccountIdLookup<AccountId, ()>;
156156
type Header = generic::Header<BlockNumber, BlakeTwo256>;
157157
type Event = Event;
158158
type BlockHashCount = BlockHashCount;
@@ -707,6 +707,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
707707
account: AccountId,
708708
nonce: <Runtime as frame_system::Config>::Index,
709709
) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
710+
use sp_runtime::traits::StaticLookup;
710711
// take the biggest period possible.
711712
let period = BlockHashCount::get()
712713
.checked_next_power_of_two()
@@ -736,7 +737,8 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
736737
C::sign(payload, public)
737738
})?;
738739
let (call, extra, _) = raw_payload.deconstruct();
739-
Some((call, (account, signature, extra)))
740+
let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
741+
Some((call, (address, signature, extra)))
740742
}
741743
}
742744

@@ -1026,7 +1028,7 @@ construct_runtime! {
10261028
}
10271029

10281030
/// The address format for describing accounts.
1029-
pub type Address = AccountId;
1031+
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
10301032
/// Block header type as expected by this runtime.
10311033
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
10321034
/// Block type as expected by this runtime.

runtime/rococo/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use sp_runtime::{
4646
ApplyExtrinsicResult, KeyTypeId, Perbill,
4747
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
4848
traits::{
49-
BlakeTwo256, Block as BlockT, OpaqueKeys, IdentityLookup,
49+
BlakeTwo256, Block as BlockT, OpaqueKeys, AccountIdLookup,
5050
Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
5151
},
5252
};
@@ -119,7 +119,7 @@ pub fn native_version() -> NativeVersion {
119119
}
120120

121121
/// The address format for describing accounts.
122-
pub type Address = AccountId;
122+
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
123123
/// Block header type as expected by this runtime.
124124
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
125125
/// Block type as expected by this runtime.
@@ -232,7 +232,7 @@ impl frame_system::Config for Runtime {
232232
type Hash = Hash;
233233
type Hashing = BlakeTwo256;
234234
type AccountId = AccountId;
235-
type Lookup = IdentityLookup<Self::AccountId>;
235+
type Lookup = AccountIdLookup<AccountId, ()>;
236236
type Header = generic::Header<BlockNumber, BlakeTwo256>;
237237
type Event = Event;
238238
type BlockHashCount = BlockHashCount;
@@ -264,6 +264,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
264264
account: AccountId,
265265
nonce: <Runtime as frame_system::Config>::Index,
266266
) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
267+
use sp_runtime::traits::StaticLookup;
267268
// take the biggest period possible.
268269
let period = BlockHashCount::get()
269270
.checked_next_power_of_two()
@@ -292,7 +293,8 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
292293
C::sign(payload, public)
293294
})?;
294295
let (call, extra, _) = raw_payload.deconstruct();
295-
Some((call, (account, signature, extra)))
296+
let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
297+
Some((call, (address, signature, extra)))
296298
}
297299
}
298300

runtime/test-runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ construct_runtime! {
528528
}
529529

530530
/// The address format for describing accounts.
531-
pub type Address = <Indices as StaticLookup>::Source;
531+
pub type Address = sp_runtime::MultiAddress<AccountId, AccountIndex>;
532532
/// Block header type as expected by this runtime.
533533
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
534534
/// Block type as expected by this runtime.

runtime/westend/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use sp_runtime::{
4141
ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
4242
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
4343
traits::{
44-
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
44+
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
4545
Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
4646
},
4747
};
@@ -129,7 +129,7 @@ impl frame_system::Config for Runtime {
129129
type Hash = Hash;
130130
type Hashing = BlakeTwo256;
131131
type AccountId = AccountId;
132-
type Lookup = IdentityLookup<Self::AccountId>;
132+
type Lookup = AccountIdLookup<AccountId, ()>;
133133
type Header = generic::Header<BlockNumber, BlakeTwo256>;
134134
type Event = Event;
135135
type BlockHashCount = BlockHashCount;
@@ -442,6 +442,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
442442
account: AccountId,
443443
nonce: <Runtime as frame_system::Config>::Index,
444444
) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
445+
use sp_runtime::traits::StaticLookup;
445446
// take the biggest period possible.
446447
let period = BlockHashCount::get()
447448
.checked_next_power_of_two()
@@ -470,7 +471,8 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
470471
C::sign(payload, public)
471472
})?;
472473
let (call, extra, _) = raw_payload.deconstruct();
473-
Some((call, (account, signature, extra)))
474+
let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
475+
Some((call, (address, signature, extra)))
474476
}
475477
}
476478

@@ -724,7 +726,7 @@ construct_runtime! {
724726
}
725727

726728
/// The address format for describing accounts.
727-
pub type Address = AccountId;
729+
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
728730
/// Block header type as expected by this runtime.
729731
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
730732
/// Block type as expected by this runtime.

0 commit comments

Comments
 (0)