aboutsummaryrefslogtreecommitdiff
path: root/tests/sign_typeddata.rs
diff options
context:
space:
mode:
authorNicholas Rodrigues Lordello <[email protected]>2021-08-31 19:29:14 +0000
committerNicholas Rodrigues Lordello <[email protected]>2021-08-31 19:29:14 +0000
commit8d7df73c2a02325c0754db28a1ca3562a8962e03 (patch)
tree6a38c3b665a7f2b57a4f2695af0f3fc1529d1db4 /tests/sign_typeddata.rs
parentf608cce748d80d46f49ba25999e4334fd959b070 (diff)
Initial typed data signing support
Diffstat (limited to 'tests/sign_typeddata.rs')
-rw-r--r--tests/sign_typeddata.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/sign_typeddata.rs b/tests/sign_typeddata.rs
new file mode 100644
index 0000000..4c6da7f
--- /dev/null
+++ b/tests/sign_typeddata.rs
@@ -0,0 +1,50 @@
+mod util;
+
+use crate::util::Hdwallet;
+
+#[test]
+fn signs_typed_data() {
+ let signature = Hdwallet::new("sign", &["typeddata", "-"])
+ .stdin(
+ r#"{
+ "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" }
+ ]
+ },
+ "primaryType": "Mail",
+ "domain": {
+ "name": "Ether Mail",
+ "version": "1",
+ "chainId": 1,
+ "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
+ },
+ "message": {
+ "from": {
+ "name": "Cow",
+ "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
+ },
+ "to": {
+ "name": "Bob",
+ "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
+ },
+ "contents": "Hello, Bob!"
+ }
+ }"#,
+ )
+ .execute()
+ .unwrap();
+ assert_eq!(signature, "0x12bdd486cb42c3b3c414bb04253acfe7d402559e7637562987af6bd78508f38623c1cc09880613762cc913d49fd7d3c091be974c0dee83fb233300b6b58727311c");
+}