1067 lines
29 KiB
Diff
1067 lines
29 KiB
Diff
From 1a95648cabf5bf6452c7b596a57a3bf5cf1a81c7 Mon Sep 17 00:00:00 2001
|
|
From: 717a56e1 <67477536+717a56e1@users.noreply.github.com>
|
|
Date: Fri, 21 Jan 2022 12:19:52 +0000
|
|
Subject: [PATCH] EIP-712: Update logos and rewrite type parser (builds on
|
|
1.53) (#463)
|
|
|
|
* update logos and rewrite type parser
|
|
|
|
* fix uint and int type parsing for variable sizes
|
|
|
|
* Update Cargo.lock
|
|
|
|
Co-authored-by: Tomas Langsetmo <tomaslangsetmo@gmail.com>
|
|
Co-authored-by: varasev <33550681+varasev@users.noreply.github.com>
|
|
Co-authored-by: POA <33550681+poa@users.noreply.github.com>
|
|
---
|
|
Cargo.lock | 52 +--
|
|
crates/util/EIP-712/Cargo.lock | 740 ++++++++++++++++++++++++++++++
|
|
crates/util/EIP-712/Cargo.toml | 2 +-
|
|
crates/util/EIP-712/src/parser.rs | 126 +++--
|
|
4 files changed, 834 insertions(+), 86 deletions(-)
|
|
create mode 100644 crates/util/EIP-712/Cargo.lock
|
|
|
|
diff --git a/Cargo.lock b/Cargo.lock
|
|
index 66d6c94d9a..be1c9ca7bc 100644
|
|
--- a/Cargo.lock
|
|
+++ b/Cargo.lock
|
|
@@ -203,6 +203,12 @@ dependencies = [
|
|
"byteorder",
|
|
]
|
|
|
|
+[[package]]
|
|
+name = "beef"
|
|
+version = "0.5.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "bed554bd50246729a1ec158d08aa3235d1b69d94ad120ebe187e28894787e736"
|
|
+
|
|
[[package]]
|
|
name = "bit-set"
|
|
version = "0.4.0"
|
|
@@ -793,7 +799,7 @@ dependencies = [
|
|
"itertools 0.7.11",
|
|
"keccak-hash",
|
|
"lazy_static",
|
|
- "lunarity-lexer",
|
|
+ "logos",
|
|
"regex 1.3.9",
|
|
"rustc-hex 2.1.0",
|
|
"serde",
|
|
@@ -1697,15 +1703,6 @@ dependencies = [
|
|
"num_cpus",
|
|
]
|
|
|
|
-[[package]]
|
|
-name = "fxhash"
|
|
-version = "0.2.1"
|
|
-source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
-checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
|
-dependencies = [
|
|
- "byteorder",
|
|
-]
|
|
-
|
|
[[package]]
|
|
name = "gcc"
|
|
version = "0.3.55"
|
|
@@ -2528,24 +2525,25 @@ dependencies = [
|
|
|
|
[[package]]
|
|
name = "logos"
|
|
-version = "0.7.7"
|
|
+version = "0.12.0"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
-checksum = "60ca690691528b32832c7e8aaae8ae1edcdee4e9ffde55b2d31a4795bc7a12d0"
|
|
+checksum = "427e2abca5be13136da9afdbf874e6b34ad9001dd70f2b103b083a85daa7b345"
|
|
dependencies = [
|
|
"logos-derive",
|
|
- "toolshed",
|
|
]
|
|
|
|
[[package]]
|
|
name = "logos-derive"
|
|
-version = "0.7.7"
|
|
+version = "0.12.0"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
-checksum = "917dccdd529d5681f3d28b26bcfdafd2ed67fe4f26d15b5ac679f67b55279f3d"
|
|
+checksum = "56a7d287fd2ac3f75b11f19a1c8a874a7d55744bd91f7a1b3e7cf87d4343c36d"
|
|
dependencies = [
|
|
- "proc-macro2 0.4.30",
|
|
- "quote 0.6.13",
|
|
+ "beef",
|
|
+ "fnv",
|
|
+ "proc-macro2 1.0.20",
|
|
+ "quote 1.0.7",
|
|
"regex-syntax 0.6.18",
|
|
- "syn 0.15.26",
|
|
+ "syn 1.0.40",
|
|
"utf8-ranges",
|
|
]
|
|
|
|
@@ -2567,15 +2565,6 @@ dependencies = [
|
|
"linked-hash-map",
|
|
]
|
|
|
|
-[[package]]
|
|
-name = "lunarity-lexer"
|
|
-version = "0.2.1"
|
|
-source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
-checksum = "28a5446c03ed5bd4ae2cca322c4c84d9bd9741b6788f75c404719474cb63d3b7"
|
|
-dependencies = [
|
|
- "logos",
|
|
-]
|
|
-
|
|
[[package]]
|
|
name = "macros"
|
|
version = "0.1.0"
|
|
@@ -4996,15 +4985,6 @@ dependencies = [
|
|
"serde",
|
|
]
|
|
|
|
-[[package]]
|
|
-name = "toolshed"
|
|
-version = "0.6.3"
|
|
-source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
-checksum = "54a272adbf14cfbb486774d09ee3e00c38d488cd390084a528f70e10e3a184a8"
|
|
-dependencies = [
|
|
- "fxhash",
|
|
-]
|
|
-
|
|
[[package]]
|
|
name = "trace-time"
|
|
version = "0.1.2"
|
|
diff --git a/crates/util/EIP-712/Cargo.lock b/crates/util/EIP-712/Cargo.lock
|
|
new file mode 100644
|
|
index 0000000000..aeb4860cbf
|
|
--- /dev/null
|
|
+++ b/crates/util/EIP-712/Cargo.lock
|
|
@@ -0,0 +1,740 @@
|
|
+# This file is automatically @generated by Cargo.
|
|
+# It is not intended for manual editing.
|
|
+version = 3
|
|
+
|
|
+[[package]]
|
|
+name = "addr2line"
|
|
+version = "0.15.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a"
|
|
+dependencies = [
|
|
+ "gimli",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "adler"
|
|
+version = "1.0.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
|
+
|
|
+[[package]]
|
|
+name = "aho-corasick"
|
|
+version = "0.7.18"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
|
+dependencies = [
|
|
+ "memchr",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "arrayvec"
|
|
+version = "0.5.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
|
+
|
|
+[[package]]
|
|
+name = "autocfg"
|
|
+version = "1.0.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
|
+
|
|
+[[package]]
|
|
+name = "backtrace"
|
|
+version = "0.3.60"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "b7815ea54e4d821e791162e078acbebfd6d8c8939cd559c9335dceb1c8ca7282"
|
|
+dependencies = [
|
|
+ "addr2line",
|
|
+ "cc",
|
|
+ "cfg-if",
|
|
+ "libc",
|
|
+ "miniz_oxide",
|
|
+ "object",
|
|
+ "rustc-demangle",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "beef"
|
|
+version = "0.5.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "6736e2428df2ca2848d846c43e88745121a6654696e349ce0054a420815a7409"
|
|
+
|
|
+[[package]]
|
|
+name = "bitvec"
|
|
+version = "0.17.4"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c"
|
|
+dependencies = [
|
|
+ "either",
|
|
+ "radium",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "byte-slice-cast"
|
|
+version = "0.3.5"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3"
|
|
+
|
|
+[[package]]
|
|
+name = "byteorder"
|
|
+version = "1.4.3"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
|
+
|
|
+[[package]]
|
|
+name = "cc"
|
|
+version = "1.0.68"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
|
|
+
|
|
+[[package]]
|
|
+name = "cfg-if"
|
|
+version = "1.0.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
+
|
|
+[[package]]
|
|
+name = "crunchy"
|
|
+version = "0.2.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
|
+
|
|
+[[package]]
|
|
+name = "eip-712"
|
|
+version = "0.1.0"
|
|
+dependencies = [
|
|
+ "ethabi",
|
|
+ "ethereum-types",
|
|
+ "failure",
|
|
+ "indexmap",
|
|
+ "itertools",
|
|
+ "keccak-hash",
|
|
+ "lazy_static",
|
|
+ "logos",
|
|
+ "regex",
|
|
+ "rustc-hex",
|
|
+ "serde",
|
|
+ "serde_derive",
|
|
+ "serde_json",
|
|
+ "validator",
|
|
+ "validator_derive",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "either"
|
|
+version = "1.6.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
|
+
|
|
+[[package]]
|
|
+name = "ethabi"
|
|
+version = "12.0.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "052a565e3de82944527d6d10a465697e6bb92476b772ca7141080c901f6a63c6"
|
|
+dependencies = [
|
|
+ "ethereum-types",
|
|
+ "rustc-hex",
|
|
+ "serde",
|
|
+ "serde_json",
|
|
+ "tiny-keccak 1.5.0",
|
|
+ "uint",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "ethbloom"
|
|
+version = "0.9.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df"
|
|
+dependencies = [
|
|
+ "crunchy",
|
|
+ "fixed-hash",
|
|
+ "impl-rlp",
|
|
+ "impl-serde",
|
|
+ "tiny-keccak 2.0.2",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "ethereum-types"
|
|
+version = "0.9.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0"
|
|
+dependencies = [
|
|
+ "ethbloom",
|
|
+ "fixed-hash",
|
|
+ "impl-rlp",
|
|
+ "impl-serde",
|
|
+ "primitive-types",
|
|
+ "uint",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "failure"
|
|
+version = "0.1.8"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
|
|
+dependencies = [
|
|
+ "backtrace",
|
|
+ "failure_derive",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "failure_derive"
|
|
+version = "0.1.8"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
|
|
+dependencies = [
|
|
+ "proc-macro2 1.0.27",
|
|
+ "quote 1.0.9",
|
|
+ "syn 1.0.73",
|
|
+ "synstructure",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "fixed-hash"
|
|
+version = "0.6.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c"
|
|
+dependencies = [
|
|
+ "byteorder",
|
|
+ "rand",
|
|
+ "rustc-hex",
|
|
+ "static_assertions",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "fnv"
|
|
+version = "1.0.7"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
|
+
|
|
+[[package]]
|
|
+name = "getrandom"
|
|
+version = "0.1.16"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
|
+dependencies = [
|
|
+ "cfg-if",
|
|
+ "libc",
|
|
+ "wasi",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "gimli"
|
|
+version = "0.24.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189"
|
|
+
|
|
+[[package]]
|
|
+name = "hashbrown"
|
|
+version = "0.9.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
|
|
+
|
|
+[[package]]
|
|
+name = "idna"
|
|
+version = "0.1.5"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
|
|
+dependencies = [
|
|
+ "matches",
|
|
+ "unicode-bidi",
|
|
+ "unicode-normalization",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "if_chain"
|
|
+version = "0.1.3"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec"
|
|
+
|
|
+[[package]]
|
|
+name = "impl-codec"
|
|
+version = "0.4.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53"
|
|
+dependencies = [
|
|
+ "parity-scale-codec",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "impl-rlp"
|
|
+version = "0.2.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5"
|
|
+dependencies = [
|
|
+ "rlp",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "impl-serde"
|
|
+version = "0.3.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "b47ca4d2b6931707a55fce5cf66aff80e2178c8b63bbb4ecb5695cbc870ddf6f"
|
|
+dependencies = [
|
|
+ "serde",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "indexmap"
|
|
+version = "1.6.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
|
|
+dependencies = [
|
|
+ "autocfg",
|
|
+ "hashbrown",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "itertools"
|
|
+version = "0.7.11"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d"
|
|
+dependencies = [
|
|
+ "either",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "itoa"
|
|
+version = "0.4.7"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
|
+
|
|
+[[package]]
|
|
+name = "keccak-hash"
|
|
+version = "0.5.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "1f58a51ef3df9398cf2434bea8d4eb61fb748d0feb1571f87388579a120a4c8f"
|
|
+dependencies = [
|
|
+ "primitive-types",
|
|
+ "tiny-keccak 2.0.2",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "lazy_static"
|
|
+version = "1.4.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|
+
|
|
+[[package]]
|
|
+name = "libc"
|
|
+version = "0.2.97"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
|
+
|
|
+[[package]]
|
|
+name = "logos"
|
|
+version = "0.12.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "427e2abca5be13136da9afdbf874e6b34ad9001dd70f2b103b083a85daa7b345"
|
|
+dependencies = [
|
|
+ "logos-derive",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "logos-derive"
|
|
+version = "0.12.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "56a7d287fd2ac3f75b11f19a1c8a874a7d55744bd91f7a1b3e7cf87d4343c36d"
|
|
+dependencies = [
|
|
+ "beef",
|
|
+ "fnv",
|
|
+ "proc-macro2 1.0.27",
|
|
+ "quote 1.0.9",
|
|
+ "regex-syntax",
|
|
+ "syn 1.0.73",
|
|
+ "utf8-ranges",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "matches"
|
|
+version = "0.1.8"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
|
+
|
|
+[[package]]
|
|
+name = "memchr"
|
|
+version = "2.4.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
|
|
+
|
|
+[[package]]
|
|
+name = "miniz_oxide"
|
|
+version = "0.4.4"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
|
|
+dependencies = [
|
|
+ "adler",
|
|
+ "autocfg",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "object"
|
|
+version = "0.25.3"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7"
|
|
+dependencies = [
|
|
+ "memchr",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "parity-scale-codec"
|
|
+version = "1.3.7"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "a4b26b16c7687c3075982af47719e481815df30bc544f7a6690763a25ca16e9d"
|
|
+dependencies = [
|
|
+ "arrayvec",
|
|
+ "bitvec",
|
|
+ "byte-slice-cast",
|
|
+ "serde",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "percent-encoding"
|
|
+version = "1.0.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
|
|
+
|
|
+[[package]]
|
|
+name = "ppv-lite86"
|
|
+version = "0.2.10"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|
+
|
|
+[[package]]
|
|
+name = "primitive-types"
|
|
+version = "0.7.3"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809"
|
|
+dependencies = [
|
|
+ "fixed-hash",
|
|
+ "impl-codec",
|
|
+ "impl-rlp",
|
|
+ "impl-serde",
|
|
+ "uint",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "proc-macro2"
|
|
+version = "0.4.30"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
|
+dependencies = [
|
|
+ "unicode-xid 0.1.0",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "proc-macro2"
|
|
+version = "1.0.27"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
|
|
+dependencies = [
|
|
+ "unicode-xid 0.2.2",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "quote"
|
|
+version = "0.6.13"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
|
+dependencies = [
|
|
+ "proc-macro2 0.4.30",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "quote"
|
|
+version = "1.0.9"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
|
|
+dependencies = [
|
|
+ "proc-macro2 1.0.27",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "radium"
|
|
+version = "0.3.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac"
|
|
+
|
|
+[[package]]
|
|
+name = "rand"
|
|
+version = "0.7.3"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
|
+dependencies = [
|
|
+ "getrandom",
|
|
+ "libc",
|
|
+ "rand_chacha",
|
|
+ "rand_core",
|
|
+ "rand_hc",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "rand_chacha"
|
|
+version = "0.2.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
|
+dependencies = [
|
|
+ "ppv-lite86",
|
|
+ "rand_core",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "rand_core"
|
|
+version = "0.5.1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
|
+dependencies = [
|
|
+ "getrandom",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "rand_hc"
|
|
+version = "0.2.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
|
+dependencies = [
|
|
+ "rand_core",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "regex"
|
|
+version = "1.5.4"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
|
+dependencies = [
|
|
+ "aho-corasick",
|
|
+ "memchr",
|
|
+ "regex-syntax",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "regex-syntax"
|
|
+version = "0.6.25"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
|
+
|
|
+[[package]]
|
|
+name = "rlp"
|
|
+version = "0.4.6"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "1190dcc8c3a512f1eef5d09bb8c84c7f39e1054e174d1795482e18f5272f2e73"
|
|
+dependencies = [
|
|
+ "rustc-hex",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "rustc-demangle"
|
|
+version = "0.1.20"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49"
|
|
+
|
|
+[[package]]
|
|
+name = "rustc-hex"
|
|
+version = "2.1.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6"
|
|
+
|
|
+[[package]]
|
|
+name = "ryu"
|
|
+version = "1.0.5"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
|
+
|
|
+[[package]]
|
|
+name = "serde"
|
|
+version = "1.0.126"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03"
|
|
+dependencies = [
|
|
+ "serde_derive",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "serde_derive"
|
|
+version = "1.0.126"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43"
|
|
+dependencies = [
|
|
+ "proc-macro2 1.0.27",
|
|
+ "quote 1.0.9",
|
|
+ "syn 1.0.73",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "serde_json"
|
|
+version = "1.0.64"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
|
|
+dependencies = [
|
|
+ "itoa",
|
|
+ "ryu",
|
|
+ "serde",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "static_assertions"
|
|
+version = "1.1.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|
+
|
|
+[[package]]
|
|
+name = "syn"
|
|
+version = "0.15.44"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
|
|
+dependencies = [
|
|
+ "proc-macro2 0.4.30",
|
|
+ "quote 0.6.13",
|
|
+ "unicode-xid 0.1.0",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "syn"
|
|
+version = "1.0.73"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
|
|
+dependencies = [
|
|
+ "proc-macro2 1.0.27",
|
|
+ "quote 1.0.9",
|
|
+ "unicode-xid 0.2.2",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "synstructure"
|
|
+version = "0.12.4"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
|
|
+dependencies = [
|
|
+ "proc-macro2 1.0.27",
|
|
+ "quote 1.0.9",
|
|
+ "syn 1.0.73",
|
|
+ "unicode-xid 0.2.2",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "tiny-keccak"
|
|
+version = "1.5.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2"
|
|
+dependencies = [
|
|
+ "crunchy",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "tiny-keccak"
|
|
+version = "2.0.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
|
|
+dependencies = [
|
|
+ "crunchy",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "tinyvec"
|
|
+version = "1.2.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342"
|
|
+dependencies = [
|
|
+ "tinyvec_macros",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "tinyvec_macros"
|
|
+version = "0.1.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
|
+
|
|
+[[package]]
|
|
+name = "uint"
|
|
+version = "0.8.5"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177"
|
|
+dependencies = [
|
|
+ "byteorder",
|
|
+ "crunchy",
|
|
+ "rustc-hex",
|
|
+ "static_assertions",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "unicode-bidi"
|
|
+version = "0.3.5"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0"
|
|
+dependencies = [
|
|
+ "matches",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "unicode-normalization"
|
|
+version = "0.1.19"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9"
|
|
+dependencies = [
|
|
+ "tinyvec",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "unicode-xid"
|
|
+version = "0.1.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
|
+
|
|
+[[package]]
|
|
+name = "unicode-xid"
|
|
+version = "0.2.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
|
+
|
|
+[[package]]
|
|
+name = "url"
|
|
+version = "1.7.2"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
|
|
+dependencies = [
|
|
+ "idna",
|
|
+ "matches",
|
|
+ "percent-encoding",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "utf8-ranges"
|
|
+version = "1.0.4"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba"
|
|
+
|
|
+[[package]]
|
|
+name = "validator"
|
|
+version = "0.8.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "236a5eda3df2c877872e98dbc55d497d943792e6405d8fc65bd4f8a5e3b53c99"
|
|
+dependencies = [
|
|
+ "idna",
|
|
+ "lazy_static",
|
|
+ "regex",
|
|
+ "serde",
|
|
+ "serde_derive",
|
|
+ "serde_json",
|
|
+ "url",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "validator_derive"
|
|
+version = "0.8.0"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "d360d6f5754972c0c1da14fb3d5580daa31aee566e1e45e2f8d3bf5950ecd3e9"
|
|
+dependencies = [
|
|
+ "if_chain",
|
|
+ "lazy_static",
|
|
+ "proc-macro2 0.4.30",
|
|
+ "quote 0.6.13",
|
|
+ "regex",
|
|
+ "syn 0.15.44",
|
|
+ "validator",
|
|
+]
|
|
+
|
|
+[[package]]
|
|
+name = "wasi"
|
|
+version = "0.9.0+wasi-snapshot-preview1"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
|
diff --git a/crates/util/EIP-712/Cargo.toml b/crates/util/EIP-712/Cargo.toml
|
|
index 48428a0b7c..2a2d0f8ae6 100644
|
|
--- a/crates/util/EIP-712/Cargo.toml
|
|
+++ b/crates/util/EIP-712/Cargo.toml
|
|
@@ -17,12 +17,12 @@ serde_json = "1.0"
|
|
ethabi = "12.0.0"
|
|
keccak-hash = "0.5.0"
|
|
ethereum-types = "0.9.2"
|
|
+logos = "0.12.0"
|
|
failure = "0.1.7"
|
|
itertools = "0.7"
|
|
lazy_static = "1.1"
|
|
regex = "1.0"
|
|
validator = "0.8"
|
|
validator_derive = "0.8"
|
|
-lunarity-lexer = "0.2"
|
|
rustc-hex = "2.0"
|
|
indexmap = "1.0.2"
|
|
diff --git a/crates/util/EIP-712/src/parser.rs b/crates/util/EIP-712/src/parser.rs
|
|
index a5700558d9..7e19e016e9 100644
|
|
--- a/crates/util/EIP-712/src/parser.rs
|
|
+++ b/crates/util/EIP-712/src/parser.rs
|
|
@@ -16,7 +16,7 @@
|
|
|
|
//! Solidity type-name parsing
|
|
use crate::error::*;
|
|
-use lunarity_lexer::{Lexer, Token};
|
|
+use logos::{Lexer, Logos};
|
|
use std::{fmt, result};
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
@@ -35,6 +35,59 @@ pub enum Type {
|
|
},
|
|
}
|
|
|
|
+#[derive(Logos, Debug, Clone, Copy, PartialEq)]
|
|
+pub enum Token {
|
|
+ #[token("bool")]
|
|
+ TypeBool,
|
|
+
|
|
+ #[token("address")]
|
|
+ TypeAddress,
|
|
+
|
|
+ #[token("string")]
|
|
+ TypeString,
|
|
+
|
|
+ #[regex("byte|bytes[1-2][0-9]?|bytes3[0-2]?|bytes[4-9]", validate_bytes)]
|
|
+ TypeByte(u8),
|
|
+
|
|
+ #[token("bytes")]
|
|
+ TypeBytes,
|
|
+
|
|
+ #[regex("int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144)")]
|
|
+ #[regex("int(152|160|168|176|184|192|200|208|216|224|232|240|248|256)")]
|
|
+ #[token("int")]
|
|
+ TypeInt,
|
|
+
|
|
+ #[regex("uint(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144)")]
|
|
+ #[regex("uint(152|160|168|176|184|192|200|208|216|224|232|240|248|256)")]
|
|
+ #[token("uint")]
|
|
+ TypeUint,
|
|
+
|
|
+ #[token("[]")]
|
|
+ Array,
|
|
+
|
|
+ #[regex("[a-zA-Z_$][a-zA-Z0-9_$]*")]
|
|
+ Identifier,
|
|
+
|
|
+ #[regex("\\[[0-9]+\\]", |lex| lex.slice()[1..lex.slice().len()-1].parse::<u64>().ok() )]
|
|
+ SizedArray(u64),
|
|
+
|
|
+ #[error]
|
|
+ Error,
|
|
+}
|
|
+
|
|
+fn validate_bytes(lex: &mut Lexer<Token>) -> Option<u8> {
|
|
+ let slice = lex.slice().as_bytes();
|
|
+
|
|
+ if slice.len() > 5 {
|
|
+ if let Some(byte) = slice.get(6) {
|
|
+ return Some((slice[5] - b'0') * 10 + (byte - b'0'));
|
|
+ }
|
|
+ return Some(slice[5] - b'0');
|
|
+ } else {
|
|
+ return Some(1);
|
|
+ }
|
|
+}
|
|
+
|
|
impl From<Type> for String {
|
|
fn from(field_type: Type) -> String {
|
|
match field_type {
|
|
@@ -66,74 +119,49 @@ impl fmt::Display for Type {
|
|
|
|
/// the type string is being validated before it's parsed.
|
|
pub fn parse_type(field_type: &str) -> Result<Type> {
|
|
- #[derive(PartialEq)]
|
|
- enum State {
|
|
- Open,
|
|
- Close,
|
|
- }
|
|
+ let mut lex = Token::lexer(field_type);
|
|
|
|
- let mut lexer = Lexer::new(field_type);
|
|
let mut token = None;
|
|
- let mut state = State::Close;
|
|
let mut array_depth = 0;
|
|
- let mut current_array_length: Option<u64> = None;
|
|
|
|
- while lexer.token != Token::EndOfProgram {
|
|
- let type_ = match lexer.token {
|
|
- Token::Identifier => Type::Custom(lexer.slice().to_owned()),
|
|
- Token::TypeByte => Type::Byte(lexer.extras.0),
|
|
+ while let Some(current_token) = lex.next() {
|
|
+ let type_ = match current_token {
|
|
+ Token::Identifier => Type::Custom(lex.slice().to_owned()),
|
|
+ Token::TypeByte(len) => Type::Byte(len),
|
|
Token::TypeBytes => Type::Bytes,
|
|
Token::TypeBool => Type::Bool,
|
|
Token::TypeUint => Type::Uint,
|
|
Token::TypeInt => Type::Int,
|
|
Token::TypeString => Type::String,
|
|
Token::TypeAddress => Type::Address,
|
|
- Token::LiteralInteger => {
|
|
- let length = lexer.slice();
|
|
- current_array_length = Some(
|
|
- length
|
|
- .parse()
|
|
- .map_err(|_| ErrorKind::InvalidArraySize(length.into()))?,
|
|
- );
|
|
- lexer.advance();
|
|
- continue;
|
|
+ Token::Array | Token::SizedArray(_) if array_depth == 10 => {
|
|
+ return Err(ErrorKind::UnsupportedArrayDepth)?;
|
|
}
|
|
- Token::BracketOpen if token.is_some() && state == State::Close => {
|
|
- state = State::Open;
|
|
- lexer.advance();
|
|
+ Token::SizedArray(len) => {
|
|
+ token = Some(Type::Array {
|
|
+ inner: Box::new(token.expect("if statement checks for some; qed")),
|
|
+ length: Some(len),
|
|
+ });
|
|
+ array_depth += 1;
|
|
continue;
|
|
}
|
|
- Token::BracketClose if array_depth < 10 => {
|
|
- if state == State::Open && token.is_some() {
|
|
- let length = current_array_length.take();
|
|
- state = State::Close;
|
|
- token = Some(Type::Array {
|
|
- inner: Box::new(token.expect("if statement checks for some; qed")),
|
|
- length,
|
|
- });
|
|
- lexer.advance();
|
|
- array_depth += 1;
|
|
- continue;
|
|
- } else {
|
|
- return Err(ErrorKind::UnexpectedToken(
|
|
- lexer.slice().to_owned(),
|
|
- field_type.to_owned(),
|
|
- ))?;
|
|
- }
|
|
- }
|
|
- Token::BracketClose if array_depth == 10 => {
|
|
- return Err(ErrorKind::UnsupportedArrayDepth)?;
|
|
+ Token::Array => {
|
|
+ token = Some(Type::Array {
|
|
+ inner: Box::new(token.expect("if statement checks for some; qed")),
|
|
+ length: None,
|
|
+ });
|
|
+ array_depth += 1;
|
|
+ continue;
|
|
}
|
|
- _ => {
|
|
+ Token::Error => {
|
|
return Err(ErrorKind::UnexpectedToken(
|
|
- lexer.slice().to_owned(),
|
|
+ lex.slice().to_owned(),
|
|
field_type.to_owned(),
|
|
- ))?
|
|
+ ))?;
|
|
}
|
|
};
|
|
|
|
token = Some(type_);
|
|
- lexer.advance();
|
|
}
|
|
|
|
Ok(token.ok_or(ErrorKind::NonExistentType)?)
|