Skip to content

Commit fbb6742

Browse files
authored
More Extensible Multiaddress Format (#7380)
* More extensible multiaddress format * update name * Don't depend on indices to define multiaddress type * Use MultiAddress in Node Template too! * reduce traits, fix build * support multiple `StaticLookup` * bump tx version * feedback
1 parent 79aae1f commit fbb6742

File tree

2 files changed

+7
-167
lines changed

2 files changed

+7
-167
lines changed

src/address.rs

Lines changed: 0 additions & 159 deletions
This file was deleted.

src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,22 @@
2121
#![cfg_attr(not(feature = "std"), no_std)]
2222

2323
mod mock;
24-
pub mod address;
2524
mod tests;
2625
mod benchmarking;
2726
pub mod weights;
2827

2928
use sp_std::prelude::*;
3029
use codec::Codec;
30+
use sp_runtime::MultiAddress;
3131
use sp_runtime::traits::{
3232
StaticLookup, Member, LookupError, Zero, Saturating, AtLeast32Bit
3333
};
3434
use frame_support::{Parameter, decl_module, decl_error, decl_event, decl_storage, ensure};
3535
use frame_support::dispatch::DispatchResult;
3636
use frame_support::traits::{Currency, ReservableCurrency, Get, BalanceStatus::Reserved};
3737
use frame_system::{ensure_signed, ensure_root};
38-
use self::address::Address as RawAddress;
3938
pub use weights::WeightInfo;
4039

41-
pub type Address<T> = RawAddress<<T as frame_system::Trait>::AccountId, <T as Trait>::AccountIndex>;
4240
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
4341

4442
/// The module's config trait.
@@ -287,24 +285,25 @@ impl<T: Trait> Module<T> {
287285

288286
/// Lookup an address to get an Id, if there's one there.
289287
pub fn lookup_address(
290-
a: address::Address<T::AccountId, T::AccountIndex>
288+
a: MultiAddress<T::AccountId, T::AccountIndex>
291289
) -> Option<T::AccountId> {
292290
match a {
293-
address::Address::Id(i) => Some(i),
294-
address::Address::Index(i) => Self::lookup_index(i),
291+
MultiAddress::Id(i) => Some(i),
292+
MultiAddress::Index(i) => Self::lookup_index(i),
293+
_ => None,
295294
}
296295
}
297296
}
298297

299298
impl<T: Trait> StaticLookup for Module<T> {
300-
type Source = address::Address<T::AccountId, T::AccountIndex>;
299+
type Source = MultiAddress<T::AccountId, T::AccountIndex>;
301300
type Target = T::AccountId;
302301

303302
fn lookup(a: Self::Source) -> Result<Self::Target, LookupError> {
304303
Self::lookup_address(a).ok_or(LookupError)
305304
}
306305

307306
fn unlookup(a: Self::Target) -> Self::Source {
308-
address::Address::Id(a)
307+
MultiAddress::Id(a)
309308
}
310309
}

0 commit comments

Comments
 (0)