This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Remove Default bound for AccountId #10403
Merged
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
d3af49f
Remove Default for AccountId
gavofyork f6827f1
More removals of default
gavofyork d397c5d
Update frame/authorship/src/lib.rs
gavofyork c446fff
Update frame/authorship/src/lib.rs
gavofyork 19023db
Update frame/authorship/src/lib.rs
gavofyork 80df1fb
Update frame/authorship/src/lib.rs
gavofyork 2cbe13a
More work
gavofyork 0930529
More work
gavofyork 016a1ee
Remove old code
gavofyork 594deb9
More work
gavofyork daa2942
pallet-asset-tx-payment
gavofyork 0f270da
tips
gavofyork 393ed87
sc-consensus-babe
gavofyork 7169d84
sc-finality-grandpa
gavofyork a853bcc
sc-consensus-babe-rpc
gavofyork 4cb42ff
sc-cli
gavofyork 2a04445
make npos crates accept non-default account (#10420)
kianenigma 452651c
more work
gavofyork 227f360
more work
gavofyork 345c87b
Tests build
gavofyork c12d8cf
Fix imonline tests
gavofyork 2cfd1d0
Formatting
gavofyork b537356
Merge branch 'master' into gav-no-default-accountid
gavofyork f5758f1
Fixes
gavofyork 9965af3
Merge branch 'gav-no-default-accountid' of github.com:paritytech/subs…
gavofyork 3dc3969
Fixes
gavofyork b7fe115
Merge remote-tracking branch 'origin/master' into gav-no-default-acco…
gavofyork c9c7ba7
Fix bench
kianenigma ea520fa
Fixes
gavofyork b694599
Fixes
gavofyork 97ec65a
Fixes
gavofyork b9c1e17
Fixes
gavofyork ddfbfa9
Fixes
gavofyork 2316103
Formatting
gavofyork d302551
Fixes
gavofyork 915bf1c
Formatting
gavofyork cfb1418
Fixes
gavofyork ed72cad
Formatting
gavofyork 6e1b9e7
Fixes
gavofyork 5fab98c
Formatting
gavofyork 8eccc1d
Merge remote-tracking branch 'origin/master' into gav-no-default-acco…
gavofyork 67492d1
Fixes
gavofyork b465b2d
Formatting
gavofyork 26053ee
Merge branch 'master' into gav-no-default-accountid
gavofyork 87351bb
Update client/keystore/src/local.rs
gavofyork f7939bb
Update client/finality-grandpa/src/lib.rs
gavofyork 5e157c9
Update client/keystore/src/local.rs
gavofyork 3557e13
Update client/keystore/src/local.rs
gavofyork c147de9
Update frame/staking/src/lib.rs
gavofyork fa596c1
Update frame/staking/src/lib.rs
gavofyork aa7ac28
Update primitives/runtime/src/traits.rs
gavofyork 175596a
Formatting
gavofyork File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Remove Default for AccountId
- Loading branch information
commit d3af49fdab8deac42b262ec8b4b59e21c5b2e062
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -222,7 +222,7 @@ pub enum PublicError { | |||||||||
| /// See <https://docs.substrate.io/v3/advanced/ss58/> | ||||||||||
| /// for information on the codec. | ||||||||||
| #[cfg(feature = "full_crypto")] | ||||||||||
| pub trait Ss58Codec: Sized + AsMut<[u8]> + AsRef<[u8]> + Default { | ||||||||||
| pub trait Ss58Codec: Sized + AsMut<[u8]> + AsRef<[u8]> + ByteArray { | ||||||||||
| /// A format filterer, can be used to ensure that `from_ss58check` family only decode for | ||||||||||
| /// allowed identifiers. By default just refuses the two reserved identifiers. | ||||||||||
| fn format_is_allowed(f: Ss58AddressFormat) -> bool { | ||||||||||
|
|
@@ -243,10 +243,7 @@ pub trait Ss58Codec: Sized + AsMut<[u8]> + AsRef<[u8]> + Default { | |||||||||
| #[cfg(feature = "std")] | ||||||||||
| fn from_ss58check_with_version(s: &str) -> Result<(Self, Ss58AddressFormat), PublicError> { | ||||||||||
| const CHECKSUM_LEN: usize = 2; | ||||||||||
| let mut res = Self::default(); | ||||||||||
|
|
||||||||||
| // Must decode to our type. | ||||||||||
| let body_len = res.as_mut().len(); | ||||||||||
| let body_len = Self::LEN; | ||||||||||
|
|
||||||||||
| let data = s.from_base58().map_err(|_| PublicError::BadBase58)?; | ||||||||||
| if data.len() < 2 { | ||||||||||
|
|
@@ -280,8 +277,9 @@ pub trait Ss58Codec: Sized + AsMut<[u8]> + AsRef<[u8]> + Default { | |||||||||
| // Invalid checksum. | ||||||||||
| return Err(PublicError::InvalidChecksum) | ||||||||||
| } | ||||||||||
| res.as_mut().copy_from_slice(&data[prefix_len..body_len + prefix_len]); | ||||||||||
| Ok((res, format)) | ||||||||||
|
|
||||||||||
| let result = Self::from_slice(&data[prefix_len..body_len + prefix_len]).map_err(|()| PublicError::BadLength)?; | ||||||||||
| Ok((result, format)) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Some if the string is a properly encoded SS58Check address, optionally with | ||||||||||
|
|
@@ -391,19 +389,13 @@ lazy_static::lazy_static! { | |||||||||
| } | ||||||||||
|
|
||||||||||
| #[cfg(feature = "std")] | ||||||||||
| impl<T: Sized + AsMut<[u8]> + AsRef<[u8]> + Default + Derive> Ss58Codec for T { | ||||||||||
| impl<T: Sized + AsMut<[u8]> + AsRef<[u8]> + Public + Derive> Ss58Codec for T { | ||||||||||
| fn from_string(s: &str) -> Result<Self, PublicError> { | ||||||||||
| let cap = SS58_REGEX.captures(s).ok_or(PublicError::InvalidFormat)?; | ||||||||||
| let s = cap.name("ss58").map(|r| r.as_str()).unwrap_or(DEV_ADDRESS); | ||||||||||
| let addr = if let Some(stripped) = s.strip_prefix("0x") { | ||||||||||
| let d = hex::decode(stripped).map_err(|_| PublicError::InvalidFormat)?; | ||||||||||
| let mut r = Self::default(); | ||||||||||
| if d.len() == r.as_ref().len() { | ||||||||||
| r.as_mut().copy_from_slice(&d); | ||||||||||
| r | ||||||||||
| } else { | ||||||||||
| return Err(PublicError::BadLength) | ||||||||||
| } | ||||||||||
| Self::from_slice(&d).map_err(|()| PublicError::BadLength)? | ||||||||||
| } else { | ||||||||||
| Self::from_ss58check(s)? | ||||||||||
| }; | ||||||||||
|
|
@@ -431,25 +423,15 @@ impl<T: Sized + AsMut<[u8]> + AsRef<[u8]> + Default + Derive> Ss58Codec for T { | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Trait suitable for typical cryptographic PKI key public type. | ||||||||||
| pub trait Public: | ||||||||||
| AsRef<[u8]> | ||||||||||
| + AsMut<[u8]> | ||||||||||
| + Default | ||||||||||
| + Derive | ||||||||||
| + CryptoType | ||||||||||
| + PartialEq | ||||||||||
| + Eq | ||||||||||
| + Clone | ||||||||||
| + Send | ||||||||||
| + Sync | ||||||||||
| + for<'a> TryFrom<&'a [u8]> | ||||||||||
| { | ||||||||||
| /// A new instance from the given slice. | ||||||||||
| /// | ||||||||||
| /// NOTE: No checking goes on to ensure this is a real public key. Only use it if | ||||||||||
| /// you are certain that the array actually is a pubkey. GIGO! | ||||||||||
| fn from_slice(data: &[u8]) -> Self; | ||||||||||
| /// Trait used for types that are really just a fixed-length array. | ||||||||||
| pub trait ByteArray: AsRef<[u8]> + AsMut<[u8]> + for<'a> TryFrom<&'a [u8], Error = ()> { | ||||||||||
| /// The "length" of the values of this type, which is always the same. | ||||||||||
| const LEN: usize; | ||||||||||
|
|
||||||||||
| /// A new instance from the given slice that should be `Self::LEN` bytes long. | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| fn from_slice(data: &[u8]) -> Result<Self, ()> { | ||||||||||
| Self::try_from(data) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Return a `Vec<u8>` filled with raw data. | ||||||||||
| fn to_raw_vec(&self) -> Vec<u8> { | ||||||||||
|
|
@@ -460,6 +442,10 @@ pub trait Public: | |||||||||
| fn as_slice(&self) -> &[u8] { | ||||||||||
| self.as_ref() | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Trait suitable for typical cryptographic PKI key public type. | ||||||||||
| pub trait Public: ByteArray + Derive + CryptoType + PartialEq + Eq + Clone + Send + Sync { | ||||||||||
| /// Return `CryptoTypePublicPair` from public key. | ||||||||||
| fn to_public_crypto_pair(&self) -> CryptoTypePublicPair; | ||||||||||
| } | ||||||||||
|
|
@@ -487,6 +473,12 @@ impl UncheckedFrom<crate::hash::H256> for AccountId32 { | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| impl ByteArray for AccountId32 { | ||||||||||
| const LEN: usize = 32; | ||||||||||
|
|
||||||||||
|
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| #[cfg(feature = "std")] | ||||||||||
| impl Ss58Codec for AccountId32 {} | ||||||||||
|
|
||||||||||
|
|
@@ -649,9 +641,10 @@ mod dummy { | |||||||||
|
|
||||||||||
| impl Derive for Dummy {} | ||||||||||
|
|
||||||||||
| impl Public for Dummy { | ||||||||||
| fn from_slice(_: &[u8]) -> Self { | ||||||||||
| Self | ||||||||||
| impl ByteArray for Dummy { | ||||||||||
| const LEN: usize = 0; | ||||||||||
| fn from_slice(_: &[u8]) -> Result<Self, ()> { | ||||||||||
| Ok(Self) | ||||||||||
| } | ||||||||||
| #[cfg(feature = "std")] | ||||||||||
| fn to_raw_vec(&self) -> Vec<u8> { | ||||||||||
|
|
@@ -660,8 +653,10 @@ mod dummy { | |||||||||
| fn as_slice(&self) -> &[u8] { | ||||||||||
| b"" | ||||||||||
| } | ||||||||||
| } | ||||||||||
| impl Public for Dummy { | ||||||||||
| fn to_public_crypto_pair(&self) -> CryptoTypePublicPair { | ||||||||||
| CryptoTypePublicPair(CryptoTypeId(*b"dumm"), Public::to_raw_vec(self)) | ||||||||||
| CryptoTypePublicPair(CryptoTypeId(*b"dumm"), <Self as ByteArray>::to_raw_vec(self)) | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.