From e8967a21cec389ff5143b9e4ea2365b392ab80c6 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 7 May 2024 13:12:10 +0400 Subject: [PATCH 01/87] add integration test scratch --- Cargo.lock | 4 ++++ Cargo.toml | 2 +- integration/Cargo.toml | 12 ++++++++++++ integration/src/erc20.rs | 0 integration/src/erc721.rs | 0 integration/src/lib.rs | 2 ++ 6 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 integration/Cargo.toml create mode 100644 integration/src/erc20.rs create mode 100644 integration/src/erc721.rs create mode 100644 integration/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 0bb348249..d2361517b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,6 +280,10 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "integration" +version = "0.1.0" + [[package]] name = "itoa" version = "1.0.11" diff --git a/Cargo.toml b/Cargo.toml index 681320295..afe65a7f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = [ "lib/grip", "lib/grip-proc", "examples/erc20", - "examples/merkle-proofs", + "examples/merkle-proofs", "integration", ] # Explicitly set the resolver to version 2, which is the default for packages # with edition >= 2021. diff --git a/integration/Cargo.toml b/integration/Cargo.toml new file mode 100644 index 000000000..5b199b095 --- /dev/null +++ b/integration/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "integration" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +license.workspace = true +keywords.workspace = true +repository.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/integration/src/erc20.rs b/integration/src/erc20.rs new file mode 100644 index 000000000..e69de29bb diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs new file mode 100644 index 000000000..e69de29bb diff --git a/integration/src/lib.rs b/integration/src/lib.rs new file mode 100644 index 000000000..15784d854 --- /dev/null +++ b/integration/src/lib.rs @@ -0,0 +1,2 @@ +mod erc721; +mod erc20; \ No newline at end of file From 2cf7a1942eb13ea37b8e67ae0da15a24474cdaaa Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 7 May 2024 15:11:53 +0400 Subject: [PATCH 02/87] add utils and infrastructure --- Cargo.lock | 3588 +++++++++++++++++++++++++++-- integration/Cargo.toml | 4 + integration/src/infrastructure.rs | 264 +++ integration/src/lib.rs | 4 +- integration/src/utils.rs | 15 + 5 files changed, 3663 insertions(+), 212 deletions(-) create mode 100644 integration/src/infrastructure.rs create mode 100644 integration/src/utils.rs diff --git a/Cargo.lock b/Cargo.lock index d2361517b..617ca01dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,42 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if 1.0.0", + "cipher", + "cpufeatures", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -53,18 +89,144 @@ dependencies = [ "const-hex", ] +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + +[[package]] +name = "async-trait" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "async_io_stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +dependencies = [ + "futures", + "pharos", + "rustc_version", +] + +[[package]] +name = "auto_impl" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -74,11 +236,106 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "sha2", + "tinyvec", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +dependencies = [ + "serde", +] + +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cc" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +dependencies = [ + "jobserver", + "libc", + "once_cell", +] [[package]] name = "cfg-if" @@ -92,6 +349,77 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "num-traits", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "coins-bip32" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" +dependencies = [ + "bs58", + "coins-core", + "digest", + "hmac", + "k256", + "serde", + "sha2", + "thiserror", +] + +[[package]] +name = "coins-bip39" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" +dependencies = [ + "bitvec", + "coins-bip32", + "hmac", + "once_cell", + "pbkdf2 0.12.2", + "rand", + "sha2", + "thiserror", +] + +[[package]] +name = "coins-core" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" +dependencies = [ + "base64 0.21.7", + "bech32", + "bs58", + "digest", + "generic-array", + "hex", + "ripemd", + "serde", + "serde_derive", + "sha2", + "sha3", + "thiserror", +] + [[package]] name = "const-hex" version = "1.11.3" @@ -105,6 +433,18 @@ dependencies = [ "serde", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "contracts" version = "0.1.0" @@ -136,6 +476,22 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpufeatures" version = "0.2.12" @@ -145,6 +501,40 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + [[package]] name = "crunchy" version = "0.2.2" @@ -161,6 +551,18 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -171,6 +573,40 @@ dependencies = [ "typenum", ] +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "derivative" version = "2.2.0" @@ -202,346 +638,2310 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", ] [[package]] -name = "dunce" -version = "1.0.4" +name = "dirs" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" - -[[package]] -name = "erc20-example" -version = "0.0.0" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "alloy-primitives", - "contracts", - "mini-alloc", - "stylus-proc", - "stylus-sdk", + "dirs-sys", ] [[package]] -name = "generic-array" -version = "0.14.7" +name = "dirs-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "typenum", - "version_check", + "cfg-if 1.0.0", + "dirs-sys-next", ] [[package]] -name = "getrandom" -version = "0.2.12" +name = "dirs-sys" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ - "cfg-if 1.0.0", "libc", - "wasi", -] - -[[package]] -name = "grip" -version = "0.1.0" -dependencies = [ - "const-hex", - "grip-proc", - "once_cell", - "tiny-keccak", + "option-ext", + "redox_users", + "windows-sys 0.48.0", ] [[package]] -name = "grip-proc" -version = "0.1.0" +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.58", + "libc", + "redox_users", + "winapi", ] [[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-literal" -version = "0.4.1" +name = "dotenv" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "integration" -version = "0.1.0" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] -name = "itoa" -version = "1.0.11" +name = "dunce" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] -name = "keccak" -version = "0.1.5" +name = "ecdsa" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ - "cpufeatures", + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", + "spki", ] [[package]] -name = "keccak-const" -version = "0.2.0" +name = "either" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d8d8ce877200136358e0bbff3a77965875db3af755a11e1fa6b1b3e2df13ea" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] -name = "lazy_static" -version = "1.4.0" +name = "elliptic-curve" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] [[package]] -name = "libc" -version = "0.2.153" +name = "ena" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" +dependencies = [ + "log", +] [[package]] -name = "libm" -version = "0.2.8" +name = "encoding_rs" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if 1.0.0", +] [[package]] -name = "memchr" -version = "2.7.2" +name = "enr" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" +dependencies = [ + "base64 0.21.7", + "bytes", + "hex", + "k256", + "log", + "rand", + "rlp", + "serde", + "sha3", + "zeroize", +] [[package]] -name = "memory_units" -version = "0.4.0" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "merkle-proofs-example" +name = "erc20-example" version = "0.0.0" dependencies = [ "alloy-primitives", - "alloy-sol-types", - "crypto", + "contracts", "mini-alloc", "stylus-proc", "stylus-sdk", ] [[package]] -name = "mini-alloc" -version = "0.4.2" +name = "errno" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9993556d3850cdbd0da06a3dc81297edcfa050048952d84d75e8b944e8f5af" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ - "cfg-if 1.0.0", - "wee_alloc", + "libc", + "windows-sys 0.52.0", ] [[package]] -name = "num-traits" -version = "0.2.18" +name = "eth-keystore" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" dependencies = [ - "autocfg", - "libm", + "aes", + "ctr", + "digest", + "hex", + "hmac", + "pbkdf2 0.11.0", + "rand", + "scrypt", + "serde", + "serde_json", + "sha2", + "sha3", + "thiserror", + "uuid", ] [[package]] -name = "once_cell" -version = "1.19.0" +name = "ethabi" +version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" +dependencies = [ + "ethereum-types", + "hex", + "once_cell", + "regex", + "serde", + "serde_json", + "sha3", + "thiserror", + "uint", +] [[package]] -name = "ppv-lite86" -version = "0.2.17" +name = "ethbloom" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +dependencies = [ + "crunchy", + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "scale-info", + "tiny-keccak", +] [[package]] -name = "proc-macro2" -version = "1.0.79" +name = "ethereum-types" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ - "unicode-ident", + "ethbloom", + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "primitive-types", + "scale-info", + "uint", ] [[package]] -name = "proptest" -version = "1.4.0" +name = "ethers" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "816841ea989f0c69e459af1cf23a6b0033b19a55424a1ea3a30099becdb8dec0" dependencies = [ - "bitflags", - "num-traits", - "rand", - "rand_chacha", - "rand_xorshift", - "unarray", + "ethers-addressbook", + "ethers-contract", + "ethers-core", + "ethers-etherscan", + "ethers-middleware", + "ethers-providers", + "ethers-signers", + "ethers-solc", ] [[package]] -name = "quote" -version = "1.0.35" +name = "ethers-addressbook" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "5495afd16b4faa556c3bba1f21b98b4983e53c1755022377051a975c3b021759" dependencies = [ - "proc-macro2", + "ethers-core", + "once_cell", + "serde", + "serde_json", ] [[package]] -name = "rand" -version = "0.8.5" +name = "ethers-contract" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "6fceafa3578c836eeb874af87abacfb041f92b4da0a78a5edd042564b8ecdaaa" dependencies = [ - "libc", - "rand_chacha", - "rand_core", + "const-hex", + "ethers-contract-abigen", + "ethers-contract-derive", + "ethers-core", + "ethers-providers", + "futures-util", + "once_cell", + "pin-project", + "serde", + "serde_json", + "thiserror", ] [[package]] -name = "rand_chacha" -version = "0.3.1" +name = "ethers-contract-abigen" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "04ba01fbc2331a38c429eb95d4a570166781f14290ef9fdb144278a90b5a739b" dependencies = [ - "ppv-lite86", - "rand_core", + "Inflector", + "const-hex", + "dunce", + "ethers-core", + "ethers-etherscan", + "eyre", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "reqwest", + "serde", + "serde_json", + "syn 2.0.58", + "toml", + "walkdir", ] [[package]] -name = "rand_core" -version = "0.6.4" +name = "ethers-contract-derive" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "87689dcabc0051cde10caaade298f9e9093d65f6125c14575db3fd8c669a168f" dependencies = [ - "getrandom", + "Inflector", + "const-hex", + "ethers-contract-abigen", + "ethers-core", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.58", ] [[package]] -name = "rand_xorshift" -version = "0.3.0" +name = "ethers-core" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" dependencies = [ - "rand_core", + "arrayvec", + "bytes", + "cargo_metadata", + "chrono", + "const-hex", + "elliptic-curve", + "ethabi", + "generic-array", + "k256", + "num_enum", + "once_cell", + "open-fastrlp", + "rand", + "rlp", + "serde", + "serde_json", + "strum", + "syn 2.0.58", + "tempfile", + "thiserror", + "tiny-keccak", + "unicode-xid", ] [[package]] -name = "regex" -version = "1.10.4" +name = "ethers-etherscan" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "e79e5973c26d4baf0ce55520bd732314328cabe53193286671b47144145b9649" dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", + "chrono", + "ethers-core", + "reqwest", + "semver", + "serde", + "serde_json", + "thiserror", + "tracing", ] [[package]] -name = "regex-automata" -version = "0.4.6" +name = "ethers-middleware" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "48f9fdf09aec667c099909d91908d5eaf9be1bd0e2500ba4172c1d28bfaa43de" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "async-trait", + "auto_impl", + "ethers-contract", + "ethers-core", + "ethers-etherscan", + "ethers-providers", + "ethers-signers", + "futures-channel", + "futures-locks", + "futures-util", + "instant", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "tracing-futures", + "url", ] [[package]] -name = "regex-syntax" -version = "0.8.3" +name = "ethers-providers" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "6434c9a33891f1effc9c75472e12666db2fa5a0fec4b29af6221680a6fe83ab2" +dependencies = [ + "async-trait", + "auto_impl", + "base64 0.21.7", + "bytes", + "const-hex", + "enr", + "ethers-core", + "futures-core", + "futures-timer", + "futures-util", + "hashers", + "http", + "instant", + "jsonwebtoken", + "once_cell", + "pin-project", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-tungstenite", + "tracing", + "tracing-futures", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "ws_stream_wasm", +] [[package]] -name = "ruint" -version = "1.12.1" +name = "ethers-signers" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +checksum = "228875491c782ad851773b652dd8ecac62cda8571d3bc32a5853644dd26766c2" dependencies = [ - "proptest", + "async-trait", + "coins-bip32", + "coins-bip39", + "const-hex", + "elliptic-curve", + "eth-keystore", + "ethers-core", "rand", - "ruint-macro", - "serde", - "valuable", - "zeroize", + "sha2", + "thiserror", + "tracing", ] [[package]] -name = "ruint-macro" -version = "1.2.0" +name = "ethers-solc" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" +checksum = "66244a771d9163282646dbeffe0e6eca4dda4146b6498644e678ac6089b11edd" +dependencies = [ + "cfg-if 1.0.0", + "const-hex", + "dirs", + "dunce", + "ethers-core", + "glob", + "home", + "md-5", + "num_cpus", + "once_cell", + "path-slash", + "rayon", + "regex", + "semver", + "serde", + "serde_json", + "solang-parser", + "svm-rs", + "thiserror", + "tiny-keccak", + "tokio", + "tracing", + "walkdir", + "yansi", +] [[package]] -name = "rustc_version" -version = "0.4.0" +name = "eyre" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" dependencies = [ - "semver", + "indenter", + "once_cell", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flate2" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-locks" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" +dependencies = [ + "futures-channel", + "futures-task", +] + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-timer" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" +dependencies = [ + "gloo-timers", + "send_wrapper 0.4.0", +] + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "grip" +version = "0.1.0" +dependencies = [ + "const-hex", + "grip-proc", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "grip-proc" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hashers" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" +dependencies = [ + "fxhash", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http", + "hyper", + "rustls", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "integration" +version = "0.1.0" +dependencies = [ + "dotenv", + "ethers", + "eyre", + "tokio", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +dependencies = [ + "base64 0.21.7", + "pem", + "ring 0.16.20", + "serde", + "serde_json", + "simple_asn1", +] + +[[package]] +name = "k256" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +dependencies = [ + "cfg-if 1.0.0", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2", + "signature", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "keccak-const" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d8d8ce877200136358e0bbff3a77965875db3af755a11e1fa6b1b3e2df13ea" + +[[package]] +name = "lalrpop" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cb077ad656299f160924eb2912aa147d7339ea7d69e1b5517326fdcec3c1ca" +dependencies = [ + "ascii-canvas", + "bit-set", + "ena", + "itertools", + "lalrpop-util", + "petgraph", + "regex", + "regex-syntax", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", + "walkdir", +] + +[[package]] +name = "lalrpop-util" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" +dependencies = [ + "regex-automata", +] + +[[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.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.5.0", + "libc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if 1.0.0", + "digest", +] + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + +[[package]] +name = "merkle-proofs-example" +version = "0.0.0" +dependencies = [ + "alloy-primitives", + "alloy-sol-types", + "crypto", + "mini-alloc", + "stylus-proc", + "stylus-sdk", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mini-alloc" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9993556d3850cdbd0da06a3dc81297edcfa050048952d84d75e8b944e8f5af" +dependencies = [ + "cfg-if 1.0.0", + "wee_alloc", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "num-bigint" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "num_enum" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "open-fastrlp" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", + "ethereum-types", + "open-fastrlp-derive", +] + +[[package]] +name = "open-fastrlp-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" +dependencies = [ + "bytes", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "parity-scale-codec" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "parking_lot" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.5", +] + +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + +[[package]] +name = "path-slash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest", + "hmac", + "password-hash", + "sha2", +] + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest", + "hmac", +] + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pharos" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" +dependencies = [ + "futures", + "rustc_version", +] + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros", + "phf_shared 0.11.2", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared 0.11.2", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator", + "phf_shared 0.11.2", + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "prettyplease" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" +dependencies = [ + "proc-macro2", + "syn 2.0.58", +] + +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "scale-info", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", +] + +[[package]] +name = "proc-macro2" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proptest" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +dependencies = [ + "bitflags 2.5.0", + "lazy_static", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax", + "unarray", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + +[[package]] +name = "redox_users" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-rustls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted 0.7.1", + "web-sys", + "winapi", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if 1.0.0", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rlp-derive", + "rustc-hex", +] + +[[package]] +name = "rlp-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ruint" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +dependencies = [ + "proptest", + "rand", + "ruint-macro", + "serde", + "valuable", + "zeroize", +] + +[[package]] +name = "ruint-macro" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring 0.17.8", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring 0.17.8", + "untrusted 0.9.0", +] + +[[package]] +name = "rustversion" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scale-info" +version = "2.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" +dependencies = [ + "cfg-if 1.0.0", + "derive_more", + "parity-scale-codec", + "scale-info-derive", +] + +[[package]] +name = "scale-info-derive" +version = "2.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "scrypt" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" +dependencies = [ + "hmac", + "pbkdf2 0.11.0", + "salsa20", + "sha2", +] + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring 0.17.8", + "untrusted 0.9.0", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", ] [[package]] name = "semver" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +dependencies = [ + "serde", +] + +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] [[package]] -name = "serde" -version = "1.0.197" +name = "siphasher" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ - "serde_derive", + "autocfg", ] [[package]] -name = "serde_derive" -version = "1.0.197" +name = "smallvec" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.58", + "libc", + "windows-sys 0.52.0", ] [[package]] -name = "sha3" -version = "0.10.8" +name = "solang-parser" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" dependencies = [ - "digest", - "keccak", + "itertools", + "lalrpop", + "lalrpop-util", + "phf", + "thiserror", + "unicode-xid", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot", + "phf_shared 0.10.0", + "precomputed-hash", +] + +[[package]] +name = "strum" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.58", ] [[package]] @@ -569,56 +2969,390 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74778bf11048b0155b937ee6d52440709d864aa488843238b62272e6c9bdbc1a" dependencies = [ - "alloy-primitives", - "alloy-sol-types", - "cfg-if 1.0.0", - "derivative", - "hex", - "keccak-const", - "lazy_static", - "stylus-proc", + "alloy-primitives", + "alloy-sol-types", + "cfg-if 1.0.0", + "derivative", + "hex", + "keccak-const", + "lazy_static", + "stylus-proc", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "svm-rs" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11297baafe5fa0c99d5722458eac6a5e25c01eb1b8e5cd137f54079093daa7a4" +dependencies = [ + "dirs", + "fs2", + "hex", + "once_cell", + "reqwest", + "semver", + "serde", + "serde_json", + "sha2", + "thiserror", + "url", + "zip", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn-solidity" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5f995d2140b0f751dbe94365be2591edbf3d1b75dcfaeac14183abbd2ff07bd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if 1.0.0", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "thiserror" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[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.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +dependencies = [ + "futures-util", + "log", + "rustls", + "tokio", + "tokio-rustls", + "tungstenite", + "webpki-roots", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.12", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.8", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", ] [[package]] -name = "syn" -version = "1.0.109" +name = "tracing-attributes" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "unicode-ident", + "syn 2.0.58", ] [[package]] -name = "syn" -version = "2.0.58" +name = "tracing-core" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "once_cell", ] [[package]] -name = "syn-solidity" -version = "0.3.1" +name = "tracing-futures" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5f995d2140b0f751dbe94365be2591edbf3d1b75dcfaeac14183abbd2ff07bd" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.58", + "pin-project", + "tracing", ] [[package]] -name = "tiny-keccak" -version = "2.0.2" +name = "try-lock" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ - "crunchy", + "byteorder", + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand", + "rustls", + "sha1", + "thiserror", + "url", + "utf-8", ] [[package]] @@ -627,24 +3361,96 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unarray" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", + "serde", +] + [[package]] name = "valuable" version = "0.1.0" @@ -657,12 +3463,113 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.58", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + [[package]] name = "wee_alloc" version = "0.4.5" @@ -691,14 +3598,273 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if 1.0.0", + "windows-sys 0.48.0", +] + +[[package]] +name = "ws_stream_wasm" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" +dependencies = [ + "async_io_stream", + "futures", + "js-sys", + "log", + "pharos", + "rustc_version", + "send_wrapper 0.6.0", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + [[package]] name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "aes", + "byteorder", + "bzip2", + "constant_time_eq", + "crc32fast", + "crossbeam-utils", + "flate2", + "hmac", + "pbkdf2 0.11.0", + "sha1", + "time", + "zstd", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.10+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/integration/Cargo.toml b/integration/Cargo.toml index 5b199b095..3531aa32d 100644 --- a/integration/Cargo.toml +++ b/integration/Cargo.toml @@ -10,3 +10,7 @@ repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +tokio = { version = "1.12.0", features = ["full"] } +ethers = "2.0" +eyre = "0.6.8" +dotenv = "0.15.0" diff --git a/integration/src/infrastructure.rs b/integration/src/infrastructure.rs new file mode 100644 index 000000000..090cb5ef3 --- /dev/null +++ b/integration/src/infrastructure.rs @@ -0,0 +1,264 @@ +use crate::function; +use dotenv::dotenv; +use ethers::abi::AbiEncode; +use ethers::contract::ContractError; +use ethers::middleware::Middleware; +use ethers::prelude::{FunctionCall, PendingTransaction, ProviderError}; +use ethers::{ + middleware::SignerMiddleware, + prelude::abigen, + providers::{Http, Provider}, + signers::{LocalWallet, Signer}, + types::{Address, TransactionReceipt, U256}, +}; +use eyre::{bail, Context, ContextCompat, Report, Result}; +use std::str::FromStr; +use std::sync::Arc; + +abigen!( + Nft, + r#"[ + function name() external view returns (string memory) + function symbol() external view returns (string memory) + function tokenURI(uint256 token_id) external view returns (string memory) + + function supportsInterface(bytes4 interface_id) external pure returns (bool) + + function balanceOf(address owner) external view returns (uint256) + function ownerOf(uint256 token_id) external view returns (address) + function safeTransferFrom(address from, address to, uint256 token_id) external + function safeTransferFrom(address from, address to, uint256 token_id, bytes calldata data) external + function transferFrom(address from, address to, uint256 token_id) external + function approve(address to, uint256 token_id) external + function setApprovalForAll(address operator, bool approved) external + function getApproved(uint256 token_id) external view returns (address) + function isApprovedForAll(address owner, address operator) external view returns (bool) + + function burn(uint256 token_id) external + function mint(address to, uint256 token_id) external + + function paused() external view returns (bool) + function pause() external + function unpause() external + + error ERC721InvalidOwner(address owner) + error ERC721NonexistentToken(uint256 tokenId) + error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner) + error ERC721InvalidSender(address sender) + error ERC721InvalidReceiver(address receiver) + error ERC721InsufficientApproval(address operator, uint256 tokenId) + error ERC721InvalidApprover(address approver) + error ERC721InvalidOperator(address operator) + + error EnforcedPause() + error ExpectedPause() + ]"# +); + +const FIRST_PRIV_KEY_PATH: &str = "FIRST_PRIV_KEY_PATH"; +const SECOND_PRIV_KEY_PATH: &str = "SECOND_PRIV_KEY_PATH"; +const RPC_URL: &str = "RPC_URL"; +const STYLUS_PROGRAM_ADDRESS: &str = "STYLUS_PROGRAM_ADDRESS"; + +pub struct Infrastructure { + pub first: Client, + pub second: Client, +} + +impl Infrastructure { + pub async fn create() -> eyre::Result { + dotenv().ok(); + + let first_priv_key_path = std::env::var(FIRST_PRIV_KEY_PATH) + .with_context(|| format!("Load {} env var", FIRST_PRIV_KEY_PATH))?; + let second_priv_key_path = std::env::var(SECOND_PRIV_KEY_PATH) + .with_context(|| format!("Load {} env var", SECOND_PRIV_KEY_PATH))?; + let rpc_url = + std::env::var(RPC_URL).with_context(|| format!("Load {} env var", RPC_URL))?; + let stylus_program_address = std::env::var(STYLUS_PROGRAM_ADDRESS) + .with_context(|| format!("Load {} env var", STYLUS_PROGRAM_ADDRESS))?; + + let program_address: Address = stylus_program_address.parse()?; + let provider = Provider::::try_from(rpc_url)?; + let first_priv_key = std::fs::read_to_string(first_priv_key_path)? + .trim() + .to_string(); + let second_priv_key = std::fs::read_to_string(second_priv_key_path)? + .trim() + .to_string(); + + Ok(Infrastructure { + first: Client::create(provider.clone(), program_address, first_priv_key).await?, + second: Client::create(provider, program_address, second_priv_key).await?, + }) + } +} + +pub struct Client { + pub wallet: LocalWallet, + pub caller: Caller, +} + +impl Client { + pub async fn create( + provider: Provider, + program_address: Address, + priv_key: String, + ) -> eyre::Result { + let wallet = LocalWallet::from_str(&priv_key)?; + let chain_id = provider.get_chainid().await?.as_u64(); + let signer = Arc::new(SignerMiddleware::new( + provider, + wallet.clone().with_chain_id(chain_id), + )); + let caller = Nft::new(program_address, signer); + Ok(Self { wallet, caller }) + } + + pub async fn name(&self) -> Result { + self.caller + .name() + .call() + .await + .context(format!("Error calling {}", function!())) + } + + pub async fn symbol(&self) -> Result { + self.caller + .symbol() + .call() + .await + .context(format!("Error calling {}", function!())) + } + + pub async fn token_uri(&self, token_id: U256) -> Result { + self.caller + .token_uri(token_id) + .call() + .await + .context(format!("Error calling {}", function!())) + } + + pub async fn balance_of(&self, owner: Address) -> Result { + self.caller + .balance_of(owner) + .call() + .await + .context(format!("Error calling {}", function!())) + } + + pub async fn mint(&self, to: Address, token_id: U256) -> Result { + self.caller + .mint(to, token_id) + .send() + .await? + .await? + .context(format!("Error sending {}", function!())) + } + + pub async fn burn(&self, token_id: U256) -> Result { + self.caller + .burn(token_id) + .send() + .await? + .await? + .context(format!("Error sending {}", function!())) + } + + pub async fn transfer_from( + &self, + from: Address, + to: Address, + token_id: U256, + ) -> Result { + self.caller + .transfer_from(from, to, token_id) + .send() + .await? + .await? + .context(format!("Error sending {}", function!())) + } + + pub async fn owner_of(&self, token_id: U256) -> Result
{ + self.caller + .owner_of(token_id) + .call() + .await + .context(format!("Error calling {}", function!())) + } + + pub async fn approve(&self, to: Address, token_id: U256) -> Result { + self.caller + .approve(to, token_id) + .send() + .await? + .await? + .context(format!("Error sending {}", function!())) + } + + pub async fn get_approved(&self, token_id: U256) -> Result
{ + self.caller + .get_approved(token_id) + .call() + .await + .context(format!("Error calling {}", function!())) + } + + pub async fn paused(&self) -> Result { + self.caller + .paused() + .call() + .await + .context(format!("Error calling {}", function!())) + } + + pub async fn pause(&self) -> Result { + self.caller + .pause() + .send() + .await? + .await? + .context(format!("Error sending {}", function!())) + } + + pub async fn unpause(&self) -> Result { + self.caller + .unpause() + .send() + .await? + .await? + .context(format!("Error sending {}", function!())) + } + + pub async fn support_interface(&self, interface_id: u32) -> Result { + let interface_id = interface_id.to_be_bytes(); + self.caller + .supports_interface(interface_id) + .call() + .await + .context(format!("Error calling {}", function!())) + } +} + +pub type Caller = Nft, LocalWallet>>; + +pub fn random_token_id() -> U256 { + let num: u32 = ethers::core::rand::random(); + num.into() +} + +pub trait Assert { + fn assert_has(&self, expected_err: E) -> Result<()>; +} + +impl Assert for Report { + fn assert_has(&self, expected_err: E) -> Result<()> { + let received_err = format!("{:#}", self); + let expected_err = expected_err.encode_hex(); + if received_err.contains(&expected_err) { + Ok(()) + } else { + bail!("Different error expected: expected error is {expected_err}: received error is {received_err}") + } + } +} diff --git a/integration/src/lib.rs b/integration/src/lib.rs index 15784d854..6d7d5a11e 100644 --- a/integration/src/lib.rs +++ b/integration/src/lib.rs @@ -1,2 +1,4 @@ mod erc721; -mod erc20; \ No newline at end of file +mod erc20; +mod infrastructure; +mod utils; \ No newline at end of file diff --git a/integration/src/utils.rs b/integration/src/utils.rs new file mode 100644 index 000000000..9b19cb643 --- /dev/null +++ b/integration/src/utils.rs @@ -0,0 +1,15 @@ +/// Retrieve name of the current function +#[macro_export] +macro_rules! function { + () => {{ + fn f() {} + fn type_name_of(_: T) -> &'static str { + std::any::type_name::() + } + type_name_of(f) + .rsplit("::") + .find(|&part| part != "f" && part != "{{closure}}") + .expect("Short function name") + }}; +} +` \ No newline at end of file From 0b7a42814a5cf698d33589781406ad7a741ba7c7 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 7 May 2024 16:22:13 +0400 Subject: [PATCH 03/87] add erc721 tests --- integration/src/erc721.rs | 152 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index e69de29bb..d45ba855c 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -0,0 +1,152 @@ +use crate::infrastructure::*; +use ethers::prelude::*; +use eyre::{bail, Result}; + +#[tokio::test] +async fn receive_context() -> Result<()> { + let infra = Infrastructure::create().await?; + let token_id = 123.into(); + + let name = infra.first.name().await?; + let symbol = infra.first.symbol().await?; + let token_uri = infra.first.token_uri(token_id).await?; + + assert_eq!(name, "PausableBurnableNft"); + assert_eq!(symbol, "PBN"); + assert_eq!( + token_uri, + "wwww.pbn.io/".to_string() + &token_id.to_string() + ); + Ok(()) +} + +#[tokio::test] +async fn mint_nft_and_check_balance() -> Result<()> { + let infra = Infrastructure::create().await?; + let token_id = random_token_id(); + let _ = infra + .first + .mint(infra.first.wallet.address(), token_id) + .await?; + let owner = infra.first.owner_of(token_id).await?; + assert_eq!(owner, infra.first.wallet.address()); + + let balance = infra.first.balance_of(infra.first.wallet.address()).await?; + assert!(balance >= U256::one()); + Ok(()) +} + +#[tokio::test] +async fn error_mint_second_nft() -> Result<()> { + let infra = Infrastructure::create().await?; + let token_id = random_token_id(); + let _ = infra + .first + .mint(infra.first.wallet.address(), token_id) + .await?; + match infra + .first + .mint(infra.first.wallet.address(), token_id) + .await + { + Ok(_) => { + bail!("Second mint of the same token should not be possible") + } + Err(e) => e.assert_has(ERC721InvalidSender { + sender: Address::zero(), + }), + } +} + +#[tokio::test] +async fn transfer_nft() -> Result<()> { + let infra = Infrastructure::create().await?; + let token_id = random_token_id(); + let _ = infra + .first + .mint(infra.first.wallet.address(), token_id) + .await?; + let _ = infra + .first + .transfer_from( + infra.first.wallet.address(), + infra.second.wallet.address(), + token_id, + ) + .await?; + let owner = infra.second.owner_of(token_id).await?; + assert_eq!(owner, infra.second.wallet.address()); + Ok(()) +} + +#[tokio::test] +async fn error_transfer_nonexistent_nft() -> Result<()> { + let infra = Infrastructure::create().await?; + let token_id = random_token_id(); + match infra + .first + .transfer_from( + infra.first.wallet.address(), + infra.second.wallet.address(), + token_id, + ) + .await + { + Ok(_) => { + bail!("Transfer of a non existent nft should not be possible") + } + Err(e) => e.assert_has(ERC721NonexistentToken { token_id }), + } +} + +#[tokio::test] +async fn approve_nft_transfer() -> Result<()> { + let infra = Infrastructure::create().await?; + let token_id = random_token_id(); + let _ = infra + .first + .mint(infra.first.wallet.address(), token_id) + .await?; + let _ = infra + .first + .approve(infra.second.wallet.address(), token_id) + .await?; + let _ = infra + .second + .transfer_from( + infra.first.wallet.address(), + infra.second.wallet.address(), + token_id, + ) + .await?; + let owner = infra.second.owner_of(token_id).await?; + assert_eq!(owner, infra.second.wallet.address()); + Ok(()) +} + +#[tokio::test] +async fn error_not_approved_nft_transfer() -> Result<()> { + let infra = Infrastructure::create().await?; + let token_id = random_token_id(); + let _ = infra + .first + .mint(infra.first.wallet.address(), token_id) + .await?; + match infra + .second + .transfer_from( + infra.first.wallet.address(), + infra.second.wallet.address(), + token_id, + ) + .await + { + Ok(_) => { + bail!("Transfer of not approved token should not happen") + } + Err(e) => e.assert_has(ERC721InsufficientApproval { + operator: infra.second.wallet.address(), + token_id, + }), + } +} \ No newline at end of file From d169206acaa79ccd65a44611526a7456bcbc6927 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 9 May 2024 10:48:33 +0400 Subject: [PATCH 04/87] add erc721 example --- Cargo.lock | 11 +++++++++++ Cargo.toml | 4 +++- examples/erc20/src/lib.rs | 2 +- examples/erc721/Cargo.toml | 17 +++++++++++++++++ examples/erc721/src/lib.rs | 17 +++++++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 examples/erc721/Cargo.toml create mode 100644 examples/erc721/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 617ca01dd..4aa568915 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -789,6 +789,17 @@ dependencies = [ "stylus-sdk", ] +[[package]] +name = "erc721-example" +version = "0.0.0" +dependencies = [ + "alloy-primitives", + "contracts", + "mini-alloc", + "stylus-proc", + "stylus-sdk", +] + [[package]] name = "errno" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index afe65a7f6..48ad16682 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,9 @@ members = [ "lib/grip", "lib/grip-proc", "examples/erc20", - "examples/merkle-proofs", "integration", + "examples/merkle-proofs", + "examples/erc721", + "integration", ] # Explicitly set the resolver to version 2, which is the default for packages # with edition >= 2021. diff --git a/examples/erc20/src/lib.rs b/examples/erc20/src/lib.rs index a6bf80752..89e3a1c5c 100644 --- a/examples/erc20/src/lib.rs +++ b/examples/erc20/src/lib.rs @@ -4,7 +4,7 @@ extern crate alloc; use alloc::string::String; use contracts::{ - erc20::{extensions::Metadata, ERC20}, + erc20::{extensions::metadata::Metadata, ERC20}, erc20_burnable_impl, }; use stylus_sdk::prelude::{entrypoint, external, sol_storage}; diff --git a/examples/erc721/Cargo.toml b/examples/erc721/Cargo.toml new file mode 100644 index 000000000..a8ba52a28 --- /dev/null +++ b/examples/erc721/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "erc721-example" +edition.workspace = true +license.workspace = true +repository.workspace = true +publish = false +version = "0.0.0" + +[dependencies] +contracts = { path = "../../contracts", features = ["erc721"]} +alloy-primitives.workspace = true +stylus-sdk.workspace = true +stylus-proc.workspace = true +mini-alloc.workspace = true + +[lib] +crate-type = ["lib", "cdylib"] diff --git a/examples/erc721/src/lib.rs b/examples/erc721/src/lib.rs new file mode 100644 index 000000000..ea832b29a --- /dev/null +++ b/examples/erc721/src/lib.rs @@ -0,0 +1,17 @@ +#![cfg_attr(not(test), no_main, no_std)] +extern crate alloc; + +use contracts::erc721::ERC721; +use stylus_sdk::prelude::{entrypoint, external, sol_storage}; + +sol_storage! { + #[entrypoint] + struct Token { + #[borrow] + ERC721 erc721; + } +} + +#[external] +#[inherit(ERC721)] +impl Token {} From f192dfeae5292be4d6564063701aeeabdf1e4a8d Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 9 May 2024 11:12:47 +0400 Subject: [PATCH 05/87] remove integration from default members --- Cargo.toml | 9 +++++++++ integration/Cargo.toml | 2 -- integration/src/utils.rs | 1 - 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 48ad16682..f3da07db4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,15 @@ members = [ "examples/erc721", "integration", ] +default-members = [ + "contracts", + "lib/crypto", + "lib/grip", + "lib/grip-proc", + "examples/erc20", + "examples/merkle-proofs", + "examples/erc721", +] # Explicitly set the resolver to version 2, which is the default for packages # with edition >= 2021. # https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html diff --git a/integration/Cargo.toml b/integration/Cargo.toml index 3531aa32d..7d76c26f6 100644 --- a/integration/Cargo.toml +++ b/integration/Cargo.toml @@ -7,8 +7,6 @@ license.workspace = true keywords.workspace = true repository.workspace = true -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] tokio = { version = "1.12.0", features = ["full"] } ethers = "2.0" diff --git a/integration/src/utils.rs b/integration/src/utils.rs index 9b19cb643..6a0d2bbf9 100644 --- a/integration/src/utils.rs +++ b/integration/src/utils.rs @@ -12,4 +12,3 @@ macro_rules! function { .expect("Short function name") }}; } -` \ No newline at end of file From 9681d039e34c9ca070223775af3b761aff8d76f7 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 9 May 2024 11:32:10 +0400 Subject: [PATCH 06/87] remove receive_context test --- integration/src/erc721.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index d45ba855c..a55fc3ee1 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -2,24 +2,6 @@ use crate::infrastructure::*; use ethers::prelude::*; use eyre::{bail, Result}; -#[tokio::test] -async fn receive_context() -> Result<()> { - let infra = Infrastructure::create().await?; - let token_id = 123.into(); - - let name = infra.first.name().await?; - let symbol = infra.first.symbol().await?; - let token_uri = infra.first.token_uri(token_id).await?; - - assert_eq!(name, "PausableBurnableNft"); - assert_eq!(symbol, "PBN"); - assert_eq!( - token_uri, - "wwww.pbn.io/".to_string() + &token_id.to_string() - ); - Ok(()) -} - #[tokio::test] async fn mint_nft_and_check_balance() -> Result<()> { let infra = Infrastructure::create().await?; From a7fa6d8bcdbd24ce5db1691995ca74044510b03d Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 9 May 2024 15:21:09 +0400 Subject: [PATCH 07/87] restructure infrastructure --- integration/src/erc721.rs | 19 +-- .../erc721.rs} | 153 ++++++------------ integration/src/infrastructure/mod.rs | 114 +++++++++++++ integration/src/{ => infrastructure}/utils.rs | 0 integration/src/lib.rs | 3 +- 5 files changed, 170 insertions(+), 119 deletions(-) rename integration/src/{infrastructure.rs => infrastructure/erc721.rs} (50%) create mode 100644 integration/src/infrastructure/mod.rs rename integration/src/{ => infrastructure}/utils.rs (100%) diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index a55fc3ee1..d39953964 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -1,10 +1,11 @@ use crate::infrastructure::*; +use crate::infrastructure::erc721::*; use ethers::prelude::*; use eyre::{bail, Result}; #[tokio::test] async fn mint_nft_and_check_balance() -> Result<()> { - let infra = Infrastructure::create().await?; + let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra .first @@ -20,7 +21,7 @@ async fn mint_nft_and_check_balance() -> Result<()> { #[tokio::test] async fn error_mint_second_nft() -> Result<()> { - let infra = Infrastructure::create().await?; + let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra .first @@ -34,7 +35,7 @@ async fn error_mint_second_nft() -> Result<()> { Ok(_) => { bail!("Second mint of the same token should not be possible") } - Err(e) => e.assert_has(ERC721InvalidSender { + Err(e) => e.assert(ERC721InvalidSender { sender: Address::zero(), }), } @@ -42,7 +43,7 @@ async fn error_mint_second_nft() -> Result<()> { #[tokio::test] async fn transfer_nft() -> Result<()> { - let infra = Infrastructure::create().await?; + let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra .first @@ -63,7 +64,7 @@ async fn transfer_nft() -> Result<()> { #[tokio::test] async fn error_transfer_nonexistent_nft() -> Result<()> { - let infra = Infrastructure::create().await?; + let infra = Infrastructure::new().await?; let token_id = random_token_id(); match infra .first @@ -77,13 +78,13 @@ async fn error_transfer_nonexistent_nft() -> Result<()> { Ok(_) => { bail!("Transfer of a non existent nft should not be possible") } - Err(e) => e.assert_has(ERC721NonexistentToken { token_id }), + Err(e) => e.assert(ERC721NonexistentToken { token_id }), } } #[tokio::test] async fn approve_nft_transfer() -> Result<()> { - let infra = Infrastructure::create().await?; + let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra .first @@ -108,7 +109,7 @@ async fn approve_nft_transfer() -> Result<()> { #[tokio::test] async fn error_not_approved_nft_transfer() -> Result<()> { - let infra = Infrastructure::create().await?; + let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra .first @@ -126,7 +127,7 @@ async fn error_not_approved_nft_transfer() -> Result<()> { Ok(_) => { bail!("Transfer of not approved token should not happen") } - Err(e) => e.assert_has(ERC721InsufficientApproval { + Err(e) => e.assert(ERC721InsufficientApproval { operator: infra.second.wallet.address(), token_id, }), diff --git a/integration/src/infrastructure.rs b/integration/src/infrastructure/erc721.rs similarity index 50% rename from integration/src/infrastructure.rs rename to integration/src/infrastructure/erc721.rs index 090cb5ef3..d37eefeca 100644 --- a/integration/src/infrastructure.rs +++ b/integration/src/infrastructure/erc721.rs @@ -1,22 +1,19 @@ -use crate::function; -use dotenv::dotenv; -use ethers::abi::AbiEncode; -use ethers::contract::ContractError; -use ethers::middleware::Middleware; -use ethers::prelude::{FunctionCall, PendingTransaction, ProviderError}; +use std::sync::Arc; + use ethers::{ - middleware::SignerMiddleware, - prelude::abigen, - providers::{Http, Provider}, - signers::{LocalWallet, Signer}, - types::{Address, TransactionReceipt, U256}, + addressbook::Address, + contract::abigen, + prelude::{TransactionReceipt, U256}, +}; +use eyre::{Context, ContextCompat}; + +use crate::{ + function, + infrastructure::{Client, HttpMiddleware, Token}, }; -use eyre::{bail, Context, ContextCompat, Report, Result}; -use std::str::FromStr; -use std::sync::Arc; abigen!( - Nft, + Erc721Token, r#"[ function name() external view returns (string memory) function symbol() external view returns (string memory) @@ -55,67 +52,16 @@ abigen!( ]"# ); -const FIRST_PRIV_KEY_PATH: &str = "FIRST_PRIV_KEY_PATH"; -const SECOND_PRIV_KEY_PATH: &str = "SECOND_PRIV_KEY_PATH"; -const RPC_URL: &str = "RPC_URL"; -const STYLUS_PROGRAM_ADDRESS: &str = "STYLUS_PROGRAM_ADDRESS"; - -pub struct Infrastructure { - pub first: Client, - pub second: Client, -} - -impl Infrastructure { - pub async fn create() -> eyre::Result { - dotenv().ok(); +pub type Erc721 = Erc721Token; - let first_priv_key_path = std::env::var(FIRST_PRIV_KEY_PATH) - .with_context(|| format!("Load {} env var", FIRST_PRIV_KEY_PATH))?; - let second_priv_key_path = std::env::var(SECOND_PRIV_KEY_PATH) - .with_context(|| format!("Load {} env var", SECOND_PRIV_KEY_PATH))?; - let rpc_url = - std::env::var(RPC_URL).with_context(|| format!("Load {} env var", RPC_URL))?; - let stylus_program_address = std::env::var(STYLUS_PROGRAM_ADDRESS) - .with_context(|| format!("Load {} env var", STYLUS_PROGRAM_ADDRESS))?; - - let program_address: Address = stylus_program_address.parse()?; - let provider = Provider::::try_from(rpc_url)?; - let first_priv_key = std::fs::read_to_string(first_priv_key_path)? - .trim() - .to_string(); - let second_priv_key = std::fs::read_to_string(second_priv_key_path)? - .trim() - .to_string(); - - Ok(Infrastructure { - first: Client::create(provider.clone(), program_address, first_priv_key).await?, - second: Client::create(provider, program_address, second_priv_key).await?, - }) +impl Token for Erc721 { + fn new>(address: T, client: Arc) -> Self { + Erc721Token::new(address, client) } } -pub struct Client { - pub wallet: LocalWallet, - pub caller: Caller, -} - -impl Client { - pub async fn create( - provider: Provider, - program_address: Address, - priv_key: String, - ) -> eyre::Result { - let wallet = LocalWallet::from_str(&priv_key)?; - let chain_id = provider.get_chainid().await?.as_u64(); - let signer = Arc::new(SignerMiddleware::new( - provider, - wallet.clone().with_chain_id(chain_id), - )); - let caller = Nft::new(program_address, signer); - Ok(Self { wallet, caller }) - } - - pub async fn name(&self) -> Result { +impl Client { + pub async fn name(&self) -> eyre::Result { self.caller .name() .call() @@ -123,7 +69,7 @@ impl Client { .context(format!("Error calling {}", function!())) } - pub async fn symbol(&self) -> Result { + pub async fn symbol(&self) -> eyre::Result { self.caller .symbol() .call() @@ -131,7 +77,7 @@ impl Client { .context(format!("Error calling {}", function!())) } - pub async fn token_uri(&self, token_id: U256) -> Result { + pub async fn token_uri(&self, token_id: U256) -> eyre::Result { self.caller .token_uri(token_id) .call() @@ -139,7 +85,7 @@ impl Client { .context(format!("Error calling {}", function!())) } - pub async fn balance_of(&self, owner: Address) -> Result { + pub async fn balance_of(&self, owner: Address) -> eyre::Result { self.caller .balance_of(owner) .call() @@ -147,7 +93,11 @@ impl Client { .context(format!("Error calling {}", function!())) } - pub async fn mint(&self, to: Address, token_id: U256) -> Result { + pub async fn mint( + &self, + to: Address, + token_id: U256, + ) -> eyre::Result { self.caller .mint(to, token_id) .send() @@ -156,7 +106,10 @@ impl Client { .context(format!("Error sending {}", function!())) } - pub async fn burn(&self, token_id: U256) -> Result { + pub async fn burn( + &self, + token_id: U256, + ) -> eyre::Result { self.caller .burn(token_id) .send() @@ -170,7 +123,7 @@ impl Client { from: Address, to: Address, token_id: U256, - ) -> Result { + ) -> eyre::Result { self.caller .transfer_from(from, to, token_id) .send() @@ -179,7 +132,7 @@ impl Client { .context(format!("Error sending {}", function!())) } - pub async fn owner_of(&self, token_id: U256) -> Result
{ + pub async fn owner_of(&self, token_id: U256) -> eyre::Result
{ self.caller .owner_of(token_id) .call() @@ -187,7 +140,11 @@ impl Client { .context(format!("Error calling {}", function!())) } - pub async fn approve(&self, to: Address, token_id: U256) -> Result { + pub async fn approve( + &self, + to: Address, + token_id: U256, + ) -> eyre::Result { self.caller .approve(to, token_id) .send() @@ -196,7 +153,7 @@ impl Client { .context(format!("Error sending {}", function!())) } - pub async fn get_approved(&self, token_id: U256) -> Result
{ + pub async fn get_approved(&self, token_id: U256) -> eyre::Result
{ self.caller .get_approved(token_id) .call() @@ -204,7 +161,7 @@ impl Client { .context(format!("Error calling {}", function!())) } - pub async fn paused(&self) -> Result { + pub async fn paused(&self) -> eyre::Result { self.caller .paused() .call() @@ -212,7 +169,7 @@ impl Client { .context(format!("Error calling {}", function!())) } - pub async fn pause(&self) -> Result { + pub async fn pause(&self) -> eyre::Result { self.caller .pause() .send() @@ -221,7 +178,7 @@ impl Client { .context(format!("Error sending {}", function!())) } - pub async fn unpause(&self) -> Result { + pub async fn unpause(&self) -> eyre::Result { self.caller .unpause() .send() @@ -230,7 +187,10 @@ impl Client { .context(format!("Error sending {}", function!())) } - pub async fn support_interface(&self, interface_id: u32) -> Result { + pub async fn support_interface( + &self, + interface_id: u32, + ) -> eyre::Result { let interface_id = interface_id.to_be_bytes(); self.caller .supports_interface(interface_id) @@ -239,26 +199,3 @@ impl Client { .context(format!("Error calling {}", function!())) } } - -pub type Caller = Nft, LocalWallet>>; - -pub fn random_token_id() -> U256 { - let num: u32 = ethers::core::rand::random(); - num.into() -} - -pub trait Assert { - fn assert_has(&self, expected_err: E) -> Result<()>; -} - -impl Assert for Report { - fn assert_has(&self, expected_err: E) -> Result<()> { - let received_err = format!("{:#}", self); - let expected_err = expected_err.encode_hex(); - if received_err.contains(&expected_err) { - Ok(()) - } else { - bail!("Different error expected: expected error is {expected_err}: received error is {received_err}") - } - } -} diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs new file mode 100644 index 000000000..c9f7add07 --- /dev/null +++ b/integration/src/infrastructure/mod.rs @@ -0,0 +1,114 @@ +use std::{str::FromStr, sync::Arc}; + +use dotenv::dotenv; +use ethers::{ + abi::AbiEncode, + middleware::{Middleware, SignerMiddleware}, + providers::{Http, Provider}, + signers::{LocalWallet, Signer}, + types::{Address, U256}, +}; +use eyre::{bail, Context, ContextCompat, Report, Result}; + +pub mod erc721; +mod utils; + +const FIRST_PRIV_KEY_PATH: &str = "FIRST_PRIV_KEY_PATH"; +const SECOND_PRIV_KEY_PATH: &str = "SECOND_PRIV_KEY_PATH"; +const RPC_URL: &str = "RPC_URL"; +const STYLUS_PROGRAM_ADDRESS: &str = "STYLUS_PROGRAM_ADDRESS"; + +pub struct Infrastructure { + pub first: Client, + pub second: Client, +} + +impl Infrastructure { + pub async fn new() -> eyre::Result { + dotenv().ok(); + + let first_priv_key_path = std::env::var(FIRST_PRIV_KEY_PATH) + .with_context(|| format!("Load {} env var", FIRST_PRIV_KEY_PATH))?; + let second_priv_key_path = std::env::var(SECOND_PRIV_KEY_PATH) + .with_context(|| { + format!("Load {} env var", SECOND_PRIV_KEY_PATH) + })?; + let rpc_url = std::env::var(RPC_URL) + .with_context(|| format!("Load {} env var", RPC_URL))?; + let stylus_program_address = std::env::var(STYLUS_PROGRAM_ADDRESS) + .with_context(|| { + format!("Load {} env var", STYLUS_PROGRAM_ADDRESS) + })?; + + let program_address: Address = stylus_program_address.parse()?; + let provider = Provider::::try_from(rpc_url)?; + let first_priv_key = + std::fs::read_to_string(first_priv_key_path)?.trim().to_string(); + let second_priv_key = + std::fs::read_to_string(second_priv_key_path)?.trim().to_string(); + + Ok(Infrastructure { + first: Client::::new( + provider.clone(), + program_address, + first_priv_key, + ) + .await?, + second: Client::::new( + provider, + program_address, + second_priv_key, + ) + .await?, + }) + } +} + +pub struct Client { + pub wallet: LocalWallet, + pub caller: T, +} + +pub trait Token { + fn new>(address: T, client: Arc) -> Self; +} + +pub type HttpMiddleware = SignerMiddleware, LocalWallet>; + +impl Client { + pub async fn new( + provider: Provider, + program_address: Address, + priv_key: String, + ) -> eyre::Result { + let wallet = LocalWallet::from_str(&priv_key)?; + let chain_id = provider.get_chainid().await?.as_u64(); + let signer = Arc::new(SignerMiddleware::new( + provider, + wallet.clone().with_chain_id(chain_id), + )); + let caller = T::new(program_address, signer); + Ok(Self { wallet, caller }) + } +} + +pub fn random_token_id() -> U256 { + let num: u32 = ethers::core::rand::random(); + num.into() +} + +pub trait Assert { + fn assert(&self, expected_err: E) -> Result<()>; +} + +impl Assert for Report { + fn assert(&self, expected_err: E) -> Result<()> { + let received_err = format!("{:#}", self); + let expected_err = expected_err.encode_hex(); + if received_err.contains(&expected_err) { + Ok(()) + } else { + bail!("Different error expected: expected error is {expected_err}: received error is {received_err}") + } + } +} diff --git a/integration/src/utils.rs b/integration/src/infrastructure/utils.rs similarity index 100% rename from integration/src/utils.rs rename to integration/src/infrastructure/utils.rs diff --git a/integration/src/lib.rs b/integration/src/lib.rs index 6d7d5a11e..237f59bad 100644 --- a/integration/src/lib.rs +++ b/integration/src/lib.rs @@ -1,4 +1,3 @@ mod erc721; mod erc20; -mod infrastructure; -mod utils; \ No newline at end of file +mod infrastructure; \ No newline at end of file From 4cee5ef6766616d51fba164f90a3b8276f356f15 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 9 May 2024 15:43:29 +0400 Subject: [PATCH 08/87] rename to alice and bob --- integration/src/erc721.rs | 68 +++++++++++++-------------- integration/src/infrastructure/mod.rs | 34 +++++++------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index d39953964..87fdba817 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -8,13 +8,13 @@ async fn mint_nft_and_check_balance() -> Result<()> { let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra - .first - .mint(infra.first.wallet.address(), token_id) + .alice + .mint(infra.alice.wallet.address(), token_id) .await?; - let owner = infra.first.owner_of(token_id).await?; - assert_eq!(owner, infra.first.wallet.address()); + let owner = infra.alice.owner_of(token_id).await?; + assert_eq!(owner, infra.alice.wallet.address()); - let balance = infra.first.balance_of(infra.first.wallet.address()).await?; + let balance = infra.alice.balance_of(infra.alice.wallet.address()).await?; assert!(balance >= U256::one()); Ok(()) } @@ -24,12 +24,12 @@ async fn error_mint_second_nft() -> Result<()> { let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra - .first - .mint(infra.first.wallet.address(), token_id) + .alice + .mint(infra.alice.wallet.address(), token_id) .await?; match infra - .first - .mint(infra.first.wallet.address(), token_id) + .alice + .mint(infra.alice.wallet.address(), token_id) .await { Ok(_) => { @@ -46,19 +46,19 @@ async fn transfer_nft() -> Result<()> { let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra - .first - .mint(infra.first.wallet.address(), token_id) + .alice + .mint(infra.alice.wallet.address(), token_id) .await?; let _ = infra - .first + .alice .transfer_from( - infra.first.wallet.address(), - infra.second.wallet.address(), + infra.alice.wallet.address(), + infra.bob.wallet.address(), token_id, ) .await?; - let owner = infra.second.owner_of(token_id).await?; - assert_eq!(owner, infra.second.wallet.address()); + let owner = infra.bob.owner_of(token_id).await?; + assert_eq!(owner, infra.bob.wallet.address()); Ok(()) } @@ -67,10 +67,10 @@ async fn error_transfer_nonexistent_nft() -> Result<()> { let infra = Infrastructure::new().await?; let token_id = random_token_id(); match infra - .first + .alice .transfer_from( - infra.first.wallet.address(), - infra.second.wallet.address(), + infra.alice.wallet.address(), + infra.bob.wallet.address(), token_id, ) .await @@ -87,23 +87,23 @@ async fn approve_nft_transfer() -> Result<()> { let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra - .first - .mint(infra.first.wallet.address(), token_id) + .alice + .mint(infra.alice.wallet.address(), token_id) .await?; let _ = infra - .first - .approve(infra.second.wallet.address(), token_id) + .alice + .approve(infra.bob.wallet.address(), token_id) .await?; let _ = infra - .second + .bob .transfer_from( - infra.first.wallet.address(), - infra.second.wallet.address(), + infra.alice.wallet.address(), + infra.bob.wallet.address(), token_id, ) .await?; - let owner = infra.second.owner_of(token_id).await?; - assert_eq!(owner, infra.second.wallet.address()); + let owner = infra.bob.owner_of(token_id).await?; + assert_eq!(owner, infra.bob.wallet.address()); Ok(()) } @@ -112,14 +112,14 @@ async fn error_not_approved_nft_transfer() -> Result<()> { let infra = Infrastructure::new().await?; let token_id = random_token_id(); let _ = infra - .first - .mint(infra.first.wallet.address(), token_id) + .alice + .mint(infra.alice.wallet.address(), token_id) .await?; match infra - .second + .bob .transfer_from( - infra.first.wallet.address(), - infra.second.wallet.address(), + infra.alice.wallet.address(), + infra.bob.wallet.address(), token_id, ) .await @@ -128,7 +128,7 @@ async fn error_not_approved_nft_transfer() -> Result<()> { bail!("Transfer of not approved token should not happen") } Err(e) => e.assert(ERC721InsufficientApproval { - operator: infra.second.wallet.address(), + operator: infra.bob.wallet.address(), token_id, }), } diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index c9f7add07..de8126d2b 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -13,25 +13,25 @@ use eyre::{bail, Context, ContextCompat, Report, Result}; pub mod erc721; mod utils; -const FIRST_PRIV_KEY_PATH: &str = "FIRST_PRIV_KEY_PATH"; -const SECOND_PRIV_KEY_PATH: &str = "SECOND_PRIV_KEY_PATH"; +const ALICE_PRIV_KEY_PATH: &str = "ALICE_PRIV_KEY_PATH"; +const BOB_PRIV_KEY_PATH: &str = "BOB_PRIV_KEY_PATH"; const RPC_URL: &str = "RPC_URL"; const STYLUS_PROGRAM_ADDRESS: &str = "STYLUS_PROGRAM_ADDRESS"; pub struct Infrastructure { - pub first: Client, - pub second: Client, + pub alice: Client, + pub bob: Client, } impl Infrastructure { pub async fn new() -> eyre::Result { dotenv().ok(); - let first_priv_key_path = std::env::var(FIRST_PRIV_KEY_PATH) - .with_context(|| format!("Load {} env var", FIRST_PRIV_KEY_PATH))?; - let second_priv_key_path = std::env::var(SECOND_PRIV_KEY_PATH) + let alice_priv_key_path = std::env::var(ALICE_PRIV_KEY_PATH) + .with_context(|| format!("Load {} env var", ALICE_PRIV_KEY_PATH))?; + let bob_priv_key_path = std::env::var(BOB_PRIV_KEY_PATH) .with_context(|| { - format!("Load {} env var", SECOND_PRIV_KEY_PATH) + format!("Load {} env var", BOB_PRIV_KEY_PATH) })?; let rpc_url = std::env::var(RPC_URL) .with_context(|| format!("Load {} env var", RPC_URL))?; @@ -42,22 +42,22 @@ impl Infrastructure { let program_address: Address = stylus_program_address.parse()?; let provider = Provider::::try_from(rpc_url)?; - let first_priv_key = - std::fs::read_to_string(first_priv_key_path)?.trim().to_string(); - let second_priv_key = - std::fs::read_to_string(second_priv_key_path)?.trim().to_string(); + let alice_priv_key = + std::fs::read_to_string(alice_priv_key_path)?.trim().to_string(); + let bob_priv_key = + std::fs::read_to_string(bob_priv_key_path)?.trim().to_string(); Ok(Infrastructure { - first: Client::::new( + alice: Client::new( provider.clone(), program_address, - first_priv_key, + alice_priv_key, ) .await?, - second: Client::::new( + bob: Client::new( provider, program_address, - second_priv_key, + bob_priv_key, ) .await?, }) @@ -108,7 +108,7 @@ impl Assert for Report { if received_err.contains(&expected_err) { Ok(()) } else { - bail!("Different error expected: expected error is {expected_err}: received error is {received_err}") + bail!("Different error expected: Expected error is {expected_err}: Received error is {received_err}") } } } From 35233481a6dae64a50ec5b6d626f8cf0172f8b82 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 9 May 2024 19:04:41 +0400 Subject: [PATCH 09/87] ++ --- integration/src/infrastructure/erc721.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index d37eefeca..6bbc09285 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -60,6 +60,7 @@ impl Token for Erc721 { } } +// TODO#q: remove call duplicates impl Client { pub async fn name(&self) -> eyre::Result { self.caller From 8672015226535a056a11eef9ec0f7d908ec67ec7 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 10 May 2024 13:27:02 +0400 Subject: [PATCH 10/87] use private keys not path --- integration/src/infrastructure/mod.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index de8126d2b..fa666555b 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -13,8 +13,8 @@ use eyre::{bail, Context, ContextCompat, Report, Result}; pub mod erc721; mod utils; -const ALICE_PRIV_KEY_PATH: &str = "ALICE_PRIV_KEY_PATH"; -const BOB_PRIV_KEY_PATH: &str = "BOB_PRIV_KEY_PATH"; +const ALICE_PRIV_KEY: &str = "ALICE_PRIV_KEY"; +const BOB_PRIV_KEY: &str = "BOB_PRIV_KEY"; const RPC_URL: &str = "RPC_URL"; const STYLUS_PROGRAM_ADDRESS: &str = "STYLUS_PROGRAM_ADDRESS"; @@ -27,11 +27,11 @@ impl Infrastructure { pub async fn new() -> eyre::Result { dotenv().ok(); - let alice_priv_key_path = std::env::var(ALICE_PRIV_KEY_PATH) - .with_context(|| format!("Load {} env var", ALICE_PRIV_KEY_PATH))?; - let bob_priv_key_path = std::env::var(BOB_PRIV_KEY_PATH) + let alice_priv_key = std::env::var(ALICE_PRIV_KEY) + .with_context(|| format!("Load {} env var", ALICE_PRIV_KEY))?; + let bob_priv_key = std::env::var(BOB_PRIV_KEY) .with_context(|| { - format!("Load {} env var", BOB_PRIV_KEY_PATH) + format!("Load {} env var", BOB_PRIV_KEY) })?; let rpc_url = std::env::var(RPC_URL) .with_context(|| format!("Load {} env var", RPC_URL))?; @@ -42,10 +42,6 @@ impl Infrastructure { let program_address: Address = stylus_program_address.parse()?; let provider = Provider::::try_from(rpc_url)?; - let alice_priv_key = - std::fs::read_to_string(alice_priv_key_path)?.trim().to_string(); - let bob_priv_key = - std::fs::read_to_string(bob_priv_key_path)?.trim().to_string(); Ok(Infrastructure { alice: Client::new( @@ -71,6 +67,8 @@ pub struct Client { pub trait Token { fn new>(address: T, client: Arc) -> Self; + + // TODO#q: add get programm address method } pub type HttpMiddleware = SignerMiddleware, LocalWallet>; From 1da57fd8a1d941ac4efaa0ddda1fe1d3c9b6e845 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 10 May 2024 15:22:50 +0400 Subject: [PATCH 11/87] have stylus deployment address as associated const --- integration/src/infrastructure/erc721.rs | 54 ++++++++++++------------ integration/src/infrastructure/mod.rs | 9 ++-- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index 6bbc09285..09e58b45d 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -55,6 +55,8 @@ abigen!( pub type Erc721 = Erc721Token; impl Token for Erc721 { + const STYLUS_PROGRAM_ADDRESS: &'static str = "ERC721_DEPLOYMENT_ADDRESS"; + fn new>(address: T, client: Arc) -> Self { Erc721Token::new(address, client) } @@ -67,7 +69,7 @@ impl Client { .name() .call() .await - .context(format!("Error calling {}", function!())) + .context(format!("calling {}", function!())) } pub async fn symbol(&self) -> eyre::Result { @@ -75,7 +77,7 @@ impl Client { .symbol() .call() .await - .context(format!("Error calling {}", function!())) + .context(format!("calling {}", function!())) } pub async fn token_uri(&self, token_id: U256) -> eyre::Result { @@ -83,7 +85,7 @@ impl Client { .token_uri(token_id) .call() .await - .context(format!("Error calling {}", function!())) + .context(format!("calling {}", function!())) } pub async fn balance_of(&self, owner: Address) -> eyre::Result { @@ -91,7 +93,7 @@ impl Client { .balance_of(owner) .call() .await - .context(format!("Error calling {}", function!())) + .context(format!("calling {}", function!())) } pub async fn mint( @@ -102,9 +104,9 @@ impl Client { self.caller .mint(to, token_id) .send() - .await? - .await? - .context(format!("Error sending {}", function!())) + .await.context(format!("sending {}", function!()))? + .await.context(format!("sending {}", function!()))? + .context(format!("sending {}", function!())) } pub async fn burn( @@ -114,9 +116,9 @@ impl Client { self.caller .burn(token_id) .send() - .await? - .await? - .context(format!("Error sending {}", function!())) + .await.context(format!("sending {}", function!()))? + .await.context(format!("sending {}", function!()))? + .context(format!("sending {}", function!())) } pub async fn transfer_from( @@ -128,9 +130,9 @@ impl Client { self.caller .transfer_from(from, to, token_id) .send() - .await? - .await? - .context(format!("Error sending {}", function!())) + .await.context(format!("sending {}", function!()))? + .await.context(format!("sending {}", function!()))? + .context(format!("sending {}", function!())) } pub async fn owner_of(&self, token_id: U256) -> eyre::Result
{ @@ -138,7 +140,7 @@ impl Client { .owner_of(token_id) .call() .await - .context(format!("Error calling {}", function!())) + .context(format!("calling {}", function!())) } pub async fn approve( @@ -149,9 +151,9 @@ impl Client { self.caller .approve(to, token_id) .send() - .await? - .await? - .context(format!("Error sending {}", function!())) + .await.context(format!("sending {}", function!()))? + .await.context(format!("sending {}", function!()))? + .context(format!("sending {}", function!())) } pub async fn get_approved(&self, token_id: U256) -> eyre::Result
{ @@ -159,7 +161,7 @@ impl Client { .get_approved(token_id) .call() .await - .context(format!("Error calling {}", function!())) + .context(format!("calling {}", function!())) } pub async fn paused(&self) -> eyre::Result { @@ -167,25 +169,25 @@ impl Client { .paused() .call() .await - .context(format!("Error calling {}", function!())) + .context(format!("calling {}", function!())) } pub async fn pause(&self) -> eyre::Result { self.caller .pause() .send() - .await? - .await? - .context(format!("Error sending {}", function!())) + .await.context(format!("sending {}", function!()))? + .await.context(format!("sending {}", function!()))? + .context(format!("sending {}", function!())) } pub async fn unpause(&self) -> eyre::Result { self.caller .unpause() .send() - .await? - .await? - .context(format!("Error sending {}", function!())) + .await.context(format!("sending {}", function!()))? + .await.context(format!("sending {}", function!()))? + .context(format!("sending {}", function!())) } pub async fn support_interface( @@ -197,6 +199,6 @@ impl Client { .supports_interface(interface_id) .call() .await - .context(format!("Error calling {}", function!())) + .context(format!("calling {}", function!())) } } diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index fa666555b..226c3a132 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -35,10 +35,11 @@ impl Infrastructure { })?; let rpc_url = std::env::var(RPC_URL) .with_context(|| format!("Load {} env var", RPC_URL))?; - let stylus_program_address = std::env::var(STYLUS_PROGRAM_ADDRESS) + let stylus_program_address = std::env::var(T::STYLUS_PROGRAM_ADDRESS) .with_context(|| { - format!("Load {} env var", STYLUS_PROGRAM_ADDRESS) + format!("Load {} env var", T::STYLUS_PROGRAM_ADDRESS) })?; + dbg!(&stylus_program_address); let program_address: Address = stylus_program_address.parse()?; let provider = Provider::::try_from(rpc_url)?; @@ -66,9 +67,9 @@ pub struct Client { } pub trait Token { - fn new>(address: T, client: Arc) -> Self; + const STYLUS_PROGRAM_ADDRESS: &'static str; - // TODO#q: add get programm address method + fn new>(address: T, client: Arc) -> Self; } pub type HttpMiddleware = SignerMiddleware, LocalWallet>; From ae44f1756727c29b026eda1ff661ad965975b88b Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 10 May 2024 16:07:21 +0400 Subject: [PATCH 12/87] add mint to erc721 example --- examples/erc721/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/erc721/src/lib.rs b/examples/erc721/src/lib.rs index ea832b29a..1ac887f69 100644 --- a/examples/erc721/src/lib.rs +++ b/examples/erc721/src/lib.rs @@ -1,6 +1,8 @@ #![cfg_attr(not(test), no_main, no_std)] extern crate alloc; +use alloy_primitives::Address; +use stylus_sdk::alloy_sol_types::private::U256; use contracts::erc721::ERC721; use stylus_sdk::prelude::{entrypoint, external, sol_storage}; @@ -14,4 +16,8 @@ sol_storage! { #[external] #[inherit(ERC721)] -impl Token {} +impl Token { + pub fn mint(&mut self, to: Address, token_id: U256) -> Result<(), contracts::erc721::Error> { + self.erc721._mint(to, token_id) + } +} From 3def92fa2e983062ef244937df92bf376bd76a72 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 13 May 2024 13:11:07 +0400 Subject: [PATCH 13/87] add integration test script --- integration/test.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 integration/test.sh diff --git a/integration/test.sh b/integration/test.sh new file mode 100755 index 000000000..833c93e6c --- /dev/null +++ b/integration/test.sh @@ -0,0 +1,31 @@ +#!/bin/zsh +set -o pipefail + +deploy_contract () { + CONTRACT_CRATE_NAME=$1 + CONTRACT_BIN_NAME="${CONTRACT_CRATE_NAME/-/_}.wasm" + PRIVATE_KEY=0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31c053d015b9fb8c9ab3298f8a2d + LOCAL_NODE_HOST=http://localhost:8547 + + echo "Deploying contract $CONTRACT_CRATE_NAME." + + DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e $LOCAL_NODE_HOST --private-key $PRIVATE_KEY) || exit $? + + echo "Contract $CONTRACT_CRATE_NAME successfully deployed to the local nitro node ($LOCAL_NODE_HOST)." + + # extract randomly created contract deployment address + DEPLOYMENT_ADDRESS="$(echo "$DEPLOY_OUTPUT" | grep 'Deploying program to address' | grep -oE "(0x)?[0-9a-fA-F]{40}")" + + if [[ -z "$DEPLOYMENT_ADDRESS" ]] + then + echo "Error: Couldn't retrieve deployment address for a contract $CONTRACT_CRATE_NAME." + exit 1 + fi +} + +cargo build --release --profile release --target wasm32-unknown-unknown + +deploy_contract erc721-example +export ERC721_DEPLOYMENT_ADDRESS=$DEPLOYMENT_ADDRESS + +RUST_TEST_THREADS=1 cargo test -p integration \ No newline at end of file From 04a3749574c33ec54963ac681bb559ef436e6436 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 13 May 2024 13:59:34 +0400 Subject: [PATCH 14/87] remove dotenv from deps --- Cargo.lock | 7 ------- integration/Cargo.toml | 3 +-- integration/src/infrastructure/mod.rs | 21 +++++---------------- integration/test.sh | 12 ++++++++---- 4 files changed, 14 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4aa568915..ed3abc2b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -685,12 +685,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dotenv" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" - [[package]] name = "dunce" version = "1.0.4" @@ -1641,7 +1635,6 @@ dependencies = [ name = "integration" version = "0.1.0" dependencies = [ - "dotenv", "ethers", "eyre", "tokio", diff --git a/integration/Cargo.toml b/integration/Cargo.toml index 7d76c26f6..fc7a365ea 100644 --- a/integration/Cargo.toml +++ b/integration/Cargo.toml @@ -10,5 +10,4 @@ repository.workspace = true [dependencies] tokio = { version = "1.12.0", features = ["full"] } ethers = "2.0" -eyre = "0.6.8" -dotenv = "0.15.0" +eyre = "0.6.8" \ No newline at end of file diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 226c3a132..09d42f432 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -1,6 +1,5 @@ use std::{str::FromStr, sync::Arc}; -use dotenv::dotenv; use ethers::{ abi::AbiEncode, middleware::{Middleware, SignerMiddleware}, @@ -9,7 +8,6 @@ use ethers::{ types::{Address, U256}, }; use eyre::{bail, Context, ContextCompat, Report, Result}; - pub mod erc721; mod utils; @@ -25,20 +23,16 @@ pub struct Infrastructure { impl Infrastructure { pub async fn new() -> eyre::Result { - dotenv().ok(); - let alice_priv_key = std::env::var(ALICE_PRIV_KEY) .with_context(|| format!("Load {} env var", ALICE_PRIV_KEY))?; let bob_priv_key = std::env::var(BOB_PRIV_KEY) - .with_context(|| { - format!("Load {} env var", BOB_PRIV_KEY) - })?; + .with_context(|| format!("Load {} env var", BOB_PRIV_KEY))?; let rpc_url = std::env::var(RPC_URL) .with_context(|| format!("Load {} env var", RPC_URL))?; let stylus_program_address = std::env::var(T::STYLUS_PROGRAM_ADDRESS) .with_context(|| { - format!("Load {} env var", T::STYLUS_PROGRAM_ADDRESS) - })?; + format!("Load {} env var", T::STYLUS_PROGRAM_ADDRESS) + })?; dbg!(&stylus_program_address); let program_address: Address = stylus_program_address.parse()?; @@ -51,12 +45,7 @@ impl Infrastructure { alice_priv_key, ) .await?, - bob: Client::new( - provider, - program_address, - bob_priv_key, - ) - .await?, + bob: Client::new(provider, program_address, bob_priv_key).await?, }) } } @@ -68,7 +57,7 @@ pub struct Client { pub trait Token { const STYLUS_PROGRAM_ADDRESS: &'static str; - + fn new>(address: T, client: Arc) -> Self; } diff --git a/integration/test.sh b/integration/test.sh index 833c93e6c..c5b7b06c9 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -1,17 +1,21 @@ #!/bin/zsh set -o pipefail +export ALICE_PRIV_KEY=0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31c053d015b9fb8c9ab3298f8a2d +export BOB_PRIV_KEY=0xa038232e463efa8ad57de6f88cd3c68ed64d1981daff2dcc015bce7eaf53db9d +export RPC_URL=${RPC_URL:-http://localhost:8547} + deploy_contract () { CONTRACT_CRATE_NAME=$1 CONTRACT_BIN_NAME="${CONTRACT_CRATE_NAME/-/_}.wasm" - PRIVATE_KEY=0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31c053d015b9fb8c9ab3298f8a2d - LOCAL_NODE_HOST=http://localhost:8547 + PRIVATE_KEY=$ALICE_PRIV_KEY + RPC_URL=$RPC_URL echo "Deploying contract $CONTRACT_CRATE_NAME." - DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e $LOCAL_NODE_HOST --private-key $PRIVATE_KEY) || exit $? + DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e $RPC_URL --private-key $PRIVATE_KEY) || exit $? - echo "Contract $CONTRACT_CRATE_NAME successfully deployed to the local nitro node ($LOCAL_NODE_HOST)." + echo "Contract $CONTRACT_CRATE_NAME successfully deployed to the local nitro node ($RPC_URL)." # extract randomly created contract deployment address DEPLOYMENT_ADDRESS="$(echo "$DEPLOY_OUTPUT" | grep 'Deploying program to address' | grep -oE "(0x)?[0-9a-fA-F]{40}")" From 1012f105323f049acdbd82a26af83dd3d3d3dab0 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 14 May 2024 00:35:12 +0400 Subject: [PATCH 15/87] add send and call with function context --- Cargo.lock | 1 + integration/Cargo.toml | 3 +- integration/src/erc721.rs | 42 ++-- integration/src/infrastructure/erc721.rs | 280 +++++++++++------------ integration/src/infrastructure/mod.rs | 70 +++++- integration/test.sh | 2 +- 6 files changed, 237 insertions(+), 161 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed3abc2b3..be76ef680 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1635,6 +1635,7 @@ dependencies = [ name = "integration" version = "0.1.0" dependencies = [ + "async-trait", "ethers", "eyre", "tokio", diff --git a/integration/Cargo.toml b/integration/Cargo.toml index fc7a365ea..6e90f99e4 100644 --- a/integration/Cargo.toml +++ b/integration/Cargo.toml @@ -10,4 +10,5 @@ repository.workspace = true [dependencies] tokio = { version = "1.12.0", features = ["full"] } ethers = "2.0" -eyre = "0.6.8" \ No newline at end of file +eyre = "0.6.8" +async-trait = "0.1.80" \ No newline at end of file diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index 87fdba817..79c0a80f6 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -1,53 +1,56 @@ -use crate::infrastructure::*; -use crate::infrastructure::erc721::*; use ethers::prelude::*; use eyre::{bail, Result}; +use crate::infrastructure::{erc721::*, *}; + #[tokio::test] async fn mint_nft_and_check_balance() -> Result<()> { - let infra = Infrastructure::new().await?; + let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra .alice .mint(infra.alice.wallet.address(), token_id) + .ctx_send() .await?; - let owner = infra.alice.owner_of(token_id).await?; + let owner = infra.alice.owner_of(token_id).ctx_call().await?; assert_eq!(owner, infra.alice.wallet.address()); - let balance = infra.alice.balance_of(infra.alice.wallet.address()).await?; + let balance = + infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; assert!(balance >= U256::one()); Ok(()) } #[tokio::test] async fn error_mint_second_nft() -> Result<()> { - let infra = Infrastructure::new().await?; + let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra .alice .mint(infra.alice.wallet.address(), token_id) + .ctx_send() .await?; match infra .alice .mint(infra.alice.wallet.address(), token_id) + .ctx_send() .await { Ok(_) => { bail!("Second mint of the same token should not be possible") } - Err(e) => e.assert(ERC721InvalidSender { - sender: Address::zero(), - }), + Err(e) => e.assert(ERC721InvalidSender { sender: Address::zero() }), } } #[tokio::test] async fn transfer_nft() -> Result<()> { - let infra = Infrastructure::new().await?; + let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra .alice .mint(infra.alice.wallet.address(), token_id) + .ctx_send() .await?; let _ = infra .alice @@ -56,15 +59,16 @@ async fn transfer_nft() -> Result<()> { infra.bob.wallet.address(), token_id, ) + .ctx_send() .await?; - let owner = infra.bob.owner_of(token_id).await?; + let owner = infra.bob.owner_of(token_id).ctx_call().await?; assert_eq!(owner, infra.bob.wallet.address()); Ok(()) } #[tokio::test] async fn error_transfer_nonexistent_nft() -> Result<()> { - let infra = Infrastructure::new().await?; + let infra = Infrastructure::::new().await?; let token_id = random_token_id(); match infra .alice @@ -73,6 +77,7 @@ async fn error_transfer_nonexistent_nft() -> Result<()> { infra.bob.wallet.address(), token_id, ) + .ctx_send() .await { Ok(_) => { @@ -84,15 +89,17 @@ async fn error_transfer_nonexistent_nft() -> Result<()> { #[tokio::test] async fn approve_nft_transfer() -> Result<()> { - let infra = Infrastructure::new().await?; + let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra .alice .mint(infra.alice.wallet.address(), token_id) + .ctx_send() .await?; let _ = infra .alice .approve(infra.bob.wallet.address(), token_id) + .ctx_send() .await?; let _ = infra .bob @@ -101,19 +108,21 @@ async fn approve_nft_transfer() -> Result<()> { infra.bob.wallet.address(), token_id, ) + .ctx_send() .await?; - let owner = infra.bob.owner_of(token_id).await?; + let owner = infra.bob.owner_of(token_id).ctx_call().await?; assert_eq!(owner, infra.bob.wallet.address()); Ok(()) } #[tokio::test] async fn error_not_approved_nft_transfer() -> Result<()> { - let infra = Infrastructure::new().await?; + let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra .alice .mint(infra.alice.wallet.address(), token_id) + .ctx_send() .await?; match infra .bob @@ -122,6 +131,7 @@ async fn error_not_approved_nft_transfer() -> Result<()> { infra.bob.wallet.address(), token_id, ) + .ctx_send() .await { Ok(_) => { @@ -132,4 +142,4 @@ async fn error_not_approved_nft_transfer() -> Result<()> { token_id, }), } -} \ No newline at end of file +} diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index 09e58b45d..1af48dc40 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -58,147 +58,147 @@ impl Token for Erc721 { const STYLUS_PROGRAM_ADDRESS: &'static str = "ERC721_DEPLOYMENT_ADDRESS"; fn new>(address: T, client: Arc) -> Self { - Erc721Token::new(address, client) + Self::new(address, client) } } // TODO#q: remove call duplicates -impl Client { - pub async fn name(&self) -> eyre::Result { - self.caller - .name() - .call() - .await - .context(format!("calling {}", function!())) - } - - pub async fn symbol(&self) -> eyre::Result { - self.caller - .symbol() - .call() - .await - .context(format!("calling {}", function!())) - } - - pub async fn token_uri(&self, token_id: U256) -> eyre::Result { - self.caller - .token_uri(token_id) - .call() - .await - .context(format!("calling {}", function!())) - } - - pub async fn balance_of(&self, owner: Address) -> eyre::Result { - self.caller - .balance_of(owner) - .call() - .await - .context(format!("calling {}", function!())) - } - - pub async fn mint( - &self, - to: Address, - token_id: U256, - ) -> eyre::Result { - self.caller - .mint(to, token_id) - .send() - .await.context(format!("sending {}", function!()))? - .await.context(format!("sending {}", function!()))? - .context(format!("sending {}", function!())) - } - - pub async fn burn( - &self, - token_id: U256, - ) -> eyre::Result { - self.caller - .burn(token_id) - .send() - .await.context(format!("sending {}", function!()))? - .await.context(format!("sending {}", function!()))? - .context(format!("sending {}", function!())) - } - - pub async fn transfer_from( - &self, - from: Address, - to: Address, - token_id: U256, - ) -> eyre::Result { - self.caller - .transfer_from(from, to, token_id) - .send() - .await.context(format!("sending {}", function!()))? - .await.context(format!("sending {}", function!()))? - .context(format!("sending {}", function!())) - } - - pub async fn owner_of(&self, token_id: U256) -> eyre::Result
{ - self.caller - .owner_of(token_id) - .call() - .await - .context(format!("calling {}", function!())) - } - - pub async fn approve( - &self, - to: Address, - token_id: U256, - ) -> eyre::Result { - self.caller - .approve(to, token_id) - .send() - .await.context(format!("sending {}", function!()))? - .await.context(format!("sending {}", function!()))? - .context(format!("sending {}", function!())) - } - - pub async fn get_approved(&self, token_id: U256) -> eyre::Result
{ - self.caller - .get_approved(token_id) - .call() - .await - .context(format!("calling {}", function!())) - } - - pub async fn paused(&self) -> eyre::Result { - self.caller - .paused() - .call() - .await - .context(format!("calling {}", function!())) - } - - pub async fn pause(&self) -> eyre::Result { - self.caller - .pause() - .send() - .await.context(format!("sending {}", function!()))? - .await.context(format!("sending {}", function!()))? - .context(format!("sending {}", function!())) - } - - pub async fn unpause(&self) -> eyre::Result { - self.caller - .unpause() - .send() - .await.context(format!("sending {}", function!()))? - .await.context(format!("sending {}", function!()))? - .context(format!("sending {}", function!())) - } - - pub async fn support_interface( - &self, - interface_id: u32, - ) -> eyre::Result { - let interface_id = interface_id.to_be_bytes(); - self.caller - .supports_interface(interface_id) - .call() - .await - .context(format!("calling {}", function!())) - } -} +// impl Client { +// pub async fn name(&self) -> eyre::Result { +// self.caller +// .name() +// .call() +// .await +// .context(format!("calling {}", function!())) +// } +// +// pub async fn symbol(&self) -> eyre::Result { +// self.caller +// .symbol() +// .call() +// .await +// .context(format!("calling {}", function!())) +// } +// +// pub async fn token_uri(&self, token_id: U256) -> eyre::Result { +// self.caller +// .token_uri(token_id) +// .call() +// .await +// .context(format!("calling {}", function!())) +// } +// +// pub async fn balance_of(&self, owner: Address) -> eyre::Result { +// self.caller +// .balance_of(owner) +// .call() +// .await +// .context(format!("calling {}", function!())) +// } +// +// pub async fn mint( +// &self, +// to: Address, +// token_id: U256, +// ) -> eyre::Result { +// self.caller +// .mint(to, token_id) +// .send() +// .await.context(format!("sending {}", function!()))? +// .await.context(format!("sending {}", function!()))? +// .context(format!("sending {}", function!())) +// } +// +// pub async fn burn( +// &self, +// token_id: U256, +// ) -> eyre::Result { +// self.caller +// .burn(token_id) +// .send() +// .await.context(format!("sending {}", function!()))? +// .await.context(format!("sending {}", function!()))? +// .context(format!("sending {}", function!())) +// } +// +// pub async fn transfer_from( +// &self, +// from: Address, +// to: Address, +// token_id: U256, +// ) -> eyre::Result { +// self.caller +// .transfer_from(from, to, token_id) +// .send() +// .await.context(format!("sending {}", function!()))? +// .await.context(format!("sending {}", function!()))? +// .context(format!("sending {}", function!())) +// } +// +// pub async fn owner_of(&self, token_id: U256) -> eyre::Result
{ +// self.caller +// .owner_of(token_id) +// .call() +// .await +// .context(format!("calling {}", function!())) +// } +// +// pub async fn approve( +// &self, +// to: Address, +// token_id: U256, +// ) -> eyre::Result { +// self.caller +// .approve(to, token_id) +// .send() +// .await.context(format!("sending {}", function!()))? +// .await.context(format!("sending {}", function!()))? +// .context(format!("sending {}", function!())) +// } +// +// pub async fn get_approved(&self, token_id: U256) -> eyre::Result
{ +// self.caller +// .get_approved(token_id) +// .call() +// .await +// .context(format!("calling {}", function!())) +// } +// +// pub async fn paused(&self) -> eyre::Result { +// self.caller +// .paused() +// .call() +// .await +// .context(format!("calling {}", function!())) +// } +// +// pub async fn pause(&self) -> eyre::Result { +// self.caller +// .pause() +// .send() +// .await.context(format!("sending {}", function!()))? +// .await.context(format!("sending {}", function!()))? +// .context(format!("sending {}", function!())) +// } +// +// pub async fn unpause(&self) -> eyre::Result { +// self.caller +// .unpause() +// .send() +// .await.context(format!("sending {}", function!()))? +// .await.context(format!("sending {}", function!()))? +// .context(format!("sending {}", function!())) +// } +// +// pub async fn support_interface( +// &self, +// interface_id: u32, +// ) -> eyre::Result { +// let interface_id = interface_id.to_be_bytes(); +// self.caller +// .supports_interface(interface_id) +// .call() +// .await +// .context(format!("calling {}", function!())) +// } +// } diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 09d42f432..b02af7c2e 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -1,13 +1,17 @@ use std::{str::FromStr, sync::Arc}; +use std::ops::Deref; +use async_trait::async_trait; use ethers::{ - abi::AbiEncode, + abi::{AbiEncode, Detokenize}, + contract::ContractCall, middleware::{Middleware, SignerMiddleware}, providers::{Http, Provider}, signers::{LocalWallet, Signer}, - types::{Address, U256}, + types::{Address, TransactionReceipt, U256}, }; use eyre::{bail, Context, ContextCompat, Report, Result}; + pub mod erc721; mod utils; @@ -55,9 +59,24 @@ pub struct Client { pub caller: T, } +impl Deref for Client { + type Target = T; + + fn deref(&self) -> &Self::Target { + &self.caller + } +} + pub trait Token { + /// Deployed program address environment variable name for the contract. + /// + /// e.g can be `MY_ERC721_TOKEN_DEPLOYMENT_ADDRESS`. + /// This env variable should address of the corresponding deployed program. const STYLUS_PROGRAM_ADDRESS: &'static str; + /// Abstracts token creation function. + /// + /// e.g. `Self::new(address, client)`. fn new>(address: T, client: Arc) -> Self; } @@ -68,7 +87,7 @@ impl Client { provider: Provider, program_address: Address, priv_key: String, - ) -> eyre::Result { + ) -> Result { let wallet = LocalWallet::from_str(&priv_key)?; let chain_id = provider.get_chainid().await?.as_u64(); let signer = Arc::new(SignerMiddleware::new( @@ -100,3 +119,48 @@ impl Assert for Report { } } } + +#[async_trait] +pub trait ContextCall { + /// Queries the blockchain via an `eth_call` for the provided transaction. + /// + /// Wraps error with function info context. + /// + /// If executed on a non-state mutating smart contract function (i.e. `view`, `pure`) + /// then it will return the raw data from the chain. + /// + /// If executed on a mutating smart contract function, it will do a "dry run" of the call + /// and return the return type of the transaction without mutating the state + async fn ctx_call(self) -> Result; +} + +#[async_trait] +impl ContextCall + for ContractCall +{ + async fn ctx_call(self) -> Result { + let function_name = self.function.name.clone(); + self.call().await.context(format!("calling {function_name}")) + } +} + +#[async_trait] +pub trait ContextSend { + /// Signs and broadcasts the provided transaction. + /// + /// Wraps error with function info context. + async fn ctx_send(self) -> Result; +} + +#[async_trait] +impl ContextSend for ContractCall { + async fn ctx_send(self) -> Result { + let function_name = self.function.name.clone(); + self.send() + .await + .context(format!("sending {function_name}"))? + .await + .context(format!("sending {function_name}"))? + .context(format!("sending {function_name}")) + } +} diff --git a/integration/test.sh b/integration/test.sh index c5b7b06c9..20e2dabb7 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -15,7 +15,7 @@ deploy_contract () { DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e $RPC_URL --private-key $PRIVATE_KEY) || exit $? - echo "Contract $CONTRACT_CRATE_NAME successfully deployed to the local nitro node ($RPC_URL)." + echo "Contract $CONTRACT_CRATE_NAME successfully deployed to the stylus environment ($RPC_URL)." # extract randomly created contract deployment address DEPLOYMENT_ADDRESS="$(echo "$DEPLOY_OUTPUT" | grep 'Deploying program to address' | grep -oE "(0x)?[0-9a-fA-F]{40}")" From 4a2c4f1769a6925db983b3133cb283bb79233c7a Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 14 May 2024 00:46:29 +0400 Subject: [PATCH 16/87] ++ --- integration/src/infrastructure/erc721.rs | 153 +---------------------- integration/src/infrastructure/mod.rs | 1 - integration/src/infrastructure/utils.rs | 14 --- 3 files changed, 2 insertions(+), 166 deletions(-) delete mode 100644 integration/src/infrastructure/utils.rs diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index 1af48dc40..d0e654a82 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -1,16 +1,8 @@ use std::sync::Arc; -use ethers::{ - addressbook::Address, - contract::abigen, - prelude::{TransactionReceipt, U256}, -}; -use eyre::{Context, ContextCompat}; +use ethers::{addressbook::Address, contract::abigen}; -use crate::{ - function, - infrastructure::{Client, HttpMiddleware, Token}, -}; +use crate::infrastructure::{HttpMiddleware, Token}; abigen!( Erc721Token, @@ -61,144 +53,3 @@ impl Token for Erc721 { Self::new(address, client) } } - -// TODO#q: remove call duplicates -// impl Client { -// pub async fn name(&self) -> eyre::Result { -// self.caller -// .name() -// .call() -// .await -// .context(format!("calling {}", function!())) -// } -// -// pub async fn symbol(&self) -> eyre::Result { -// self.caller -// .symbol() -// .call() -// .await -// .context(format!("calling {}", function!())) -// } -// -// pub async fn token_uri(&self, token_id: U256) -> eyre::Result { -// self.caller -// .token_uri(token_id) -// .call() -// .await -// .context(format!("calling {}", function!())) -// } -// -// pub async fn balance_of(&self, owner: Address) -> eyre::Result { -// self.caller -// .balance_of(owner) -// .call() -// .await -// .context(format!("calling {}", function!())) -// } -// -// pub async fn mint( -// &self, -// to: Address, -// token_id: U256, -// ) -> eyre::Result { -// self.caller -// .mint(to, token_id) -// .send() -// .await.context(format!("sending {}", function!()))? -// .await.context(format!("sending {}", function!()))? -// .context(format!("sending {}", function!())) -// } -// -// pub async fn burn( -// &self, -// token_id: U256, -// ) -> eyre::Result { -// self.caller -// .burn(token_id) -// .send() -// .await.context(format!("sending {}", function!()))? -// .await.context(format!("sending {}", function!()))? -// .context(format!("sending {}", function!())) -// } -// -// pub async fn transfer_from( -// &self, -// from: Address, -// to: Address, -// token_id: U256, -// ) -> eyre::Result { -// self.caller -// .transfer_from(from, to, token_id) -// .send() -// .await.context(format!("sending {}", function!()))? -// .await.context(format!("sending {}", function!()))? -// .context(format!("sending {}", function!())) -// } -// -// pub async fn owner_of(&self, token_id: U256) -> eyre::Result
{ -// self.caller -// .owner_of(token_id) -// .call() -// .await -// .context(format!("calling {}", function!())) -// } -// -// pub async fn approve( -// &self, -// to: Address, -// token_id: U256, -// ) -> eyre::Result { -// self.caller -// .approve(to, token_id) -// .send() -// .await.context(format!("sending {}", function!()))? -// .await.context(format!("sending {}", function!()))? -// .context(format!("sending {}", function!())) -// } -// -// pub async fn get_approved(&self, token_id: U256) -> eyre::Result
{ -// self.caller -// .get_approved(token_id) -// .call() -// .await -// .context(format!("calling {}", function!())) -// } -// -// pub async fn paused(&self) -> eyre::Result { -// self.caller -// .paused() -// .call() -// .await -// .context(format!("calling {}", function!())) -// } -// -// pub async fn pause(&self) -> eyre::Result { -// self.caller -// .pause() -// .send() -// .await.context(format!("sending {}", function!()))? -// .await.context(format!("sending {}", function!()))? -// .context(format!("sending {}", function!())) -// } -// -// pub async fn unpause(&self) -> eyre::Result { -// self.caller -// .unpause() -// .send() -// .await.context(format!("sending {}", function!()))? -// .await.context(format!("sending {}", function!()))? -// .context(format!("sending {}", function!())) -// } -// -// pub async fn support_interface( -// &self, -// interface_id: u32, -// ) -> eyre::Result { -// let interface_id = interface_id.to_be_bytes(); -// self.caller -// .supports_interface(interface_id) -// .call() -// .await -// .context(format!("calling {}", function!())) -// } -// } diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index b02af7c2e..1b75310dd 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -13,7 +13,6 @@ use ethers::{ use eyre::{bail, Context, ContextCompat, Report, Result}; pub mod erc721; -mod utils; const ALICE_PRIV_KEY: &str = "ALICE_PRIV_KEY"; const BOB_PRIV_KEY: &str = "BOB_PRIV_KEY"; diff --git a/integration/src/infrastructure/utils.rs b/integration/src/infrastructure/utils.rs deleted file mode 100644 index 6a0d2bbf9..000000000 --- a/integration/src/infrastructure/utils.rs +++ /dev/null @@ -1,14 +0,0 @@ -/// Retrieve name of the current function -#[macro_export] -macro_rules! function { - () => {{ - fn f() {} - fn type_name_of(_: T) -> &'static str { - std::any::type_name::() - } - type_name_of(f) - .rsplit("::") - .find(|&part| part != "f" && part != "{{closure}}") - .expect("Short function name") - }}; -} From e4a9e762d12b4931d3b524b0a1e132d1c5108f71 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 14 May 2024 14:22:02 +0400 Subject: [PATCH 17/87] add auto deployment of every contract at example dir --- integration/README.md | 19 +++++++++++ integration/src/erc721.rs | 2 ++ integration/src/infrastructure/erc721.rs | 2 +- integration/test.sh | 42 +++++++++++++++++------- 4 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 integration/README.md diff --git a/integration/README.md b/integration/README.md new file mode 100644 index 000000000..fdfdcbba8 --- /dev/null +++ b/integration/README.md @@ -0,0 +1,19 @@ +# Integration Tests +## Testing Examples Contracts +Deploying every contract from `./examples` and running integration tests. +### Against local nitro node +Set up first a local nitro node according to this [guide](https://github.com/OffchainLabs/nitro-testnode/blob/release/README.md) and run this command from the project root: +```terminal + ./integration/test.sh +``` + +### Against stylus dev net +ALICE_PRIV_KEY and BOB_PRIV_KEY should be valid funded wallets. + +Run this command from the project root: +```terminal + ALICE_PRIV_KEY=0x... \ + BOB_PRIV_KEY=0x... \ + RPC_URL=https://stylus-testnet.arbitrum.io/rpc \ + ./integration/test.sh +``` \ No newline at end of file diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index 79c0a80f6..c0d84a29c 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -3,6 +3,8 @@ use eyre::{bail, Result}; use crate::infrastructure::{erc721::*, *}; +// TODO: add isolation with mutex per contract + #[tokio::test] async fn mint_nft_and_check_balance() -> Result<()> { let infra = Infrastructure::::new().await?; diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index d0e654a82..f62a025c4 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -47,7 +47,7 @@ abigen!( pub type Erc721 = Erc721Token; impl Token for Erc721 { - const STYLUS_PROGRAM_ADDRESS: &'static str = "ERC721_DEPLOYMENT_ADDRESS"; + const STYLUS_PROGRAM_ADDRESS: &'static str = "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"; fn new>(address: T, client: Arc) -> Self { Self::new(address, client) diff --git a/integration/test.sh b/integration/test.sh index 20e2dabb7..110ffa707 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -1,23 +1,22 @@ #!/bin/zsh set -o pipefail -export ALICE_PRIV_KEY=0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31c053d015b9fb8c9ab3298f8a2d -export BOB_PRIV_KEY=0xa038232e463efa8ad57de6f88cd3c68ed64d1981daff2dcc015bce7eaf53db9d -export RPC_URL=${RPC_URL:-http://localhost:8547} - +# Deploy contract by rust crate name. +# Sets $DEPLOYMENT_ADDRESS environment variable after successful deployment. deploy_contract () { - CONTRACT_CRATE_NAME=$1 - CONTRACT_BIN_NAME="${CONTRACT_CRATE_NAME/-/_}.wasm" - PRIVATE_KEY=$ALICE_PRIV_KEY - RPC_URL=$RPC_URL + local CONTRACT_CRATE_NAME=$1 + local CONTRACT_BIN_NAME="${CONTRACT_CRATE_NAME//-/_}.wasm" + local PRIVATE_KEY=$ALICE_PRIV_KEY + local RPC_URL=$RPC_URL echo "Deploying contract $CONTRACT_CRATE_NAME." - DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e $RPC_URL --private-key $PRIVATE_KEY) || exit $? + DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e "$RPC_URL" --private-key "$PRIVATE_KEY") || exit $? echo "Contract $CONTRACT_CRATE_NAME successfully deployed to the stylus environment ($RPC_URL)." # extract randomly created contract deployment address + # NOTE: optimistically relying on the 'Deploying program to address' string in output DEPLOYMENT_ADDRESS="$(echo "$DEPLOY_OUTPUT" | grep 'Deploying program to address' | grep -oE "(0x)?[0-9a-fA-F]{40}")" if [[ -z "$DEPLOYMENT_ADDRESS" ]] @@ -27,9 +26,28 @@ deploy_contract () { fi } -cargo build --release --profile release --target wasm32-unknown-unknown +# Retrieve all contract's crate names in `./examples` directory. +get_example_crate_names () { + # NOTE: optimistically relying on the 'name = ' string at Cargo.toml file + find ./examples -type f -print0 -name "Cargo.toml" | xargs -0 grep 'name = ' | grep -oE '".*"' | tr -d "'\"" +} + +export ALICE_PRIV_KEY=${ALICE_PRIV_KEY:-0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31c053d015b9fb8c9ab3298f8a2d} +export BOB_PRIV_KEY=${BOB_PRIV_KEY:-0xa038232e463efa8ad57de6f88cd3c68ed64d1981daff2dcc015bce7eaf53db9d} +export RPC_URL=${RPC_URL:-http://localhost:8547} + +cargo build --release --target wasm32-unknown-unknown + +for CRATE_NAME in $(get_example_crate_names) +do + deploy_contract "$CRATE_NAME" + + DEPLOYMENT_ADDRESS_ENV_VAR_NAME="${${CRATE_NAME//-/_}:u}_DEPLOYMENT_ADDRESS" -deploy_contract erc721-example -export ERC721_DEPLOYMENT_ADDRESS=$DEPLOYMENT_ADDRESS + # export dynamically created variable + set -a + printf -v "$DEPLOYMENT_ADDRESS_ENV_VAR_NAME" "%s" "$DEPLOYMENT_ADDRESS" + set +a +done RUST_TEST_THREADS=1 cargo test -p integration \ No newline at end of file From 21b9d1bc9d364b3b8c72d610b590d8a1e74db8a8 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 14 May 2024 16:41:11 +0400 Subject: [PATCH 18/87] add erc20-example test --- examples/erc20/src/lib.rs | 19 ++++++++- integration/src/erc20.rs | 27 ++++++++++++ integration/src/erc721.rs | 2 + integration/src/infrastructure/erc20.rs | 35 ++++++++++++++++ integration/src/infrastructure/erc721.rs | 2 +- integration/src/infrastructure/mod.rs | 52 ++++++++++++++++-------- 6 files changed, 118 insertions(+), 19 deletions(-) create mode 100644 integration/src/infrastructure/erc20.rs diff --git a/examples/erc20/src/lib.rs b/examples/erc20/src/lib.rs index 89e3a1c5c..aca699034 100644 --- a/examples/erc20/src/lib.rs +++ b/examples/erc20/src/lib.rs @@ -3,8 +3,11 @@ extern crate alloc; use alloc::string::String; +use alloy_primitives::{Address, U256}; use contracts::{ - erc20::{extensions::metadata::Metadata, ERC20}, + erc20::{ + extensions::metadata::Metadata, ERC20InvalidReceiver, Error, ERC20, + }, erc20_burnable_impl, }; use stylus_sdk::prelude::{entrypoint, external, sol_storage}; @@ -39,4 +42,18 @@ impl Token { pub fn decimals(&self) -> u8 { DECIMALS } + + pub fn mint( + &mut self, + account: Address, + value: U256, + ) -> Result<(), Error> { + // TODO: create function _mint at erc20 similar to solidity + if account.is_zero() { + return Err(Error::InvalidReceiver(ERC20InvalidReceiver { + receiver: Address::ZERO, + })); + } + self.erc20._update(Address::ZERO, account, value) + } } diff --git a/integration/src/erc20.rs b/integration/src/erc20.rs index e69de29bb..c48396e72 100644 --- a/integration/src/erc20.rs +++ b/integration/src/erc20.rs @@ -0,0 +1,27 @@ +use ethers::prelude::*; +use eyre::{bail, Result}; + +use crate::infrastructure::{erc20::*, *}; + +#[tokio::test] +async fn mint() -> Result<()> { + let infra = Infrastructure::::new().await?; + let one = U256::from(1); + + let initial_balance = + infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; + let initial_supply = + infra.alice.total_supply().ctx_call().await?; + + let _ = + infra.alice.mint(infra.alice.wallet.address(), one).ctx_send().await?; + + let new_balance = infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; + let new_supply = infra.alice.total_supply().ctx_call().await?; + + assert_eq!(initial_balance + one, new_balance); + assert_eq!(initial_supply + one, new_supply); + Ok(()) +} + +// TODO: add rest of the tests for erc20 base implementation \ No newline at end of file diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index c0d84a29c..e8f8dc1f6 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -5,6 +5,8 @@ use crate::infrastructure::{erc721::*, *}; // TODO: add isolation with mutex per contract +// TODO#q: refactor these tests similarly to unit tests + #[tokio::test] async fn mint_nft_and_check_balance() -> Result<()> { let infra = Infrastructure::::new().await?; diff --git a/integration/src/infrastructure/erc20.rs b/integration/src/infrastructure/erc20.rs new file mode 100644 index 000000000..3385b20a5 --- /dev/null +++ b/integration/src/infrastructure/erc20.rs @@ -0,0 +1,35 @@ +use std::sync::Arc; + +use ethers::prelude::*; + +use crate::infrastructure::{HttpMiddleware, Token}; + +abigen!( + Erc20Token, + r#"[ + function init(uint256) external + function name() external view returns (string) + function symbol() external view returns (string) + function decimals() external view returns (uint8) + function totalSupply() external view returns (uint256) + function balanceOf(address account) external view returns (uint256) + function transfer(address recipient, uint256 amount) external returns (bool) + function allowance(address owner, address spender) external view returns (uint256) + function approve(address spender, uint256 amount) external returns (bool) + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) + + function mint(address account, uint256 amount) external + function burn(uint256 amount) external + ]"# +); + +pub type Erc20 = Erc20Token; + +impl Token for Erc20 { + const STYLUS_PROGRAM_ADDRESS: &'static str = + "ERC20_EXAMPLE_DEPLOYMENT_ADDRESS"; + + fn new(address: Address, client: Arc) -> Self { + Self::new(address, client) + } +} diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index f62a025c4..0f83a6cca 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -49,7 +49,7 @@ pub type Erc721 = Erc721Token; impl Token for Erc721 { const STYLUS_PROGRAM_ADDRESS: &'static str = "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"; - fn new>(address: T, client: Arc) -> Self { + fn new(address: Address, client: Arc) -> Self { Self::new(address, client) } } diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 1b75310dd..c886bb070 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -1,5 +1,7 @@ -use std::{str::FromStr, sync::Arc}; -use std::ops::Deref; +pub mod erc20; +pub mod erc721; + +use std::{ops::Deref, str::FromStr, sync::Arc}; use async_trait::async_trait; use ethers::{ @@ -12,19 +14,25 @@ use ethers::{ }; use eyre::{bail, Context, ContextCompat, Report, Result}; -pub mod erc721; - const ALICE_PRIV_KEY: &str = "ALICE_PRIV_KEY"; const BOB_PRIV_KEY: &str = "BOB_PRIV_KEY"; const RPC_URL: &str = "RPC_URL"; -const STYLUS_PROGRAM_ADDRESS: &str = "STYLUS_PROGRAM_ADDRESS"; + +/// Integration testing infrastructure that allows to act on behalf of `alice` +/// and `bob` accounts. pub struct Infrastructure { pub alice: Client, pub bob: Client, } impl Infrastructure { + /// Constructs new instance of an integration testing infrastructure. + /// + /// Requires env variables `ALICE_PRIV_KEY`, `BOB_PRIV_KEY`, `RPC_URL` + /// and _DEPLOYMENT_ADDRESS + /// where is the "SCREAMING_SNAKE_CASE" conversion of the crate + /// name from the `./examples` directory. pub async fn new() -> eyre::Result { let alice_priv_key = std::env::var(ALICE_PRIV_KEY) .with_context(|| format!("Load {} env var", ALICE_PRIV_KEY))?; @@ -36,7 +44,6 @@ impl Infrastructure { .with_context(|| { format!("Load {} env var", T::STYLUS_PROGRAM_ADDRESS) })?; - dbg!(&stylus_program_address); let program_address: Address = stylus_program_address.parse()?; let provider = Provider::::try_from(rpc_url)?; @@ -53,11 +60,13 @@ impl Infrastructure { } } +/// Client of participant that allows to check wallet address and call contract functions. pub struct Client { pub wallet: LocalWallet, pub caller: T, } +// Lets not to mention `caller` property every time we call a function. impl Deref for Client { type Target = T; @@ -66,17 +75,23 @@ impl Deref for Client { } } + +/// Abstraction for the deployed contract. pub trait Token { /// Deployed program address environment variable name for the contract. - /// - /// e.g can be `MY_ERC721_TOKEN_DEPLOYMENT_ADDRESS`. - /// This env variable should address of the corresponding deployed program. + /// + /// e.g can be `ERC721_EXAMPLE_DEPLOYMENT_ADDRESS`. + /// Formed by template _DEPLOYMENT_ADDRESS + /// where is the "SCREAMING_SNAKE_CASE" conversion of the crate + /// name from the `./examples` directory. + /// That environment variable should store an address of the corresponding + /// deployed program. const STYLUS_PROGRAM_ADDRESS: &'static str; /// Abstracts token creation function. - /// + /// /// e.g. `Self::new(address, client)`. - fn new>(address: T, client: Arc) -> Self; + fn new(address: Address, client: Arc) -> Self; } pub type HttpMiddleware = SignerMiddleware, LocalWallet>; @@ -104,6 +119,8 @@ pub fn random_token_id() -> U256 { } pub trait Assert { + /// Asserts that current error result corresponds to the typed abi encoded + /// error `expected_err`. fn assert(&self, expected_err: E) -> Result<()>; } @@ -122,14 +139,15 @@ impl Assert for Report { #[async_trait] pub trait ContextCall { /// Queries the blockchain via an `eth_call` for the provided transaction. - /// + /// /// Wraps error with function info context. /// - /// If executed on a non-state mutating smart contract function (i.e. `view`, `pure`) - /// then it will return the raw data from the chain. + /// If executed on a non-state mutating smart contract function (i.e. + /// `view`, `pure`) then it will return the raw data from the chain. /// - /// If executed on a mutating smart contract function, it will do a "dry run" of the call - /// and return the return type of the transaction without mutating the state + /// If executed on a mutating smart contract function, it will do a "dry + /// run" of the call and return the return type of the transaction + /// without mutating the state async fn ctx_call(self) -> Result; } @@ -146,7 +164,7 @@ impl ContextCall #[async_trait] pub trait ContextSend { /// Signs and broadcasts the provided transaction. - /// + /// /// Wraps error with function info context. async fn ctx_send(self) -> Result; } From 7a6dd9049ef5016ab676370e3cebe137c2886442 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 14 May 2024 18:41:15 +0400 Subject: [PATCH 19/87] ++ --- integration/src/infrastructure/erc20.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/integration/src/infrastructure/erc20.rs b/integration/src/infrastructure/erc20.rs index 3385b20a5..0732e04fb 100644 --- a/integration/src/infrastructure/erc20.rs +++ b/integration/src/infrastructure/erc20.rs @@ -20,6 +20,12 @@ abigen!( function mint(address account, uint256 amount) external function burn(uint256 amount) external + + error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed) + error ERC20InvalidSender(address sender) + error ERC20InvalidReceiver(address receiver) + error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed) + error ERC20InvalidSpender(address spender) ]"# ); From 6282bd059136fc6b9c4224b39b2a7b998577fa29 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 15 May 2024 16:09:22 +0400 Subject: [PATCH 20/87] add integration workflow --- .github/workflows/integration.yml | 50 +++++++++++++++++++++++++++++++ integration/test.sh | 3 ++ 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/integration.yml diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 000000000..e833139e7 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,50 @@ +name: integration +# TODO#q: add workflow description +permissions: + contents: read +on: + push: + branches: [main] + pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +jobs: + integration: + name: integration testing suite + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} + - name: set up rust + uses: dtolnay/rust-toolchain@stable + with: + target: wasm32-unknown-unknown, + toolchain: 1.77.0 + - name: install cargo-stylus + run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 + - name: setup nitro node + run: \ + # clone nitro test node repo + git clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git && cd nitro-testnode + + # setup nitro test node + ./test-node.bash --no-run --init + ./test-node.bash --detach + + # fund Alice's wallet + ./test-node.bash script send-l2 --to address_0x01fA6bf4Ee48B6C95900BCcf9BEA172EF5DBd478 --ethamount 10000 + # fund Bob's wallet + ./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000 + shell: zsh + - name: run integration tests + run: ./integration/test.sh + shell: zsh \ No newline at end of file diff --git a/integration/test.sh b/integration/test.sh index 110ffa707..b2b8959dd 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -38,10 +38,12 @@ export RPC_URL=${RPC_URL:-http://localhost:8547} cargo build --release --target wasm32-unknown-unknown +# TODO#q: try to deploy contracts asynchronously for CRATE_NAME in $(get_example_crate_names) do deploy_contract "$CRATE_NAME" + # TODO#q: move to to deploy_contract DEPLOYMENT_ADDRESS_ENV_VAR_NAME="${${CRATE_NAME//-/_}:u}_DEPLOYMENT_ADDRESS" # export dynamically created variable @@ -50,4 +52,5 @@ do set +a done +# TODO: run tests in parallel when concurrency scope will be per contract RUST_TEST_THREADS=1 cargo test -p integration \ No newline at end of file From f8e2af700f01cd66ef482efa5955a9e7f9e7abc5 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 15 May 2024 22:11:04 +0400 Subject: [PATCH 21/87] add more docs --- .github/workflows/integration.yml | 6 +++- integration/README.md | 52 ++++++++++++++++++++++++--- integration/src/erc721.rs | 2 ++ integration/src/infrastructure/mod.rs | 4 +-- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index e833139e7..edd1e61e4 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,5 +1,8 @@ name: integration -# TODO#q: add workflow description +# This is an integration test workflow that: +# - spins local nitro node +# - deploys and check every contract at `./examples` directory +# - runs integration test suite against all contracts deployed locally permissions: contents: read on: @@ -31,6 +34,7 @@ jobs: toolchain: 1.77.0 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 + # TODO#q: cache nitro node images and nitro-testnode sources since it is a bottleneck for the routine - name: setup nitro node run: \ # clone nitro test node repo diff --git a/integration/README.md b/integration/README.md index fdfdcbba8..571a372f9 100644 --- a/integration/README.md +++ b/integration/README.md @@ -1,6 +1,6 @@ # Integration Tests -## Testing Examples Contracts -Deploying every contract from `./examples` and running integration tests. +## Run tests +Deploying every contract from `./examples` directory and running integration tests. ### Against local nitro node Set up first a local nitro node according to this [guide](https://github.com/OffchainLabs/nitro-testnode/blob/release/README.md) and run this command from the project root: ```terminal @@ -8,12 +8,56 @@ Set up first a local nitro node according to this [guide](https://github.com/Off ``` ### Against stylus dev net -ALICE_PRIV_KEY and BOB_PRIV_KEY should be valid funded wallets. - +`ALICE_PRIV_KEY` and `BOB_PRIV_KEY` should be valid funded wallets. +`RPC_URL` should contain url of the stylus testnet. Run this command from the project root: ```terminal ALICE_PRIV_KEY=0x... \ BOB_PRIV_KEY=0x... \ RPC_URL=https://stylus-testnet.arbitrum.io/rpc \ ./integration/test.sh +``` +## Add test for the new contract +Assuming that contract associated crate exists at `./examples` directory +with the crate name `erc20-example`. +Add ethereum contracts to `./integration/src/infrastructure` directory like: +```rust +abigen!( + Erc20Token, + r#"[ + function decimals() external view returns (uint8) + function totalSupply() external view returns (uint256) + function balanceOf(address account) external view returns (uint256) + function transfer(address recipient, uint256 amount) external returns (bool) + function allowance(address owner, address spender) external view returns (uint256) + function approve(address spender, uint256 amount) external returns (bool) + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) + function mint(address account, uint256 amount) external + function burn(uint256 amount) external + + error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed) + ]"# +); +``` +Then add wrapper type for the contract: +```rust +pub type Erc20 = Erc20Token; + +impl Token for Erc20 { + const STYLUS_PROGRAM_ADDRESS: &'static str = + "ERC20_EXAMPLE_DEPLOYMENT_ADDRESS"; + + fn new(address: Address, client: Arc) -> Self { + Self::new(address, client) + } +} +``` +Function `new` should forward call to the contract factory method. +`STYLUS_PROGRAM_ADDRESS` should have a value of formed by the template `_DEPLOYMENT_ADDRESS` +where `` is the "SCREAMING_SNAKE_CASE" conversion of the crate name. +`ERC20_EXAMPLE_DEPLOYMENT_ADDRESS` in this example. + +Tests should create new infrastructure instance like this: +```rust +let infra = Infrastructure::::new().await?; ``` \ No newline at end of file diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index e8f8dc1f6..07b922dc2 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -147,3 +147,5 @@ async fn error_not_approved_nft_transfer() -> Result<()> { }), } } + +// TODO: add more tests for erc721 diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index c886bb070..9cfa58aa7 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -66,7 +66,7 @@ pub struct Client { pub caller: T, } -// Lets not to mention `caller` property every time we call a function. +// Allows not to mention `caller` property every time we call a function. impl Deref for Client { type Target = T; @@ -81,7 +81,7 @@ pub trait Token { /// Deployed program address environment variable name for the contract. /// /// e.g can be `ERC721_EXAMPLE_DEPLOYMENT_ADDRESS`. - /// Formed by template _DEPLOYMENT_ADDRESS + /// Formed by the template _DEPLOYMENT_ADDRESS /// where is the "SCREAMING_SNAKE_CASE" conversion of the crate /// name from the `./examples` directory. /// That environment variable should store an address of the corresponding From dc6697c92bbd633e78af20bf4a02ddc964c0511f Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 16 May 2024 18:37:22 +0400 Subject: [PATCH 22/87] fix fmt --- Cargo.lock | 12 +++++++++++- contracts/src/erc721/mod.rs | 6 ++++-- examples/erc20/src/lib.rs | 8 ++------ examples/erc721/src/lib.rs | 15 +++++++++++---- integration/src/erc20.rs | 12 ++++++------ integration/src/erc721.rs | 2 +- integration/src/infrastructure/erc721.rs | 3 ++- integration/src/infrastructure/mod.rs | 5 ++--- integration/src/lib.rs | 4 ++-- 9 files changed, 41 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be76ef680..910948ad1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -452,7 +452,6 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "cfg-if 1.0.0", - "derive_more", "grip", "mini-alloc", "once_cell", @@ -1991,6 +1990,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ownable-example" +version = "0.0.0" +dependencies = [ + "alloy-primitives", + "contracts", + "mini-alloc", + "stylus-proc", + "stylus-sdk", +] + [[package]] name = "parity-scale-codec" version = "3.6.12" diff --git a/contracts/src/erc721/mod.rs b/contracts/src/erc721/mod.rs index dc7e7f5bf..b3f5d3c35 100644 --- a/contracts/src/erc721/mod.rs +++ b/contracts/src/erc721/mod.rs @@ -1,7 +1,9 @@ //! Implementation of the ERC-721 token standard. use alloc::vec; -use alloy_primitives::{fixed_bytes, Address, FixedBytes, U128, U256}; +use alloy_primitives::{ + fixed_bytes, private::derive_more::From, Address, FixedBytes, U128, U256, +}; use stylus_sdk::{ abi::Bytes, alloy_sol_types::sol, call::Call, evm, msg, prelude::*, }; @@ -101,7 +103,7 @@ sol! { /// An ERC-721 error defined as described in [ERC-6093]. /// /// [ERC-6093]: https://eips.ethereum.org/EIPS/eip-6093 -#[derive(SolidityError, Debug)] +#[derive(SolidityError, Debug, From)] pub enum Error { /// Indicates that an address can't be an owner. /// For example, `Address::ZERO` is a forbidden owner in ERC-721. Used in diff --git a/examples/erc20/src/lib.rs b/examples/erc20/src/lib.rs index 9b6c0567d..32501f000 100644 --- a/examples/erc20/src/lib.rs +++ b/examples/erc20/src/lib.rs @@ -5,7 +5,7 @@ use alloc::string::String; use alloy_primitives::{Address, U256}; use contracts::{ - erc20::{extensions::ERC20Metadata, ERC20, Error, ERC20InvalidReceiver}, + erc20::{extensions::ERC20Metadata, ERC20InvalidReceiver, Error, ERC20}, erc20_burnable_impl, }; use stylus_sdk::prelude::{entrypoint, external, sol_storage}; @@ -41,11 +41,7 @@ impl Token { DECIMALS } - pub fn mint( - &mut self, - account: Address, - value: U256, - ) -> Result<(), Error> { + pub fn mint(&mut self, account: Address, value: U256) -> Result<(), Error> { // TODO: create function _mint at erc20 similar to solidity if account.is_zero() { return Err(Error::InvalidReceiver(ERC20InvalidReceiver { diff --git a/examples/erc721/src/lib.rs b/examples/erc721/src/lib.rs index a39e1e1da..28b2321c6 100644 --- a/examples/erc721/src/lib.rs +++ b/examples/erc721/src/lib.rs @@ -2,10 +2,13 @@ extern crate alloc; use alloc::string::String; -use contracts::erc721::{extensions::ERC721Metadata, ERC721}; + use alloy_primitives::Address; -use stylus_sdk::alloy_sol_types::private::U256; -use stylus_sdk::prelude::{entrypoint, external, sol_storage}; +use contracts::erc721::{extensions::ERC721Metadata, ERC721}; +use stylus_sdk::{ + alloy_sol_types::private::U256, + prelude::{entrypoint, external, sol_storage}, +}; sol_storage! { #[entrypoint] @@ -33,7 +36,11 @@ impl Token { self.metadata.constructor(name, symbol, base_uri); } - pub fn mint(&mut self, to: Address, token_id: U256) -> Result<(), contracts::erc721::Error> { + pub fn mint( + &mut self, + to: Address, + token_id: U256, + ) -> Result<(), contracts::erc721::Error> { self.erc721._mint(to, token_id) } } diff --git a/integration/src/erc20.rs b/integration/src/erc20.rs index c48396e72..53638235a 100644 --- a/integration/src/erc20.rs +++ b/integration/src/erc20.rs @@ -10,13 +10,13 @@ async fn mint() -> Result<()> { let initial_balance = infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; - let initial_supply = - infra.alice.total_supply().ctx_call().await?; - + let initial_supply = infra.alice.total_supply().ctx_call().await?; + let _ = infra.alice.mint(infra.alice.wallet.address(), one).ctx_send().await?; - - let new_balance = infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; + + let new_balance = + infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; let new_supply = infra.alice.total_supply().ctx_call().await?; assert_eq!(initial_balance + one, new_balance); @@ -24,4 +24,4 @@ async fn mint() -> Result<()> { Ok(()) } -// TODO: add rest of the tests for erc20 base implementation \ No newline at end of file +// TODO: add rest of the tests for erc20 base implementation diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index 07b922dc2..7effe881a 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -5,7 +5,7 @@ use crate::infrastructure::{erc721::*, *}; // TODO: add isolation with mutex per contract -// TODO#q: refactor these tests similarly to unit tests +// TODO#q: refactor these tests similarly to unit tests #[tokio::test] async fn mint_nft_and_check_balance() -> Result<()> { diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index 0f83a6cca..50ad21ba8 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -47,7 +47,8 @@ abigen!( pub type Erc721 = Erc721Token; impl Token for Erc721 { - const STYLUS_PROGRAM_ADDRESS: &'static str = "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"; + const STYLUS_PROGRAM_ADDRESS: &'static str = + "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"; fn new(address: Address, client: Arc) -> Self { Self::new(address, client) diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 9cfa58aa7..17fd112c2 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -18,7 +18,6 @@ const ALICE_PRIV_KEY: &str = "ALICE_PRIV_KEY"; const BOB_PRIV_KEY: &str = "BOB_PRIV_KEY"; const RPC_URL: &str = "RPC_URL"; - /// Integration testing infrastructure that allows to act on behalf of `alice` /// and `bob` accounts. pub struct Infrastructure { @@ -60,7 +59,8 @@ impl Infrastructure { } } -/// Client of participant that allows to check wallet address and call contract functions. +/// Client of participant that allows to check wallet address and call contract +/// functions. pub struct Client { pub wallet: LocalWallet, pub caller: T, @@ -75,7 +75,6 @@ impl Deref for Client { } } - /// Abstraction for the deployed contract. pub trait Token { /// Deployed program address environment variable name for the contract. diff --git a/integration/src/lib.rs b/integration/src/lib.rs index 237f59bad..5ea0b88b5 100644 --- a/integration/src/lib.rs +++ b/integration/src/lib.rs @@ -1,3 +1,3 @@ -mod erc721; mod erc20; -mod infrastructure; \ No newline at end of file +mod erc721; +mod infrastructure; From b1d337435ab0c6886a7fe18a60ea49bb2dc61c32 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 16 May 2024 18:47:38 +0400 Subject: [PATCH 23/87] ++ --- .github/workflows/integration.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index edd1e61e4..5cbe632ab 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -3,6 +3,7 @@ name: integration # - spins local nitro node # - deploys and check every contract at `./examples` directory # - runs integration test suite against all contracts deployed locally +# TODO#q: cache nitro node images and nitro-testnode sources since it is a bottleneck for the routine permissions: contents: read on: @@ -12,6 +13,8 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +env: + CARGO_TERM_COLOR: always jobs: integration: name: integration testing suite @@ -34,7 +37,6 @@ jobs: toolchain: 1.77.0 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 - # TODO#q: cache nitro node images and nitro-testnode sources since it is a bottleneck for the routine - name: setup nitro node run: \ # clone nitro test node repo From d2260682e5c40cdf3b1944120095c34fa1fa19c9 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 16 May 2024 18:52:35 +0400 Subject: [PATCH 24/87] ++ --- .github/workflows/integration.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 5cbe632ab..c5e2ec089 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -3,12 +3,11 @@ name: integration # - spins local nitro node # - deploys and check every contract at `./examples` directory # - runs integration test suite against all contracts deployed locally -# TODO#q: cache nitro node images and nitro-testnode sources since it is a bottleneck for the routine permissions: contents: read on: push: - branches: [main] + branches: [ main ] pull_request: concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -33,12 +32,13 @@ jobs: - name: set up rust uses: dtolnay/rust-toolchain@stable with: - target: wasm32-unknown-unknown, + target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu toolchain: 1.77.0 + #TODO#q: cache nitro node images and nitro-testnode sources since it is a bottleneck for the routine - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 - name: setup nitro node - run: \ + run: | # clone nitro test node repo git clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git && cd nitro-testnode From bf17c7dba1f1fb7b8e6387ee560677a2b3a77d25 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 16 May 2024 19:12:02 +0400 Subject: [PATCH 25/87] ++ --- .github/workflows/integration.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index c5e2ec089..a81053ba1 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -50,7 +50,5 @@ jobs: ./test-node.bash script send-l2 --to address_0x01fA6bf4Ee48B6C95900BCcf9BEA172EF5DBd478 --ethamount 10000 # fund Bob's wallet ./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000 - shell: zsh - name: run integration tests - run: ./integration/test.sh - shell: zsh \ No newline at end of file + run: ./integration/test.sh \ No newline at end of file From 859219e46de341fb0ba59fd9d28215d738cd3a8e Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 16 May 2024 20:05:00 +0400 Subject: [PATCH 26/87] use bash instead zsh --- .github/workflows/integration.yml | 3 ++- integration/test.sh | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index a81053ba1..6e1d7e45a 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | ~/.cargo/bin/ @@ -29,6 +29,7 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} + save-always: true #TODO#q: remove it when github pipeline stop failing - name: set up rust uses: dtolnay/rust-toolchain@stable with: diff --git a/integration/test.sh b/integration/test.sh index b2b8959dd..ee035e928 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -1,4 +1,4 @@ -#!/bin/zsh +#!/bin/bash set -o pipefail # Deploy contract by rust crate name. @@ -43,8 +43,8 @@ for CRATE_NAME in $(get_example_crate_names) do deploy_contract "$CRATE_NAME" - # TODO#q: move to to deploy_contract - DEPLOYMENT_ADDRESS_ENV_VAR_NAME="${${CRATE_NAME//-/_}:u}_DEPLOYMENT_ADDRESS" + # TODO#q: move to deploy_contract function + DEPLOYMENT_ADDRESS_ENV_VAR_NAME="$(echo "$CRATE_NAME" | tr '-' '_' | tr '[:lower:]' '[:upper:]')_DEPLOYMENT_ADDRESS" # export dynamically created variable set -a From 71795e758674cc382324d0ca6aabd190a7a4fc4d Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 16 May 2024 22:30:34 +0400 Subject: [PATCH 27/87] refactor erc721 integration tests --- .github/workflows/integration.yml | 19 +++++++++-- integration/src/erc721.rs | 49 ++++++++++----------------- integration/src/infrastructure/mod.rs | 1 + 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 6e1d7e45a..fe6431edd 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -23,21 +23,33 @@ jobs: - uses: actions/cache@v4 with: path: | - ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} - save-always: true #TODO#q: remove it when github pipeline stop failing + #TODO#q: remove save-always policy when github pipeline stop failing + save-always: true + + - name: cache cargo-stylus + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/.crates.toml + key: ${{ runner.os }}-cargo-bin-cargo-stylus@0.2.1 + save-always: true + - name: set up rust uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu toolchain: 1.77.0 - #TODO#q: cache nitro node images and nitro-testnode sources since it is a bottleneck for the routine + - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 + + #TODO#q: cache nitro node images and nitro-testnode sources since it is a bottleneck for the routine - name: setup nitro node run: | # clone nitro test node repo @@ -51,5 +63,6 @@ jobs: ./test-node.bash script send-l2 --to address_0x01fA6bf4Ee48B6C95900BCcf9BEA172EF5DBd478 --ethamount 10000 # fund Bob's wallet ./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000 + - name: run integration tests run: ./integration/test.sh \ No newline at end of file diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index 7effe881a..dc58b5fe9 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -8,7 +8,7 @@ use crate::infrastructure::{erc721::*, *}; // TODO#q: refactor these tests similarly to unit tests #[tokio::test] -async fn mint_nft_and_check_balance() -> Result<()> { +async fn mint() -> Result<()> { let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra @@ -26,7 +26,7 @@ async fn mint_nft_and_check_balance() -> Result<()> { } #[tokio::test] -async fn error_mint_second_nft() -> Result<()> { +async fn error_when_reusing_token_id() -> Result<()> { let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra @@ -34,21 +34,16 @@ async fn error_mint_second_nft() -> Result<()> { .mint(infra.alice.wallet.address(), token_id) .ctx_send() .await?; - match infra + let err = infra .alice .mint(infra.alice.wallet.address(), token_id) .ctx_send() - .await - { - Ok(_) => { - bail!("Second mint of the same token should not be possible") - } - Err(e) => e.assert(ERC721InvalidSender { sender: Address::zero() }), - } + .await.expect_err("should not mint a token id twice"); + err.assert(ERC721InvalidSender { sender: Address::zero() }) } #[tokio::test] -async fn transfer_nft() -> Result<()> { +async fn transfer() -> Result<()> { let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra @@ -71,10 +66,10 @@ async fn transfer_nft() -> Result<()> { } #[tokio::test] -async fn error_transfer_nonexistent_nft() -> Result<()> { +async fn error_when_transfer_nonexistent_token() -> Result<()> { let infra = Infrastructure::::new().await?; let token_id = random_token_id(); - match infra + let err = infra .alice .transfer_from( infra.alice.wallet.address(), @@ -83,16 +78,12 @@ async fn error_transfer_nonexistent_nft() -> Result<()> { ) .ctx_send() .await - { - Ok(_) => { - bail!("Transfer of a non existent nft should not be possible") - } - Err(e) => e.assert(ERC721NonexistentToken { token_id }), - } + .expect_err("should not transfer a non existent token"); + err.assert(ERC721NonexistentToken { token_id }) } #[tokio::test] -async fn approve_nft_transfer() -> Result<()> { +async fn approve_token_transfer() -> Result<()> { let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra @@ -120,7 +111,7 @@ async fn approve_nft_transfer() -> Result<()> { } #[tokio::test] -async fn error_not_approved_nft_transfer() -> Result<()> { +async fn error_when_transfer_unapproved_token() -> Result<()> { let infra = Infrastructure::::new().await?; let token_id = random_token_id(); let _ = infra @@ -128,7 +119,7 @@ async fn error_not_approved_nft_transfer() -> Result<()> { .mint(infra.alice.wallet.address(), token_id) .ctx_send() .await?; - match infra + let err = infra .bob .transfer_from( infra.alice.wallet.address(), @@ -137,15 +128,11 @@ async fn error_not_approved_nft_transfer() -> Result<()> { ) .ctx_send() .await - { - Ok(_) => { - bail!("Transfer of not approved token should not happen") - } - Err(e) => e.assert(ERC721InsufficientApproval { - operator: infra.bob.wallet.address(), - token_id, - }), - } + .expect_err("should not transfer unapproved token"); + err.assert(ERC721InsufficientApproval { + operator: infra.bob.wallet.address(), + token_id, + }) } // TODO: add more tests for erc721 diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 17fd112c2..691f79c25 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -168,6 +168,7 @@ pub trait ContextSend { async fn ctx_send(self) -> Result; } +// TODO#q: add wallet owner name to to ContractCall (self.tx.from()) #[async_trait] impl ContextSend for ContractCall { async fn ctx_send(self) -> Result { From 25605c80ce32235a4e06b404f0dbe7daae9741ec Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 17 May 2024 00:08:46 +0400 Subject: [PATCH 28/87] add token_imp! macro --- integration/README.md | 10 +--------- integration/src/erc721.rs | 2 -- integration/src/infrastructure/erc20.rs | 12 ++---------- integration/src/infrastructure/erc721.rs | 11 ++--------- integration/src/infrastructure/mod.rs | 13 +++++++++++++ integration/test.sh | 5 +++++ 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/integration/README.md b/integration/README.md index 571a372f9..987d2febf 100644 --- a/integration/README.md +++ b/integration/README.md @@ -42,15 +42,7 @@ abigen!( Then add wrapper type for the contract: ```rust pub type Erc20 = Erc20Token; - -impl Token for Erc20 { - const STYLUS_PROGRAM_ADDRESS: &'static str = - "ERC20_EXAMPLE_DEPLOYMENT_ADDRESS"; - - fn new(address: Address, client: Arc) -> Self { - Self::new(address, client) - } -} +token_impl!(Erc20, "ERC20_EXAMPLE_DEPLOYMENT_ADDRESS"); ``` Function `new` should forward call to the contract factory method. `STYLUS_PROGRAM_ADDRESS` should have a value of formed by the template `_DEPLOYMENT_ADDRESS` diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index dc58b5fe9..4bd0eaa9e 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -5,8 +5,6 @@ use crate::infrastructure::{erc721::*, *}; // TODO: add isolation with mutex per contract -// TODO#q: refactor these tests similarly to unit tests - #[tokio::test] async fn mint() -> Result<()> { let infra = Infrastructure::::new().await?; diff --git a/integration/src/infrastructure/erc20.rs b/integration/src/infrastructure/erc20.rs index 0732e04fb..c760104d7 100644 --- a/integration/src/infrastructure/erc20.rs +++ b/integration/src/infrastructure/erc20.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use ethers::prelude::*; -use crate::infrastructure::{HttpMiddleware, Token}; +use crate::{infrastructure::*, token_impl}; abigen!( Erc20Token, @@ -30,12 +30,4 @@ abigen!( ); pub type Erc20 = Erc20Token; - -impl Token for Erc20 { - const STYLUS_PROGRAM_ADDRESS: &'static str = - "ERC20_EXAMPLE_DEPLOYMENT_ADDRESS"; - - fn new(address: Address, client: Arc) -> Self { - Self::new(address, client) - } -} +token_impl!(Erc20, "ERC20_EXAMPLE_DEPLOYMENT_ADDRESS"); diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index 50ad21ba8..31db4e962 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use ethers::{addressbook::Address, contract::abigen}; use crate::infrastructure::{HttpMiddleware, Token}; +use crate::token_impl; abigen!( Erc721Token, @@ -45,12 +46,4 @@ abigen!( ); pub type Erc721 = Erc721Token; - -impl Token for Erc721 { - const STYLUS_PROGRAM_ADDRESS: &'static str = - "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"; - - fn new(address: Address, client: Arc) -> Self { - Self::new(address, client) - } -} +token_impl!(Erc721, "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"); \ No newline at end of file diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 691f79c25..29953a635 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -93,6 +93,19 @@ pub trait Token { fn new(address: Address, client: Arc) -> Self; } +#[macro_export] +macro_rules! token_impl { + ($token_type:ty, $program_address:expr) => { + impl Token for $token_type { + const STYLUS_PROGRAM_ADDRESS: &'static str = $program_address; + + fn new(address: Address, client: Arc) -> Self { + Self::new(address, client) + } + } + }; +} + pub type HttpMiddleware = SignerMiddleware, LocalWallet>; impl Client { diff --git a/integration/test.sh b/integration/test.sh index ee035e928..9412350ec 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -1,6 +1,11 @@ #!/bin/bash set -o pipefail +# make sure we will be running script from the project root. +mydir=$(dirname $0) +cd "$mydir" || exit +cd .. + # Deploy contract by rust crate name. # Sets $DEPLOYMENT_ADDRESS environment variable after successful deployment. deploy_contract () { From 8193953d1ffab641e4d12dd6f7a34e0a78bc7bc4 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 17 May 2024 00:11:17 +0400 Subject: [PATCH 29/87] remove --workspace flags since we have default members of the workspace --- .github/workflows/check.yml | 2 +- .github/workflows/nostd.yml | 2 +- .github/workflows/test.yml | 6 +++--- Cargo.toml | 1 - GUIDELINES.md | 6 +++--- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 7888042fc..61995b7ef 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -79,7 +79,7 @@ jobs: - name: Install nightly uses: dtolnay/rust-toolchain@nightly - name: cargo doc - run: cargo doc --workspace --no-deps --all-features + run: cargo doc --no-deps --all-features env: RUSTDOCFLAGS: --cfg docsrs hack: diff --git a/.github/workflows/nostd.yml b/.github/workflows/nostd.yml index 2bc67b248..bc79972cd 100644 --- a/.github/workflows/nostd.yml +++ b/.github/workflows/nostd.yml @@ -29,4 +29,4 @@ jobs: - name: rustup target add ${{ matrix.target }} run: rustup target add ${{ matrix.target }} - name: cargo check - run: cargo check --release --target ${{ matrix.target }} --no-default-features --workspace --all-features + run: cargo check --release --target ${{ matrix.target }} --no-default-features --all-features diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6e6d24f94..49b3a402f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,10 +50,10 @@ jobs: run: cargo generate-lockfile # https://twitter.com/jonhoo/status/1571290371124260865 - name: cargo test --locked - run: cargo test --locked --all-features --all-targets --workspace + run: cargo test --locked --all-features --all-targets # https://github.com/rust-lang/cargo/issues/6669 - name: cargo test --doc - run: cargo test --locked --all-features --doc --workspace + run: cargo test --locked --all-features --doc os-check: # Run cargo test on MacOS and Windows. runs-on: ${{ matrix.os }} @@ -74,7 +74,7 @@ jobs: if: hashFiles('Cargo.lock') == '' run: cargo generate-lockfile - name: cargo test - run: cargo test --locked --all-features --all-targets --workspace + run: cargo test --locked --all-features --all-targets coverage: # Use llvm-cov to build and collect coverage and outputs in a format that # is compatible with codecov.io. diff --git a/Cargo.toml b/Cargo.toml index 9df9617e9..be16a22f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ members = [ "examples/erc20", "examples/erc721", "examples/merkle-proofs", - "examples/erc721", "examples/ownable", "integration", ] diff --git a/GUIDELINES.md b/GUIDELINES.md index 3c2a9d98a..6f41be091 100644 --- a/GUIDELINES.md +++ b/GUIDELINES.md @@ -193,7 +193,7 @@ Some other examples of automation are: Always check your code with the linter (`clippy`), by running: - $ cargo clippy --workspace --tests --all-features + $ cargo clippy --tests --all-features And make sure your code is formatted with, using: @@ -205,14 +205,14 @@ Finally, ensure there is no trailing whitespace anywhere. Make sure all tests are passing with: - $ cargo test --workspace --all-features + $ cargo test --all-features ### Checking the docs If you make documentation changes, you may want to check whether there are any warnings or errors: - $ cargo doc --workspace --all-features + $ cargo doc --all-features ## Pull requests From 62b5c4fa9fcbe3a4ae4bfbac53822287a7635bc2 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 17 May 2024 01:12:59 +0400 Subject: [PATCH 30/87] revert shims for stylus 0.4.3 --- lib/grip/src/shims.rs | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/grip/src/shims.rs b/lib/grip/src/shims.rs index a77acf088..684093658 100644 --- a/lib/grip/src/shims.rs +++ b/lib/grip/src/shims.rs @@ -120,35 +120,26 @@ pub unsafe extern "C" fn storage_load_bytes32(key: *const u8, out: *mut u8) { unsafe { write_bytes32(out, value) }; } -/// Writes a 32-byte value to the permanent storage cache. Stylus's storage -/// format is identical to that of the EVM. This means that, under the hood, -/// this hostio represents storing a 32-byte value into the EVM state trie at -/// offset `key`. Refunds are tabulated exactly as in the EVM. The semantics, +/// Stores a 32-byte value to permanent storage. Stylus's storage format is +/// identical to that of the EVM. This means that, under the hood, this hostio +/// is storing a 32-byte value into the EVM state trie at offset `key`. +/// Furthermore, refunds are tabulated exactly as in the EVM. The semantics, /// then, are equivalent to that of the EVM's [`SSTORE`] opcode. /// -/// Note: because the value is cached, one must call `storage_flush_cache` to -/// persist it. +/// Note: we require the [`SSTORE`] sentry per EVM rules. The `gas_cost` +/// returned by the EVM API may exceed this amount, but that's ok because the +/// predominant cost is due to state bloat concerns. /// /// [`SSTORE`]: https://www.evm.codes/#55 #[no_mangle] -pub unsafe extern "C" fn storage_cache_bytes32( +pub unsafe extern "C" fn storage_store_bytes32( key: *const u8, value: *const u8, ) { let (key, value) = unsafe { (read_bytes32(key), read_bytes32(value)) }; - STORAGE.lock().unwrap().insert(key, value); } -/// Persists any dirty values in the storage cache to the EVM state trie, -/// dropping the cache entirely if requested. Analogous to repeated invocations -/// of [`SSTORE`]. -/// -/// [`SSTORE`]: https://www.evm.codes/#55 -pub fn storage_flush_cache(_: bool) { - // No-op: we don't use the cache in our unit-tests. -} - /// Dummy msg sender set for tests. pub const MSG_SENDER: &[u8; 42] = b"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF"; From c1b2feeb5db68afdd8d4fb570565efdb53f9ba84 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 17 May 2024 01:16:17 +0400 Subject: [PATCH 31/87] ++ --- integration/src/erc721.rs | 3 ++- integration/src/infrastructure/erc721.rs | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index 4bd0eaa9e..531e917c6 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -36,7 +36,8 @@ async fn error_when_reusing_token_id() -> Result<()> { .alice .mint(infra.alice.wallet.address(), token_id) .ctx_send() - .await.expect_err("should not mint a token id twice"); + .await + .expect_err("should not mint a token id twice"); err.assert(ERC721InvalidSender { sender: Address::zero() }) } diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index 31db4e962..4b0b73632 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -2,8 +2,10 @@ use std::sync::Arc; use ethers::{addressbook::Address, contract::abigen}; -use crate::infrastructure::{HttpMiddleware, Token}; -use crate::token_impl; +use crate::{ + infrastructure::{HttpMiddleware, Token}, + token_impl, +}; abigen!( Erc721Token, @@ -46,4 +48,4 @@ abigen!( ); pub type Erc721 = Erc721Token; -token_impl!(Erc721, "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"); \ No newline at end of file +token_impl!(Erc721, "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"); From 5596f3bfc989201a8caeae111db5e526fa6c4604 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 17 May 2024 02:37:24 +0400 Subject: [PATCH 32/87] remove token bridge --- .github/workflows/integration.yml | 2 +- integration/src/erc721.rs | 2 +- integration/src/infrastructure/mod.rs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index fe6431edd..121965df4 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -56,7 +56,7 @@ jobs: git clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git && cd nitro-testnode # setup nitro test node - ./test-node.bash --no-run --init + ./test-node.bash --no-run --init --no-tokenbridge ./test-node.bash --detach # fund Alice's wallet diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index 531e917c6..8e6a91576 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -3,7 +3,7 @@ use eyre::{bail, Result}; use crate::infrastructure::{erc721::*, *}; -// TODO: add isolation with mutex per contract +// TODO#q: add isolation with mutex per contract #[tokio::test] async fn mint() -> Result<()> { diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 29953a635..d0fb1de0f 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -93,6 +93,7 @@ pub trait Token { fn new(address: Address, client: Arc) -> Self; } +// TODO#q: parse crate name with this macro #[macro_export] macro_rules! token_impl { ($token_type:ty, $program_address:expr) => { From b970115e996e2d6bec48f5453bd2f6e443bea9b1 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 17 May 2024 11:42:31 +0400 Subject: [PATCH 33/87] refactor --- integration/Cargo.toml | 5 +- integration/README.md | 34 +++++----- integration/src/infrastructure/erc20.rs | 6 +- integration/src/infrastructure/erc721.rs | 11 +--- integration/src/infrastructure/mod.rs | 82 ++++++++++++++++-------- integration/src/lib.rs | 2 +- integration/test.sh | 15 ++--- 7 files changed, 90 insertions(+), 65 deletions(-) diff --git a/integration/Cargo.toml b/integration/Cargo.toml index 6e90f99e4..97f6f67e8 100644 --- a/integration/Cargo.toml +++ b/integration/Cargo.toml @@ -11,4 +11,7 @@ repository.workspace = true tokio = { version = "1.12.0", features = ["full"] } ethers = "2.0" eyre = "0.6.8" -async-trait = "0.1.80" \ No newline at end of file +async-trait = "0.1.80" + +[lib] +doctest = false \ No newline at end of file diff --git a/integration/README.md b/integration/README.md index 987d2febf..5102490e5 100644 --- a/integration/README.md +++ b/integration/README.md @@ -1,55 +1,59 @@ # Integration Tests + ## Run tests + Deploying every contract from `./examples` directory and running integration tests. + ### Against local nitro node -Set up first a local nitro node according to this [guide](https://github.com/OffchainLabs/nitro-testnode/blob/release/README.md) and run this command from the project root: + +Set up first a local nitro node according to +this [guide](https://github.com/OffchainLabs/nitro-testnode/blob/release/README.md) and run this command from the +project root: + ```terminal ./integration/test.sh ``` ### Against stylus dev net + `ALICE_PRIV_KEY` and `BOB_PRIV_KEY` should be valid funded wallets. `RPC_URL` should contain url of the stylus testnet. Run this command from the project root: + ```terminal ALICE_PRIV_KEY=0x... \ BOB_PRIV_KEY=0x... \ RPC_URL=https://stylus-testnet.arbitrum.io/rpc \ ./integration/test.sh ``` + ## Add test for the new contract -Assuming that contract associated crate exists at `./examples` directory + +Assuming that contract associated crate exists at `./examples` directory with the crate name `erc20-example`. Add ethereum contracts to `./integration/src/infrastructure` directory like: + ```rust -abigen!( +ethers::contract::abigen!( Erc20Token, r#"[ - function decimals() external view returns (uint8) - function totalSupply() external view returns (uint256) - function balanceOf(address account) external view returns (uint256) - function transfer(address recipient, uint256 amount) external returns (bool) - function allowance(address owner, address spender) external view returns (uint256) - function approve(address spender, uint256 amount) external returns (bool) function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) function mint(address account, uint256 amount) external - function burn(uint256 amount) external error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed) ]"# ); ``` + Then add wrapper type for the contract: + ```rust pub type Erc20 = Erc20Token; -token_impl!(Erc20, "ERC20_EXAMPLE_DEPLOYMENT_ADDRESS"); +link_to_crate!(Erc20, "erc20-example"); ``` -Function `new` should forward call to the contract factory method. -`STYLUS_PROGRAM_ADDRESS` should have a value of formed by the template `_DEPLOYMENT_ADDRESS` -where `` is the "SCREAMING_SNAKE_CASE" conversion of the crate name. -`ERC20_EXAMPLE_DEPLOYMENT_ADDRESS` in this example. Tests should create new infrastructure instance like this: + ```rust let infra = Infrastructure::::new().await?; ``` \ No newline at end of file diff --git a/integration/src/infrastructure/erc20.rs b/integration/src/infrastructure/erc20.rs index c760104d7..1e4c9ba50 100644 --- a/integration/src/infrastructure/erc20.rs +++ b/integration/src/infrastructure/erc20.rs @@ -1,8 +1,6 @@ -use std::sync::Arc; - use ethers::prelude::*; -use crate::{infrastructure::*, token_impl}; +use crate::{infrastructure::*, link_to_crate}; abigen!( Erc20Token, @@ -30,4 +28,4 @@ abigen!( ); pub type Erc20 = Erc20Token; -token_impl!(Erc20, "ERC20_EXAMPLE_DEPLOYMENT_ADDRESS"); +link_to_crate!(Erc20, "erc20-example"); diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index 4b0b73632..610447c7b 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -1,11 +1,6 @@ -use std::sync::Arc; +use ethers::contract::abigen; -use ethers::{addressbook::Address, contract::abigen}; - -use crate::{ - infrastructure::{HttpMiddleware, Token}, - token_impl, -}; +use crate::{infrastructure::HttpMiddleware, link_to_crate}; abigen!( Erc721Token, @@ -48,4 +43,4 @@ abigen!( ); pub type Erc721 = Erc721Token; -token_impl!(Erc721, "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"); +link_to_crate!(Erc721, "erc721-example"); diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index d0fb1de0f..699745a5a 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -1,7 +1,11 @@ pub mod erc20; pub mod erc721; -use std::{ops::Deref, str::FromStr, sync::Arc}; +use std::{ + ops::{Add, Deref}, + str::FromStr, + sync::Arc, +}; use async_trait::async_trait; use ethers::{ @@ -20,12 +24,12 @@ const RPC_URL: &str = "RPC_URL"; /// Integration testing infrastructure that allows to act on behalf of `alice` /// and `bob` accounts. -pub struct Infrastructure { +pub struct Infrastructure { pub alice: Client, pub bob: Client, } -impl Infrastructure { +impl Infrastructure { /// Constructs new instance of an integration testing infrastructure. /// /// Requires env variables `ALICE_PRIV_KEY`, `BOB_PRIV_KEY`, `RPC_URL` @@ -39,12 +43,17 @@ impl Infrastructure { .with_context(|| format!("Load {} env var", BOB_PRIV_KEY))?; let rpc_url = std::env::var(RPC_URL) .with_context(|| format!("Load {} env var", RPC_URL))?; - let stylus_program_address = std::env::var(T::STYLUS_PROGRAM_ADDRESS) + + let program_address_env_name = T::CRATE_NAME + .replace('-', "_") + .to_ascii_uppercase() + .add("_DEPLOYMENT_ADDRESS"); + let program_address: Address = std::env::var(&program_address_env_name) .with_context(|| { - format!("Load {} env var", T::STYLUS_PROGRAM_ADDRESS) - })?; + format!("Load {} env var", program_address_env_name) + })? + .parse()?; - let program_address: Address = stylus_program_address.parse()?; let provider = Provider::::try_from(rpc_url)?; Ok(Infrastructure { @@ -61,31 +70,26 @@ impl Infrastructure { /// Client of participant that allows to check wallet address and call contract /// functions. -pub struct Client { +pub struct Client { pub wallet: LocalWallet, - pub caller: T, + pub contract: T, } -// Allows not to mention `caller` property every time we call a function. -impl Deref for Client { +// Allows not to mention `contract` property every time we call a function. +impl Deref for Client { type Target = T; fn deref(&self) -> &Self::Target { - &self.caller + &self.contract } } /// Abstraction for the deployed contract. -pub trait Token { - /// Deployed program address environment variable name for the contract. +pub trait Contract { + /// Crate name of the contract. /// - /// e.g can be `ERC721_EXAMPLE_DEPLOYMENT_ADDRESS`. - /// Formed by the template _DEPLOYMENT_ADDRESS - /// where is the "SCREAMING_SNAKE_CASE" conversion of the crate - /// name from the `./examples` directory. - /// That environment variable should store an address of the corresponding - /// deployed program. - const STYLUS_PROGRAM_ADDRESS: &'static str; + /// e.g can be `erc721-example`. + const CRATE_NAME: &'static str; /// Abstracts token creation function. /// @@ -93,14 +97,36 @@ pub trait Token { fn new(address: Address, client: Arc) -> Self; } -// TODO#q: parse crate name with this macro +/// Link `abigen!` contract to the crate name in `./examples` directory. +/// +/// # Example +/// ``` +/// use integration::{link_to_crate, infrastructure::HttpMiddleware}; +/// use ethers::contract::abigen; +/// +/// abigen!( +/// Erc20Token, +/// r#"[ +/// function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) +/// function mint(address account, uint256 amount) external +/// +/// error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed) +/// ]"# +/// ); +/// +/// pub type Erc20 = Erc20Token; +/// link_to_crate!(Erc20, "erc20-example"); +/// ``` #[macro_export] -macro_rules! token_impl { +macro_rules! link_to_crate { ($token_type:ty, $program_address:expr) => { - impl Token for $token_type { - const STYLUS_PROGRAM_ADDRESS: &'static str = $program_address; + impl $crate::infrastructure::Contract for $token_type { + const CRATE_NAME: &'static str = $program_address; - fn new(address: Address, client: Arc) -> Self { + fn new( + address: ethers::types::Address, + client: std::sync::Arc, + ) -> Self { Self::new(address, client) } } @@ -109,7 +135,7 @@ macro_rules! token_impl { pub type HttpMiddleware = SignerMiddleware, LocalWallet>; -impl Client { +impl Client { pub async fn new( provider: Provider, program_address: Address, @@ -122,7 +148,7 @@ impl Client { wallet.clone().with_chain_id(chain_id), )); let caller = T::new(program_address, signer); - Ok(Self { wallet, caller }) + Ok(Self { wallet, contract: caller }) } } diff --git a/integration/src/lib.rs b/integration/src/lib.rs index 5ea0b88b5..47210c5bb 100644 --- a/integration/src/lib.rs +++ b/integration/src/lib.rs @@ -1,3 +1,3 @@ mod erc20; mod erc721; -mod infrastructure; +pub mod infrastructure; diff --git a/integration/test.sh b/integration/test.sh index 9412350ec..91af786f7 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -29,6 +29,13 @@ deploy_contract () { echo "Error: Couldn't retrieve deployment address for a contract $CONTRACT_CRATE_NAME." exit 1 fi + + DEPLOYMENT_ADDRESS_ENV_VAR_NAME="$(echo "$CRATE_NAME" | tr '-' '_' | tr '[:lower:]' '[:upper:]')_DEPLOYMENT_ADDRESS" + + # export dynamically created variable + set -a + printf -v "$DEPLOYMENT_ADDRESS_ENV_VAR_NAME" "%s" "$DEPLOYMENT_ADDRESS" + set +a } # Retrieve all contract's crate names in `./examples` directory. @@ -47,14 +54,6 @@ cargo build --release --target wasm32-unknown-unknown for CRATE_NAME in $(get_example_crate_names) do deploy_contract "$CRATE_NAME" - - # TODO#q: move to deploy_contract function - DEPLOYMENT_ADDRESS_ENV_VAR_NAME="$(echo "$CRATE_NAME" | tr '-' '_' | tr '[:lower:]' '[:upper:]')_DEPLOYMENT_ADDRESS" - - # export dynamically created variable - set -a - printf -v "$DEPLOYMENT_ADDRESS_ENV_VAR_NAME" "%s" "$DEPLOYMENT_ADDRESS" - set +a done # TODO: run tests in parallel when concurrency scope will be per contract From 097027beb95ed11ed67227b3576ffc5701048b76 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Fri, 17 May 2024 13:34:57 +0400 Subject: [PATCH 34/87] ++ --- .github/workflows/integration.yml | 3 - integration/README.md | 2 +- integration/src/erc20.rs | 15 ++-- integration/src/erc721.rs | 110 ++++++++------------------ integration/src/infrastructure/mod.rs | 11 ++- integration/test.sh | 4 +- 6 files changed, 46 insertions(+), 99 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 121965df4..1d6e7f7e2 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -28,8 +28,6 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} - #TODO#q: remove save-always policy when github pipeline stop failing - save-always: true - name: cache cargo-stylus uses: actions/cache@v4 @@ -49,7 +47,6 @@ jobs: - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 - #TODO#q: cache nitro node images and nitro-testnode sources since it is a bottleneck for the routine - name: setup nitro node run: | # clone nitro test node repo diff --git a/integration/README.md b/integration/README.md index 5102490e5..f59886ecd 100644 --- a/integration/README.md +++ b/integration/README.md @@ -2,7 +2,7 @@ ## Run tests -Deploying every contract from `./examples` directory and running integration tests. +Deploy every contract from `./examples` directory and running integration tests. ### Against local nitro node diff --git a/integration/src/erc20.rs b/integration/src/erc20.rs index 53638235a..fdf3ef53a 100644 --- a/integration/src/erc20.rs +++ b/integration/src/erc20.rs @@ -1,23 +1,22 @@ use ethers::prelude::*; -use eyre::{bail, Result}; +use eyre::Result; use crate::infrastructure::{erc20::*, *}; #[tokio::test] async fn mint() -> Result<()> { - let infra = Infrastructure::::new().await?; + let Infrastructure { alice, bob } = Infrastructure::::new().await?; let one = U256::from(1); let initial_balance = - infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; - let initial_supply = infra.alice.total_supply().ctx_call().await?; + alice.balance_of(alice.wallet.address()).ctx_call().await?; + let initial_supply = alice.total_supply().ctx_call().await?; - let _ = - infra.alice.mint(infra.alice.wallet.address(), one).ctx_send().await?; + let _ = alice.mint(alice.wallet.address(), one).ctx_send().await?; let new_balance = - infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; - let new_supply = infra.alice.total_supply().ctx_call().await?; + alice.balance_of(alice.wallet.address()).ctx_call().await?; + let new_supply = alice.total_supply().ctx_call().await?; assert_eq!(initial_balance + one, new_balance); assert_eq!(initial_supply + one, new_supply); diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index 8e6a91576..08a17d2f7 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -1,40 +1,28 @@ use ethers::prelude::*; -use eyre::{bail, Result}; +use eyre::Result; use crate::infrastructure::{erc721::*, *}; -// TODO#q: add isolation with mutex per contract - #[tokio::test] async fn mint() -> Result<()> { - let infra = Infrastructure::::new().await?; + let Infrastructure { alice, bob } = Infrastructure::::new().await?; let token_id = random_token_id(); - let _ = infra - .alice - .mint(infra.alice.wallet.address(), token_id) - .ctx_send() - .await?; - let owner = infra.alice.owner_of(token_id).ctx_call().await?; - assert_eq!(owner, infra.alice.wallet.address()); + let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; + let owner = alice.owner_of(token_id).ctx_call().await?; + assert_eq!(owner, alice.wallet.address()); - let balance = - infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; + let balance = alice.balance_of(alice.wallet.address()).ctx_call().await?; assert!(balance >= U256::one()); Ok(()) } #[tokio::test] async fn error_when_reusing_token_id() -> Result<()> { - let infra = Infrastructure::::new().await?; + let Infrastructure { alice, bob } = Infrastructure::::new().await?; let token_id = random_token_id(); - let _ = infra - .alice - .mint(infra.alice.wallet.address(), token_id) - .ctx_send() - .await?; - let err = infra - .alice - .mint(infra.alice.wallet.address(), token_id) + let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; + let err = alice + .mint(alice.wallet.address(), token_id) .ctx_send() .await .expect_err("should not mint a token id twice"); @@ -43,38 +31,24 @@ async fn error_when_reusing_token_id() -> Result<()> { #[tokio::test] async fn transfer() -> Result<()> { - let infra = Infrastructure::::new().await?; + let Infrastructure { alice, bob } = Infrastructure::::new().await?; let token_id = random_token_id(); - let _ = infra - .alice - .mint(infra.alice.wallet.address(), token_id) - .ctx_send() - .await?; - let _ = infra - .alice - .transfer_from( - infra.alice.wallet.address(), - infra.bob.wallet.address(), - token_id, - ) + let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; + let _ = alice + .transfer_from(alice.wallet.address(), bob.wallet.address(), token_id) .ctx_send() .await?; - let owner = infra.bob.owner_of(token_id).ctx_call().await?; - assert_eq!(owner, infra.bob.wallet.address()); + let owner = bob.owner_of(token_id).ctx_call().await?; + assert_eq!(owner, bob.wallet.address()); Ok(()) } #[tokio::test] async fn error_when_transfer_nonexistent_token() -> Result<()> { - let infra = Infrastructure::::new().await?; + let Infrastructure { alice, bob } = Infrastructure::::new().await?; let token_id = random_token_id(); - let err = infra - .alice - .transfer_from( - infra.alice.wallet.address(), - infra.bob.wallet.address(), - token_id, - ) + let err = alice + .transfer_from(alice.wallet.address(), bob.wallet.address(), token_id) .ctx_send() .await .expect_err("should not transfer a non existent token"); @@ -83,53 +57,31 @@ async fn error_when_transfer_nonexistent_token() -> Result<()> { #[tokio::test] async fn approve_token_transfer() -> Result<()> { - let infra = Infrastructure::::new().await?; + let Infrastructure { alice, bob } = Infrastructure::::new().await?; let token_id = random_token_id(); - let _ = infra - .alice - .mint(infra.alice.wallet.address(), token_id) + let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; + let _ = alice.approve(bob.wallet.address(), token_id).ctx_send().await?; + let _ = bob + .transfer_from(alice.wallet.address(), bob.wallet.address(), token_id) .ctx_send() .await?; - let _ = infra - .alice - .approve(infra.bob.wallet.address(), token_id) - .ctx_send() - .await?; - let _ = infra - .bob - .transfer_from( - infra.alice.wallet.address(), - infra.bob.wallet.address(), - token_id, - ) - .ctx_send() - .await?; - let owner = infra.bob.owner_of(token_id).ctx_call().await?; - assert_eq!(owner, infra.bob.wallet.address()); + let owner = bob.owner_of(token_id).ctx_call().await?; + assert_eq!(owner, bob.wallet.address()); Ok(()) } #[tokio::test] async fn error_when_transfer_unapproved_token() -> Result<()> { - let infra = Infrastructure::::new().await?; + let Infrastructure { alice, bob } = Infrastructure::::new().await?; let token_id = random_token_id(); - let _ = infra - .alice - .mint(infra.alice.wallet.address(), token_id) - .ctx_send() - .await?; - let err = infra - .bob - .transfer_from( - infra.alice.wallet.address(), - infra.bob.wallet.address(), - token_id, - ) + let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; + let err = bob + .transfer_from(alice.wallet.address(), bob.wallet.address(), token_id) .ctx_send() .await .expect_err("should not transfer unapproved token"); err.assert(ERC721InsufficientApproval { - operator: infra.bob.wallet.address(), + operator: bob.wallet.address(), token_id, }) } diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 699745a5a..779edf1d0 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -36,7 +36,7 @@ impl Infrastructure { /// and _DEPLOYMENT_ADDRESS /// where is the "SCREAMING_SNAKE_CASE" conversion of the crate /// name from the `./examples` directory. - pub async fn new() -> eyre::Result { + pub async fn new() -> Result { let alice_priv_key = std::env::var(ALICE_PRIV_KEY) .with_context(|| format!("Load {} env var", ALICE_PRIV_KEY))?; let bob_priv_key = std::env::var(BOB_PRIV_KEY) @@ -196,7 +196,7 @@ impl ContextCall { async fn ctx_call(self) -> Result { let function_name = self.function.name.clone(); - self.call().await.context(format!("calling {function_name}")) + self.call().await.context(format!("call {function_name}")) } } @@ -208,16 +208,15 @@ pub trait ContextSend { async fn ctx_send(self) -> Result; } -// TODO#q: add wallet owner name to to ContractCall (self.tx.from()) #[async_trait] impl ContextSend for ContractCall { async fn ctx_send(self) -> Result { let function_name = self.function.name.clone(); self.send() .await - .context(format!("sending {function_name}"))? + .context(format!("send {function_name}"))? .await - .context(format!("sending {function_name}"))? - .context(format!("sending {function_name}")) + .context(format!("send {function_name}"))? + .context(format!("send {function_name}")) } } diff --git a/integration/test.sh b/integration/test.sh index 91af786f7..2cf57c617 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -50,11 +50,11 @@ export RPC_URL=${RPC_URL:-http://localhost:8547} cargo build --release --target wasm32-unknown-unknown -# TODO#q: try to deploy contracts asynchronously +# TODO: deploy contracts asynchronously for CRATE_NAME in $(get_example_crate_names) do deploy_contract "$CRATE_NAME" done -# TODO: run tests in parallel when concurrency scope will be per contract +# TODO: run tests in parallel when concurrency scope will be per test/contract RUST_TEST_THREADS=1 cargo test -p integration \ No newline at end of file From caebc20f59672d75a82e91c71077f9cd3c3e750a Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Sat, 18 May 2024 15:54:18 +0400 Subject: [PATCH 35/87] ++ --- integration/src/infrastructure/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 779edf1d0..cfddfc4df 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -22,8 +22,8 @@ const ALICE_PRIV_KEY: &str = "ALICE_PRIV_KEY"; const BOB_PRIV_KEY: &str = "BOB_PRIV_KEY"; const RPC_URL: &str = "RPC_URL"; -/// Integration testing infrastructure that allows to act on behalf of `alice` -/// and `bob` accounts. +/// Integration testing infrastructure that allows to act on behalf of `Alice` +/// and `Bob` accounts. pub struct Infrastructure { pub alice: Client, pub bob: Client, From e596b706e89240903638da0bb372c63ff9cadec1 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Sat, 18 May 2024 23:10:30 +0400 Subject: [PATCH 36/87] ++ --- .github/workflows/integration.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 1d6e7f7e2..ceeeaad8b 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -42,7 +42,6 @@ jobs: uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu - toolchain: 1.77.0 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From cdb90a59f61d2aa6967d42cda3d759543d2a3f97 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Sun, 19 May 2024 00:11:36 +0400 Subject: [PATCH 37/87] ++ --- Cargo.lock | 11 +++++++++++ integration/README.md | 18 +++++++++++++++--- integration/src/erc20.rs | 5 +++++ integration/src/infrastructure/erc20.rs | 3 ++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 910948ad1..f553120ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,6 +12,17 @@ dependencies = [ "regex", ] +[[package]] +name = "access-control-example" +version = "0.0.0" +dependencies = [ + "alloy-primitives", + "contracts", + "mini-alloc", + "stylus-proc", + "stylus-sdk", +] + [[package]] name = "addr2line" version = "0.21.0" diff --git a/integration/README.md b/integration/README.md index f59886ecd..48ce41ff4 100644 --- a/integration/README.md +++ b/integration/README.md @@ -6,9 +6,21 @@ Deploy every contract from `./examples` directory and running integration tests. ### Against local nitro node -Set up first a local nitro node according to -this [guide](https://github.com/OffchainLabs/nitro-testnode/blob/release/README.md) and run this command from the -project root: +Set up first a local nitro node according to this [guide](https://github.com/OffchainLabs/nitro-testnode/blob/release/README.md) + +```terminal +# setup nitro test node in detached mode +# docker images should be shutdown manually later +./test-node.bash --no-run --init --no-tokenbridge +./test-node.bash --detach + +# fund Alice's wallet +./test-node.bash script send-l2 --to address_0x01fA6bf4Ee48B6C95900BCcf9BEA172EF5DBd478 --ethamount 10000 +# fund Bob's wallet +./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000 +``` + +Run integration testing command from the project root: ```terminal ./integration/test.sh diff --git a/integration/src/erc20.rs b/integration/src/erc20.rs index fdf3ef53a..c706d7cc0 100644 --- a/integration/src/erc20.rs +++ b/integration/src/erc20.rs @@ -6,6 +6,11 @@ use crate::infrastructure::{erc20::*, *}; #[tokio::test] async fn mint() -> Result<()> { let Infrastructure { alice, bob } = Infrastructure::::new().await?; + // TODO: has a nicer support for custom constructors + let _ = alice + .constructor("MyErc20".to_string(), "MRC".to_string(), U256::from(10)) + .ctx_send() + .await?; let one = U256::from(1); let initial_balance = diff --git a/integration/src/infrastructure/erc20.rs b/integration/src/infrastructure/erc20.rs index 1e4c9ba50..8b49a4cc7 100644 --- a/integration/src/infrastructure/erc20.rs +++ b/integration/src/infrastructure/erc20.rs @@ -5,7 +5,8 @@ use crate::{infrastructure::*, link_to_crate}; abigen!( Erc20Token, r#"[ - function init(uint256) external + function constructor(string memory name, string memory symbol, uint256 cap) external + function name() external view returns (string) function symbol() external view returns (string) function decimals() external view returns (uint8) From 075b110d28ccd3048d4980412f952a0f72f82a3c Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Sun, 19 May 2024 00:51:50 +0400 Subject: [PATCH 38/87] ++ --- .github/workflows/integration.yml | 1 + integration/src/erc20.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index ceeeaad8b..1d6e7f7e2 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -42,6 +42,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu + toolchain: 1.77.0 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 diff --git a/integration/src/erc20.rs b/integration/src/erc20.rs index c706d7cc0..06199aa42 100644 --- a/integration/src/erc20.rs +++ b/integration/src/erc20.rs @@ -6,7 +6,7 @@ use crate::infrastructure::{erc20::*, *}; #[tokio::test] async fn mint() -> Result<()> { let Infrastructure { alice, bob } = Infrastructure::::new().await?; - // TODO: has a nicer support for custom constructors + // TODO: have a nicer support for custom constructors let _ = alice .constructor("MyErc20".to_string(), "MRC".to_string(), U256::from(10)) .ctx_send() From 9d84cfed5685256df1ab19dba42c5de767f8ed31 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 12:02:25 +0400 Subject: [PATCH 39/87] ++ --- .github/workflows/integration.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 1d6e7f7e2..21c2b297d 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,8 +1,8 @@ name: integration -# This is an integration test workflow that: -# - spins local nitro node -# - deploys and check every contract at `./examples` directory -# - runs integration test suite against all contracts deployed locally +# This is an integration workflow that runs following jobs: +# - integration-test: Spins local nitro node. +# Deploys and check every contract at `./examples` directory. +# Runs integration test suite against all contracts deployed locally. permissions: contents: read on: @@ -15,7 +15,7 @@ concurrency: env: CARGO_TERM_COLOR: always jobs: - integration: + test: name: integration testing suite runs-on: ubuntu-latest steps: From 2abc5a79b50abe68ad1ff3ce289d62f5ecf28213 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 13:06:22 +0400 Subject: [PATCH 40/87] ++ --- integration/README.md | 7 ++++--- integration/src/erc20.rs | 2 +- integration/src/infrastructure/erc20.rs | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/integration/README.md b/integration/README.md index 48ce41ff4..5a668d02f 100644 --- a/integration/README.md +++ b/integration/README.md @@ -6,7 +6,8 @@ Deploy every contract from `./examples` directory and running integration tests. ### Against local nitro node -Set up first a local nitro node according to this [guide](https://github.com/OffchainLabs/nitro-testnode/blob/release/README.md) +Set up first a local nitro node according to +this [guide](https://github.com/OffchainLabs/nitro-testnode/blob/release/README.md) ```terminal # setup nitro test node in detached mode @@ -20,7 +21,7 @@ Set up first a local nitro node according to this [guide](https://github.com/Off ./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000 ``` -Run integration testing command from the project root: +Run integration testing command: ```terminal ./integration/test.sh @@ -30,7 +31,7 @@ Run integration testing command from the project root: `ALICE_PRIV_KEY` and `BOB_PRIV_KEY` should be valid funded wallets. `RPC_URL` should contain url of the stylus testnet. -Run this command from the project root: +Run this command: ```terminal ALICE_PRIV_KEY=0x... \ diff --git a/integration/src/erc20.rs b/integration/src/erc20.rs index 06199aa42..dc045d7d5 100644 --- a/integration/src/erc20.rs +++ b/integration/src/erc20.rs @@ -8,7 +8,7 @@ async fn mint() -> Result<()> { let Infrastructure { alice, bob } = Infrastructure::::new().await?; // TODO: have a nicer support for custom constructors let _ = alice - .constructor("MyErc20".to_string(), "MRC".to_string(), U256::from(10)) + .constructor("MyErc20".to_string(), "MRC".to_string(), U256::from(10), false) .ctx_send() .await?; let one = U256::from(1); diff --git a/integration/src/infrastructure/erc20.rs b/integration/src/infrastructure/erc20.rs index 8b49a4cc7..30d550a06 100644 --- a/integration/src/infrastructure/erc20.rs +++ b/integration/src/infrastructure/erc20.rs @@ -5,7 +5,7 @@ use crate::{infrastructure::*, link_to_crate}; abigen!( Erc20Token, r#"[ - function constructor(string memory name, string memory symbol, uint256 cap) external + function constructor(string memory name, string memory symbol, uint256 cap, bool paused) external function name() external view returns (string) function symbol() external view returns (string) From 3d42455c16bf534ebda25efc5b2421b6c7413eb7 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 13:15:33 +0400 Subject: [PATCH 41/87] ++ --- integration/src/erc20.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/integration/src/erc20.rs b/integration/src/erc20.rs index dc045d7d5..7f9102c8f 100644 --- a/integration/src/erc20.rs +++ b/integration/src/erc20.rs @@ -8,7 +8,12 @@ async fn mint() -> Result<()> { let Infrastructure { alice, bob } = Infrastructure::::new().await?; // TODO: have a nicer support for custom constructors let _ = alice - .constructor("MyErc20".to_string(), "MRC".to_string(), U256::from(10), false) + .constructor( + "MyErc20".to_string(), + "MRC".to_string(), + U256::from(10), + false, + ) .ctx_send() .await?; let one = U256::from(1); From d517352b40dbf1e2f0038641f5f2d48218f79c4c Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh <37006439+qalisander@users.noreply.github.com> Date: Mon, 20 May 2024 13:48:05 +0400 Subject: [PATCH 42/87] Update .github/workflows/integration.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander González --- .github/workflows/integration.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 21c2b297d..850f55ef2 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,8 +1,11 @@ name: integration -# This is an integration workflow that runs following jobs: -# - integration-test: Spins local nitro node. -# Deploys and check every contract at `./examples` directory. -# Runs integration test suite against all contracts deployed locally. +# This workflow runs our integration tests suite. +# +# It roughly follows this steps: +# - A local `nitro-testnode` gets spun up. +# - Contracts get deployed to the local node. +# - A few addresses get funded. +# - The test suite runs. permissions: contents: read on: From e4dfa8d615bcf13f4392903c4b29f437c0f82ad3 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 14:10:54 +0400 Subject: [PATCH 43/87] ++ --- Cargo.toml | 1 + lib/grip/src/shims.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 52fc42c5d..694fb9727 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ repository = "https://github.com/OpenZeppelin/rust-contracts-stylus" [workspace.dependencies] alloy-primitives = { version = "0.3.1", default-features = false } alloy-sol-types = { version = "0.3.1", default-features = false } +# TODO: lift stylus-sdk and stylus-proc versions once nitro test node will work stylus-sdk = { version = "0.4.3", default-features = false } stylus-proc = { version = "0.4.3", default-features = false } mini-alloc = "0.4.2" diff --git a/lib/grip/src/shims.rs b/lib/grip/src/shims.rs index 684093658..51cd8a2bf 100644 --- a/lib/grip/src/shims.rs +++ b/lib/grip/src/shims.rs @@ -120,6 +120,7 @@ pub unsafe extern "C" fn storage_load_bytes32(key: *const u8, out: *mut u8) { unsafe { write_bytes32(out, value) }; } +// TODO: change it when 0.5.0 release will work with a nitro test node /// Stores a 32-byte value to permanent storage. Stylus's storage format is /// identical to that of the EVM. This means that, under the hood, this hostio /// is storing a 32-byte value into the EVM state trie at offset `key`. From 051f8cfe8e8f0a0db6cd088e3100b4a47c6896e4 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 14:52:34 +0400 Subject: [PATCH 44/87] ++ --- .github/workflows/{integration.yml => e2e-tests.yml} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{integration.yml => e2e-tests.yml} (95%) diff --git a/.github/workflows/integration.yml b/.github/workflows/e2e-tests.yml similarity index 95% rename from .github/workflows/integration.yml rename to .github/workflows/e2e-tests.yml index 850f55ef2..b431dac1d 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,5 +1,5 @@ -name: integration -# This workflow runs our integration tests suite. +name: e2e-tests +# This workflow runs our end-to-end tests suite. # # It roughly follows this steps: # - A local `nitro-testnode` gets spun up. @@ -19,7 +19,7 @@ env: CARGO_TERM_COLOR: always jobs: test: - name: integration testing suite + name: integration tests suite runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 990c47d29c01544a695e43639b20688e856943b1 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 15:17:34 +0400 Subject: [PATCH 45/87] ++ --- .github/workflows/e2e-tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b431dac1d..3885af870 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -18,7 +18,7 @@ concurrency: env: CARGO_TERM_COLOR: always jobs: - test: + e2e-tests: name: integration tests suite runs-on: ubuntu-latest steps: @@ -45,7 +45,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu - toolchain: 1.77.0 + toolchain: 1.70 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 @@ -54,11 +54,13 @@ jobs: run: | # clone nitro test node repo git clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git && cd nitro-testnode + git reset --hard f5ac2b2271b59827915258471bdf99a1426b5671 # setup nitro test node ./test-node.bash --no-run --init --no-tokenbridge ./test-node.bash --detach + # TODO: remove hard coded wallets when user creation will be per test case # fund Alice's wallet ./test-node.bash script send-l2 --to address_0x01fA6bf4Ee48B6C95900BCcf9BEA172EF5DBd478 --ethamount 10000 # fund Bob's wallet From 13d825d41b385b64b15ca9ac10d6754c1bb6ea67 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 15:35:14 +0400 Subject: [PATCH 46/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 3885af870..a1785305c 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -45,7 +45,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu - toolchain: 1.70 + toolchain: 1.70.0 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From 61beba04a28248de9e853835d9b53028366d32b7 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 16:39:57 +0400 Subject: [PATCH 47/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- Cargo.lock | 20 +++++----- Cargo.toml | 38 +++++++++---------- {integration => e2e-tests}/Cargo.toml | 2 +- {integration => e2e-tests}/README.md | 0 {integration => e2e-tests}/src/erc20.rs | 0 {integration => e2e-tests}/src/erc721.rs | 0 .../src/infrastructure/erc20.rs | 0 .../src/infrastructure/erc721.rs | 0 .../src/infrastructure/mod.rs | 0 {integration => e2e-tests}/src/lib.rs | 0 {integration => e2e-tests}/test.sh | 0 12 files changed, 31 insertions(+), 31 deletions(-) rename {integration => e2e-tests}/Cargo.toml (93%) rename {integration => e2e-tests}/README.md (100%) rename {integration => e2e-tests}/src/erc20.rs (100%) rename {integration => e2e-tests}/src/erc721.rs (100%) rename {integration => e2e-tests}/src/infrastructure/erc20.rs (100%) rename {integration => e2e-tests}/src/infrastructure/erc721.rs (100%) rename {integration => e2e-tests}/src/infrastructure/mod.rs (100%) rename {integration => e2e-tests}/src/lib.rs (100%) rename {integration => e2e-tests}/test.sh (100%) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index a1785305c..ab2f2bfdc 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -45,7 +45,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu - toolchain: 1.70.0 + toolchain: 1.77.0 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 diff --git a/Cargo.lock b/Cargo.lock index f553120ff..30e17c4f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -701,6 +701,16 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +[[package]] +name = "e2e-tests" +version = "0.1.0" +dependencies = [ + "async-trait", + "ethers", + "eyre", + "tokio", +] + [[package]] name = "ecdsa" version = "0.16.9" @@ -1641,16 +1651,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "integration" -version = "0.1.0" -dependencies = [ - "async-trait", - "ethers", - "eyre", - "tokio", -] - [[package]] name = "ipnet" version = "2.9.0" diff --git a/Cargo.toml b/Cargo.toml index 694fb9727..44c6d0efd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,26 +1,26 @@ [workspace] members = [ - "contracts", - "lib/crypto", - "lib/grip", - "lib/grip-proc", - "examples/erc20", - "examples/erc721", - "examples/merkle-proofs", - "examples/ownable", - "examples/access-control", - "integration", + "contracts", + "lib/crypto", + "lib/grip", + "lib/grip-proc", + "examples/erc20", + "examples/erc721", + "examples/merkle-proofs", + "examples/ownable", + "examples/access-control", + "e2e-tests", ] default-members = [ - "contracts", - "lib/crypto", - "lib/grip", - "lib/grip-proc", - "examples/erc20", - "examples/erc721", - "examples/merkle-proofs", - "examples/access-control", - "examples/ownable", + "contracts", + "lib/crypto", + "lib/grip", + "lib/grip-proc", + "examples/erc20", + "examples/erc721", + "examples/merkle-proofs", + "examples/access-control", + "examples/ownable", ] # Explicitly set the resolver to version 2, which is the default for packages # with edition >= 2021. diff --git a/integration/Cargo.toml b/e2e-tests/Cargo.toml similarity index 93% rename from integration/Cargo.toml rename to e2e-tests/Cargo.toml index 97f6f67e8..947d4223d 100644 --- a/integration/Cargo.toml +++ b/e2e-tests/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "integration" +name = "e2e-tests" version = "0.1.0" authors.workspace = true edition.workspace = true diff --git a/integration/README.md b/e2e-tests/README.md similarity index 100% rename from integration/README.md rename to e2e-tests/README.md diff --git a/integration/src/erc20.rs b/e2e-tests/src/erc20.rs similarity index 100% rename from integration/src/erc20.rs rename to e2e-tests/src/erc20.rs diff --git a/integration/src/erc721.rs b/e2e-tests/src/erc721.rs similarity index 100% rename from integration/src/erc721.rs rename to e2e-tests/src/erc721.rs diff --git a/integration/src/infrastructure/erc20.rs b/e2e-tests/src/infrastructure/erc20.rs similarity index 100% rename from integration/src/infrastructure/erc20.rs rename to e2e-tests/src/infrastructure/erc20.rs diff --git a/integration/src/infrastructure/erc721.rs b/e2e-tests/src/infrastructure/erc721.rs similarity index 100% rename from integration/src/infrastructure/erc721.rs rename to e2e-tests/src/infrastructure/erc721.rs diff --git a/integration/src/infrastructure/mod.rs b/e2e-tests/src/infrastructure/mod.rs similarity index 100% rename from integration/src/infrastructure/mod.rs rename to e2e-tests/src/infrastructure/mod.rs diff --git a/integration/src/lib.rs b/e2e-tests/src/lib.rs similarity index 100% rename from integration/src/lib.rs rename to e2e-tests/src/lib.rs diff --git a/integration/test.sh b/e2e-tests/test.sh similarity index 100% rename from integration/test.sh rename to e2e-tests/test.sh From cf869133979df543de0ee1af76031f92425d378a Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 16:59:30 +0400 Subject: [PATCH 48/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- e2e-tests/README.md | 6 +++--- e2e-tests/src/infrastructure/mod.rs | 2 +- e2e-tests/test.sh | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index ab2f2bfdc..f36df41ef 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -67,4 +67,4 @@ jobs: ./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000 - name: run integration tests - run: ./integration/test.sh \ No newline at end of file + run: ./e2e-tests/test.sh \ No newline at end of file diff --git a/e2e-tests/README.md b/e2e-tests/README.md index 5a668d02f..591567518 100644 --- a/e2e-tests/README.md +++ b/e2e-tests/README.md @@ -24,7 +24,7 @@ this [guide](https://github.com/OffchainLabs/nitro-testnode/blob/release/README. Run integration testing command: ```terminal - ./integration/test.sh + ./e2e-tests/test.sh ``` ### Against stylus dev net @@ -37,14 +37,14 @@ Run this command: ALICE_PRIV_KEY=0x... \ BOB_PRIV_KEY=0x... \ RPC_URL=https://stylus-testnet.arbitrum.io/rpc \ - ./integration/test.sh + ./e2e-tests//test.sh ``` ## Add test for the new contract Assuming that contract associated crate exists at `./examples` directory with the crate name `erc20-example`. -Add ethereum contracts to `./integration/src/infrastructure` directory like: +Add ethereum contracts to `./e2e-tests//src/infrastructure` directory like: ```rust ethers::contract::abigen!( diff --git a/e2e-tests/src/infrastructure/mod.rs b/e2e-tests/src/infrastructure/mod.rs index cfddfc4df..faffd1855 100644 --- a/e2e-tests/src/infrastructure/mod.rs +++ b/e2e-tests/src/infrastructure/mod.rs @@ -101,7 +101,7 @@ pub trait Contract { /// /// # Example /// ``` -/// use integration::{link_to_crate, infrastructure::HttpMiddleware}; +/// use e2e-tests::{link_to_crate, infrastructure::HttpMiddleware}; /// use ethers::contract::abigen; /// /// abigen!( diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index 2cf57c617..d8908016d 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -57,4 +57,4 @@ do done # TODO: run tests in parallel when concurrency scope will be per test/contract -RUST_TEST_THREADS=1 cargo test -p integration \ No newline at end of file +RUST_TEST_THREADS=1 cargo test -p e2e-tests \ No newline at end of file From 14fde20c6994aa2b8d2d15d2f3c491ccce7ee995 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 22:04:00 +0400 Subject: [PATCH 49/87] ++ --- .github/workflows/check.yml | 6 +++--- .github/workflows/e2e-tests.yml | 2 +- .github/workflows/nostd.yml | 6 +++--- .github/workflows/test.yml | 12 ++++++------ Cargo.lock | 1 + Cargo.toml | 13 +------------ e2e-tests/Cargo.toml | 6 ++++++ e2e-tests/src/infrastructure/erc20.rs | 2 +- e2e-tests/src/infrastructure/erc721.rs | 2 +- e2e-tests/src/infrastructure/mod.rs | 3 ++- e2e-tests/src/lib.rs | 10 +++++++--- e2e-tests/test.sh | 4 ++-- 12 files changed, 34 insertions(+), 33 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 61995b7ef..057f5cd7c 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -13,7 +13,7 @@ permissions: # main branch ensures that the PR only gets built once. on: push: - branches: [main] + branches: [ main ] pull_request: # If new code is pushed to a PR branch, then cancel in progress workflows for # that PR. Ensures that we don't waste CI time, and returns results quicker. @@ -50,7 +50,7 @@ jobs: matrix: # Get early warning of new lints which are regularly introduced in beta # channels. - toolchain: [stable, beta] + toolchain: [ stable, beta ] steps: - uses: actions/checkout@v4 with: @@ -79,7 +79,7 @@ jobs: - name: Install nightly uses: dtolnay/rust-toolchain@nightly - name: cargo doc - run: cargo doc --no-deps --all-features + run: cargo doc --workspace --no-deps --all-features env: RUSTDOCFLAGS: --cfg docsrs hack: diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index f36df41ef..b5ba794ef 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -54,7 +54,7 @@ jobs: run: | # clone nitro test node repo git clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git && cd nitro-testnode - git reset --hard f5ac2b2271b59827915258471bdf99a1426b5671 + git reset --hard 1886f4b89f5c20fd5b0c2cf3d08a009ee73e45ca # setup nitro test node ./test-node.bash --no-run --init --no-tokenbridge diff --git a/.github/workflows/nostd.yml b/.github/workflows/nostd.yml index bc79972cd..7f98f9b64 100644 --- a/.github/workflows/nostd.yml +++ b/.github/workflows/nostd.yml @@ -6,7 +6,7 @@ permissions: contents: read on: push: - branches: [main] + branches: [ main ] pull_request: concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -19,7 +19,7 @@ jobs: name: ${{ matrix.target }} strategy: matrix: - target: [wasm32-unknown-unknown] + target: [ wasm32-unknown-unknown ] steps: - uses: actions/checkout@v4 with: @@ -29,4 +29,4 @@ jobs: - name: rustup target add ${{ matrix.target }} run: rustup target add ${{ matrix.target }} - name: cargo check - run: cargo check --release --target ${{ matrix.target }} --no-default-features --all-features + run: cargo check --release --target ${{ matrix.target }} --no-default-features --workspace --all-features diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49b3a402f..833ef48ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ permissions: contents: read on: push: - branches: [main] + branches: [ main ] paths-ignore: - "**.md" - "**.adoc" @@ -34,7 +34,7 @@ jobs: matrix: # Run on stable and beta to ensure that tests won't break on the next # version of the rust toolchain. - toolchain: [stable, beta] + toolchain: [ stable, beta ] steps: - uses: actions/checkout@v4 with: @@ -50,10 +50,10 @@ jobs: run: cargo generate-lockfile # https://twitter.com/jonhoo/status/1571290371124260865 - name: cargo test --locked - run: cargo test --locked --all-features --all-targets + run: cargo test --locked --all-features --all-targets --workspace # https://github.com/rust-lang/cargo/issues/6669 - name: cargo test --doc - run: cargo test --locked --all-features --doc + run: cargo test --locked --all-features --doc --workspace os-check: # Run cargo test on MacOS and Windows. runs-on: ${{ matrix.os }} @@ -61,7 +61,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest] + os: [ macos-latest ] # Windows fails because of `stylus-proc`. # os: [macos-latest, windows-latest] steps: @@ -74,7 +74,7 @@ jobs: if: hashFiles('Cargo.lock') == '' run: cargo generate-lockfile - name: cargo test - run: cargo test --locked --all-features --all-targets + run: cargo test --locked --all-features --all-targets --workspace coverage: # Use llvm-cov to build and collect coverage and outputs in a format that # is compatible with codecov.io. diff --git a/Cargo.lock b/Cargo.lock index 30e17c4f6..a9d2e0a20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -706,6 +706,7 @@ name = "e2e-tests" version = "0.1.0" dependencies = [ "async-trait", + "cfg-if 1.0.0", "ethers", "eyre", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 44c6d0efd..9f8a06542 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,17 +11,6 @@ members = [ "examples/access-control", "e2e-tests", ] -default-members = [ - "contracts", - "lib/crypto", - "lib/grip", - "lib/grip-proc", - "examples/erc20", - "examples/erc721", - "examples/merkle-proofs", - "examples/access-control", - "examples/ownable", -] # Explicitly set the resolver to version 2, which is the default for packages # with edition >= 2021. # https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html @@ -37,7 +26,7 @@ repository = "https://github.com/OpenZeppelin/rust-contracts-stylus" [workspace.dependencies] alloy-primitives = { version = "0.3.1", default-features = false } alloy-sol-types = { version = "0.3.1", default-features = false } -# TODO: lift stylus-sdk and stylus-proc versions once nitro test node will work +# TODO: lift stylus-sdk and stylus-proc versions once nitro test node will be compatible stylus-sdk = { version = "0.4.3", default-features = false } stylus-proc = { version = "0.4.3", default-features = false } mini-alloc = "0.4.2" diff --git a/e2e-tests/Cargo.toml b/e2e-tests/Cargo.toml index 947d4223d..dc964fa0a 100644 --- a/e2e-tests/Cargo.toml +++ b/e2e-tests/Cargo.toml @@ -8,10 +8,16 @@ keywords.workspace = true repository.workspace = true [dependencies] +cfg-if = "1.0.0" + +[dev-dependencies] tokio = { version = "1.12.0", features = ["full"] } ethers = "2.0" eyre = "0.6.8" async-trait = "0.1.80" +[features] +std = [] + [lib] doctest = false \ No newline at end of file diff --git a/e2e-tests/src/infrastructure/erc20.rs b/e2e-tests/src/infrastructure/erc20.rs index 30d550a06..40d299f06 100644 --- a/e2e-tests/src/infrastructure/erc20.rs +++ b/e2e-tests/src/infrastructure/erc20.rs @@ -1,6 +1,6 @@ use ethers::prelude::*; -use crate::{infrastructure::*, link_to_crate}; +use crate::infrastructure::*; abigen!( Erc20Token, diff --git a/e2e-tests/src/infrastructure/erc721.rs b/e2e-tests/src/infrastructure/erc721.rs index 610447c7b..5de3dedb4 100644 --- a/e2e-tests/src/infrastructure/erc721.rs +++ b/e2e-tests/src/infrastructure/erc721.rs @@ -1,6 +1,6 @@ use ethers::contract::abigen; -use crate::{infrastructure::HttpMiddleware, link_to_crate}; +use crate::infrastructure::*; abigen!( Erc721Token, diff --git a/e2e-tests/src/infrastructure/mod.rs b/e2e-tests/src/infrastructure/mod.rs index faffd1855..9cb46baee 100644 --- a/e2e-tests/src/infrastructure/mod.rs +++ b/e2e-tests/src/infrastructure/mod.rs @@ -117,7 +117,6 @@ pub trait Contract { /// pub type Erc20 = Erc20Token; /// link_to_crate!(Erc20, "erc20-example"); /// ``` -#[macro_export] macro_rules! link_to_crate { ($token_type:ty, $program_address:expr) => { impl $crate::infrastructure::Contract for $token_type { @@ -133,6 +132,8 @@ macro_rules! link_to_crate { }; } +pub(crate) use link_to_crate; + pub type HttpMiddleware = SignerMiddleware, LocalWallet>; impl Client { diff --git a/e2e-tests/src/lib.rs b/e2e-tests/src/lib.rs index 47210c5bb..d406fea3e 100644 --- a/e2e-tests/src/lib.rs +++ b/e2e-tests/src/lib.rs @@ -1,3 +1,7 @@ -mod erc20; -mod erc721; -pub mod infrastructure; +cfg_if::cfg_if! { + if #[cfg(all(test, feature = "std"))] { + mod erc20; + mod erc721; + pub mod infrastructure; + } +} diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index d8908016d..c53964b9b 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -2,7 +2,7 @@ set -o pipefail # make sure we will be running script from the project root. -mydir=$(dirname $0) +mydir=$(dirname "$0") cd "$mydir" || exit cd .. @@ -57,4 +57,4 @@ do done # TODO: run tests in parallel when concurrency scope will be per test/contract -RUST_TEST_THREADS=1 cargo test -p e2e-tests \ No newline at end of file +RUST_TEST_THREADS=1 cargo test -p e2e-tests --all-features \ No newline at end of file From 3a980312b133681d98270c44c899e98417ebaf60 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 22:23:53 +0400 Subject: [PATCH 50/87] ++ --- e2e-tests/src/erc20.rs | 2 +- e2e-tests/src/erc721.rs | 12 ++++++------ e2e-tests/src/infrastructure/mod.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/e2e-tests/src/erc20.rs b/e2e-tests/src/erc20.rs index 7f9102c8f..91af419af 100644 --- a/e2e-tests/src/erc20.rs +++ b/e2e-tests/src/erc20.rs @@ -5,7 +5,7 @@ use crate::infrastructure::{erc20::*, *}; #[tokio::test] async fn mint() -> Result<()> { - let Infrastructure { alice, bob } = Infrastructure::::new().await?; + let Context { alice, bob } = Context::::new().await?; // TODO: have a nicer support for custom constructors let _ = alice .constructor( diff --git a/e2e-tests/src/erc721.rs b/e2e-tests/src/erc721.rs index 08a17d2f7..8111dfbf1 100644 --- a/e2e-tests/src/erc721.rs +++ b/e2e-tests/src/erc721.rs @@ -5,7 +5,7 @@ use crate::infrastructure::{erc721::*, *}; #[tokio::test] async fn mint() -> Result<()> { - let Infrastructure { alice, bob } = Infrastructure::::new().await?; + let Context { alice, bob } = Context::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let owner = alice.owner_of(token_id).ctx_call().await?; @@ -18,7 +18,7 @@ async fn mint() -> Result<()> { #[tokio::test] async fn error_when_reusing_token_id() -> Result<()> { - let Infrastructure { alice, bob } = Infrastructure::::new().await?; + let Context { alice, bob } = Context::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let err = alice @@ -31,7 +31,7 @@ async fn error_when_reusing_token_id() -> Result<()> { #[tokio::test] async fn transfer() -> Result<()> { - let Infrastructure { alice, bob } = Infrastructure::::new().await?; + let Context { alice, bob } = Context::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let _ = alice @@ -45,7 +45,7 @@ async fn transfer() -> Result<()> { #[tokio::test] async fn error_when_transfer_nonexistent_token() -> Result<()> { - let Infrastructure { alice, bob } = Infrastructure::::new().await?; + let Context { alice, bob } = Context::::new().await?; let token_id = random_token_id(); let err = alice .transfer_from(alice.wallet.address(), bob.wallet.address(), token_id) @@ -57,7 +57,7 @@ async fn error_when_transfer_nonexistent_token() -> Result<()> { #[tokio::test] async fn approve_token_transfer() -> Result<()> { - let Infrastructure { alice, bob } = Infrastructure::::new().await?; + let Context { alice, bob } = Context::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let _ = alice.approve(bob.wallet.address(), token_id).ctx_send().await?; @@ -72,7 +72,7 @@ async fn approve_token_transfer() -> Result<()> { #[tokio::test] async fn error_when_transfer_unapproved_token() -> Result<()> { - let Infrastructure { alice, bob } = Infrastructure::::new().await?; + let Context { alice, bob } = Context::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let err = bob diff --git a/e2e-tests/src/infrastructure/mod.rs b/e2e-tests/src/infrastructure/mod.rs index 9cb46baee..fe1d41164 100644 --- a/e2e-tests/src/infrastructure/mod.rs +++ b/e2e-tests/src/infrastructure/mod.rs @@ -24,12 +24,12 @@ const RPC_URL: &str = "RPC_URL"; /// Integration testing infrastructure that allows to act on behalf of `Alice` /// and `Bob` accounts. -pub struct Infrastructure { +pub struct Context { pub alice: Client, pub bob: Client, } -impl Infrastructure { +impl Context { /// Constructs new instance of an integration testing infrastructure. /// /// Requires env variables `ALICE_PRIV_KEY`, `BOB_PRIV_KEY`, `RPC_URL` @@ -56,7 +56,7 @@ impl Infrastructure { let provider = Provider::::try_from(rpc_url)?; - Ok(Infrastructure { + Ok(Context { alice: Client::new( provider.clone(), program_address, From 5ddbc7be4dcc983117e12e07d6cabc9d3621d283 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Mon, 20 May 2024 23:03:21 +0400 Subject: [PATCH 51/87] ++ --- .github/workflows/check.yml | 2 +- .github/workflows/nostd.yml | 2 +- .github/workflows/test.yml | 6 +++--- Cargo.lock | 1 - Cargo.toml | 12 ++++++++++++ e2e-tests/Cargo.toml | 6 ------ e2e-tests/README.md | 2 +- e2e-tests/src/erc20.rs | 2 +- e2e-tests/src/erc721.rs | 12 ++++++------ e2e-tests/src/infrastructure/mod.rs | 8 ++++---- e2e-tests/src/lib.rs | 10 +++------- e2e-tests/test.sh | 2 +- 12 files changed, 33 insertions(+), 32 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 057f5cd7c..3b4521ba2 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -79,7 +79,7 @@ jobs: - name: Install nightly uses: dtolnay/rust-toolchain@nightly - name: cargo doc - run: cargo doc --workspace --no-deps --all-features + run: cargo doc --no-deps --all-features env: RUSTDOCFLAGS: --cfg docsrs hack: diff --git a/.github/workflows/nostd.yml b/.github/workflows/nostd.yml index 7f98f9b64..e372b1f6c 100644 --- a/.github/workflows/nostd.yml +++ b/.github/workflows/nostd.yml @@ -29,4 +29,4 @@ jobs: - name: rustup target add ${{ matrix.target }} run: rustup target add ${{ matrix.target }} - name: cargo check - run: cargo check --release --target ${{ matrix.target }} --no-default-features --workspace --all-features + run: cargo check --release --target ${{ matrix.target }} --no-default-features --all-features diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 833ef48ad..a0e282bff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,10 +50,10 @@ jobs: run: cargo generate-lockfile # https://twitter.com/jonhoo/status/1571290371124260865 - name: cargo test --locked - run: cargo test --locked --all-features --all-targets --workspace + run: cargo test --locked --all-features --all-targets # https://github.com/rust-lang/cargo/issues/6669 - name: cargo test --doc - run: cargo test --locked --all-features --doc --workspace + run: cargo test --locked --all-features --doc os-check: # Run cargo test on MacOS and Windows. runs-on: ${{ matrix.os }} @@ -74,7 +74,7 @@ jobs: if: hashFiles('Cargo.lock') == '' run: cargo generate-lockfile - name: cargo test - run: cargo test --locked --all-features --all-targets --workspace + run: cargo test --locked --all-features --all-targets coverage: # Use llvm-cov to build and collect coverage and outputs in a format that # is compatible with codecov.io. diff --git a/Cargo.lock b/Cargo.lock index a9d2e0a20..30e17c4f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -706,7 +706,6 @@ name = "e2e-tests" version = "0.1.0" dependencies = [ "async-trait", - "cfg-if 1.0.0", "ethers", "eyre", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 9f8a06542..45a687f57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,18 @@ members = [ "examples/access-control", "e2e-tests", ] +default-members = [ + "contracts", + "lib/crypto", + "lib/grip", + "lib/grip-proc", + "examples/erc20", + "examples/erc721", + "examples/merkle-proofs", + "examples/ownable", + "examples/access-control", +] + # Explicitly set the resolver to version 2, which is the default for packages # with edition >= 2021. # https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html diff --git a/e2e-tests/Cargo.toml b/e2e-tests/Cargo.toml index dc964fa0a..947d4223d 100644 --- a/e2e-tests/Cargo.toml +++ b/e2e-tests/Cargo.toml @@ -8,16 +8,10 @@ keywords.workspace = true repository.workspace = true [dependencies] -cfg-if = "1.0.0" - -[dev-dependencies] tokio = { version = "1.12.0", features = ["full"] } ethers = "2.0" eyre = "0.6.8" async-trait = "0.1.80" -[features] -std = [] - [lib] doctest = false \ No newline at end of file diff --git a/e2e-tests/README.md b/e2e-tests/README.md index 591567518..cb9b2f281 100644 --- a/e2e-tests/README.md +++ b/e2e-tests/README.md @@ -68,5 +68,5 @@ link_to_crate!(Erc20, "erc20-example"); Tests should create new infrastructure instance like this: ```rust -let infra = Infrastructure::::new().await?; +let context = E2EContext::::new().await?; ``` \ No newline at end of file diff --git a/e2e-tests/src/erc20.rs b/e2e-tests/src/erc20.rs index 91af419af..2065b9912 100644 --- a/e2e-tests/src/erc20.rs +++ b/e2e-tests/src/erc20.rs @@ -5,7 +5,7 @@ use crate::infrastructure::{erc20::*, *}; #[tokio::test] async fn mint() -> Result<()> { - let Context { alice, bob } = Context::::new().await?; + let E2EContext { alice, bob } = E2EContext::::new().await?; // TODO: have a nicer support for custom constructors let _ = alice .constructor( diff --git a/e2e-tests/src/erc721.rs b/e2e-tests/src/erc721.rs index 8111dfbf1..19965dfb2 100644 --- a/e2e-tests/src/erc721.rs +++ b/e2e-tests/src/erc721.rs @@ -5,7 +5,7 @@ use crate::infrastructure::{erc721::*, *}; #[tokio::test] async fn mint() -> Result<()> { - let Context { alice, bob } = Context::::new().await?; + let E2EContext { alice, bob } = E2EContext::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let owner = alice.owner_of(token_id).ctx_call().await?; @@ -18,7 +18,7 @@ async fn mint() -> Result<()> { #[tokio::test] async fn error_when_reusing_token_id() -> Result<()> { - let Context { alice, bob } = Context::::new().await?; + let E2EContext { alice, bob } = E2EContext::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let err = alice @@ -31,7 +31,7 @@ async fn error_when_reusing_token_id() -> Result<()> { #[tokio::test] async fn transfer() -> Result<()> { - let Context { alice, bob } = Context::::new().await?; + let E2EContext { alice, bob } = E2EContext::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let _ = alice @@ -45,7 +45,7 @@ async fn transfer() -> Result<()> { #[tokio::test] async fn error_when_transfer_nonexistent_token() -> Result<()> { - let Context { alice, bob } = Context::::new().await?; + let E2EContext { alice, bob } = E2EContext::::new().await?; let token_id = random_token_id(); let err = alice .transfer_from(alice.wallet.address(), bob.wallet.address(), token_id) @@ -57,7 +57,7 @@ async fn error_when_transfer_nonexistent_token() -> Result<()> { #[tokio::test] async fn approve_token_transfer() -> Result<()> { - let Context { alice, bob } = Context::::new().await?; + let E2EContext { alice, bob } = E2EContext::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let _ = alice.approve(bob.wallet.address(), token_id).ctx_send().await?; @@ -72,7 +72,7 @@ async fn approve_token_transfer() -> Result<()> { #[tokio::test] async fn error_when_transfer_unapproved_token() -> Result<()> { - let Context { alice, bob } = Context::::new().await?; + let E2EContext { alice, bob } = E2EContext::::new().await?; let token_id = random_token_id(); let _ = alice.mint(alice.wallet.address(), token_id).ctx_send().await?; let err = bob diff --git a/e2e-tests/src/infrastructure/mod.rs b/e2e-tests/src/infrastructure/mod.rs index fe1d41164..b2dcda410 100644 --- a/e2e-tests/src/infrastructure/mod.rs +++ b/e2e-tests/src/infrastructure/mod.rs @@ -22,14 +22,14 @@ const ALICE_PRIV_KEY: &str = "ALICE_PRIV_KEY"; const BOB_PRIV_KEY: &str = "BOB_PRIV_KEY"; const RPC_URL: &str = "RPC_URL"; -/// Integration testing infrastructure that allows to act on behalf of `Alice` +/// End-to-end testing context that allows to act on behalf of `Alice` /// and `Bob` accounts. -pub struct Context { +pub struct E2EContext { pub alice: Client, pub bob: Client, } -impl Context { +impl E2EContext { /// Constructs new instance of an integration testing infrastructure. /// /// Requires env variables `ALICE_PRIV_KEY`, `BOB_PRIV_KEY`, `RPC_URL` @@ -56,7 +56,7 @@ impl Context { let provider = Provider::::try_from(rpc_url)?; - Ok(Context { + Ok(E2EContext { alice: Client::new( provider.clone(), program_address, diff --git a/e2e-tests/src/lib.rs b/e2e-tests/src/lib.rs index d406fea3e..47210c5bb 100644 --- a/e2e-tests/src/lib.rs +++ b/e2e-tests/src/lib.rs @@ -1,7 +1,3 @@ -cfg_if::cfg_if! { - if #[cfg(all(test, feature = "std"))] { - mod erc20; - mod erc721; - pub mod infrastructure; - } -} +mod erc20; +mod erc721; +pub mod infrastructure; diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index c53964b9b..87daac28f 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -57,4 +57,4 @@ do done # TODO: run tests in parallel when concurrency scope will be per test/contract -RUST_TEST_THREADS=1 cargo test -p e2e-tests --all-features \ No newline at end of file +RUST_TEST_THREADS=1 cargo test -p e2e-tests \ No newline at end of file From 641b153b92c54dbb76d09c16ae4faf1cc7504b29 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 21 May 2024 17:19:30 +0400 Subject: [PATCH 52/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b5ba794ef..965f1e709 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -45,7 +45,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu - toolchain: 1.77.0 + toolchain: 1.75.0 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From 5ee3fb671107cee6980f6767c2583d4c652d6412 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Tue, 21 May 2024 17:55:20 +0400 Subject: [PATCH 53/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- examples/erc721/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 965f1e709..b5ba794ef 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -45,7 +45,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu - toolchain: 1.75.0 + toolchain: 1.77.0 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 diff --git a/examples/erc721/src/lib.rs b/examples/erc721/src/lib.rs index 9a85102ac..bc739ade4 100644 --- a/examples/erc721/src/lib.rs +++ b/examples/erc721/src/lib.rs @@ -3,7 +3,7 @@ extern crate alloc; use alloc::string::{String, ToString}; -use alloy_primitives::{U256, Address}; +use alloy_primitives::{Address, U256}; use contracts::erc721::{ extensions::{ERC721Metadata, ERC721UriStorage}, ERC721, From 2b2698a22c3b884efe529f27dd9a9c1a1acbf392 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 22 May 2024 17:31:57 +0400 Subject: [PATCH 54/87] fix erc721 exceeding wasm binary size --- e2e-tests/test.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index 87daac28f..551007a39 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -16,9 +16,18 @@ deploy_contract () { echo "Deploying contract $CONTRACT_CRATE_NAME." - DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e "$RPC_URL" --private-key "$PRIVATE_KEY") || exit $? + DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e "$RPC_URL" --private-key "$PRIVATE_KEY" --nightly) || exit $? - echo "Contract $CONTRACT_CRATE_NAME successfully deployed to the stylus environment ($RPC_URL)." + # extract compressed wasm binary size + # NOTE: optimistically relying on the 'Compressed WASM size to be deployed onchain' string in output + WASM_BIN_SIZE="$(echo "$DEPLOY_OUTPUT" | grep 'Compressed WASM size to be deployed onchain' | grep -oE "\d*\.\d* KB")" + + if [[ -z "$WASM_BIN_SIZE" ]] + then + echo "Contract $CONTRACT_CRATE_NAME successfully deployed to the stylus environment ($RPC_URL)." + else + echo "Contract $CONTRACT_CRATE_NAME successfully deployed to the stylus environment ($RPC_URL). Wasm binary size is $WASM_BIN_SIZE" + fi # extract randomly created contract deployment address # NOTE: optimistically relying on the 'Deploying program to address' string in output @@ -48,7 +57,7 @@ export ALICE_PRIV_KEY=${ALICE_PRIV_KEY:-0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31 export BOB_PRIV_KEY=${BOB_PRIV_KEY:-0xa038232e463efa8ad57de6f88cd3c68ed64d1981daff2dcc015bce7eaf53db9d} export RPC_URL=${RPC_URL:-http://localhost:8547} -cargo build --release --target wasm32-unknown-unknown +cargo +nightly build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort # TODO: deploy contracts asynchronously for CRATE_NAME in $(get_example_crate_names) From 5989f49168f9ca97fb7447613186dfdfafc8aa5b Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 22 May 2024 18:40:03 +0400 Subject: [PATCH 55/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- e2e-tests/test.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b5ba794ef..b42333a9b 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -44,7 +44,7 @@ jobs: - name: set up rust uses: dtolnay/rust-toolchain@stable with: - target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu + target: wasm32-unknown-unknown, nightly-wasm32-unknown-unknown, x86_64-unknown-linux-gnu, nightly-x86_64-unknown-linux-gnu toolchain: 1.77.0 - name: install cargo-stylus diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index 551007a39..300f524d4 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -19,8 +19,8 @@ deploy_contract () { DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e "$RPC_URL" --private-key "$PRIVATE_KEY" --nightly) || exit $? # extract compressed wasm binary size - # NOTE: optimistically relying on the 'Compressed WASM size to be deployed onchain' string in output - WASM_BIN_SIZE="$(echo "$DEPLOY_OUTPUT" | grep 'Compressed WASM size to be deployed onchain' | grep -oE "\d*\.\d* KB")" + # NOTE: optimistically relying on the 'Compressed WASM size' string in output + WASM_BIN_SIZE="$(echo "$DEPLOY_OUTPUT" | grep 'Compressed WASM size' | grep -oE "\d*\.\d* KB")" if [[ -z "$WASM_BIN_SIZE" ]] then From cc2fd3a7cbf904dc11fb802ba0b42cec391148df Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 22 May 2024 18:45:55 +0400 Subject: [PATCH 56/87] ++ --- .github/workflows/e2e-tests.yml | 4 ++-- e2e-tests/test.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b42333a9b..65f3458fe 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,9 +42,9 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@nightly with: - target: wasm32-unknown-unknown, nightly-wasm32-unknown-unknown, x86_64-unknown-linux-gnu, nightly-x86_64-unknown-linux-gnu + target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu toolchain: 1.77.0 - name: install cargo-stylus diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index 300f524d4..600df5b3b 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -66,4 +66,4 @@ do done # TODO: run tests in parallel when concurrency scope will be per test/contract -RUST_TEST_THREADS=1 cargo test -p e2e-tests \ No newline at end of file +RUST_TEST_THREADS=1 cargo +stable test -p e2e-tests \ No newline at end of file From d425626f7632d04a9b09d20371b1af7f8e52e023 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 22 May 2024 19:00:40 +0400 Subject: [PATCH 57/87] ++ --- .github/workflows/e2e-tests.yml | 3 +-- e2e-tests/test.sh | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 65f3458fe..6a4074d5f 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,10 +42,9 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@nightly-2024-01-01 with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu - toolchain: 1.77.0 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index 600df5b3b..6b87b1436 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -19,8 +19,8 @@ deploy_contract () { DEPLOY_OUTPUT=$(cargo stylus deploy --wasm-file-path ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" -e "$RPC_URL" --private-key "$PRIVATE_KEY" --nightly) || exit $? # extract compressed wasm binary size - # NOTE: optimistically relying on the 'Compressed WASM size' string in output - WASM_BIN_SIZE="$(echo "$DEPLOY_OUTPUT" | grep 'Compressed WASM size' | grep -oE "\d*\.\d* KB")" + # NOTE: optimistically relying on the 'Compressed WASM size to be deployed' string in output + WASM_BIN_SIZE="$(echo "$DEPLOY_OUTPUT" | grep 'Compressed WASM size to be deployed' | grep -oE "[0-9]*\.[0-9]* KB")" if [[ -z "$WASM_BIN_SIZE" ]] then From 941a1d6680e852c7cce6c2d83794a80a4cafa8fe Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 22 May 2024 19:03:54 +0400 Subject: [PATCH 58/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 6a4074d5f..180a955d0 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,7 +42,7 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@nightly-2024-01-01 + uses: dtolnay/rust-toolchain@nightly-2024-05-21 with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu From 1244f291b65d35a9ad056ce1ce63a3878e59e422 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 22 May 2024 19:06:49 +0400 Subject: [PATCH 59/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 180a955d0..d0cc7e362 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,7 +42,7 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@nightly-2024-05-21 + uses: dtolnay/rust-toolchain@1.77.0 with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu From 5c4f5882d32626cb0540931ee8dc50e23420cdc0 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 22 May 2024 19:23:16 +0400 Subject: [PATCH 60/87] ++ --- e2e-tests/README.md | 2 +- e2e-tests/src/{infrastructure => context}/erc20.rs | 2 +- e2e-tests/src/{infrastructure => context}/erc721.rs | 2 +- e2e-tests/src/{infrastructure => context}/mod.rs | 2 +- e2e-tests/src/erc20.rs | 2 +- e2e-tests/src/erc721.rs | 2 +- e2e-tests/src/lib.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) rename e2e-tests/src/{infrastructure => context}/erc20.rs (97%) rename e2e-tests/src/{infrastructure => context}/erc721.rs (98%) rename e2e-tests/src/{infrastructure => context}/mod.rs (99%) diff --git a/e2e-tests/README.md b/e2e-tests/README.md index cb9b2f281..53986ec99 100644 --- a/e2e-tests/README.md +++ b/e2e-tests/README.md @@ -44,7 +44,7 @@ Run this command: Assuming that contract associated crate exists at `./examples` directory with the crate name `erc20-example`. -Add ethereum contracts to `./e2e-tests//src/infrastructure` directory like: +Add ethereum contracts to `./e2e-tests/src/context` directory like: ```rust ethers::contract::abigen!( diff --git a/e2e-tests/src/infrastructure/erc20.rs b/e2e-tests/src/context/erc20.rs similarity index 97% rename from e2e-tests/src/infrastructure/erc20.rs rename to e2e-tests/src/context/erc20.rs index 40d299f06..24577fece 100644 --- a/e2e-tests/src/infrastructure/erc20.rs +++ b/e2e-tests/src/context/erc20.rs @@ -1,6 +1,6 @@ use ethers::prelude::*; -use crate::infrastructure::*; +use crate::context::*; abigen!( Erc20Token, diff --git a/e2e-tests/src/infrastructure/erc721.rs b/e2e-tests/src/context/erc721.rs similarity index 98% rename from e2e-tests/src/infrastructure/erc721.rs rename to e2e-tests/src/context/erc721.rs index 5de3dedb4..75a17c4b4 100644 --- a/e2e-tests/src/infrastructure/erc721.rs +++ b/e2e-tests/src/context/erc721.rs @@ -1,6 +1,6 @@ use ethers::contract::abigen; -use crate::infrastructure::*; +use crate::context::*; abigen!( Erc721Token, diff --git a/e2e-tests/src/infrastructure/mod.rs b/e2e-tests/src/context/mod.rs similarity index 99% rename from e2e-tests/src/infrastructure/mod.rs rename to e2e-tests/src/context/mod.rs index b2dcda410..a0184cfcb 100644 --- a/e2e-tests/src/infrastructure/mod.rs +++ b/e2e-tests/src/context/mod.rs @@ -119,7 +119,7 @@ pub trait Contract { /// ``` macro_rules! link_to_crate { ($token_type:ty, $program_address:expr) => { - impl $crate::infrastructure::Contract for $token_type { + impl $crate::context::Contract for $token_type { const CRATE_NAME: &'static str = $program_address; fn new( diff --git a/e2e-tests/src/erc20.rs b/e2e-tests/src/erc20.rs index 2065b9912..ed87c43d0 100644 --- a/e2e-tests/src/erc20.rs +++ b/e2e-tests/src/erc20.rs @@ -1,7 +1,7 @@ use ethers::prelude::*; use eyre::Result; -use crate::infrastructure::{erc20::*, *}; +use crate::context::{erc20::*, *}; #[tokio::test] async fn mint() -> Result<()> { diff --git a/e2e-tests/src/erc721.rs b/e2e-tests/src/erc721.rs index 19965dfb2..674c88285 100644 --- a/e2e-tests/src/erc721.rs +++ b/e2e-tests/src/erc721.rs @@ -1,7 +1,7 @@ use ethers::prelude::*; use eyre::Result; -use crate::infrastructure::{erc721::*, *}; +use crate::context::{erc721::*, *}; #[tokio::test] async fn mint() -> Result<()> { diff --git a/e2e-tests/src/lib.rs b/e2e-tests/src/lib.rs index 47210c5bb..33db6aaa7 100644 --- a/e2e-tests/src/lib.rs +++ b/e2e-tests/src/lib.rs @@ -1,3 +1,3 @@ mod erc20; mod erc721; -pub mod infrastructure; +pub mod context; From 93acbf0d4ca0d2316a4442efa05c21aa29d8419c Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 22 May 2024 19:24:18 +0400 Subject: [PATCH 61/87] ++ --- e2e-tests/src/context/mod.rs | 4 ++-- e2e-tests/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-tests/src/context/mod.rs b/e2e-tests/src/context/mod.rs index a0184cfcb..26e617dd6 100644 --- a/e2e-tests/src/context/mod.rs +++ b/e2e-tests/src/context/mod.rs @@ -30,7 +30,7 @@ pub struct E2EContext { } impl E2EContext { - /// Constructs new instance of an integration testing infrastructure. + /// Constructs new instance of an integration testing context. /// /// Requires env variables `ALICE_PRIV_KEY`, `BOB_PRIV_KEY`, `RPC_URL` /// and _DEPLOYMENT_ADDRESS @@ -101,7 +101,7 @@ pub trait Contract { /// /// # Example /// ``` -/// use e2e-tests::{link_to_crate, infrastructure::HttpMiddleware}; +/// use e2e-tests::{link_to_crate, context::HttpMiddleware}; /// use ethers::contract::abigen; /// /// abigen!( diff --git a/e2e-tests/src/lib.rs b/e2e-tests/src/lib.rs index 33db6aaa7..0be245e6e 100644 --- a/e2e-tests/src/lib.rs +++ b/e2e-tests/src/lib.rs @@ -1,3 +1,3 @@ +pub mod context; mod erc20; mod erc721; -pub mod context; From b9be1e5536999516047794df7d22f83c9ff4b6d4 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 13:18:05 +0400 Subject: [PATCH 62/87] ++ --- e2e-tests/src/context/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-tests/src/context/mod.rs b/e2e-tests/src/context/mod.rs index 26e617dd6..81d4916af 100644 --- a/e2e-tests/src/context/mod.rs +++ b/e2e-tests/src/context/mod.rs @@ -196,7 +196,7 @@ impl ContextCall for ContractCall { async fn ctx_call(self) -> Result { - let function_name = self.function.name.clone(); + let function_name = &self.function.name; self.call().await.context(format!("call {function_name}")) } } @@ -212,7 +212,7 @@ pub trait ContextSend { #[async_trait] impl ContextSend for ContractCall { async fn ctx_send(self) -> Result { - let function_name = self.function.name.clone(); + let function_name = &self.function.name; self.send() .await .context(format!("send {function_name}"))? From b8b7d026200e930be1cdc310fbe5ffd8af2765f0 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 13:19:40 +0400 Subject: [PATCH 63/87] ++ --- e2e-tests/src/context/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-tests/src/context/mod.rs b/e2e-tests/src/context/mod.rs index 81d4916af..30ec75f0d 100644 --- a/e2e-tests/src/context/mod.rs +++ b/e2e-tests/src/context/mod.rs @@ -75,7 +75,6 @@ pub struct Client { pub contract: T, } -// Allows not to mention `contract` property every time we call a function. impl Deref for Client { type Target = T; From c32ccbde7604827b4ec2452ac19239d7f7724e43 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 13:22:45 +0400 Subject: [PATCH 64/87] ++ --- e2e-tests/src/context/erc721.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-tests/src/context/erc721.rs b/e2e-tests/src/context/erc721.rs index 75a17c4b4..02e0afdd2 100644 --- a/e2e-tests/src/context/erc721.rs +++ b/e2e-tests/src/context/erc721.rs @@ -1,4 +1,4 @@ -use ethers::contract::abigen; +use ethers::prelude::*; use crate::context::*; From 51c106246a1ed9f397f324412d4435d359d65022 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 13:24:55 +0400 Subject: [PATCH 65/87] ++ --- e2e-tests/src/context/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-tests/src/context/mod.rs b/e2e-tests/src/context/mod.rs index 30ec75f0d..cb11986c7 100644 --- a/e2e-tests/src/context/mod.rs +++ b/e2e-tests/src/context/mod.rs @@ -117,7 +117,7 @@ pub trait Contract { /// link_to_crate!(Erc20, "erc20-example"); /// ``` macro_rules! link_to_crate { - ($token_type:ty, $program_address:expr) => { + ($token_type: ty, $program_address: literal) => { impl $crate::context::Contract for $token_type { const CRATE_NAME: &'static str = $program_address; From 8ad936fec802bc97bdce27de5b761055a91bd767 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 13:26:34 +0400 Subject: [PATCH 66/87] ++ --- e2e-tests/src/context/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-tests/src/context/mod.rs b/e2e-tests/src/context/mod.rs index cb11986c7..a6175c843 100644 --- a/e2e-tests/src/context/mod.rs +++ b/e2e-tests/src/context/mod.rs @@ -117,7 +117,7 @@ pub trait Contract { /// link_to_crate!(Erc20, "erc20-example"); /// ``` macro_rules! link_to_crate { - ($token_type: ty, $program_address: literal) => { + ($token_type:ty, $program_address:literal) => { impl $crate::context::Contract for $token_type { const CRATE_NAME: &'static str = $program_address; From 16c9e285de8320dc4e17f3430bf8101edad46f38 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 13:32:55 +0400 Subject: [PATCH 67/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index d0cc7e362..f3e3cd8d9 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,7 +1,7 @@ name: e2e-tests # This workflow runs our end-to-end tests suite. # -# It roughly follows this steps: +# It roughly follows these steps: # - A local `nitro-testnode` gets spun up. # - Contracts get deployed to the local node. # - A few addresses get funded. From e9a75b7516a63b5f63efd66dbef70c3905ffd404 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 14:27:04 +0400 Subject: [PATCH 68/87] ++ --- e2e-tests/test.sh | 7 ++++--- examples/erc721/src/lib.rs | 8 ++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index 6b87b1436..633aadcf0 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -o pipefail +set -e # make sure we will be running script from the project root. mydir=$(dirname "$0") @@ -47,10 +47,11 @@ deploy_contract () { set +a } -# Retrieve all contract's crate names in `./examples` directory. +# Retrieve all alphanumeric contract's crate names in `./examples` directory. get_example_crate_names () { + # shellcheck disable=SC2038 # NOTE: optimistically relying on the 'name = ' string at Cargo.toml file - find ./examples -type f -print0 -name "Cargo.toml" | xargs -0 grep 'name = ' | grep -oE '".*"' | tr -d "'\"" + find ./examples -type f -name "Cargo.toml" | xargs grep 'name = ' | grep -oE '".*"' | tr -d "'\"" } export ALICE_PRIV_KEY=${ALICE_PRIV_KEY:-0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31c053d015b9fb8c9ab3298f8a2d} diff --git a/examples/erc721/src/lib.rs b/examples/erc721/src/lib.rs index ebf489cd5..3d040f5e3 100644 --- a/examples/erc721/src/lib.rs +++ b/examples/erc721/src/lib.rs @@ -49,13 +49,9 @@ impl Token { self.metadata.constructor(name, symbol, base_uri); } - pub fn mint( - &mut self, - to: Address, - token_id: U256, - ) -> Result<(), contracts::erc721::Error> { + pub fn mint(&mut self, to: Address, token_id: U256) -> Result<(), Vec> { self.pausable.when_not_paused()?; - self.erc721._mint(to, token_id) + self.erc721._mint(to, token_id).map_err(|e| e.into()) } pub fn burn(&mut self, token_id: U256) -> Result<(), Vec> { From 30dec615cb24c3eaf6e3784eda7f5ca6f5915bf0 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 14:45:40 +0400 Subject: [PATCH 69/87] ++ --- .github/workflows/e2e-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index f3e3cd8d9..961e66231 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,9 +42,10 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@1.77.0 + uses: dtolnay/rust-toolchain@master with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu + toolchain: nightly-2024-01-01 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From 3c1d0056e41ab62fd0246abb48e8a7642b260b38 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 14:59:37 +0400 Subject: [PATCH 70/87] ++ --- .github/workflows/e2e-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 961e66231..867f944cb 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,10 +42,9 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@master + uses: dtolnay/rust-toolchain@@nightly with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu - toolchain: nightly-2024-01-01 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From ed6209c5447cd982818f75e9ffaa48d1a12daf45 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 14:59:55 +0400 Subject: [PATCH 71/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 867f944cb..4ebf65d3c 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,7 +42,7 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@@nightly + uses: dtolnay/rust-toolchain@nightly with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu From e41113236639b0127cc1784762701eff7579374c Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 15:08:42 +0400 Subject: [PATCH 72/87] ++ --- .github/workflows/e2e-tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 4ebf65d3c..eb0ef7615 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,9 +42,10 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@master with: - target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu + target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu, nightly-x86_64-unknown-linux-gnu + toolchain: nightly-2024-01-01 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From be23a7af9529fe487b81cbb3bea2f0722ac1ec00 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 15:14:12 +0400 Subject: [PATCH 73/87] ++ --- .github/workflows/e2e-tests.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index eb0ef7615..c430536fe 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,10 +42,9 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@master + uses: dtolnay/rust-toolchain@nightly with: - target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu, nightly-x86_64-unknown-linux-gnu - toolchain: nightly-2024-01-01 + target: wasm32-unknown-unknown, nightly-wasm32-unknown-unknown, x86_64-unknown-linux-gnu, nightly-x86_64-unknown-linux-gnu - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From e40006157622ef83127c850e85b586ddd55e218c Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh <37006439+qalisander@users.noreply.github.com> Date: Thu, 23 May 2024 15:44:18 +0400 Subject: [PATCH 74/87] Update e2e-tests/src/context/mod.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander González --- e2e-tests/src/context/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-tests/src/context/mod.rs b/e2e-tests/src/context/mod.rs index a6175c843..28b268a07 100644 --- a/e2e-tests/src/context/mod.rs +++ b/e2e-tests/src/context/mod.rs @@ -38,7 +38,7 @@ impl E2EContext { /// name from the `./examples` directory. pub async fn new() -> Result { let alice_priv_key = std::env::var(ALICE_PRIV_KEY) - .with_context(|| format!("Load {} env var", ALICE_PRIV_KEY))?; + .with_context(|| format!("failed to load {} env var", ALICE_PRIV_KEY))?; let bob_priv_key = std::env::var(BOB_PRIV_KEY) .with_context(|| format!("Load {} env var", BOB_PRIV_KEY))?; let rpc_url = std::env::var(RPC_URL) From a50af55bae635ac8fa56c14f8d43da111a3b81d8 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 15:49:20 +0400 Subject: [PATCH 75/87] ++ --- e2e-tests/src/context/mod.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/e2e-tests/src/context/mod.rs b/e2e-tests/src/context/mod.rs index 28b268a07..2f86ec7d4 100644 --- a/e2e-tests/src/context/mod.rs +++ b/e2e-tests/src/context/mod.rs @@ -37,12 +37,15 @@ impl E2EContext { /// where is the "SCREAMING_SNAKE_CASE" conversion of the crate /// name from the `./examples` directory. pub async fn new() -> Result { - let alice_priv_key = std::env::var(ALICE_PRIV_KEY) - .with_context(|| format!("failed to load {} env var", ALICE_PRIV_KEY))?; - let bob_priv_key = std::env::var(BOB_PRIV_KEY) - .with_context(|| format!("Load {} env var", BOB_PRIV_KEY))?; + let alice_priv_key = + std::env::var(ALICE_PRIV_KEY).with_context(|| { + format!("failed to load {} env var", ALICE_PRIV_KEY) + })?; + let bob_priv_key = std::env::var(BOB_PRIV_KEY).with_context(|| { + format!("failed to load {} env var", BOB_PRIV_KEY) + })?; let rpc_url = std::env::var(RPC_URL) - .with_context(|| format!("Load {} env var", RPC_URL))?; + .with_context(|| format!("failed to load {} env var", RPC_URL))?; let program_address_env_name = T::CRATE_NAME .replace('-', "_") From aea120bdea76f6a484c2cdfd72419837c1a7ece3 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 15:52:14 +0400 Subject: [PATCH 76/87] ++ --- .github/workflows/e2e-tests.yml | 4 ++-- e2e-tests/test.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index c430536fe..f3e3cd8d9 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,9 +42,9 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@1.77.0 with: - target: wasm32-unknown-unknown, nightly-wasm32-unknown-unknown, x86_64-unknown-linux-gnu, nightly-x86_64-unknown-linux-gnu + target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index 633aadcf0..a856caef1 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -58,6 +58,7 @@ export ALICE_PRIV_KEY=${ALICE_PRIV_KEY:-0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31 export BOB_PRIV_KEY=${BOB_PRIV_KEY:-0xa038232e463efa8ad57de6f88cd3c68ed64d1981daff2dcc015bce7eaf53db9d} export RPC_URL=${RPC_URL:-http://localhost:8547} +rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu cargo +nightly build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort # TODO: deploy contracts asynchronously From 562d6445fbb202eb6be242f117f41722575544a6 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 15:52:36 +0400 Subject: [PATCH 77/87] ++ --- e2e-tests/src/context/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-tests/src/context/mod.rs b/e2e-tests/src/context/mod.rs index 2f86ec7d4..fe60d00af 100644 --- a/e2e-tests/src/context/mod.rs +++ b/e2e-tests/src/context/mod.rs @@ -53,7 +53,7 @@ impl E2EContext { .add("_DEPLOYMENT_ADDRESS"); let program_address: Address = std::env::var(&program_address_env_name) .with_context(|| { - format!("Load {} env var", program_address_env_name) + format!("failed to load {} env var", program_address_env_name) })? .parse()?; From fd0c1026db89b326ff59373f7d88b669cccc9ef3 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 16:01:30 +0400 Subject: [PATCH 78/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index f3e3cd8d9..4ebf65d3c 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,7 +42,7 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@1.77.0 + uses: dtolnay/rust-toolchain@nightly with: target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu From 50390422ab7a490eba3c327e31192f9409cfc546 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 16:18:17 +0400 Subject: [PATCH 79/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- e2e-tests/test.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 4ebf65d3c..39bb4759a 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -44,7 +44,7 @@ jobs: - name: set up rust uses: dtolnay/rust-toolchain@nightly with: - target: wasm32-unknown-unknown, x86_64-unknown-linux-gnu + target: wasm32-unknown-unknown, nightly-x86_64-unknown-linux-gnu - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index a856caef1..633aadcf0 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -58,7 +58,6 @@ export ALICE_PRIV_KEY=${ALICE_PRIV_KEY:-0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31 export BOB_PRIV_KEY=${BOB_PRIV_KEY:-0xa038232e463efa8ad57de6f88cd3c68ed64d1981daff2dcc015bce7eaf53db9d} export RPC_URL=${RPC_URL:-http://localhost:8547} -rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu cargo +nightly build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort # TODO: deploy contracts asynchronously From 787cd71c84b30e907b84036321d2a34a799c5fab Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 16:35:43 +0400 Subject: [PATCH 80/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 39bb4759a..b3d213356 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -44,7 +44,7 @@ jobs: - name: set up rust uses: dtolnay/rust-toolchain@nightly with: - target: wasm32-unknown-unknown, nightly-x86_64-unknown-linux-gnu + target: wasm32-unknown-unknown - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From a050b15b9d856dac75bbb230e905ab190a1ae343 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 17:03:12 +0400 Subject: [PATCH 81/87] ++ --- .github/workflows/e2e-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b3d213356..ed66493cd 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -45,6 +45,7 @@ jobs: uses: dtolnay/rust-toolchain@nightly with: target: wasm32-unknown-unknown + components: rust-src - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From 317dbd3d9d58ed607e2749077613e96ff104ccdd Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 17:23:30 +0400 Subject: [PATCH 82/87] ++ --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index ed66493cd..f1789c0af 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,7 +42,7 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@nightly-2024-01-01 with: target: wasm32-unknown-unknown components: rust-src From d8447cfde1402d7def8a009c3e9a79c0036d4910 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 17:26:38 +0400 Subject: [PATCH 83/87] ++ --- .github/workflows/e2e-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index f1789c0af..02596e261 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,10 +42,11 @@ jobs: save-always: true - name: set up rust - uses: dtolnay/rust-toolchain@nightly-2024-01-01 + uses: dtolnay/rust-toolchain@master with: target: wasm32-unknown-unknown components: rust-src + toolchain: nightly-2024-01-01 - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 From 9bf995daff2229ee9b22d3a20ae07cdf90cbf6f0 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 17:37:13 +0400 Subject: [PATCH 84/87] ++ --- .github/workflows/e2e-tests.yml | 4 +++- e2e-tests/test.sh | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 02596e261..580357562 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -68,4 +68,6 @@ jobs: ./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000 - name: run integration tests - run: ./e2e-tests/test.sh \ No newline at end of file + run: | + export NIGHTLY_TOOLCHAIN=${{steps.toolchain.outputs.name}} + ./e2e-tests/test.sh \ No newline at end of file diff --git a/e2e-tests/test.sh b/e2e-tests/test.sh index 633aadcf0..bdff0292f 100755 --- a/e2e-tests/test.sh +++ b/e2e-tests/test.sh @@ -57,8 +57,9 @@ get_example_crate_names () { export ALICE_PRIV_KEY=${ALICE_PRIV_KEY:-0x5744b91fe94e38f7cde31b0cc83e7fa1f45e31c053d015b9fb8c9ab3298f8a2d} export BOB_PRIV_KEY=${BOB_PRIV_KEY:-0xa038232e463efa8ad57de6f88cd3c68ed64d1981daff2dcc015bce7eaf53db9d} export RPC_URL=${RPC_URL:-http://localhost:8547} +NIGHTLY_TOOLCHAIN=${NIGHTLY_TOOLCHAIN:-nightly} -cargo +nightly build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort +cargo +"$NIGHTLY_TOOLCHAIN" build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort # TODO: deploy contracts asynchronously for CRATE_NAME in $(get_example_crate_names) From d8f8a762de524ac4f5b80ed6618e32d164a34505 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 17:46:08 +0400 Subject: [PATCH 85/87] ++ --- .github/workflows/e2e-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 580357562..b669cff4d 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -47,6 +47,8 @@ jobs: target: wasm32-unknown-unknown components: rust-src toolchain: nightly-2024-01-01 + + - run: export NIGHTLY_TOOLCHAIN=${{steps.toolchain.outputs.name}} - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 @@ -68,6 +70,4 @@ jobs: ./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000 - name: run integration tests - run: | - export NIGHTLY_TOOLCHAIN=${{steps.toolchain.outputs.name}} - ./e2e-tests/test.sh \ No newline at end of file + run: ./e2e-tests/test.sh \ No newline at end of file From 05a74f22d7bc93c148bfc709ae6c9e6bf8dae1e8 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 17:51:25 +0400 Subject: [PATCH 86/87] ++ --- .github/workflows/e2e-tests.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b669cff4d..0ada0c87c 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -43,13 +43,12 @@ jobs: - name: set up rust uses: dtolnay/rust-toolchain@master + id: toolchain with: target: wasm32-unknown-unknown components: rust-src toolchain: nightly-2024-01-01 - - run: export NIGHTLY_TOOLCHAIN=${{steps.toolchain.outputs.name}} - - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 @@ -70,4 +69,6 @@ jobs: ./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000 - name: run integration tests - run: ./e2e-tests/test.sh \ No newline at end of file + run: | + export NIGHTLY_TOOLCHAIN=${{steps.toolchain.outputs.name}} + ./e2e-tests/test.sh \ No newline at end of file From 403f90472d8e98c6cfbc59ccd07f8f52a5ccc608 Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 23 May 2024 18:22:03 +0400 Subject: [PATCH 87/87] ++ --- .github/workflows/e2e-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 0ada0c87c..8735a15d7 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -48,7 +48,7 @@ jobs: target: wasm32-unknown-unknown components: rust-src toolchain: nightly-2024-01-01 - + - name: install cargo-stylus run: RUSTFLAGS="-C link-args=-rdynamic" cargo install cargo-stylus@0.2.1 @@ -56,7 +56,7 @@ jobs: run: | # clone nitro test node repo git clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git && cd nitro-testnode - git reset --hard 1886f4b89f5c20fd5b0c2cf3d08a009ee73e45ca + git checkout 1886f4b89f5c20fd5b0c2cf3d08a009ee73e45ca # setup nitro test node ./test-node.bash --no-run --init --no-tokenbridge