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.6k
support custom ss58addressformat in from_ss58check_with_version #5526
Merged
bkchr
merged 13 commits into
paritytech:master
from
atenjin:fix/custom_ss58addressformat_convent
Jul 30, 2020
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
be67a65
support custom ss58addressformat in from_ss58check_with_version
atenjin dbc0d78
fix str parse
atenjin 0afd38d
add a test
atenjin 435e439
typo
atenjin 50882b1
add error description in test
atenjin 607d38e
Merge branch 'master' into fix/custom_ss58addressformat_convent
atenjin aecd649
fix the `TryFrom<u8>` for `Ss58AddressFormat`
atenjin 805d585
use Ss58AddressFormat::default() replace DEFAULT_VERSION
atenjin bc6fd54
Apply suggestions from code review
bkchr 5695c9f
Update primitives/core/src/crypto.rs
bkchr 3c66e9a
Update primitives/core/src/crypto.rs
bkchr d9b4dbd
Update primitives/core/src/crypto.rs
bkchr 199d25c
Update primitives/core/src/crypto.rs
bkchr 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -524,7 +524,7 @@ impl CryptoType for Pair { | |
| mod test { | ||
| use super::*; | ||
| use hex_literal::hex; | ||
| use crate::crypto::DEV_PHRASE; | ||
| use crate::crypto::{DEV_PHRASE, set_default_ss58_version}; | ||
| use serde_json; | ||
|
|
||
| #[test] | ||
|
|
@@ -648,6 +648,20 @@ mod test { | |
| assert_eq!(cmp, public); | ||
| } | ||
|
|
||
| #[test] | ||
| fn ss58check_custom_format_works() { | ||
| use crate::crypto::Ss58AddressFormat; | ||
| let default_format = Ss58AddressFormat::default(); | ||
| set_default_ss58_version(Ss58AddressFormat::try_from("200").expect("")); | ||
|
Contributor
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. expect better have some descriptive error |
||
| // custom | ||
| let addr = "2X64kMNEWAW5KLZMSKcGKEc96MyuaRsRUku7vomuYxKgqjVCRj"; | ||
| let _ = Public::from_ss58check(&addr).unwrap(); | ||
|
Contributor
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. also maybe replace
Contributor
Author
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. ok I fix it |
||
| set_default_ss58_version(default_format); | ||
| // normal | ||
| let addr = "KWAfgC2aRG5UVD6CpbPQXCx4YZZUhvWqqAJE6qcYc9Rtr6g5C"; | ||
| let _ = Public::from_ss58check(&addr).unwrap(); | ||
| } | ||
|
|
||
| #[test] | ||
| fn signature_serialization_works() { | ||
| let pair = Pair::from_seed(b"12345678901234567890123456789012"); | ||
|
|
||
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.