This repository was archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Move EIP-712 crate back to parity-ethereum #10106
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
[package] | ||
name = "eip712" | ||
name = "eip-712" | ||
version = "0.1.0" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
repository = "https://github.com/paritytech/parity-ethereum" | ||
documentation = "https://docs.rs/eip-712" | ||
readme = "README.md" | ||
description = "eip-712 encoding" | ||
keywords = ["eip-712", "eip712", "eip"] | ||
license = "GPL-3.0" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
serde_derive = "1.0" | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# EIP-712  [](https://docs.rs/EIP-712) | ||
|
||
## Example | ||
|
||
```rust | ||
use eip_712::{EIP712, hash_structured_data}; | ||
use serde_json::from_str; | ||
use rustc_hex::ToHex; | ||
|
||
fn main() { | ||
let json = r#"{ | ||
"primaryType": "Mail", | ||
"domain": { | ||
"name": "Ether Mail", | ||
"version": "1", | ||
"chainId": "0x1", | ||
"verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" | ||
}, | ||
"message": { | ||
"from": { | ||
"name": "Cow", | ||
"wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" | ||
}, | ||
"to": { | ||
"name": "Bob", | ||
"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" | ||
}, | ||
"contents": "Hello, Bob!" | ||
}, | ||
"types": { | ||
"EIP712Domain": [ | ||
{ "name": "name", "type": "string" }, | ||
{ "name": "version", "type": "string" }, | ||
{ "name": "chainId", "type": "uint256" }, | ||
{ "name": "verifyingContract", "type": "address" } | ||
], | ||
"Person": [ | ||
{ "name": "name", "type": "string" }, | ||
{ "name": "wallet", "type": "address" } | ||
], | ||
"Mail": [ | ||
{ "name": "from", "type": "Person" }, | ||
{ "name": "to", "type": "Person" }, | ||
{ "name": "contents", "type": "string" } | ||
] | ||
} | ||
}"#; | ||
let typed_data = from_str::<EIP712>(json).unwrap(); | ||
|
||
assert_eq!( | ||
hash_structured_data(typed_data).unwrap().to_hex::<String>(), | ||
"be609aee343fb3c4b28e1df9e632fca64fcfaede20f02e86244efddf30957bd2" | ||
) | ||
} | ||
|
||
``` | ||
|
||
## License | ||
|
||
This crate is distributed under the terms of GNU GENERAL PUBLIC LICENSE version 3.0. | ||
|
||
See [LICENSE](../../LICENSE) for details. |
This file contains 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 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove
unused_extern_crates
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this module uses rust 2018, no need for extern crates