diff --git a/.cargo/config.toml b/.cargo/config.toml index ccf80a40a..12c71a010 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -8,8 +8,9 @@ rustflags = [ "target-feature=+bulk-memory", ] +#TODO#q: remove -A warnings suppress flag [target.aarch64-apple-darwin] -rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"] +rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup", "-A", "warnings"] [target.x86_64-apple-darwin] rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"] diff --git a/.github/workflows/check-wasm.yml b/.github/workflows/check-wasm.yml index 1c4d33ef6..df021956b 100644 --- a/.github/workflows/check-wasm.yml +++ b/.github/workflows/check-wasm.yml @@ -27,5 +27,8 @@ jobs: - name: Install cargo-stylus run: cargo install --locked --force cargo-stylus@0.6.3 + - name: Install wasm-opt + run: cargo install wasm-opt@0.116.1 + - name: Run wasm check run: ./scripts/check-wasm.sh diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5f86d724f..d171e2af3 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -93,7 +93,7 @@ jobs: rustflags: "" - name: Cargo doc - run: cargo doc --no-deps --all-features + run: cargo doc --no-deps --features ruint env: RUSTDOCFLAGS: --cfg docsrs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d102a09e0..01ee37ee4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,7 +61,7 @@ jobs: # https://github.com/rust-lang/cargo/issues/6669 - name: Run doc tests - run: cargo test --locked --doc + run: cargo test --locked --doc -p openzeppelin-stylus -p openzeppelin-stylus-proc -p openzeppelin-crypto --features ruint os-check: # Run cargo test on MacOS and Windows. runs-on: ${{ matrix.os }} diff --git a/Cargo.lock b/Cargo.lock index 1f563d335..fdb737f49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,9 +27,9 @@ dependencies = [ [[package]] name = "adler2" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "ahash" @@ -38,7 +38,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom 0.3.3", "once_cell", "version_check", "zerocopy", @@ -61,32 +60,33 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy" -version = "0.7.3" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b0561294ccedc6181e5528b850b4579e3fbde696507baa00109bfd9054c5bb" +checksum = "36f63701831729cb154cf0b6945256af46c426074646c98b9d123148ba1d8bde" dependencies = [ - "alloy-consensus 0.7.3", + "alloy-consensus", "alloy-contract", "alloy-core", - "alloy-eips 0.7.3", + "alloy-eips", "alloy-genesis", - "alloy-json-rpc 0.7.3", - "alloy-network 0.7.3", - "alloy-provider 0.7.3", - "alloy-rpc-client 0.7.3", + "alloy-json-rpc", + "alloy-network", + "alloy-provider", + "alloy-rpc-client", "alloy-rpc-types", - "alloy-serde 0.7.3", - "alloy-signer 0.7.3", - "alloy-signer-local 0.7.3", - "alloy-transport 0.7.3", - "alloy-transport-http 0.7.3", + "alloy-serde", + "alloy-signer", + "alloy-signer-local", + "alloy-transport", + "alloy-transport-http", + "alloy-trie", ] [[package]] name = "alloy-chains" -version = "0.1.69" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28e2652684758b0d9b389d248b209ed9fd9989ef489a550265fe4bb8454fe7eb" +checksum = "ef8ff73a143281cb77c32006b04af9c047a6b8fe5860e85a88ad325328965355" dependencies = [ "alloy-primitives", "num_enum", @@ -95,91 +95,70 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a101d4d016f47f13890a74290fdd17b05dd175191d9337bc600791fb96e4dea8" -dependencies = [ - "alloy-eips 0.7.3", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.7.3", - "alloy-trie", - "auto_impl", - "c-kzg", - "derive_more", - "serde", -] - -[[package]] -name = "alloy-consensus" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69e32ef5c74bbeb1733c37f4ac7f866f8c8af208b7b4265e21af609dcac5bd5e" +checksum = "64a3bd0305a44fb457cae77de1e82856eadd42ea3cdf0dae29df32eb3b592979" dependencies = [ - "alloy-eips 0.11.1", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.11.1", + "alloy-serde", "alloy-trie", + "alloy-tx-macros", "auto_impl", "c-kzg", "derive_more", + "either", + "k256", + "once_cell", + "rand 0.8.5", + "secp256k1 0.30.0", "serde", + "serde_with", + "thiserror", ] [[package]] name = "alloy-consensus-any" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa60357dda9a3d0f738f18844bd6d0f4a5924cc5cf00bfad2ff1369897966123" -dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.7.3", - "serde", -] - -[[package]] -name = "alloy-consensus-any" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa13b7b1e1e3fedc42f0728103bfa3b4d566d3d42b606db449504d88dbdbdcf" +checksum = "7a842b4023f571835e62ac39fb8d523d19fcdbacfa70bf796ff96e7e19586f50" dependencies = [ - "alloy-consensus 0.11.1", - "alloy-eips 0.11.1", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.11.1", + "alloy-serde", "serde", ] [[package]] name = "alloy-contract" -version = "0.7.3" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2869e4fb31331d3b8c58c7db567d1e4e4e94ef64640beda3b6dd9b7045690941" +checksum = "591104333286b52b03ec4e8162983e31122b318d21ae2b0900d1e8b51727ad40" dependencies = [ + "alloy-consensus", "alloy-dyn-abi", "alloy-json-abi", - "alloy-network 0.7.3", - "alloy-network-primitives 0.7.3", + "alloy-network", + "alloy-network-primitives", "alloy-primitives", - "alloy-provider 0.7.3", - "alloy-rpc-types-eth 0.7.3", + "alloy-provider", + "alloy-rpc-types-eth", "alloy-sol-types", - "alloy-transport 0.7.3", + "alloy-transport", "futures", "futures-util", + "serde_json", "thiserror", ] [[package]] name = "alloy-core" -version = "0.8.20" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "074e41c92e2a3cc36448d4a9b94ba05b8faac466d7981d158ed68fd88e22d3b7" +checksum = "bfe6c56d58fbfa9f0f6299376e8ce33091fc6494239466814c3f54b55743cb09" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -190,15 +169,14 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.20" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2d547eba3f2d331b0e08f64a24e202f66d4f291e2a3e0073914c0e1400ced3" +checksum = "a3f56873f3cac7a2c63d8e98a4314b8311aa96adb1a0f82ae923eb2119809d2c" dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-sol-type-parser", "alloy-sol-types", - "const-hex", "itoa", "serde", "serde_json", @@ -207,107 +185,81 @@ dependencies = [ [[package]] name = "alloy-eip2124" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "675264c957689f0fd75f5993a73123c2cc3b5c235a38f5b9037fe6c826bfb2c0" +checksum = "741bdd7499908b3aa0b159bba11e71c8cddd009a2c2eb7a06e825f1ec87900a5" dependencies = [ "alloy-primitives", "alloy-rlp", "crc", + "serde", "thiserror", ] [[package]] name = "alloy-eip2930" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "serde", -] - -[[package]] -name = "alloy-eip7702" -version = "0.4.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c986539255fb839d1533c128e190e557e52ff652c9ef62939e233a81dd93f7e" +checksum = "7b82752a889170df67bbb36d42ca63c531eb16274f0d7299ae2a680facba17bd" dependencies = [ "alloy-primitives", "alloy-rlp", - "derive_more", "serde", ] [[package]] name = "alloy-eip7702" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b15b13d38b366d01e818fe8e710d4d702ef7499eacd44926a06171dd9585d0c" +checksum = "9d4769c6ffddca380b0070d71c8b7f30bed375543fe76bb2f74ec0acf4b7cd16" dependencies = [ "alloy-primitives", "alloy-rlp", - "k256", "serde", "thiserror", ] [[package]] name = "alloy-eips" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6755b093afef5925f25079dd5a7c8d096398b804ba60cb5275397b06b31689" -dependencies = [ - "alloy-eip2930", - "alloy-eip7702 0.4.2", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.7.3", - "c-kzg", - "derive_more", - "once_cell", - "serde", - "sha2", -] - -[[package]] -name = "alloy-eips" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5591581ca2ab0b3e7226a4047f9a1bfcf431da1d0cce3752fda609fea3c27e37" +checksum = "5cd749c57f38f8cbf433e651179fc5a676255e6b95044f467d49255d2b81725a" dependencies = [ "alloy-eip2124", "alloy-eip2930", - "alloy-eip7702 0.5.1", + "alloy-eip7702", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.11.1", + "alloy-serde", "auto_impl", "c-kzg", "derive_more", - "once_cell", + "either", "serde", - "sha2", + "serde_with", + "sha2 0.10.9", + "thiserror", ] [[package]] name = "alloy-genesis" -version = "0.7.3" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeec8e6eab6e52b7c9f918748c9b811e87dbef7312a2e3a2ca1729a92966a6af" +checksum = "7d32cbf6c26d7d87e8a4e5925bbce41456e0bbeed95601add3443af277cd604e" dependencies = [ + "alloy-eips", "alloy-primitives", - "alloy-serde 0.7.3", + "alloy-serde", "alloy-trie", "serde", + "serde_with", ] [[package]] name = "alloy-json-abi" -version = "0.8.20" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d62cf1b25f5a50ca2d329b0b4aeb0a0dedeaf225ad3c5099d83b1a4c4616186e" +checksum = "125a1c373261b252e53e04d6e92c37d881833afc1315fceab53fd46045695640" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -317,26 +269,13 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fa077efe0b834bcd89ff4ba547f48fb081e4fdc3673dd7da1b295a2cf2bb7b7" -dependencies = [ - "alloy-primitives", - "alloy-sol-types", - "serde", - "serde_json", - "thiserror", - "tracing", -] - -[[package]] -name = "alloy-json-rpc" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "762414662d793d7aaa36ee3af6928b6be23227df1681ce9c039f6f11daadef64" +checksum = "f614019a029c8fec14ae661aa7d4302e6e66bdbfb869dab40e78dcfba935fc97" dependencies = [ "alloy-primitives", "alloy-sol-types", + "http", "serde", "serde_json", "thiserror", @@ -345,48 +284,24 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209a1882a08e21aca4aac6e2a674dc6fcf614058ef8cb02947d63782b1899552" -dependencies = [ - "alloy-consensus 0.7.3", - "alloy-consensus-any 0.7.3", - "alloy-eips 0.7.3", - "alloy-json-rpc 0.7.3", - "alloy-network-primitives 0.7.3", - "alloy-primitives", - "alloy-rpc-types-any 0.7.3", - "alloy-rpc-types-eth 0.7.3", - "alloy-serde 0.7.3", - "alloy-signer 0.7.3", - "alloy-sol-types", - "async-trait", - "auto_impl", - "futures-utils-wasm", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "alloy-network" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be03f2ebc00cf88bd06d3c6caf387dceaa9c7e6b268216779fa68a9bf8ab4e6" +checksum = "be8b6d58e98803017bbfea01dde96c4d270a29e7aed3beb65c8d28b5ab464e0e" dependencies = [ - "alloy-consensus 0.11.1", - "alloy-consensus-any 0.11.1", - "alloy-eips 0.11.1", - "alloy-json-rpc 0.11.1", - "alloy-network-primitives 0.11.1", + "alloy-consensus", + "alloy-consensus-any", + "alloy-eips", + "alloy-json-rpc", + "alloy-network-primitives", "alloy-primitives", - "alloy-rpc-types-any 0.11.1", - "alloy-rpc-types-eth 0.11.1", - "alloy-serde 0.11.1", - "alloy-signer 0.11.1", + "alloy-rpc-types-any", + "alloy-rpc-types-eth", + "alloy-serde", + "alloy-signer", "alloy-sol-types", "async-trait", "auto_impl", + "derive_more", "futures-utils-wasm", "serde", "serde_json", @@ -395,54 +310,40 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20219d1ad261da7a6331c16367214ee7ded41d001fabbbd656fbf71898b2773" -dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", - "alloy-primitives", - "alloy-serde 0.7.3", - "serde", -] - -[[package]] -name = "alloy-network-primitives" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a00ce618ae2f78369918be0c20f620336381502c83b6ed62c2f7b2db27698b0" +checksum = "db489617bffe14847bf89f175b1c183e5dd7563ef84713936e2c34255cfbd845" dependencies = [ - "alloy-consensus 0.11.1", - "alloy-eips 0.11.1", + "alloy-consensus", + "alloy-eips", "alloy-primitives", - "alloy-serde 0.11.1", + "alloy-serde", "serde", ] [[package]] name = "alloy-primitives" -version = "0.8.20" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc1360603efdfba91151e623f13a4f4d3dc4af4adc1cbd90bf37c81e84db4c77" +checksum = "bc9485c56de23438127a731a6b4c87803d49faf1a7068dcd1d8768aca3a9edb9" dependencies = [ "alloy-rlp", "arbitrary", "bytes", "cfg-if", "const-hex", - "derive_arbitrary", "derive_more", "foldhash", - "getrandom 0.2.16", - "hashbrown 0.15.3", - "indexmap", + "getrandom 0.3.3", + "hashbrown 0.15.5", + "indexmap 2.11.3", "itoa", "k256", "keccak-asm", "paste", "proptest", "proptest-derive", - "rand 0.8.5", + "rand 0.9.2", "ruint", "rustc-hash", "serde", @@ -452,66 +353,31 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eefa6f4c798ad01f9b4202d02cea75f5ec11fa180502f4701e2b47965a8c0bb" -dependencies = [ - "alloy-chains", - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", - "alloy-json-rpc 0.7.3", - "alloy-network 0.7.3", - "alloy-network-primitives 0.7.3", - "alloy-primitives", - "alloy-rpc-client 0.7.3", - "alloy-rpc-types-eth 0.7.3", - "alloy-transport 0.7.3", - "alloy-transport-http 0.7.3", - "async-stream", - "async-trait", - "auto_impl", - "dashmap", - "futures", - "futures-utils-wasm", - "lru 0.12.5", - "parking_lot", - "pin-project", - "reqwest", - "schnellru", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", - "url", - "wasmtimer", -] - -[[package]] -name = "alloy-provider" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbe0a2acff0c4bd1669c71251ce10fc455cbffa1b4d0a817d5ea4ba7e5bb3db7" +checksum = "ed90278374435e076a04dbddbb6d714bdd518eb274a64dbd70f65701429dd747" dependencies = [ "alloy-chains", - "alloy-consensus 0.11.1", - "alloy-eips 0.11.1", - "alloy-json-rpc 0.11.1", - "alloy-network 0.11.1", - "alloy-network-primitives 0.11.1", + "alloy-consensus", + "alloy-eips", + "alloy-json-rpc", + "alloy-network", + "alloy-network-primitives", "alloy-primitives", - "alloy-rpc-client 0.11.1", - "alloy-rpc-types-eth 0.11.1", + "alloy-rpc-client", + "alloy-rpc-types-eth", + "alloy-signer", "alloy-sol-types", - "alloy-transport 0.11.1", - "alloy-transport-http 0.11.1", + "alloy-transport", + "alloy-transport-http", "async-stream", "async-trait", "auto_impl", "dashmap", + "either", "futures", "futures-utils-wasm", - "lru 0.13.0", + "lru", "parking_lot", "pin-project", "reqwest", @@ -543,42 +409,19 @@ checksum = "64b728d511962dda67c1bc7ea7c03736ec275ed2cf4c35d9585298ac9ccf3b73" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", -] - -[[package]] -name = "alloy-rpc-client" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed30bf1041e84cabc5900f52978ca345dd9969f2194a945e6fdec25b0620705c" -dependencies = [ - "alloy-json-rpc 0.7.3", - "alloy-primitives", - "alloy-transport 0.7.3", - "alloy-transport-http 0.7.3", - "futures", - "pin-project", - "reqwest", - "serde", - "serde_json", - "tokio", - "tokio-stream", - "tower", - "tracing", - "url", - "wasmtimer", + "syn 2.0.106", ] [[package]] name = "alloy-rpc-client" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b37cc3c7883dc41be1b01460127ad7930466d0a4bb6ba15a02ee34d2745e2d7c" +checksum = "33732242ca63f107f5f8284190244038905fb233280f4b7c41f641d4f584d40d" dependencies = [ - "alloy-json-rpc 0.11.1", + "alloy-json-rpc", "alloy-primitives", - "alloy-transport 0.11.1", - "alloy-transport-http 0.11.1", + "alloy-transport", + "alloy-transport-http", "futures", "pin-project", "reqwest", @@ -594,94 +437,53 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.7.3" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab686b0fa475d2a4f5916c5f07797734a691ec58e44f0f55d4746ea39cbcefb" +checksum = "bb2683049c5f3037d64722902e2c1081f3d45de68696aca0511bbea834905746" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 0.7.3", - "alloy-serde 0.7.3", + "alloy-rpc-types-eth", + "alloy-serde", "serde", ] [[package]] name = "alloy-rpc-types-any" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200661999b6e235d9840be5d60a6e8ae2f0af9eb2a256dd378786744660e36ec" -dependencies = [ - "alloy-consensus-any 0.7.3", - "alloy-rpc-types-eth 0.7.3", - "alloy-serde 0.7.3", -] - -[[package]] -name = "alloy-rpc-types-any" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "318ae46dd12456df42527c3b94c1ae9001e1ceb707f7afe2c7807ac4e49ebad9" -dependencies = [ - "alloy-consensus-any 0.11.1", - "alloy-rpc-types-eth 0.11.1", - "alloy-serde 0.11.1", -] - -[[package]] -name = "alloy-rpc-types-eth" -version = "0.7.3" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0600b8b5e2dc0cab12cbf91b5a885c35871789fb7b3a57b434bd4fced5b7a8b" +checksum = "18f27c0c41a16cd0af4f5dbf791f7be2a60502ca8b0e840e0ad29803fac2d587" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-consensus-any 0.7.3", - "alloy-eips 0.7.3", - "alloy-network-primitives 0.7.3", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.7.3", - "alloy-sol-types", - "derive_more", - "itertools 0.13.0", - "serde", - "serde_json", + "alloy-consensus-any", + "alloy-rpc-types-eth", + "alloy-serde", ] [[package]] name = "alloy-rpc-types-eth" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b4dbee4d82f8a22dde18c28257bed759afeae7ba73da4a1479a039fd1445d04" +checksum = "7f5812f81c3131abc2cd8953dc03c41999e180cff7252abbccaba68676e15027" dependencies = [ - "alloy-consensus 0.11.1", - "alloy-consensus-any 0.11.1", - "alloy-eips 0.11.1", - "alloy-network-primitives 0.11.1", + "alloy-consensus", + "alloy-consensus-any", + "alloy-eips", + "alloy-network-primitives", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.11.1", + "alloy-serde", "alloy-sol-types", "itertools 0.14.0", "serde", "serde_json", + "serde_with", "thiserror", ] [[package]] name = "alloy-serde" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa753a97002a33b2ccb707d9f15f31c81b8c1b786c95b73cc62bb1d1fd0c3f" -dependencies = [ - "alloy-primitives", - "serde", - "serde_json", -] - -[[package]] -name = "alloy-serde" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8732058f5ca28c1d53d241e8504620b997ef670315d7c8afab856b3e3b80d945" +checksum = "04dfe41a47805a34b848c83448946ca96f3d36842e8c074bcf8fa0870e337d12" dependencies = [ "alloy-primitives", "serde", @@ -690,23 +492,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2cbff01a673936c2efd7e00d4c0e9a4dbbd6d600e2ce298078d33efbb19cd7" -dependencies = [ - "alloy-primitives", - "async-trait", - "auto_impl", - "elliptic-curve", - "k256", - "thiserror", -] - -[[package]] -name = "alloy-signer" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f96b3526fdd779a4bd0f37319cfb4172db52a7ac24cdbb8804b72091c18e1701" +checksum = "f79237b4c1b0934d5869deea4a54e6f0a7425a8cd943a739d6293afdf893d847" dependencies = [ "alloy-primitives", "async-trait", @@ -719,30 +507,14 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6d988cb6cd7d2f428a74476515b1a6e901e08c796767f9f93311ab74005c8b" -dependencies = [ - "alloy-consensus 0.7.3", - "alloy-network 0.7.3", - "alloy-primitives", - "alloy-signer 0.7.3", - "async-trait", - "k256", - "rand 0.8.5", - "thiserror", -] - -[[package]] -name = "alloy-signer-local" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe8f78cd6b7501c7e813a1eb4a087b72d23af51f5bb66d4e948dc840bdd207d8" +checksum = "d6e90a3858da59d1941f496c17db8d505f643260f7e97cdcdd33823ddca48fc1" dependencies = [ - "alloy-consensus 0.11.1", - "alloy-network 0.11.1", + "alloy-consensus", + "alloy-network", "alloy-primitives", - "alloy-signer 0.11.1", + "alloy-signer", "async-trait", "k256", "rand 0.8.5", @@ -751,59 +523,60 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.20" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13f28f2131dc3a7b8e2cda882758ad4d5231ca26281b9861d4b18c700713e2da" +checksum = "d20d867dcf42019d4779519a1ceb55eba8d7f3d0e4f0a89bcba82b8f9eb01e48" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.20" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee2da033256a3b27131c030933eab0460a709fbcc4d4bd57bf9a5650b2441c5" +checksum = "b74e91b0b553c115d14bd0ed41898309356dc85d0e3d4b9014c4e7715e48c8ad" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", "const-hex", "heck", - "indexmap", + "indexmap 2.11.3", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.20" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9d9918b0abb632818bf27e2dfb86b209be8433baacf22100b190bbc0904bd4" +checksum = "84194d31220803f5f62d0a00f583fd3a062b36382e2bea446f1af96727754565" dependencies = [ "alloy-json-abi", "const-hex", "dunce", "heck", + "macro-string", "proc-macro2", "quote", "serde_json", - "syn 2.0.101", + "syn 2.0.106", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.25" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d162f8524adfdfb0e4bd0505c734c985f3e2474eb022af32eef0d52a4f3935c" +checksum = "fe8c27b3cf6b2bb8361904732f955bc7c05e00be5f469cec7e2280b6167f3ff0" dependencies = [ "serde", "winnow", @@ -811,46 +584,30 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.20" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f306fc801b3aa2e3c4785b7b5252ec8b19f77b30e3b75babfd23849c81bd8c" +checksum = "f5383d34ea00079e6dd89c652bcbdb764db160cef84e6250926961a0b2295d04" dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-sol-macro", - "const-hex", "serde", ] [[package]] name = "alloy-transport" -version = "0.7.3" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d69d36982b9e46075ae6b792b0f84208c6c2c15ad49f6c500304616ef67b70e0" +checksum = "cb43750e137fe3a69a325cd89a8f8e2bbf4f83e70c0f60fbe49f22511ca075e8" dependencies = [ - "alloy-json-rpc 0.7.3", - "base64", - "futures-util", - "futures-utils-wasm", - "serde", - "serde_json", - "thiserror", - "tokio", - "tower", - "tracing", - "url", - "wasmtimer", -] - -[[package]] -name = "alloy-transport" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a8d762eadce3e9b65eac09879430c6f4fce3736cac3cac123f9b1bf435ddd13" -dependencies = [ - "alloy-json-rpc 0.11.1", + "alloy-json-rpc", + "alloy-primitives", + "auto_impl", "base64", + "derive_more", + "futures", "futures-utils-wasm", + "parking_lot", "serde", "serde_json", "thiserror", @@ -863,27 +620,12 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e02ffd5d93ffc51d72786e607c97de3b60736ca3e636ead0ec1f7dce68ea3fd" -dependencies = [ - "alloy-json-rpc 0.7.3", - "alloy-transport 0.7.3", - "reqwest", - "serde_json", - "tower", - "tracing", - "url", -] - -[[package]] -name = "alloy-transport-http" -version = "0.11.1" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20819c4cb978fb39ce6ac31991ba90f386d595f922f42ef888b4a18be190713e" +checksum = "f9b42c7d8b666eed975739201f407afc3320d3cd2e4d807639c2918fc736ea67" dependencies = [ - "alloy-json-rpc 0.11.1", - "alloy-transport 0.11.1", + "alloy-json-rpc", + "alloy-transport", "reqwest", "serde_json", "tower", @@ -893,9 +635,9 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.7.9" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a94854e420f07e962f7807485856cde359ab99ab6413883e15235ad996e8b" +checksum = "e3412d52bb97c6c6cc27ccc28d4e6e8cf605469101193b50b0bd5813b1f990b5" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -907,11 +649,33 @@ dependencies = [ "tracing", ] +[[package]] +name = "alloy-tx-macros" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e434e0917dce890f755ea774f59d6f12557bc8c7dd9fa06456af80cfe0f0181e" +dependencies = [ + "alloy-primitives", + "darling 0.21.3", + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" dependencies = [ "anstyle", "anstyle-parse", @@ -924,44 +688,92 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.8" +version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa" +checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] name = "arbitrary" -version = "1.4.1" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" +dependencies = [ + "derive_arbitrary", +] + +[[package]] +name = "ark-bls12-381" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df4dcc01ff89867cd86b0da835f23c3f02738353aaee7dde7495af71363b8d5" +dependencies = [ + "ark-ec", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "ark-std 0.5.0", +] + +[[package]] +name = "ark-bn254" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d69eab57e8d2663efa5c63135b2af4f396d66424f88954c21104125ab6b3e6bc" +dependencies = [ + "ark-ec", + "ark-ff 0.5.0", + "ark-r1cs-std", + "ark-std 0.5.0", +] + +[[package]] +name = "ark-ec" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" +checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce" +dependencies = [ + "ahash", + "ark-ff 0.5.0", + "ark-poly", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "educe", + "fnv", + "hashbrown 0.15.5", + "itertools 0.13.0", + "num-bigint", + "num-integer", + "num-traits", + "zeroize", +] [[package]] name = "ark-ff" @@ -1001,6 +813,26 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ark-ff" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a177aba0ed1e0fbb62aa9f6d0502e9b46dad8c2eab04c14258a1212d2557ea70" +dependencies = [ + "ark-ff-asm 0.5.0", + "ark-ff-macros 0.5.0", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "arrayvec", + "digest 0.10.7", + "educe", + "itertools 0.13.0", + "num-bigint", + "num-traits", + "paste", + "zeroize", +] + [[package]] name = "ark-ff-asm" version = "0.3.0" @@ -1021,6 +853,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-ff-asm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" +dependencies = [ + "quote", + "syn 2.0.106", +] + [[package]] name = "ark-ff-macros" version = "0.3.0" @@ -1046,6 +888,63 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-ff-macros" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "ark-poly" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27" +dependencies = [ + "ahash", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "educe", + "fnv", + "hashbrown 0.15.5", +] + +[[package]] +name = "ark-r1cs-std" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "941551ef1df4c7a401de7068758db6503598e6f01850bdb2cfdb614a1f9dbea1" +dependencies = [ + "ark-ec", + "ark-ff 0.5.0", + "ark-relations", + "ark-std 0.5.0", + "educe", + "num-bigint", + "num-integer", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-relations" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec46ddc93e7af44bcab5230937635b06fb5744464dd6a7e7b083e80ebd274384" +dependencies = [ + "ark-ff 0.5.0", + "ark-std 0.5.0", + "tracing", + "tracing-subscriber", +] + [[package]] name = "ark-serialize" version = "0.3.0" @@ -1067,6 +966,30 @@ dependencies = [ "num-bigint", ] +[[package]] +name = "ark-serialize" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7" +dependencies = [ + "ark-serialize-derive", + "ark-std 0.5.0", + "arrayvec", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "ark-std" version = "0.3.0" @@ -1087,6 +1010,22 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "ark-std" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + [[package]] name = "arrayvec" version = "0.7.6" @@ -1115,20 +1054,26 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "async-trait" -version = "0.1.88" +version = "0.1.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "aurora-engine-modexp" version = "1.2.0" @@ -1147,14 +1092,20 @@ checksum = "ffdcb70bdbc4d478427380519163274ac86e52916e10f0a8889adf0f96d3fee7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "autocfg" -version = "1.4.0" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "az" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" [[package]] name = "backtrace" @@ -1185,9 +1136,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" -version = "1.7.3" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e25b6adfb930f02d1981565a6e5d9c547ac15a96606256d3b59040e5cd4ca3" +checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" [[package]] name = "basic-example" @@ -1256,11 +1207,27 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" +[[package]] +name = "bitcoin-io" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf" + +[[package]] +name = "bitcoin_hashes" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16" +dependencies = [ + "bitcoin-io", + "hex-conservative", +] + [[package]] name = "bitflags" -version = "2.9.1" +version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" [[package]] name = "bitvec" @@ -1274,6 +1241,15 @@ dependencies = [ "wyz", ] +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -1285,9 +1261,9 @@ dependencies = [ [[package]] name = "blst" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c79a94619fade3c0b887670333513a67ac28a6a7e653eb260bf0d4103db38d" +checksum = "4fd49896f12ac9b6dcd7a5998466b9b58263a695a3dd1ecc1aaca2e12a90b080" dependencies = [ "cc", "glob", @@ -1306,9 +1282,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.17.0" +version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "byte-slice-cast" @@ -1333,9 +1309,9 @@ dependencies = [ [[package]] name = "c-kzg" -version = "1.0.3" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0307f72feab3300336fb803a57134159f6e20139af1357f36c54cb90d8e8928" +checksum = "7318cfa722931cb5fe0838b98d3ce5621e75f6a6408abc21721d80de9223f2e4" dependencies = [ "blst", "cc", @@ -1348,24 +1324,37 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.23" +version = "1.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766" +checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44" dependencies = [ + "find-msvc-tools", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" + +[[package]] +name = "chrono" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +dependencies = [ + "iana-time-zone", + "num-traits", + "serde", + "windows-link 0.2.0", +] [[package]] name = "clap" -version = "4.5.38" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" +checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931" dependencies = [ "clap_builder", "clap_derive", @@ -1373,9 +1362,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.38" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" +checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6" dependencies = [ "anstream", "anstyle", @@ -1385,39 +1374,38 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.32" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" +checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "clap_lex" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "colorchoice" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "const-hex" -version = "1.14.1" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e22e0ed40b96a48d3db274f72fd365bd78f67af39b6bbd47e8a15e1c6207ff" +checksum = "b6407bff74dea37e0fa3dc1c1c974e5d46405f0c987bf9997a0762adce71eda6" dependencies = [ "cfg-if", "cpufeatures", - "hex", "proptest", - "serde", + "serde_core", ] [[package]] @@ -1512,9 +1500,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "crypto-bigint" @@ -1538,6 +1526,77 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core 0.20.11", + "darling_macro 0.20.11", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core 0.21.3", + "darling_macro 0.21.3", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.106", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "serde", + "strsim", + "syn 2.0.106", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core 0.20.11", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core 0.21.3", + "quote", + "syn 2.0.106", +] + [[package]] name = "dashmap" version = "6.1.0" @@ -1562,6 +1621,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "deranged" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d630bccd429a5bb5a64b5e94f693bfc48c9f8566418fda4c494cc94f911f87cc" +dependencies = [ + "powerfmt", + "serde", +] + [[package]] name = "derivative" version = "2.2.0" @@ -1575,33 +1644,33 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" +checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "derive_more" -version = "1.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" dependencies = [ "derive_more-impl", ] [[package]] name = "derive_more-impl" -version = "1.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", "unicode-xid", ] @@ -1620,7 +1689,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", + "block-buffer 0.10.4", "const-oid", "crypto-common", "subtle", @@ -1634,7 +1703,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -1645,9 +1714,9 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "dyn-clone" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "e2e" @@ -1659,7 +1728,7 @@ dependencies = [ "regex", "stylus-sdk", "tokio", - "toml", + "toml 0.8.23", ] [[package]] @@ -1668,7 +1737,7 @@ version = "0.2.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -1681,6 +1750,7 @@ dependencies = [ "digest 0.10.7", "elliptic-curve", "rfc6979", + "serdect", "signature", "spki", ] @@ -1707,7 +1777,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -1715,6 +1785,9 @@ name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +dependencies = [ + "serde", +] [[package]] name = "elliptic-curve" @@ -1731,6 +1804,7 @@ dependencies = [ "pkcs8", "rand_core 0.6.4", "sec1", + "serdect", "subtle", "zeroize", ] @@ -1752,18 +1826,7 @@ checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", -] - -[[package]] -name = "enumn" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -1929,7 +1992,7 @@ dependencies = [ "e2e", "eyre", "openzeppelin-stylus", - "rand 0.9.1", + "rand 0.9.2", "stylus-sdk", "tokio", ] @@ -1943,7 +2006,7 @@ dependencies = [ "e2e", "eyre", "openzeppelin-stylus", - "rand 0.9.1", + "rand 0.9.2", "stylus-sdk", "tokio", ] @@ -1971,7 +2034,7 @@ dependencies = [ "e2e", "eyre", "openzeppelin-stylus", - "rand 0.9.1", + "rand 0.9.2", "stylus-sdk", "tokio", ] @@ -1991,12 +2054,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.12" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.0", ] [[package]] @@ -2047,6 +2110,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d" + [[package]] name = "fixed-hash" version = "0.8.0" @@ -2088,9 +2157,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" dependencies = [ "percent-encoding", ] @@ -2157,7 +2226,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -2215,7 +2284,7 @@ checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.11.1+wasi-snapshot-preview1", ] [[package]] @@ -2227,7 +2296,7 @@ dependencies = [ "cfg-if", "libc", "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "wasi 0.14.7+wasi-0.2.4", ] [[package]] @@ -2238,9 +2307,19 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" -version = "0.3.2" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "gmp-mpfr-sys" +version = "1.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +checksum = "60f8970a75c006bb2f8ae79c6768a116dd215fa8346a87aed99bf9d82ca43394" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] [[package]] name = "group" @@ -2255,9 +2334,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" @@ -2267,9 +2346,9 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.15.3" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ "allocator-api2", "equivalent", @@ -2285,17 +2364,23 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-conservative" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd" dependencies = [ - "serde", + "arrayvec", ] [[package]] @@ -2355,18 +2440,20 @@ checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "hyper" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" dependencies = [ + "atomic-waker", "bytes", "futures-channel", - "futures-util", + "futures-core", "http", "http-body", "httparse", "itoa", "pin-project-lite", + "pin-utils", "smallvec", "tokio", "want", @@ -2390,17 +2477,21 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.12" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9f1e950e0d9d1d3c47184416723cf29c0d1f93bd8cccf37e4beb6b44f31710" +checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" dependencies = [ + "base64", "bytes", "futures-channel", + "futures-core", "futures-util", "http", "http-body", "hyper", + "ipnet", "libc", + "percent-encoding", "pin-project-lite", "socket2", "tokio", @@ -2408,6 +2499,30 @@ dependencies = [ "tracing", ] +[[package]] +name = "iana-time-zone" +version = "0.1.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "icu_collections" version = "2.0.0" @@ -2494,11 +2609,17 @@ dependencies = [ "zerovec", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" dependencies = [ "idna_adapter", "smallvec", @@ -2532,25 +2653,48 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "indenter" -version = "0.3.3" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" + +[[package]] +name = "indexmap" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] [[package]] name = "indexmap" -version = "2.9.0" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +checksum = "92119844f513ffa41556430369ab02c295a3578af21cf945caa3e9e0c2481ac3" dependencies = [ "arbitrary", "equivalent", - "hashbrown 0.15.3", + "hashbrown 0.15.5", "serde", + "serde_core", +] + +[[package]] +name = "io-uring" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b" +dependencies = [ + "bitflags", + "cfg-if", + "libc", ] [[package]] @@ -2559,6 +2703,16 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +[[package]] +name = "iri-string" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -2600,9 +2754,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "6247da8b8658ad4e73a186e747fcc5fc2a29f979d6fe6269127fdb5fd08298d0" dependencies = [ "once_cell", "wasm-bindgen", @@ -2618,7 +2772,8 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", - "sha2", + "serdect", + "sha2 0.10.9", ] [[package]] @@ -2651,15 +2806,12 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "libc" -version = "0.2.172" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "libm" @@ -2667,11 +2819,57 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" +[[package]] +name = "libsecp256k1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79019718125edc905a079a70cfa5f3820bc76139fc91d6f9abc27ea2a887139" +dependencies = [ + "arrayref", + "base64", + "digest 0.9.0", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", + "sha2 0.9.9", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + [[package]] name = "linux-raw-sys" -version = "0.9.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "litemap" @@ -2681,9 +2879,9 @@ checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" dependencies = [ "autocfg", "scopeguard", @@ -2691,33 +2889,35 @@ dependencies = [ [[package]] name = "log" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "lru" -version = "0.12.5" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" dependencies = [ - "hashbrown 0.15.3", + "hashbrown 0.15.5", ] [[package]] -name = "lru" -version = "0.13.0" +name = "macro-string" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" +checksum = "1b27834086c65ec3f9387b096d66e99f221cf081c2b738042aa252bcd41204e3" dependencies = [ - "hashbrown 0.15.3", + "proc-macro2", + "quote", + "syn 2.0.106", ] [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "merkle-proofs-example" @@ -2729,49 +2929,42 @@ dependencies = [ "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.9.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56630dba7f5c3ac7e37caa66d2388197fc2d4742b216104cba14c16dce55bf" +checksum = "b620761d4c29ede39bb1351c4360dba54d3b414d9fb460d37cba4c98b37a0b9d" dependencies = [ "cfg-if", ] [[package]] name = "miniz_oxide" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", ] [[package]] name = "motsu" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ffb08358f3acb5e97757047c898c2e0f852997f6b8ff4b32613971a4d8219d" +source = "git+https://github.com/OpenZeppelin/stylus-test-helpers.git?branch=bump%2Fsdk-v0.10#927dff6188e488c2109cf8b02e4ddd9d40e91fed" dependencies = [ "alloy-primitives", - "alloy-signer-local 0.11.1", + "alloy-signer-local", "alloy-sol-types", "const-hex", "dashmap", @@ -2786,12 +2979,11 @@ dependencies = [ [[package]] name = "motsu-proc" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "596b892439b97b288be7c6bf616c62ea607fe74a7a9a41903f9d78b7b1274ac4" +source = "git+https://github.com/OpenZeppelin/stylus-test-helpers.git?branch=bump%2Fsdk-v0.10#927dff6188e488c2109cf8b02e4ddd9d40e91fed" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -2844,6 +3036,12 @@ dependencies = [ "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" @@ -2887,9 +3085,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ "hermit-abi", "libc", @@ -2897,33 +3095,36 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" +checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" dependencies = [ "num_enum_derive", + "rustversion", ] [[package]] name = "num_enum_derive" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" +checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" dependencies = [ + "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "nybbles" -version = "0.3.4" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8983bb634df7248924ee0c4c3a749609b5abcb082c28fffe3254b3eb3602b307" +checksum = "f0418987d1aaed324d95b4beffc93635e19be965ed5d63ec07a35980fe3b71a4" dependencies = [ "alloy-rlp", - "const-hex", + "cfg-if", "proptest", + "ruint", "serde", "smallvec", ] @@ -2945,18 +3146,21 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "once_cell_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2611b99ab098a31bdc8be48b4f1a285ca0ced28bd5b4f23e45efa8c63b09efa5" -dependencies = [ - "once_cell", -] +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.72" +version = "0.10.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" +checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" dependencies = [ "bitflags", "cfg-if", @@ -2975,7 +3179,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -2986,9 +3190,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.108" +version = "0.9.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847" +checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" dependencies = [ "cc", "libc", @@ -3006,9 +3210,9 @@ dependencies = [ "num-traits", "paste", "proptest", - "rand 0.9.1", + "rand 0.9.2", "ruint", - "sha2", + "sha2 0.10.9", "static_assertions", "tiny-keccak", "zeroize", @@ -3019,7 +3223,7 @@ name = "openzeppelin-stylus" version = "0.3.0" dependencies = [ "alloy-primitives", - "alloy-signer 0.11.1", + "alloy-signer", "alloy-sol-macro", "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -3037,7 +3241,7 @@ dependencies = [ "convert_case 0.9.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -3066,6 +3270,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.9", +] + [[package]] name = "parity-scale-codec" version = "3.7.5" @@ -3091,14 +3307,14 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "parking_lot" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" dependencies = [ "lock_api", "parking_lot_core", @@ -3106,9 +3322,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.10" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "cfg-if", "libc", @@ -3138,15 +3354,15 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.8.0" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6" +checksum = "21e0a3a33733faeaf8651dfee72dd0f388f0c8e5ad496a3478fa5a922f49cfa8" dependencies = [ "memchr", "thiserror", @@ -3170,7 +3386,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -3216,13 +3432,19 @@ dependencies = [ [[package]] name = "potential_utf" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +checksum = "84df19adbe5b5a0782edcab45899906947ab039ccf4573713735ee7de1e6b08a" dependencies = [ "zerovec", ] +[[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.21" @@ -3245,6 +3467,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "primitive-types" version = "0.12.2" @@ -3258,11 +3489,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" +checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit", + "toml_edit 0.23.5", ] [[package]] @@ -3308,14 +3539,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] @@ -3331,7 +3562,7 @@ dependencies = [ "bitflags", "lazy_static", "num-traits", - "rand 0.9.1", + "rand 0.9.2", "rand_chacha 0.9.0", "rand_xorshift", "regex-syntax", @@ -3348,7 +3579,7 @@ checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -3382,9 +3613,9 @@ dependencies = [ [[package]] name = "r-efi" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "radium" @@ -3406,12 +3637,13 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", + "serde", ] [[package]] @@ -3450,6 +3682,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom 0.3.3", + "serde", ] [[package]] @@ -3472,18 +3705,38 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.12" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" dependencies = [ "bitflags", ] +[[package]] +name = "ref-cast" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "regex" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" dependencies = [ "aho-corasick", "memchr", @@ -3493,9 +3746,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" dependencies = [ "aho-corasick", "memchr", @@ -3504,35 +3757,31 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" [[package]] name = "reqwest" -version = "0.12.15" +version = "0.12.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" +checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb" dependencies = [ "base64", "bytes", "futures-core", - "futures-util", "http", "http-body", "http-body-util", "hyper", "hyper-tls", "hyper-util", - "ipnet", "js-sys", "log", - "mime", "native-tls", - "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", @@ -3540,50 +3789,49 @@ dependencies = [ "tokio", "tokio-native-tls", "tower", + "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "windows-registry", ] [[package]] name = "revm-precompile" -version = "16.2.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99743c3a2cac341084cc15ac74286c4bf34a0941ebf60aa420cfdb9f81f72f9f" +checksum = "25b57d4bd9e6b5fe469da5452a8a137bc2d030a3cd47c46908efc615bbc699da" dependencies = [ + "ark-bls12-381", + "ark-bn254", + "ark-ec", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "arrayref", "aurora-engine-modexp", "blst", "c-kzg", "cfg-if", "k256", - "once_cell", + "libsecp256k1", + "p256", "revm-primitives", "ripemd", - "secp256k1", - "sha2", - "substrate-bn", + "rug", + "secp256k1 0.31.1", + "sha2 0.10.9", ] [[package]] name = "revm-primitives" -version = "15.2.0" +version = "20.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f987564210317706def498421dfba2ae1af64a8edce82c6102758b48133fcb" +checksum = "5aa29d9da06fe03b249b6419b33968ecdf92ad6428e2f012dc57bcd619b5d94e" dependencies = [ - "alloy-eip2930", - "alloy-eip7702 0.5.1", "alloy-primitives", - "auto_impl", - "bitflags", - "bitvec", - "c-kzg", - "cfg-if", - "dyn-clone", - "enumn", - "hex", + "num_enum", + "once_cell", "serde", ] @@ -3616,11 +3864,23 @@ dependencies = [ "rustc-hex", ] +[[package]] +name = "rug" +version = "1.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58ad2e973fe3c3214251a840a621812a4f40468da814b1a3d6947d433c2af11f" +dependencies = [ + "az", + "gmp-mpfr-sys", + "libc", + "libm", +] + [[package]] name = "ruint" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78a46eb779843b2c4f21fac5773e25d6d5b7c8f0922876c91541790d2ca27eef" +checksum = "11256b5fe8c68f56ac6f39ef0720e592f33d2367a4782740d9c9142e889c7fb4" dependencies = [ "alloy-rlp", "arbitrary", @@ -3636,7 +3896,7 @@ dependencies = [ "primitive-types", "proptest", "rand 0.8.5", - "rand 0.9.1", + "rand 0.9.2", "rlp", "ruint-macro", "serde", @@ -3652,9 +3912,9 @@ checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rustc-demangle" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" [[package]] name = "rustc-hash" @@ -3695,29 +3955,20 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver 1.0.26", + "semver 1.0.27", ] [[package]] name = "rustix" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.59.0", -] - -[[package]] -name = "rustls-pemfile" -version = "2.2.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "rustls-pki-types", + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.0", ] [[package]] @@ -3731,9 +3982,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "rusty-fork" @@ -3769,22 +4020,35 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.0", ] [[package]] -name = "schnellru" -version = "0.2.4" +name = "schemars" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356285bbf17bea63d9e52e96bd18f039672ac92b55b8cb997d6162a2a37d1649" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" dependencies = [ - "ahash", - "cfg-if", - "hashbrown 0.13.2", + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", ] [[package]] @@ -3803,18 +4067,32 @@ dependencies = [ "der", "generic-array", "pkcs8", + "serdect", "subtle", "zeroize", ] [[package]] name = "secp256k1" -version = "0.29.1" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +checksum = "b50c5943d326858130af85e049f2661ba3c78b26589b8ab98e65e80ae44a1252" dependencies = [ + "bitcoin_hashes", "rand 0.8.5", - "secp256k1-sys", + "secp256k1-sys 0.10.1", + "serde", +] + +[[package]] +name = "secp256k1" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3c81b43dc2d8877c216a3fccf76677ee1ebccd429566d3e67447290d0c42b2" +dependencies = [ + "bitcoin_hashes", + "rand 0.9.2", + "secp256k1-sys 0.11.0", ] [[package]] @@ -3826,6 +4104,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb913707158fadaf0d8702c2db0e857de66eb003ccfdda5924b5f5ac98efb38" +dependencies = [ + "cc", +] + [[package]] name = "security-framework" version = "2.11.1" @@ -3841,9 +4128,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" dependencies = [ "core-foundation-sys", "libc", @@ -3869,9 +4156,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] name = "semver-parser" @@ -3890,45 +4177,65 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.219" +version = "1.0.225" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "fd6c24dee235d0da097043389623fb913daddf92c76e9f5a1db88607a0bcbd1d" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.225" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "659356f9a0cb1e529b24c01e43ad2bdf520ec4ceaf83047b83ddcc2251f96383" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.225" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "0ea936adf78b1f766949a4977b91d2f5595825bd6ec079aa9543ad2685fc4516" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] name = "serde_spanned" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2789234a13a53fc4be1b51ea1bab45a3c338bdb884862a257d10e5a74ae009e6" +dependencies = [ + "serde_core", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3941,6 +4248,61 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2c45cd61fefa9db6f254525d46e392b852e0e61d9a1fd36e5bd183450a556d5" +dependencies = [ + "base64", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.11.3", + "schemars 0.9.0", + "schemars 1.0.4", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de90945e6565ce0d9a25098082ed4ee4002e047cb59892c318d66821e14bb30f" +dependencies = [ + "darling 0.20.11", + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "serdect" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" +dependencies = [ + "base16ct", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + [[package]] name = "sha2" version = "0.10.9" @@ -3980,9 +4342,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.5" +version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" dependencies = [ "libc", ] @@ -3999,38 +4361,29 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.9" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "smallvec" -version = "1.15.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" dependencies = [ "serde", ] [[package]] name = "socket2" -version = "0.5.9" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] -[[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" @@ -4061,43 +4414,44 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" +checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" +checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" dependencies = [ "heck", "proc-macro2", "quote", - "rustversion", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "stylus-core" -version = "0.9.0" +version = "0.10.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96d0a4daa641fb5904cc3302c90b2d160f59c62aae7a19c2c6b94e28e3ab93e" +checksum = "942343730f1153f3b730be880986002be9e104ae4bdfb2f8fbcfab95b4cea725" dependencies = [ "alloy-primitives", "alloy-sol-types", "cfg-if", "dyn-clone", + "lazy_static", + "regex", ] [[package]] name = "stylus-proc" -version = "0.9.0" +version = "0.10.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87cad1205aac3d46a3bb303ebe24976de3e88652d001a2e0e489b1e2bd6d0b9" +checksum = "7870ffc7a78e31de24ed67807f6f374c21c2ee6aca672d3dfb3e45187de7251f" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -4109,28 +4463,29 @@ dependencies = [ "quote", "regex", "sha3", - "syn 2.0.101", + "stylus-core", + "syn 2.0.106", "syn-solidity", "trybuild", ] [[package]] name = "stylus-sdk" -version = "0.9.0" +version = "0.10.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38519923dae967837b90f00cd669b9d6df778ec1f0df849089f4dd456be96bf8" +checksum = "7db93dbd7878f8433e0335f3315cdd9c590d37588bbddaab2c5f1e7c3c083332" dependencies = [ "alloy-primitives", "alloy-sol-types", + "branches", "cfg-if", "clap", "derivative", "hex", "keccak-const", - "lazy_static", "mini-alloc", "rclite", - "regex", + "ruint", "stylus-core", "stylus-proc", "stylus-test", @@ -4138,31 +4493,18 @@ dependencies = [ [[package]] name = "stylus-test" -version = "0.9.0" +version = "0.10.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abef8a75532dab6480d83577e47f4db429e7f0330825b3e167a3c9ddb363fd1f" +checksum = "a1e4e7125e969040a09ebdc166848e3aeaf81fa297fc5a782850e069cb1fffc0" dependencies = [ "alloy-primitives", - "alloy-provider 0.11.1", + "alloy-provider", "alloy-sol-types", "stylus-core", "tokio", "url", ] -[[package]] -name = "substrate-bn" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b5bbfa79abbae15dd642ea8176a21a635ff3c00059961d1ea27ad04e5b441c" -dependencies = [ - "byteorder", - "crunchy", - "lazy_static", - "rand 0.8.5", - "rustc-hex", -] - [[package]] name = "subtle" version = "2.6.1" @@ -4182,9 +4524,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.101" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -4193,14 +4535,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.25" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4560533fbd6914b94a8fb5cc803ed6801c3455668db3b810702c57612bac9412" +checksum = "a0b198d366dbec045acfcd97295eb653a7a2b40e4dc764ef1e79aafcad439d3c" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -4220,7 +4562,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -4237,15 +4579,15 @@ checksum = "1ac9aa371f599d22256307c24a9d748c041e548cbf599f35d890f9d365361790" [[package]] name = "tempfile" -version = "3.20.0" +version = "3.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +checksum = "84fa4d11fadde498443cca10fd3ac23c951f0dc59e080e9f4b93d4df4e4eea53" dependencies = [ "fastrand", "getrandom 0.3.3", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.61.0", ] [[package]] @@ -4259,22 +4601,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.12" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -4286,6 +4628,36 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "time" +version = "0.3.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83bde6f1ec10e72d583d91623c939f623002284ef622b87de38cfd546cbf2031" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" + +[[package]] +name = "time-macros" +version = "0.2.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -4307,20 +4679,22 @@ dependencies = [ [[package]] name = "tokio" -version = "1.45.0" +version = "1.47.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" dependencies = [ "backtrace", "bytes", + "io-uring", "libc", "mio", "parking_lot", "pin-project-lite", "signal-hook-registry", + "slab", "socket2", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4331,7 +4705,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -4358,9 +4732,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" dependencies = [ "bytes", "futures-core", @@ -4371,44 +4745,95 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.22" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", + "toml_edit 0.22.27", +] + +[[package]] +name = "toml" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae2a4cf385da23d1d53bc15cdfa5c2109e93d8d362393c801e87da2f72f0e201" +dependencies = [ + "indexmap 2.11.3", + "serde_core", + "serde_spanned 1.0.1", + "toml_datetime 0.7.1", + "toml_parser", + "toml_writer", + "winnow", ] [[package]] name = "toml_datetime" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a197c0ec7d131bfc6f7e82c8442ba1595aeab35da7adbf05b6b73cd06a16b6be" +dependencies = [ + "serde_core", +] + [[package]] name = "toml_edit" -version = "0.22.26" +version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap", + "indexmap 2.11.3", "serde", - "serde_spanned", - "toml_datetime", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", "toml_write", "winnow", ] +[[package]] +name = "toml_edit" +version = "0.23.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2ad0b7ae9cfeef5605163839cb9221f453399f15cfb5c10be9885fcf56611f9" +dependencies = [ + "indexmap 2.11.3", + "toml_datetime 0.7.1", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10" +dependencies = [ + "winnow", +] + [[package]] name = "toml_write" -version = "0.1.1" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + +[[package]] +name = "toml_writer" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076" +checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" [[package]] name = "tower" @@ -4425,6 +4850,24 @@ dependencies = [ "tower-service", ] +[[package]] +name = "tower-http" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -4450,22 +4893,32 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "tracing-core", ] [[package]] @@ -4476,9 +4929,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "trybuild" -version = "1.0.105" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9bf9513a2f4aeef5fdac8677d7d349c79fdbcc03b9c86da6e9d254f1e43be2" +checksum = "0ded9fdb81f30a5708920310bfcd9ea7482ff9cba5f54601f7a19a877d5c2392" dependencies = [ "glob", "serde", @@ -4486,7 +4939,7 @@ dependencies = [ "serde_json", "target-triple", "termcolor", - "toml", + "toml 0.9.6", ] [[package]] @@ -4521,9 +4974,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" [[package]] name = "unicode-segmentation" @@ -4553,13 +5006,14 @@ dependencies = [ [[package]] name = "url" -version = "2.5.4" +version = "2.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] @@ -4654,50 +5108,60 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" -version = "0.14.2+wasi-0.2.4" +version = "0.14.7+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" +dependencies = [ + "wasip2", +] + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" dependencies = [ - "wit-bindgen-rt", + "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "4ad224d2776649cfb4f4471124f8176e54c1cca67a88108e30a0cd98b90e7ad3" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", + "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.100" +version = "0.2.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +checksum = "3a1364104bdcd3c03f22b16a3b1c9620891469f5e9f09bc38b2db121e593e732" dependencies = [ "bumpalo", "log", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.50" +version = "0.4.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +checksum = "9c0a08ecf5d99d5604a6666a70b3cde6ab7cc6142f5e641a8ef48fc744ce8854" dependencies = [ "cfg-if", "js-sys", @@ -4708,9 +5172,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "0d7ab4ca3e367bb1ed84ddbd83cc6e41e115f8337ed047239578210214e36c76" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4718,31 +5182,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "4a518014843a19e2dbbd0ed5dfb6b99b23fb886b14e6192a00803a3e14c552b0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "255eb0aa4cc2eea3662a00c2bbd66e93911b7361d5e0fcd62385acfd7e15dcee" dependencies = [ "unicode-ident", ] [[package]] name = "wasmtimer" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0048ad49a55b9deb3953841fa1fc5858f0efbcb7a18868c899a360269fac1b23" +checksum = "1c598d6b99ea013e35844697fc4670d08339d5cda15588f193c6beedd12f644b" dependencies = [ "futures", "js-sys", @@ -4754,9 +5218,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.77" +version = "0.3.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +checksum = "50462a022f46851b81d5441d1a6f5bac0b21a1d72d64bd4906fbdd4bf7230ec7" dependencies = [ "js-sys", "wasm-bindgen", @@ -4764,64 +5228,103 @@ dependencies = [ [[package]] name = "winapi-util" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.0", ] [[package]] -name = "windows-link" -version = "0.1.1" +name = "windows-core" +version = "0.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" +checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.2.0", + "windows-result", + "windows-strings", +] [[package]] -name = "windows-registry" -version = "0.4.0" +name = "windows-implement" +version = "0.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ - "windows-result", - "windows-strings", - "windows-targets 0.53.0", + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", ] +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-link" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" + [[package]] name = "windows-result" -version = "0.3.4" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" dependencies = [ - "windows-link", + "windows-link 0.2.0", ] [[package]] name = "windows-strings" -version = "0.3.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" +checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" dependencies = [ - "windows-link", + "windows-link 0.2.0", ] [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets 0.52.6", ] [[package]] name = "windows-sys" -version = "0.59.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.52.6", + "windows-targets 0.53.3", +] + +[[package]] +name = "windows-sys" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e201184e40b2ede64bc2ea34968b28e33622acdbbf37104f0e4a33f7abe657aa" +dependencies = [ + "windows-link 0.2.0", ] [[package]] @@ -4842,10 +5345,11 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.0" +version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" dependencies = [ + "windows-link 0.1.3", "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", "windows_i686_gnu 0.53.0", @@ -4954,21 +5458,18 @@ checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winnow" -version = "0.7.10" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" dependencies = [ "memchr", ] [[package]] -name = "wit-bindgen-rt" -version = "0.39.0" +name = "wit-bindgen" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" -dependencies = [ - "bitflags", -] +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "writeable" @@ -5005,28 +5506,28 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.25" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.25" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -5046,7 +5547,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", "synstructure", ] @@ -5067,7 +5568,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] [[package]] @@ -5083,9 +5584,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.2" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" dependencies = [ "yoke", "zerofrom", @@ -5100,5 +5601,5 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.106", ] diff --git a/Cargo.toml b/Cargo.toml index 1e26af950..849dea649 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ members = [ "examples/erc721-consecutive", "examples/erc721-metadata", "examples/erc721-wrapper", + "examples/erc721-holder", "examples/erc1155", "examples/erc1155-metadata-uri", "examples/erc1155-supply", @@ -36,7 +37,6 @@ members = [ "examples/beacon-proxy", "examples/uups-proxy", "examples/uups-proxy-new-version", - "examples/erc721-holder", "examples/erc1155-holder", "examples/eddsa", ] @@ -58,6 +58,7 @@ default-members = [ "examples/erc721-consecutive", "examples/erc721-metadata", "examples/erc721-wrapper", + "examples/erc721-holder", "examples/erc1155", "examples/erc1155-metadata-uri", "examples/erc1155-supply", @@ -75,7 +76,6 @@ default-members = [ "examples/beacon-proxy", "examples/uups-proxy", "examples/uups-proxy-new-version", - "examples/erc721-holder", "examples/erc1155-holder", "examples/eddsa", ] @@ -105,9 +105,9 @@ all = "warn" [workspace.dependencies] # Stylus SDK related -stylus-sdk = "=0.9.0" +stylus-sdk = { version = "0.10.0-rc.1" } -alloy = { version = "=0.7.3", features = [ +alloy = { version = "1.0.1", features = [ "contract", "network", "providers", @@ -121,16 +121,18 @@ alloy = { version = "=0.7.3", features = [ # Even though `alloy` includes `alloy-primitives` and `alloy-sol-types` we need # to keep both versions for compatibility with the Stylus SDK. Once they start # using `alloy` we can remove these. -alloy-primitives = { version = "=0.8.20", default-features = false, features = [ - "tiny-keccak", +alloy-primitives = { version = "1.0.1", default-features = false, features = [ + # Since nitro test node supports precompiled keccak, + # we can save on wasm binary ~1kb of "tiny-keccak" dependency. + "native-keccak", ] } -alloy-sol-types = { version = "=0.8.20", default-features = false } -alloy-sol-macro = { version = "=0.8.20", default-features = false } -alloy-sol-macro-expander = { version = "=0.8.20", default-features = false } -alloy-sol-macro-input = { version = "=0.8.20", default-features = false } -alloy-signer = { version = "=0.11.1", default-features = false } +alloy-sol-types = { version = "1.0.1", default-features = false } +alloy-sol-macro = { version = "1.0.1", default-features = false } +alloy-sol-macro-expander = { version = "1.0.1", default-features = false } +alloy-sol-macro-input = { version = "1.0.1", default-features = false } +alloy-signer = { version = "1.0", default-features = false } -ruint = "^1.12.3" +ruint = "1.15.0" eyre = "0.6.8" keccak-const = "0.2.0" @@ -181,3 +183,8 @@ default = { extend-ignore-identifiers-re = [ "[0-9a-fA-F][0-9a-fA-F]", ] } files = { extend-exclude = [] } + +# TODO#q: update patch after motsu release +[patch.crates-io.motsu] +git = "https://github.com/OpenZeppelin/stylus-test-helpers.git" +branch = "bump/sdk-v0.10" diff --git a/benches/src/access_control.rs b/benches/src/access_control.rs index c16d13564..8d7634509 100644 --- a/benches/src/access_control.rs +++ b/benches/src/access_control.rs @@ -6,7 +6,7 @@ use alloy::{ sol, sol_types::SolCall, }; -use e2e::{constructor, receipt, Account}; +use e2e::{constructor, get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -43,17 +43,15 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice_addr = alice.address(); let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let bob = Account::new().await?; let bob_addr = bob.address(); let bob_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(bob.signer.clone())) - .on_http(bob.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/eddsa.rs b/benches/src/eddsa.rs index a69f30f5d..bc9b33248 100644 --- a/benches/src/eddsa.rs +++ b/benches/src/eddsa.rs @@ -6,7 +6,7 @@ use alloy::{ sol_types::SolCall, }; use alloy_primitives::hex; -use e2e::{receipt, Account}; +use e2e::{get_rpc_url, receipt, Account}; use openzeppelin_crypto::{ curve::CurveGroup, eddsa::{Signature, SigningKey, VerifyingKey}, @@ -33,9 +33,8 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice = Account::new().await?; let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/erc1155.rs b/benches/src/erc1155.rs index 484e99fb5..40dbc4f7b 100644 --- a/benches/src/erc1155.rs +++ b/benches/src/erc1155.rs @@ -6,7 +6,7 @@ use alloy::{ sol_types::SolCall, uint, }; -use e2e::{receipt, Account}; +use e2e::{get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -38,17 +38,15 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice_addr = alice.address(); let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let bob = Account::new().await?; let bob_addr = bob.address(); let bob_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(bob.signer.clone())) - .on_http(bob.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/erc1155_metadata_uri.rs b/benches/src/erc1155_metadata_uri.rs index 631205eaa..29558abe9 100644 --- a/benches/src/erc1155_metadata_uri.rs +++ b/benches/src/erc1155_metadata_uri.rs @@ -5,7 +5,7 @@ use alloy::{ sol, sol_types::SolCall, }; -use e2e::{constructor, receipt, Account}; +use e2e::{constructor, get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -33,9 +33,8 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice = Account::new().await?; let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/erc1155_supply.rs b/benches/src/erc1155_supply.rs index 5d1e76b62..2f139b5f9 100644 --- a/benches/src/erc1155_supply.rs +++ b/benches/src/erc1155_supply.rs @@ -6,7 +6,7 @@ use alloy::{ sol_types::SolCall, uint, }; -use e2e::{receipt, Account}; +use e2e::{get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -32,9 +32,8 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice_addr = alice.address(); let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/erc20.rs b/benches/src/erc20.rs index 32cc00621..307e3d9c6 100644 --- a/benches/src/erc20.rs +++ b/benches/src/erc20.rs @@ -7,7 +7,7 @@ use alloy::{ uint, }; use alloy_primitives::U256; -use e2e::{constructor, receipt, Account}; +use e2e::{constructor, get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -49,17 +49,15 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice_addr = alice.address(); let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let bob = Account::new().await?; let bob_addr = bob.address(); let bob_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(bob.signer.clone())) - .on_http(bob.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/erc721.rs b/benches/src/erc721.rs index c5f5f357d..4c92e9535 100644 --- a/benches/src/erc721.rs +++ b/benches/src/erc721.rs @@ -6,7 +6,7 @@ use alloy::{ sol_types::SolCall, uint, }; -use e2e::{receipt, Account}; +use e2e::{get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -39,9 +39,8 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice_addr = alice.address(); let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let bob = Account::new().await?; let bob_addr = bob.address(); diff --git a/benches/src/merkle_proofs.rs b/benches/src/merkle_proofs.rs index 5867d5e61..ac0ce3c26 100644 --- a/benches/src/merkle_proofs.rs +++ b/benches/src/merkle_proofs.rs @@ -6,7 +6,7 @@ use alloy::{ sol, sol_types::SolCall, }; -use e2e::{receipt, Account}; +use e2e::{get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -68,9 +68,8 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice = Account::new().await?; let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/ownable.rs b/benches/src/ownable.rs index 0c6461757..8d736784e 100644 --- a/benches/src/ownable.rs +++ b/benches/src/ownable.rs @@ -5,7 +5,7 @@ use alloy::{ sol, sol_types::SolCall, }; -use e2e::{constructor, receipt, Account}; +use e2e::{constructor, get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -29,17 +29,15 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice = Account::new().await?; let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let bob = Account::new().await?; let bob_addr = bob.address(); let bob_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(bob.signer.clone())) - .on_http(bob.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/pedersen.rs b/benches/src/pedersen.rs index 9d8724a2b..c05103399 100644 --- a/benches/src/pedersen.rs +++ b/benches/src/pedersen.rs @@ -5,7 +5,7 @@ use alloy::{ sol, sol_types::SolCall, }; -use e2e::{receipt, Account}; +use e2e::{get_rpc_url, receipt, Account}; use openzeppelin_crypto::arithmetic::uint::{from_str_hex, U256}; use crate::{ @@ -29,9 +29,8 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice = Account::new().await?; let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/poseidon.rs b/benches/src/poseidon.rs index a596bccc0..f1c0c6df5 100644 --- a/benches/src/poseidon.rs +++ b/benches/src/poseidon.rs @@ -6,7 +6,7 @@ use alloy::{ sol_types::SolCall, }; use alloy_primitives::uint; -use e2e::{receipt, Account}; +use e2e::{get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -29,9 +29,8 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice = Account::new().await?; let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt).await?; diff --git a/benches/src/poseidon_asm_sol.rs b/benches/src/poseidon_asm_sol.rs index 45577030f..539f2968f 100644 --- a/benches/src/poseidon_asm_sol.rs +++ b/benches/src/poseidon_asm_sol.rs @@ -6,7 +6,7 @@ use alloy::{ sol_types::SolCall, }; use alloy_primitives::uint; -use e2e::{receipt, Account}; +use e2e::{get_rpc_url, receipt, Account}; use crate::report::{ContractReport, FunctionReport}; @@ -32,9 +32,8 @@ pub async fn run() -> eyre::Result> { let alice = Account::new().await?; let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice).await?; diff --git a/benches/src/poseidon_sol.rs b/benches/src/poseidon_sol.rs index 4e6a2d77f..95b38ace0 100644 --- a/benches/src/poseidon_sol.rs +++ b/benches/src/poseidon_sol.rs @@ -6,7 +6,7 @@ use alloy::{ sol_types::SolCall, }; use alloy_primitives::uint; -use e2e::{receipt, Account}; +use e2e::{get_rpc_url, receipt, Account}; use crate::report::{ContractReport, FunctionReport}; @@ -31,9 +31,8 @@ pub async fn run() -> eyre::Result> { let alice = Account::new().await?; let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice).await?; diff --git a/benches/src/report.rs b/benches/src/report.rs index 736255bc2..25d1264e1 100644 --- a/benches/src/report.rs +++ b/benches/src/report.rs @@ -217,7 +217,7 @@ impl Display for BenchmarkReport { const BASE_GAS_FEE: u128 = 21_000; fn get_l2_gas_used(receipt: &AnyTransactionReceipt) -> eyre::Result { - let l2_gas = receipt.gas_used; + let l2_gas = receipt.gas_used as u128; let arb_fields: ArbOtherFields = receipt.other.deserialize_as()?; let l1_gas = arb_fields.gas_used_for_l1.to::(); Ok(l2_gas - l1_gas - BASE_GAS_FEE) diff --git a/benches/src/vesting_wallet.rs b/benches/src/vesting_wallet.rs index 4b518e1f5..7cdfc0394 100644 --- a/benches/src/vesting_wallet.rs +++ b/benches/src/vesting_wallet.rs @@ -8,7 +8,7 @@ use alloy::{ uint, }; use alloy_primitives::U256; -use e2e::{constructor, receipt, Account}; +use e2e::{constructor, get_rpc_url, receipt, Account}; use crate::{ report::{ContractReport, FunctionReport}, @@ -53,9 +53,8 @@ pub async fn run(cache_opt: Opt) -> eyre::Result> { let alice = Account::new().await?; let alice_wallet = ProviderBuilder::new() .network::() - .with_recommended_fillers() .wallet(EthereumWallet::from(alice.signer.clone())) - .on_http(alice.url().parse()?); + .connect_http(get_rpc_url()); let contract_addr = deploy(&alice, cache_opt.clone()).await?; let erc20_addr = deploy_token(&alice, cache_opt).await?; diff --git a/contracts/Cargo.toml b/contracts/Cargo.toml index 30b14a84f..01394a913 100644 --- a/contracts/Cargo.toml +++ b/contracts/Cargo.toml @@ -26,6 +26,7 @@ motsu.workspace = true [features] reentrant = ["stylus-sdk/reentrant"] export-abi = ["stylus-sdk/export-abi"] +contract-client-gen = [] [lib] crate-type = ["lib"] diff --git a/contracts/src/access/control/extensions/enumerable.rs b/contracts/src/access/control/extensions/enumerable.rs index 243768d5d..2114741c4 100644 --- a/contracts/src/access/control/extensions/enumerable.rs +++ b/contracts/src/access/control/extensions/enumerable.rs @@ -44,6 +44,7 @@ pub struct AccessControlEnumerable { /// Interface for the [`AccessControlEnumerable`] extension. #[interface_id] +#[public] pub trait IAccessControlEnumerable { /// The error type associated to the trait implementation. type Error: Into>; @@ -176,7 +177,6 @@ mod tests { use alloy_primitives::{uint, Address}; use motsu::prelude::*; - use stylus_sdk::msg; use super::*; use crate::access::control::{self, IAccessControl}; @@ -252,7 +252,7 @@ mod tests { role: B256, confirmation: Address, ) -> Result<(), Self::Error> { - if msg::sender() != confirmation { + if self.vm().msg_sender() != confirmation { return Err(control::Error::BadConfirmation( control::AccessControlBadConfirmation {}, )); diff --git a/contracts/src/access/control/mod.rs b/contracts/src/access/control/mod.rs index 1daf88ada..98184d3d3 100644 --- a/contracts/src/access/control/mod.rs +++ b/contracts/src/access/control/mod.rs @@ -18,7 +18,7 @@ //! //! ```rust,ignore //! pub fn foo() { -//! assert!(self.has_role(MY_ROLE.into(), msg::sender())); +//! assert!(self.has_role(MY_ROLE.into(), self.vm().msg_sender())); //! // ... //! } //! ``` @@ -45,8 +45,6 @@ use alloy_primitives::{aliases::B32, Address, B256}; use openzeppelin_stylus_proc::interface_id; pub use sol::*; use stylus_sdk::{ - call::MethodError, - evm, msg, prelude::*, storage::{StorageB256, StorageBool, StorageMap}, }; @@ -115,7 +113,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -141,6 +139,7 @@ pub struct AccessControl { /// Interface for an [`AccessControl`] contract. #[interface_id] +#[public] pub trait IAccessControl { /// The error type associated with this interface implementation. type Error: Into>; @@ -154,7 +153,7 @@ pub trait IAccessControl { /// * `account` - The account to check for membership. fn has_role(&self, role: B256, account: Address) -> bool; - /// Checks if [`msg::sender`] has been granted `role`. + /// Checks if `msg_sender()` has been granted `role`. /// /// # Arguments /// @@ -163,7 +162,7 @@ pub trait IAccessControl { /// /// # Errors /// - /// * [`Error::UnauthorizedAccount`] - If [`msg::sender`] has not been + /// * [`Error::UnauthorizedAccount`] - If `msg_sender()` has not been /// granted `role`. fn only_role(&self, role: B256) -> Result<(), Self::Error>; @@ -191,7 +190,7 @@ pub trait IAccessControl { /// /// # Errors /// - /// * [`Error::UnauthorizedAccount`] - If [`msg::sender`] has not been + /// * [`Error::UnauthorizedAccount`] - If `msg_sender()` has not been /// granted `role`. /// /// # Events @@ -215,7 +214,7 @@ pub trait IAccessControl { /// /// # Errors /// - /// * [`Error::UnauthorizedAccount`] - If [`msg::sender`] has not been + /// * [`Error::UnauthorizedAccount`] - If `msg_sender()` has not been /// granted `role`. /// /// # Events @@ -242,7 +241,7 @@ pub trait IAccessControl { /// /// # Errors /// - /// * [`Error::BadConfirmation`] - If [`msg::sender`] is not the + /// * [`Error::BadConfirmation`] - If `msg_sender()` is not the /// `confirmation` address. /// /// # Events @@ -268,7 +267,7 @@ impl IAccessControl for AccessControl { } fn only_role(&self, role: B256) -> Result<(), Self::Error> { - self._check_role(role, msg::sender()) + self._check_role(role, self.vm().msg_sender()) } fn get_role_admin(&self, role: B256) -> B256 { @@ -302,7 +301,7 @@ impl IAccessControl for AccessControl { role: B256, confirmation: Address, ) -> Result<(), Self::Error> { - if msg::sender() != confirmation { + if self.vm().msg_sender() != confirmation { return Err(Error::BadConfirmation( AccessControlBadConfirmation {}, )); @@ -331,7 +330,7 @@ impl AccessControl { pub fn _set_role_admin(&mut self, role: B256, new_admin_role: B256) { let previous_admin_role = self.get_role_admin(role); self.roles.setter(role).admin_role.set(new_admin_role); - evm::log(RoleAdminChanged { + self.vm().log(RoleAdminChanged { role, previous_admin_role, new_admin_role, @@ -348,7 +347,7 @@ impl AccessControl { /// /// # Errors /// - /// * [`Error::UnauthorizedAccount`] - If [`msg::sender`] has not been + /// * [`Error::UnauthorizedAccount`] - If `msg_sender()` has not been /// granted `role`. pub fn _check_role( &self, @@ -383,7 +382,11 @@ impl AccessControl { false } else { self.roles.setter(role).has_role.insert(account, true); - evm::log(RoleGranted { role, account, sender: msg::sender() }); + self.vm().log(RoleGranted { + role, + account, + sender: self.vm().msg_sender(), + }); true } } @@ -405,7 +408,11 @@ impl AccessControl { pub fn _revoke_role(&mut self, role: B256, account: Address) -> bool { if self.has_role(role, account) { self.roles.setter(role).has_role.insert(account, false); - evm::log(RoleRevoked { role, account, sender: msg::sender() }); + self.vm().log(RoleRevoked { + role, + account, + sender: self.vm().msg_sender(), + }); true } else { false diff --git a/contracts/src/access/ownable.rs b/contracts/src/access/ownable.rs index 2bba4bca0..2751a6b78 100644 --- a/contracts/src/access/ownable.rs +++ b/contracts/src/access/ownable.rs @@ -13,9 +13,7 @@ use alloc::{vec, vec::Vec}; use alloy_primitives::{aliases::B32, Address}; use openzeppelin_stylus_proc::interface_id; pub use sol::*; -use stylus_sdk::{ - call::MethodError, evm, msg, prelude::*, storage::StorageAddress, -}; +use stylus_sdk::{prelude::*, storage::StorageAddress}; use crate::utils::introspection::erc165::IErc165; @@ -59,7 +57,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -74,6 +72,7 @@ pub struct Ownable { /// Interface for an [`Ownable`] contract. #[interface_id] +#[public] pub trait IOwnable { /// The error type associated to the trait implementation. type Error: Into>; @@ -241,7 +240,7 @@ impl Ownable { } impl Ownable { - /// Checks if the [`msg::sender`] is set as the owner. + /// Checks if the `msg_sender()` is set as the owner. /// /// # Arguments /// @@ -252,7 +251,7 @@ impl Ownable { /// * [`Error::UnauthorizedAccount`] - If called by any account other than /// the owner. pub fn only_owner(&self) -> Result<(), Error> { - let account = msg::sender(); + let account = self.vm().msg_sender(); if self.owner() != account { return Err(Error::UnauthorizedAccount( OwnableUnauthorizedAccount { account }, @@ -276,7 +275,7 @@ impl Ownable { pub fn _transfer_ownership(&mut self, new_owner: Address) { let previous_owner = self.owner.get(); self.owner.set(new_owner); - evm::log(OwnershipTransferred { previous_owner, new_owner }); + self.vm().log(OwnershipTransferred { previous_owner, new_owner }); } } diff --git a/contracts/src/access/ownable_two_step.rs b/contracts/src/access/ownable_two_step.rs index efcdce764..0d1923497 100644 --- a/contracts/src/access/ownable_two_step.rs +++ b/contracts/src/access/ownable_two_step.rs @@ -21,7 +21,7 @@ use alloc::{vec, vec::Vec}; use alloy_primitives::{aliases::B32, Address}; use openzeppelin_stylus_proc::interface_id; pub use sol::*; -use stylus_sdk::{evm, msg, prelude::*, storage::StorageAddress}; +use stylus_sdk::{prelude::*, storage::StorageAddress}; use crate::{ access::ownable::{self, Ownable}, @@ -42,7 +42,6 @@ mod sol { address indexed previous_owner, address indexed new_owner ); - } } @@ -59,6 +58,7 @@ pub struct Ownable2Step { /// Interface for an [`Ownable2Step`] contract. #[interface_id] +#[public] pub trait IOwnable2Step { /// The error type associated to the trait implementation. type Error: Into>; @@ -176,7 +176,7 @@ impl IOwnable2Step for Ownable2Step { self.pending_owner.set(new_owner); let current_owner = self.owner(); - evm::log(OwnershipTransferStarted { + self.vm().log(OwnershipTransferStarted { previous_owner: current_owner, new_owner, }); @@ -184,7 +184,7 @@ impl IOwnable2Step for Ownable2Step { } fn accept_ownership(&mut self) -> Result<(), Self::Error> { - let sender = msg::sender(); + let sender = self.vm().msg_sender(); let pending_owner = self.pending_owner(); if sender != pending_owner { return Err(ownable::Error::UnauthorizedAccount( @@ -204,6 +204,7 @@ impl IOwnable2Step for Ownable2Step { // This is implemented so that [`Ownable2Step`] could be passed to functions // expecting [`ownable::IOwnable`]. +#[public] impl ownable::IOwnable for Ownable2Step { type Error = ownable::Error; diff --git a/contracts/src/finance/vesting_wallet.rs b/contracts/src/finance/vesting_wallet.rs index d5f5cdf1b..9a89e3e5a 100644 --- a/contracts/src/finance/vesting_wallet.rs +++ b/contracts/src/finance/vesting_wallet.rs @@ -35,9 +35,8 @@ use alloy_primitives::{aliases::B32, Address, U256, U64}; use openzeppelin_stylus_proc::interface_id; pub use sol::*; use stylus_sdk::{ - block, - call::{call, Call, MethodError}, - contract, evm, + call::call, + function_selector, prelude::*, storage::{StorageMap, StorageU256, StorageU64}, }; @@ -126,13 +125,13 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl From for Error { - fn from(value: stylus_sdk::call::Error) -> Self { +impl From for Error { + fn from(value: errors::Error) -> Self { match value { - stylus_sdk::call::Error::AbiDecodingFailed(_) => { + errors::Error::AbiDecodingFailed(_) => { Error::FailedCall(FailedCall {}) } - stylus_sdk::call::Error::Revert(reason) => { + errors::Error::Revert(reason) => { Error::ReleaseEtherFailed(ReleaseEtherFailed { reason: String::from_utf8_lossy(&reason).to_string(), }) @@ -156,7 +155,7 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -188,6 +187,7 @@ unsafe impl TopLevelStorage for VestingWallet {} /// Required interface of a [`VestingWallet`] compliant contract. #[interface_id] +#[public] pub trait IVestingWallet { /// The error type associated to this trait implementation. type Error: Into>; @@ -492,7 +492,8 @@ impl IVestingWallet for VestingWallet { fn releasable_eth(&self) -> U256 { // SAFETY: total vested amount is by definition greater than or equal to // the released amount. - self.vested_amount_eth(block::timestamp()) - self.released_eth() + self.vested_amount_eth(self.vm().block_timestamp()) + - self.released_eth() } #[selector(name = "releasable")] @@ -500,7 +501,8 @@ impl IVestingWallet for VestingWallet { &mut self, token: Address, ) -> Result { - let vested = self.vested_amount_erc20(token, block::timestamp())?; + let vested = + self.vested_amount_erc20(token, self.vm().block_timestamp())?; // SAFETY: total vested amount is by definition greater than or equal to // the released amount. Ok(vested - self.released_erc20(token)) @@ -517,9 +519,10 @@ impl IVestingWallet for VestingWallet { let owner = self.ownable.owner(); - call(Call::new_in(self).value(amount), owner, &[])?; + let call_context = Call::new_payable(self, amount); + call(self.vm(), call_context, owner, &[])?; - evm::log(EtherReleased { amount }); + self.vm().log(EtherReleased { amount }); Ok(()) } @@ -536,14 +539,16 @@ impl IVestingWallet for VestingWallet { self.safe_erc20.safe_transfer(token, owner, amount)?; - evm::log(ERC20Released { token, amount }); + self.vm().log(ERC20Released { token, amount }); Ok(()) } #[selector(name = "vestedAmount")] fn vested_amount_eth(&self, timestamp: u64) -> U256 { - let total_allocation = contract::balance() + let total_allocation = self + .vm() + .balance(self.vm().contract_address()) .checked_add(self.released_eth()) .expect("total allocation should not exceed `U256::MAX`"); @@ -558,7 +563,7 @@ impl IVestingWallet for VestingWallet { ) -> Result { let erc20 = Erc20Interface::new(token); let balance = erc20 - .balance_of(Call::new_in(self), contract::address()) + .balance_of(self.vm(), Call::new(), self.vm().contract_address()) .map_err(|_| InvalidToken { token })?; let total_allocation = balance @@ -619,10 +624,7 @@ impl IErc165 for VestingWallet { #[cfg(test)] mod tests { use motsu::prelude::*; - use stylus_sdk::{ - alloy_primitives::{uint, Address, U256, U64}, - block, - }; + use stylus_sdk::alloy_primitives::{uint, Address, U256, U64}; use super::*; use crate::token::erc20::{Erc20, IErc20}; @@ -632,7 +634,7 @@ mod tests { const DURATION: U64 = uint!(126144000_U64); // 4 years fn start() -> U64 { - U64::from(block::timestamp() + 3600) // 1 hour + U64::from(VM::context().block_timestamp() + 3600) // 1 hour } #[motsu::test] diff --git a/contracts/src/proxy/beacon/mod.rs b/contracts/src/proxy/beacon/mod.rs index 1a6e047b8..6b41d7261 100644 --- a/contracts/src/proxy/beacon/mod.rs +++ b/contracts/src/proxy/beacon/mod.rs @@ -2,6 +2,7 @@ use alloc::vec::Vec; use alloy_primitives::Address; +use stylus_sdk::prelude::public; pub mod proxy; pub mod upgradeable; @@ -14,6 +15,7 @@ pub use crate::proxy::abi::BeaconInterface; /// This is the interface that [`BeaconProxy`] expects of its beacon. #[interface_id] +#[public] pub trait IBeacon { /// Must return an address that can be used as a delegate call target. /// diff --git a/contracts/src/proxy/beacon/proxy.rs b/contracts/src/proxy/beacon/proxy.rs index 57f8e2d56..9239121f2 100644 --- a/contracts/src/proxy/beacon/proxy.rs +++ b/contracts/src/proxy/beacon/proxy.rs @@ -32,6 +32,7 @@ use crate::proxy::{ #[storage] pub struct BeaconProxy { beacon: StorageAddress, + erc1967_utils: Erc1967Utils, } /// NOTE: Implementation of [`TopLevelStorage`] to be able use `&mut self` when @@ -57,10 +58,9 @@ impl BeaconProxy { /// /// * [`Error::InvalidBeacon`] - If the beacon is not a contract with the /// interface [`IBeacon`][IBeacon]. - /// * [`Error::NonPayable`] - If the data is empty and - /// [`msg::value`][msg_value] is not [`U256::ZERO`][U256]. + /// * [`Error::NonPayable`] - If the data is empty and `msg_value()` is not + /// [`U256::ZERO`][U256]. /// - /// [msg_value]: stylus_sdk::msg::value /// [IBeacon]: super::IBeacon /// [U256]: alloy_primitives::U256 pub fn constructor( @@ -68,7 +68,7 @@ impl BeaconProxy { beacon: Address, data: &Bytes, ) -> Result<(), Error> { - Erc1967Utils::upgrade_beacon_to_and_call(self, beacon, data)?; + self.erc1967_utils.upgrade_beacon_to_and_call(beacon, data)?; self.beacon.set(beacon); Ok(()) } @@ -86,7 +86,8 @@ impl BeaconProxy { unsafe impl IProxy for BeaconProxy { fn implementation(&self) -> Result> { - Ok(BeaconInterface::new(self.get_beacon()).implementation(self)?) + Ok(BeaconInterface::new(self.get_beacon()) + .implementation(self.vm(), Call::new())?) } } @@ -107,12 +108,13 @@ mod tests { token::erc20::{self, abi::Erc20Abi}, }; - #[entrypoint] #[storage] struct BeaconProxyExample { beacon_proxy: BeaconProxy, } + unsafe impl TopLevelStorage for BeaconProxyExample {} + #[public] impl BeaconProxyExample { #[constructor] diff --git a/contracts/src/proxy/beacon/upgradeable.rs b/contracts/src/proxy/beacon/upgradeable.rs index 9b87e2dbd..dd89cb716 100644 --- a/contracts/src/proxy/beacon/upgradeable.rs +++ b/contracts/src/proxy/beacon/upgradeable.rs @@ -4,11 +4,12 @@ use alloc::{vec, vec::Vec}; use alloy_primitives::Address; pub use sol::*; -use stylus_sdk::{call::MethodError, evm, prelude::*, storage::StorageAddress}; +use stylus_sdk::{prelude::*, storage::StorageAddress}; use crate::{ access::ownable::{self, IOwnable, Ownable}, proxy::beacon::IBeacon, + utils::account::AccountAccessExt, }; #[cfg_attr(coverage_nightly, coverage(off))] @@ -47,7 +48,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -73,6 +74,7 @@ impl From for Error { /// upgrading the proxies that use this beacon. /// /// [BeaconProxy]: super::BeaconProxy +#[public] pub trait IUpgradeableBeacon: IBeacon + IOwnable> { /// Upgrades the beacon to a new implementation. /// @@ -181,7 +183,7 @@ impl UpgradeableBeacon { &mut self, new_implementation: Address, ) -> Result<(), Error> { - if !new_implementation.has_code() { + if !self.vm().has_code(new_implementation) { return Err(Error::InvalidImplementation( BeaconInvalidImplementation { implementation: new_implementation, @@ -189,7 +191,7 @@ impl UpgradeableBeacon { )); } self.implementation.set(new_implementation); - evm::log(Upgraded { implementation: new_implementation }); + self.vm().log(Upgraded { implementation: new_implementation }); Ok(()) } } @@ -224,7 +226,7 @@ impl IOwnable for UpgradeableBeacon { #[cfg(test)] mod tests { use motsu::prelude::*; - use stylus_sdk::alloy_primitives::Address; + use stylus_sdk::{alloy_primitives::Address, prelude::errors::MethodError}; use super::*; use crate::proxy::{beacon::IBeacon, tests::Erc20Example}; diff --git a/contracts/src/proxy/erc1967/mod.rs b/contracts/src/proxy/erc1967/mod.rs index 3a3192cb5..7f9fb81f6 100644 --- a/contracts/src/proxy/erc1967/mod.rs +++ b/contracts/src/proxy/erc1967/mod.rs @@ -41,7 +41,9 @@ mod sol { /// State of an [`Erc1967Proxy`] token. #[storage] -pub struct Erc1967Proxy; +pub struct Erc1967Proxy { + erc1967_utils: Erc1967Utils, +} /// NOTE: Implementation of [`TopLevelStorage`] to be able use `&mut self` when /// calling other contracts and not `&mut (impl TopLevelStorage + @@ -67,26 +69,25 @@ impl Erc1967Proxy { /// /// * [`Error::InvalidImplementation`] - If the implementation is not a /// valid implementation. - /// * [`Error::NonPayable`] - If `data` is empty and - /// [`msg::value`][msg_value] is not [`U256::ZERO`][U256]. + /// * [`Error::NonPayable`] - If `data` is empty and `msg::value()` is not + /// [`U256::ZERO`][U256]. /// * [`Error::FailedCall`] - If the call to the implementation fails. /// * [`Error::FailedCallWithReason`] - If the call to the implementation /// fails with a revert reason. /// - /// [msg_value]: stylus_sdk::msg::value /// [U256]: alloy_primitives::U256 pub fn constructor( &mut self, implementation: Address, - data: &Bytes, + data: Bytes, ) -> Result<(), Error> { - Erc1967Utils::upgrade_to_and_call(self, implementation, data) + self.erc1967_utils.upgrade_to_and_call(implementation, data) } } unsafe impl IProxy for Erc1967Proxy { fn implementation(&self) -> Result> { - Ok(Erc1967Utils::get_implementation()) + Ok(self.erc1967_utils.get_implementation()) } } @@ -107,12 +108,13 @@ mod tests { token::erc20::{self, abi::Erc20Abi}, }; - #[entrypoint] #[storage] struct Erc1967ProxyExample { erc1967: Erc1967Proxy, } + unsafe impl TopLevelStorage for Erc1967ProxyExample {} + #[public] impl Erc1967ProxyExample { #[constructor] @@ -121,7 +123,7 @@ mod tests { implementation: Address, data: Bytes, ) -> Result<(), Error> { - self.erc1967.constructor(implementation, &data) + self.erc1967.constructor(implementation, data) } fn implementation(&self) -> Result> { diff --git a/contracts/src/proxy/erc1967/utils.rs b/contracts/src/proxy/erc1967/utils.rs index d65993bb5..96c67ab8e 100644 --- a/contracts/src/proxy/erc1967/utils.rs +++ b/contracts/src/proxy/erc1967/utils.rs @@ -3,16 +3,16 @@ //! //! [ERC-1967]: https://eips.ethereum.org/EIPS/eip-1967 +use alloc::{vec, vec::Vec}; + use alloy_primitives::{aliases::B256, Address, U256}; pub use sol::*; -use stylus_sdk::{ - abi::Bytes, call::MethodError, evm, msg, prelude::*, - storage::StorageAddress, -}; +use stylus_sdk::{abi::Bytes, prelude::*, storage::StorageAddress}; use crate::{ proxy::{abi::BeaconInterface, erc1967}, utils::{ + account::AccountAccessExt, address::{self, AddressUtils}, storage_slot::StorageSlot, }, @@ -48,7 +48,7 @@ mod sol { error ERC1967InvalidBeacon(address beacon); /// Indicates an error relatoed to the fact that an upgrade function - /// sees [`stylus_sdk::msg::value()`] > [`U256::ZERO`] that may be lost. + /// sees `msg::value()` > [`U256::ZERO`] that may be lost. #[derive(Debug)] #[allow(missing_docs)] error ERC1967NonPayable(); @@ -68,7 +68,7 @@ pub enum Error { /// of the proxy is invalid. InvalidBeacon(ERC1967InvalidBeacon), /// Indicates an error relatoed to the fact that an upgrade function - /// sees [`stylus_sdk::msg::value()`] > [`alloy_primitives::U256::ZERO`] + /// sees `msg::value()` > [`alloy_primitives::U256::ZERO`] /// that may be lost. NonPayable(ERC1967NonPayable), /// There's no code at `target` (it is not a contract). @@ -94,7 +94,7 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -129,19 +129,23 @@ pub const BEACON_SLOT: B256 = { /// [ERC-1967] slots. /// /// [ERC-1967]: https://eips.ethereum.org/EIPS/eip-1967 -pub struct Erc1967Utils; +#[storage] +pub struct Erc1967Utils { + storage_slot: StorageSlot, + address_utils: AddressUtils, +} /// Implementation of the [`Erc1967Utils`] library. impl Erc1967Utils { /// Returns the current implementation address. #[must_use] - pub fn get_implementation() -> Address { - StorageSlot::get_slot::(IMPLEMENTATION_SLOT).get() + pub fn get_implementation(&self) -> Address { + self.storage_slot.get_slot::(IMPLEMENTATION_SLOT).get() } /// Performs implementation upgrade with additional setup call if /// data is nonempty. This function is payable only if the setup call - /// is performed, otherwise [`msg::value()`] is rejected to avoid stuck + /// is performed, otherwise `msg::value()` is rejected to avoid stuck /// value in the contract. /// /// # Arguments @@ -154,29 +158,26 @@ impl Erc1967Utils { /// /// * [`Error::InvalidImplementation`] - If the `new_implementation` address /// is not a valid implementation. - /// * [`Error::NonPayable`] - If `data` is empty and [`msg::value`] is not + /// * [`Error::NonPayable`] - If `data` is empty and `msg::value()` is not /// [`U256::ZERO`]. /// * [`Error::FailedCall`] - If the call to the implementation contract /// fails. /// * [`Error::FailedCallWithReason`] - If the call to the implementation /// contract fails with a revert reason. - pub fn upgrade_to_and_call( - context: &mut T, + pub fn upgrade_to_and_call( + &mut self, new_implementation: Address, - data: &Bytes, + data: Bytes, ) -> Result<(), Error> { - Erc1967Utils::set_implementation(new_implementation)?; + self.set_implementation(new_implementation)?; - evm::log(erc1967::Upgraded { implementation: new_implementation }); + self.vm().log(erc1967::Upgraded { implementation: new_implementation }); if data.is_empty() { - Erc1967Utils::check_non_payable()?; + self.check_non_payable()?; } else { - AddressUtils::function_delegate_call( - context, - new_implementation, - data.as_slice(), - )?; + self.address_utils + .function_delegate_call(new_implementation, data.as_ref())?; } Ok(()) @@ -184,8 +185,8 @@ impl Erc1967Utils { /// Returns the current admin. #[must_use] - pub fn get_admin() -> Address { - StorageSlot::get_slot::(ADMIN_SLOT).get() + pub fn get_admin(&self) -> Address { + self.storage_slot.get_slot::(ADMIN_SLOT).get() } /// Changes the admin of the proxy. @@ -198,24 +199,24 @@ impl Erc1967Utils { /// /// * [`Error::InvalidAdmin`] - If the `new_admin` address is not a valid /// admin. - pub fn change_admin(new_admin: Address) -> Result<(), Error> { - evm::log(erc1967::AdminChanged { - previous_admin: Erc1967Utils::get_admin(), + pub fn change_admin(&self, new_admin: Address) -> Result<(), Error> { + self.vm().log(erc1967::AdminChanged { + previous_admin: self.get_admin(), new_admin, }); - Erc1967Utils::set_admin(new_admin) + self.set_admin(new_admin) } /// Returns the current beacon. #[must_use] - pub fn get_beacon() -> Address { - StorageSlot::get_slot::(BEACON_SLOT).get() + pub fn get_beacon(&self) -> Address { + self.storage_slot.get_slot::(BEACON_SLOT).get() } /// Change the beacon and trigger a setup call if data is nonempty. /// This function is payable only if the setup call is performed, - /// otherwise [`msg::value()`] is rejected to avoid stuck value in the + /// otherwise `msg::value()` is rejected to avoid stuck value in the /// contract. /// /// # Arguments @@ -230,31 +231,28 @@ impl Erc1967Utils { /// beacon. /// * [`Error::InvalidImplementation`] - If the beacon implementation is not /// a valid implementation. - /// * [`Error::NonPayable`] - If `data` is empty and [`msg::value`] is not + /// * [`Error::NonPayable`] - If `data` is empty and `msg::value()` is not /// [`U256::ZERO`]. /// * [`Error::FailedCall`] - If the call to the beacon implementation /// fails. /// * [`Error::FailedCallWithReason`] - If the call to the beacon /// implementation fails with a revert reason. - pub fn upgrade_beacon_to_and_call( - context: &mut T, + pub fn upgrade_beacon_to_and_call( + &mut self, new_beacon: Address, data: &Bytes, ) -> Result<(), Error> { - Erc1967Utils::set_beacon(context, new_beacon)?; - evm::log(erc1967::BeaconUpgraded { beacon: new_beacon }); + self.set_beacon(new_beacon)?; + self.vm().log(erc1967::BeaconUpgraded { beacon: new_beacon }); if data.is_empty() { - Erc1967Utils::check_non_payable()?; + self.check_non_payable()?; } else { let beacon_implementation = - Erc1967Utils::get_beacon_implementation(context, new_beacon)?; + self.get_beacon_implementation(new_beacon)?; - AddressUtils::function_delegate_call( - context, - beacon_implementation, - data.as_slice(), - )?; + self.address_utils + .function_delegate_call(beacon_implementation, data.as_ref())?; } Ok(()) @@ -262,16 +260,16 @@ impl Erc1967Utils { } impl Erc1967Utils { - /// Reverts if [`msg::value()`] is not [`alloy_primitives::U256::ZERO`]. It - /// can be used to avoid [`msg::value()`] stuck in the contract if an + /// Reverts if `msg::value()` is not [`alloy_primitives::U256::ZERO`]. It + /// can be used to avoid `msg::value()` stuck in the contract if an /// upgrade does not perform an initialization call. /// /// # Errors /// - /// * [`Error::NonPayable`] - If [`msg::value()`] is not + /// * [`Error::NonPayable`] - If `msg::value()` is not /// [`alloy_primitives::U256::ZERO`]. - fn check_non_payable() -> Result<(), Error> { - if msg::value().is_zero() { + fn check_non_payable(&self) -> Result<(), Error> { + if self.vm().msg_value().is_zero() { Ok(()) } else { Err(ERC1967NonPayable {}.into()) @@ -288,15 +286,19 @@ impl Erc1967Utils { /// /// * [`Error::InvalidImplementation`] - If the `new_implementation` address /// is not a valid implementation. - fn set_implementation(new_implementation: Address) -> Result<(), Error> { - if !new_implementation.has_code() { + fn set_implementation( + &self, + new_implementation: Address, + ) -> Result<(), Error> { + if !self.vm().has_code(new_implementation) { return Err(ERC1967InvalidImplementation { implementation: new_implementation, } .into()); } - StorageSlot::get_slot::(IMPLEMENTATION_SLOT) + self.storage_slot + .get_slot::(IMPLEMENTATION_SLOT) .set(new_implementation); Ok(()) @@ -312,12 +314,12 @@ impl Erc1967Utils { /// /// * [`Error::InvalidAdmin`] - If the `new_admin` address is not a valid /// admin. - fn set_admin(new_admin: Address) -> Result<(), Error> { + fn set_admin(&self, new_admin: Address) -> Result<(), Error> { if new_admin.is_zero() { return Err(ERC1967InvalidAdmin { admin: new_admin }.into()); } - StorageSlot::get_slot::(ADMIN_SLOT).set(new_admin); + self.storage_slot.get_slot::(ADMIN_SLOT).set(new_admin); Ok(()) } @@ -339,20 +341,19 @@ impl Erc1967Utils { /// fails. /// * [`Error::FailedCallWithReason`] - If the call to the beacon /// implementation fails with a revert reason. - fn set_beacon( - context: &mut T, - new_beacon: Address, - ) -> Result<(), Error> { - if !new_beacon.has_code() { + fn set_beacon(&self, new_beacon: Address) -> Result<(), Error> { + if !self.vm().has_code(new_beacon) { return Err(ERC1967InvalidBeacon { beacon: new_beacon }.into()); } - StorageSlot::get_slot::(BEACON_SLOT).set(new_beacon); + self.storage_slot + .get_slot::(BEACON_SLOT) + .set(new_beacon); let beacon_implementation = - Erc1967Utils::get_beacon_implementation(context, new_beacon)?; + self.get_beacon_implementation(new_beacon)?; - if !beacon_implementation.has_code() { + if !self.vm().has_code(beacon_implementation) { return Err(ERC1967InvalidImplementation { implementation: beacon_implementation, } @@ -378,13 +379,13 @@ impl Erc1967Utils { /// * [`Error::FailedCallWithReason`] - If the call to the beacon /// implementation fails with a revert reason. /// * [`Error::EmptyCode`] - If the beacon implementation has no code. - fn get_beacon_implementation( - context: &T, + fn get_beacon_implementation( + &self, beacon: Address, ) -> Result { - Ok(AddressUtils::verify_call_result_from_target( + Ok(self.address_utils.verify_call_result_from_target( beacon, - BeaconInterface::new(beacon).implementation(context), + BeaconInterface::new(beacon).implementation(self.vm(), Call::new()), )?) } } @@ -392,28 +393,30 @@ impl Erc1967Utils { #[cfg(test)] #[allow(clippy::needless_pass_by_value, clippy::unused_self)] mod tests { - use alloy_sol_types::SolCall; use motsu::prelude::*; use stylus_sdk::{ alloy_primitives::{uint, Address}, function_selector, - prelude::*, + prelude::{errors::MethodError, *}, storage::StorageAddress, }; use super::*; use crate::proxy::beacon::IBeacon; - #[entrypoint] #[storage] - struct TestContract; + struct TestContract { + erc1967_utils: Erc1967Utils, + } + + unsafe impl TopLevelStorage for TestContract {} #[public] impl TestContract { // test functions that wrap [`Erc1967Utils`] methods. fn test_get_implementation(&self) -> Address { - Erc1967Utils::get_implementation() + self.erc1967_utils.get_implementation() } fn test_upgrade_to_and_call( @@ -421,26 +424,24 @@ mod tests { new_implementation: Address, data: Bytes, ) -> Result<(), Vec> { - Ok(Erc1967Utils::upgrade_to_and_call( - self, - new_implementation, - &data, - )?) + Ok(self + .erc1967_utils + .upgrade_to_and_call(new_implementation, data)?) } fn test_get_admin(&self) -> Address { - Erc1967Utils::get_admin() + self.erc1967_utils.get_admin() } fn test_change_admin( &mut self, new_admin: Address, ) -> Result<(), Vec> { - Ok(Erc1967Utils::change_admin(new_admin)?) + Ok(self.erc1967_utils.change_admin(new_admin)?) } fn test_get_beacon(&self) -> Address { - Erc1967Utils::get_beacon() + self.erc1967_utils.get_beacon() } fn test_upgrade_beacon_to_and_call( @@ -448,9 +449,9 @@ mod tests { new_beacon: Address, data: Bytes, ) -> Result<(), Vec> { - Ok(Erc1967Utils::upgrade_beacon_to_and_call( - self, new_beacon, &data, - )?) + Ok(self + .erc1967_utils + .upgrade_beacon_to_and_call(new_beacon, &data)?) } } @@ -506,7 +507,7 @@ mod tests { ImplementationError(ImplementationSolidityError), } - impl MethodError for ImplementationError { + impl errors::MethodError for ImplementationError { fn encode(self) -> Vec { self.into() } @@ -528,7 +529,7 @@ mod tests { ImplementationSolidityError {}, )); } - evm::log(ImplementationEvent {}); + self.vm().log(ImplementationEvent {}); Ok(()) } } @@ -694,7 +695,7 @@ mod tests { assert_eq!( err, Error::FailedCallWithReason(address::FailedCallWithReason { - reason: stylus_sdk::call::Error::Revert(vec).encode().into() + reason: errors::Error::Revert(vec).encode().into() }) .encode(), ); @@ -1132,7 +1133,7 @@ mod tests { assert_eq!( err, Error::FailedCallWithReason(address::FailedCallWithReason { - reason: stylus_sdk::call::Error::Revert(vec).encode().into() + reason: errors::Error::Revert(vec).encode().into() }) .encode(), ); @@ -1253,13 +1254,12 @@ mod tests { // target.has_code() == false, // AddressUtils::verify_call_result_from_target must return // AddressEmptyCode. - let err = Erc1967Utils::get_beacon_implementation( - &*contract.sender(alice), + let err = contract.sender(alice).erc1967_utils.get_beacon_implementation( invalid_beacon.address(), ) - .motsu_expect_err( - "expected EmptyCode when beacon call returns empty and has no code", - ); + .motsu_expect_err( + "expected EmptyCode when beacon call returns empty and has no code", + ); assert!(matches!( err, diff --git a/contracts/src/proxy/mod.rs b/contracts/src/proxy/mod.rs index 948103d11..c5320656e 100644 --- a/contracts/src/proxy/mod.rs +++ b/contracts/src/proxy/mod.rs @@ -3,10 +3,7 @@ use alloc::vec::Vec; use alloy_primitives::Address; -use stylus_sdk::{ - call::{self, Call, Error}, - prelude::*, -}; +use stylus_sdk::{call, prelude::*}; pub mod abi; pub mod beacon; @@ -14,7 +11,7 @@ pub mod erc1967; pub mod utils; /// This trait provides a fallback function that delegates all calls to another -/// contract using the Stylus [`delegate_call`][delegate_call] function. We +/// contract using the Stylus [`delegate_call`] function. We /// refer to the second contract as the _implementation_ behind the proxy, and /// it has to be specified by overriding the virtual [`IProxy::implementation`] /// function. @@ -29,15 +26,13 @@ pub mod utils; /// # Safety /// /// This trait is unsafe to implement because it uses the `unsafe` -/// [`delegate_call`][delegate_call] function. +/// [`delegate_call`] function. /// /// The caller must ensure that `self` is a valid contract storage context. /// /// The caller must ensure that the implementation contract is a valid contract /// address. -/// -/// [delegate_call]: stylus_sdk::call::delegate_call -pub unsafe trait IProxy: TopLevelStorage + Sized { +pub unsafe trait IProxy: TopLevelStorage + Sized + HostAccess { /// Delegates the current call to [`IProxy::implementation`]. /// /// This function does not return to its internal call site, it will @@ -51,7 +46,7 @@ pub unsafe trait IProxy: TopLevelStorage + Sized { /// /// # Errors /// - /// Returns a [`stylus_sdk::call::Error`] if the delegate call fails. This + /// Returns a [`errors::Error`] if the delegate call fails. This /// error may represent: /// * A revert from the implementation contract, containing the revert data. /// * Failure to decode the return data from the implementation contract. @@ -61,8 +56,9 @@ pub unsafe trait IProxy: TopLevelStorage + Sized { &mut self, implementation: Address, calldata: &[u8], - ) -> Result, Error> { - call::delegate_call(Call::new_in(self), implementation, calldata) + ) -> Result, errors::Error> { + let call = Call::new_mutating(self); + call::delegate_call(self.vm(), call, implementation, calldata) } /// This is a virtual function that should be overridden so it @@ -124,13 +120,14 @@ mod tests { use super::*; use crate::token::erc20::{self, abi::Erc20Abi, Erc20, IErc20}; - #[entrypoint] #[storage] struct ProxyExample { implementation: StorageAddress, error_on_implementation: StorageBool, } + unsafe impl TopLevelStorage for ProxyExample {} + #[public] impl ProxyExample { #[constructor] diff --git a/contracts/src/proxy/utils/erc1822.rs b/contracts/src/proxy/utils/erc1822.rs index 58cb3c1cc..04bc4a5ef 100644 --- a/contracts/src/proxy/utils/erc1822.rs +++ b/contracts/src/proxy/utils/erc1822.rs @@ -5,12 +5,14 @@ use alloc::vec::Vec; use alloy_primitives::aliases::B256; use openzeppelin_stylus_proc::interface_id; +use stylus_sdk::prelude::public; /// Public interface for Universal Upgradeable Proxy Standard (UUPS). /// /// This interface documents a method for upgradeability through a simplified /// proxy whose upgrades are fully controlled by the current implementation. #[interface_id] +#[public] pub trait IErc1822Proxiable { /// Returns the storage slot that the proxiable contract assumes is being /// used to store the implementation address. diff --git a/contracts/src/proxy/utils/uups_upgradeable.rs b/contracts/src/proxy/utils/uups_upgradeable.rs index 221eccf70..d6757aaf4 100644 --- a/contracts/src/proxy/utils/uups_upgradeable.rs +++ b/contracts/src/proxy/utils/uups_upgradeable.rs @@ -24,7 +24,6 @@ use alloy_sol_types::SolCall; pub use sol::*; use stylus_sdk::{ abi::Bytes, - call::{Call, MethodError}, prelude::*, storage::{StorageBool, StorageU32}, }; @@ -55,7 +54,7 @@ pub const UPGRADE_INTERFACE_VERSION: &str = "5.0.0"; pub const VERSION_NUMBER: U32 = U32::ONE; /// A sentinel storage slot used by the implementation to distinguish -/// implementation vs. proxy ([`delegate_call`][delegate_call]) execution +/// implementation vs. proxy ([`delegate_call`]) execution /// contexts. /// /// The slot key is derived from `keccak256("Stylus.uups.logic.flag") - 1`, @@ -63,14 +62,11 @@ pub const VERSION_NUMBER: U32 = U32::ONE; /// /// Behavior: /// - When called directly on the implementation, `logic_flag == true`. -/// - When called via a proxy ([`delegate_call`][delegate_call]), `logic_flag == -/// false` (i.e., the proxy’s storage does not contain this -/// implementation-only flag). +/// - When called via a proxy ([`delegate_call`]), `logic_flag == false` (i.e., +/// the proxy’s storage does not contain this implementation-only flag). /// /// Security notes: /// - This boolean flag replaces Solidity’s `immutable __self` pattern. -/// -/// [delegate_call]: stylus_sdk::call::delegate_call pub const LOGIC_FLAG_SLOT: B256 = { const HASH: [u8; 32] = keccak_const::Keccak256::new() .update(b"Stylus.uups.logic.flag") @@ -129,7 +125,7 @@ pub enum Error { /// of the proxy is invalid. InvalidBeacon(ERC1967InvalidBeacon), /// Indicates an error related to the fact that an upgrade function - /// sees [`stylus_sdk::msg::value()`] > [`alloy_primitives::U256::ZERO`] + /// sees `msg::value()` > [`alloy_primitives::U256::ZERO`] /// that may be lost. NonPayable(ERC1967NonPayable), /// There's no code at `target` (it is not a contract). @@ -167,7 +163,7 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -180,6 +176,7 @@ unsafe impl TopLevelStorage for UUPSUpgradeable {} /// Interface for a UUPS (Universal Upgradeable Proxy Standard) upgradeable /// contract. +#[public] pub trait IUUPSUpgradeable: IErc1822Proxiable { /// Returns the version of the upgrade interface of the contract. /// @@ -342,6 +339,9 @@ pub trait IUUPSUpgradeable: IErc1822Proxiable { pub struct UUPSUpgradeable { /// Logic version number stored in the proxy contract. pub version: StorageU32, + address_utils: AddressUtils, + storage_slot: StorageSlot, + erc1967_utils: Erc1967Utils, } #[public] @@ -408,15 +408,12 @@ impl IUUPSUpgradeable for UUPSUpgradeable { data: Bytes, ) -> Result<(), Vec> { self.only_proxy()?; - self._upgrade_to_and_call_uups(new_implementation, &data)?; + self._upgrade_to_and_call_uups(new_implementation, data)?; let data_set_version = UUPSUpgradeableAbi::setVersionCall {}.abi_encode(); - AddressUtils::function_delegate_call( - self, - new_implementation, - &data_set_version, - )?; + self.address_utils + .function_delegate_call(new_implementation, &data_set_version)?; Ok(()) } @@ -440,7 +437,7 @@ impl UUPSUpgradeable { /// * `&self` - Read access to the contract's state. #[must_use] pub fn logic_flag(&self) -> StorageBool { - StorageSlot::get_slot::(LOGIC_FLAG_SLOT) + self.storage_slot.get_slot::(LOGIC_FLAG_SLOT) } /// Return the value stored in the logic flag slot. @@ -456,8 +453,8 @@ impl UUPSUpgradeable { /// Ensures the call is being made through a valid [ERC-1967] proxy. /// /// Checks: - /// 1. Execution is happening via [`delegate_call`][delegate_call] (checked - /// via `!self.is_logic()`). + /// 1. Execution is happening via [`delegate_call`] (checked via + /// `!self.is_logic()`). /// 2. The caller is a valid [ERC-1967] proxy (implementation slot is /// non-zero). /// 3. The proxy state is consistent for this logic (the proxy-stored @@ -489,10 +486,9 @@ impl UUPSUpgradeable { /// /// [ERC-1967]: https://eips.ethereum.org/EIPS/eip-1967 /// [ERC-1167]: https://eips.ethereum.org/EIPS/eip-1167 - /// [delegate_call]: stylus_sdk::call::delegate_call pub fn only_proxy(&self) -> Result<(), Error> { if self.is_logic() - || Erc1967Utils::get_implementation().is_zero() + || self.erc1967_utils.get_implementation().is_zero() || U32::from(self.get_version()) != self.version.get() { Err(Error::UnauthorizedCallContext(UUPSUnauthorizedCallContext {})) @@ -583,10 +579,10 @@ impl UUPSUpgradeable { fn _upgrade_to_and_call_uups( &mut self, new_implementation: Address, - data: &Bytes, + data: Bytes, ) -> Result<(), Error> { let slot = Erc1822ProxiableInterface::new(new_implementation) - .proxiable_uuid(Call::new_in(self)) + .proxiable_uuid(self.vm(), Call::new()) .map_err(|_e| { Error::InvalidImplementation(ERC1967InvalidImplementation { implementation: new_implementation, @@ -594,7 +590,8 @@ impl UUPSUpgradeable { })?; if slot == IMPLEMENTATION_SLOT { - Erc1967Utils::upgrade_to_and_call(self, new_implementation, data) + self.erc1967_utils + .upgrade_to_and_call(new_implementation, data) .map_err(Error::from) } else { Err(Error::UnsupportedProxiableUUID(UUPSUnsupportedProxiableUUID { @@ -638,12 +635,13 @@ mod tests { } - #[entrypoint] #[storage] pub struct Erc1967ProxyExample { erc1967: Erc1967Proxy, } + unsafe impl TopLevelStorage for Erc1967ProxyExample {} + #[public] impl Erc1967ProxyExample { #[constructor] @@ -652,7 +650,7 @@ mod tests { implementation: Address, ) -> Result<(), proxy::erc1967::utils::Error> { let data = TestErc20Abi::setVersionCall {}.abi_encode(); - self.erc1967.constructor(implementation, &data.into()) + self.erc1967.constructor(implementation, data.into()) } pub(super) fn implementation(&self) -> Result> { diff --git a/contracts/src/token/common/erc2981.rs b/contracts/src/token/common/erc2981.rs index c2723a0ed..26ca03d66 100644 --- a/contracts/src/token/common/erc2981.rs +++ b/contracts/src/token/common/erc2981.rs @@ -26,7 +26,6 @@ use alloy_primitives::{ use openzeppelin_stylus_proc::interface_id; pub use sol::*; use stylus_sdk::{ - call::MethodError, prelude::*, storage::{StorageAddress, StorageMap}, }; @@ -99,7 +98,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -133,6 +132,7 @@ pub struct Erc2981 { /// tokens (NFTs) to enable universal support for royalty payments across all /// NFT marketplaces and ecosystem participants. #[interface_id] +#[public] pub trait IErc2981: IErc165 { /// Returns how much royalty is owed and to whom, based on a sale price that /// may be denominated in any unit of exchange. diff --git a/contracts/src/token/erc1155/extensions/burnable.rs b/contracts/src/token/erc1155/extensions/burnable.rs index 1440f717f..aab654678 100644 --- a/contracts/src/token/erc1155/extensions/burnable.rs +++ b/contracts/src/token/erc1155/extensions/burnable.rs @@ -4,7 +4,7 @@ use alloc::vec::Vec; use alloy_primitives::{Address, U256}; use openzeppelin_stylus_proc::interface_id; -use stylus_sdk::msg; +use stylus_sdk::prelude::{public, HostAccess, MessageAccess}; use crate::token::erc1155::{ self, ERC1155MissingApprovalForAll, Erc1155, IErc1155, @@ -13,6 +13,7 @@ use crate::token::erc1155::{ /// Extension of [`Erc1155`] that allows token holders to destroy both their /// own tokens and those that they have been approved to use. #[interface_id] +#[public] pub trait IErc1155Burnable { /// The error type associated to this trait implementation. type Error: Into>; @@ -69,6 +70,7 @@ pub trait IErc1155Burnable { ) -> Result<(), Self::Error>; } +#[public] impl IErc1155Burnable for Erc1155 { type Error = erc1155::Error; @@ -98,7 +100,7 @@ impl Erc1155 { &self, account: Address, ) -> Result<(), erc1155::Error> { - let sender = msg::sender(); + let sender = self.vm().msg_sender(); if account != sender && !self.is_approved_for_all(account, sender) { return Err(erc1155::Error::MissingApprovalForAll( ERC1155MissingApprovalForAll { diff --git a/contracts/src/token/erc1155/extensions/metadata_uri.rs b/contracts/src/token/erc1155/extensions/metadata_uri.rs index 307f87a16..d4ffbb4e5 100644 --- a/contracts/src/token/erc1155/extensions/metadata_uri.rs +++ b/contracts/src/token/erc1155/extensions/metadata_uri.rs @@ -40,6 +40,7 @@ pub struct Erc1155MetadataUri { /// Interface for the optional metadata functions from the ERC-1155 standard. #[interface_id] +#[public] pub trait IErc1155MetadataUri { /// Returns the URI for token type `id`. /// diff --git a/contracts/src/token/erc1155/extensions/supply.rs b/contracts/src/token/erc1155/extensions/supply.rs index c88ab8420..e1baabafc 100644 --- a/contracts/src/token/erc1155/extensions/supply.rs +++ b/contracts/src/token/erc1155/extensions/supply.rs @@ -17,7 +17,6 @@ use alloy_primitives::{aliases::B32, Address, U256}; use openzeppelin_stylus_proc::interface_id; use stylus_sdk::{ abi::Bytes, - msg, prelude::*, storage::{StorageMap, StorageU256}, }; @@ -43,6 +42,7 @@ pub struct Erc1155Supply { /// Required interface of a [`Erc1155Supply`] contract. #[interface_id] +#[public] pub trait IErc1155Supply: IErc165 { /// Total value of tokens in with a given id. /// @@ -295,7 +295,7 @@ impl Erc1155Supply { if !to.is_zero() { self.erc1155._check_on_erc1155_received( - msg::sender(), + self.vm().msg_sender(), from, to, erc1155::Erc1155ReceiverData::new(ids, values), diff --git a/contracts/src/token/erc1155/extensions/uri_storage.rs b/contracts/src/token/erc1155/extensions/uri_storage.rs index 6af2f99bc..dcceea0e2 100644 --- a/contracts/src/token/erc1155/extensions/uri_storage.rs +++ b/contracts/src/token/erc1155/extensions/uri_storage.rs @@ -6,7 +6,6 @@ use alloc::{string::String, vec, vec::Vec}; use alloy_primitives::U256; use openzeppelin_stylus_proc::interface_id; use stylus_sdk::{ - evm, prelude::*, storage::{StorageMap, StorageString}, }; @@ -25,6 +24,7 @@ pub struct Erc1155UriStorage { /// Interface of an optional extension for ERC-1155 with storage based token URI /// management. #[interface_id] +#[public] pub trait IErc1155UriStorage { /// Returns the Uniform Resource Identifier (URI) for `token_id` token. /// @@ -71,7 +71,8 @@ impl Erc1155UriStorage { metadata_uri: &impl IErc1155MetadataUri, ) { self.token_uris.setter(token_id).set_str(token_uri); - evm::log(URI { value: self.uri(token_id, metadata_uri), id: token_id }); + self.vm() + .log(URI { value: self.uri(token_id, metadata_uri), id: token_id }); } /// Sets `base_uri` as the `base_uri` for all tokens. diff --git a/contracts/src/token/erc1155/mod.rs b/contracts/src/token/erc1155/mod.rs index 4b5780e35..e933ec40f 100644 --- a/contracts/src/token/erc1155/mod.rs +++ b/contracts/src/token/erc1155/mod.rs @@ -9,8 +9,7 @@ use alloy_primitives::{aliases::B32, Address, U256}; use openzeppelin_stylus_proc::interface_id; use stylus_sdk::{ abi::Bytes, - call::{self, Call, MethodError}, - evm, msg, + function_selector, prelude::*, storage::{StorageBool, StorageMap, StorageU256}, }; @@ -30,6 +29,9 @@ pub use receiver::{ IErc1155Receiver, BATCH_TRANSFER_FN_SELECTOR, SINGLE_TRANSFER_FN_SELECTOR, }; pub use sol::*; + +use crate::utils::account::AccountAccessExt; + #[cfg_attr(coverage_nightly, coverage(off))] mod sol { use alloy_sol_macro::sol; @@ -179,7 +181,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -202,6 +204,7 @@ unsafe impl TopLevelStorage for Erc1155 {} /// Required interface of an [`Erc1155`] compliant contract. #[interface_id] +#[public] pub trait IErc1155: IErc165 { /// The error type associated to this ERC-1155 trait implementation. type Error: Into>; @@ -242,7 +245,7 @@ pub trait IErc1155: IErc165 { /// * `operator` - Account to add to the set of authorized operators. /// * `approved` - Flag that determines whether or not permission will be /// granted to `operator`. If true, this means `operator` will be allowed - /// to manage `msg::sender()`'s assets. + /// to manage `self.vm().msg_sender()`'s assets. /// /// # Errors /// @@ -287,8 +290,8 @@ pub trait IErc1155: IErc165 { /// interface id or returned with error. /// * [`Error::InvalidSender`] - Returned when `from` is [`Address::ZERO`]. /// * [`Error::MissingApprovalForAll`] - Returned when `from` is not the - /// caller (`msg::sender()`), and the caller does not have the right to - /// approve. + /// caller (`self.vm().msg_sender()`), and the caller does not have the + /// right to approve. /// * [`Error::InsufficientBalance`] - Returned when `value` is greater than /// the balance of the `from` account. /// @@ -327,8 +330,8 @@ pub trait IErc1155: IErc165 { /// * [`Error::InsufficientBalance`] - Returned when any of the `values` is /// greater than the balance of the `from` account. /// * [`Error::MissingApprovalForAll`] - Returned when `from` is not the - /// caller (`msg::sender()`), and the caller does not have the right to - /// approve. + /// caller (`self.vm().msg_sender()`), and the caller does not have the + /// right to approve. /// /// # Events /// @@ -377,7 +380,7 @@ impl IErc1155 for Erc1155 { operator: Address, approved: bool, ) -> Result<(), Self::Error> { - self._set_approval_for_all(msg::sender(), operator, approved) + self._set_approval_for_all(self.vm().msg_sender(), operator, approved) } fn is_approved_for_all(&self, account: Address, operator: Address) -> bool { @@ -458,7 +461,7 @@ impl Erc1155 { ) -> Result<(), Error> { Self::require_equal_arrays_length(&ids, &values)?; - let operator = msg::sender(); + let operator = self.vm().msg_sender(); for (&token_id, &value) in ids.iter().zip(values.iter()) { self.do_update(from, to, token_id, value)?; @@ -467,9 +470,9 @@ impl Erc1155 { if ids.len() == 1 { let id = ids[0]; let value = values[0]; - evm::log(TransferSingle { operator, from, to, id, value }); + self.vm().log(TransferSingle { operator, from, to, id, value }); } else { - evm::log(TransferBatch { operator, from, to, ids, values }); + self.vm().log(TransferBatch { operator, from, to, ids, values }); } Ok(()) @@ -522,7 +525,7 @@ impl Erc1155 { if !to.is_zero() { self._check_on_erc1155_received( - msg::sender(), + self.vm().msg_sender(), from, to, Erc1155ReceiverData::new(ids, values), @@ -672,7 +675,7 @@ impl Erc1155 { /// # Arguments /// /// * `&mut self` - Write access to the contract's state. - /// * `owner` - Tokens owner (`msg::sender`). + /// * `owner` - Tokens owner (`msg_sender()`). /// * `operator` - Account to add to the set of authorized operators. /// * `approved` - Flag that determines whether or not permission will be /// granted to `operator`. If true, this means `operator` will be allowed @@ -697,7 +700,7 @@ impl Erc1155 { })); } self.operator_approvals.setter(owner).setter(operator).set(approved); - evm::log(ApprovalForAll { account: owner, operator, approved }); + self.vm().log(ApprovalForAll { account: owner, operator, approved }); Ok(()) } } @@ -719,7 +722,7 @@ impl Erc1155 { /// /// * `&mut self` - Write access to the contract's state. /// * `operator` - Generally the address that initiated the token transfer - /// (e.g. `msg::sender()`). + /// (e.g. `self.vm().msg_sender()`). /// * `from` - Account of the sender. /// * `to` - Account of the recipient. /// * `details` - Details about token transfer, check @@ -745,26 +748,39 @@ impl Erc1155 { details: Erc1155ReceiverData, data: alloy_primitives::Bytes, ) -> Result<(), Error> { - if !to.has_code() { + if !self.vm().has_code(to) { return Ok(()); } let receiver = Erc1155ReceiverInterface::new(to); - let call = Call::new_in(self); + let call = Call::new_mutating(self); let result = match details.transfer { - Transfer::Single { id, value } => receiver - .on_erc_1155_received(call, operator, from, id, value, data), + Transfer::Single { id, value } => receiver.on_erc_1155_received( + self.vm(), + call, + operator, + from, + id, + value, + data, + ), Transfer::Batch { ids, values } => receiver .on_erc_1155_batch_received( - call, operator, from, ids, values, data, + self.vm(), + call, + operator, + from, + ids, + values, + data, ), }; let id = match result { Ok(id) => id, Err(e) => { - if let call::Error::Revert(ref reason) = e { + if let errors::Error::Revert(ref reason) = e { if !reason.is_empty() { return Err(Error::InvalidReceiverWithReason( InvalidReceiverWithReason { @@ -1022,7 +1038,7 @@ impl Erc1155 { Ok(()) } - /// Checks if `msg::sender()` is authorized to transfer tokens. + /// Checks if `self.vm().msg_sender()` is authorized to transfer tokens. /// /// # Arguments /// @@ -1032,9 +1048,10 @@ impl Erc1155 { /// # Errors /// /// * [`Error::MissingApprovalForAll`] - If the `from` is not the caller - /// (`msg::sender()`), and the caller does not have the right to approve. + /// (`self.vm().msg_sender()`), and the caller does not have the right to + /// approve. fn authorize_transfer(&self, from: Address) -> Result<(), Error> { - let sender = msg::sender(); + let sender = self.vm().msg_sender(); if from != sender && !self.is_approved_for_all(from, sender) { return Err(Error::MissingApprovalForAll( ERC1155MissingApprovalForAll { operator: sender, owner: from }, diff --git a/contracts/src/token/erc1155/receiver.rs b/contracts/src/token/erc1155/receiver.rs index c925dfaaa..bbb4096e2 100644 --- a/contracts/src/token/erc1155/receiver.rs +++ b/contracts/src/token/erc1155/receiver.rs @@ -6,7 +6,7 @@ use alloc::vec::Vec; use alloy_primitives::{aliases::B32, Address, U256}; use openzeppelin_stylus_proc::interface_id; -use stylus_sdk::{abi::Bytes, function_selector}; +use stylus_sdk::{abi::Bytes, function_selector, prelude::*}; use crate::utils::introspection::erc165::IErc165; @@ -34,6 +34,7 @@ pub const BATCH_TRANSFER_FN_SELECTOR: B32 = B32::new(function_selector!( /// Interface that must be implemented by smart contracts in order to receive /// ERC-1155 token transfers. #[interface_id] +#[public] pub trait IErc1155Receiver: IErc165 { /// Handles the receipt of a single ERC-1155 token type. This function /// is called at the end of [`super::IErc1155::safe_transfer_from`] after diff --git a/contracts/src/token/erc20/extensions/burnable.rs b/contracts/src/token/erc20/extensions/burnable.rs index b0a1d38e6..306632730 100644 --- a/contracts/src/token/erc20/extensions/burnable.rs +++ b/contracts/src/token/erc20/extensions/burnable.rs @@ -1,13 +1,16 @@ //! Optional Burnable extension of the ERC-20 standard. +use alloc::vec::Vec; + use alloy_primitives::{Address, U256}; -use stylus_sdk::msg; +use stylus_sdk::prelude::{public, HostAccess, MessageAccess}; use crate::token::erc20::{self, Erc20}; /// Extension of [`Erc20`] that allows token holders to destroy both /// their own tokens and those that they have an allowance for, /// in a way that can be recognized off-chain (via event analysis). +#[public] pub trait IErc20Burnable { /// The error type associated to this ERC-20 Burnable trait implementation. type Error: Into>; @@ -58,11 +61,12 @@ pub trait IErc20Burnable { ) -> Result<(), Self::Error>; } +#[public] impl IErc20Burnable for Erc20 { type Error = erc20::Error; fn burn(&mut self, value: U256) -> Result<(), Self::Error> { - self._burn(msg::sender(), value) + self._burn(self.vm().msg_sender(), value) } fn burn_from( @@ -70,7 +74,7 @@ impl IErc20Burnable for Erc20 { account: Address, value: U256, ) -> Result<(), Self::Error> { - self._spend_allowance(account, msg::sender(), value)?; + self._spend_allowance(account, self.vm().msg_sender(), value)?; self._burn(account, value) } } @@ -126,7 +130,7 @@ mod tests { #[motsu::test] fn burn_from(contract: Contract, alice: Address, bob: Address) { - // Alice approves `msg::sender`. + // Alice approves `msg_sender()`. let one = U256::ONE; contract.sender(alice).approve(bob, one).motsu_unwrap(); @@ -152,7 +156,7 @@ mod tests { alice: Address, bob: Address, ) { - // Alice approves `msg::sender`. + // Alice approves `msg_sender()`. let one = U256::ONE; contract.sender(alice).approve(bob, one).motsu_unwrap(); diff --git a/contracts/src/token/erc20/extensions/capped.rs b/contracts/src/token/erc20/extensions/capped.rs index 43ae6099a..5058424be 100644 --- a/contracts/src/token/erc20/extensions/capped.rs +++ b/contracts/src/token/erc20/extensions/capped.rs @@ -10,7 +10,7 @@ use alloc::{vec, vec::Vec}; use alloy_primitives::U256; use openzeppelin_stylus_proc::interface_id; pub use sol::*; -use stylus_sdk::{call::MethodError, prelude::*, storage::StorageU256}; +use stylus_sdk::{prelude::*, storage::StorageU256}; #[cfg_attr(coverage_nightly, coverage(off))] mod sol { @@ -43,7 +43,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -58,6 +58,7 @@ pub struct Capped { /// Interface for the token supply cap logic. #[interface_id] +#[public] pub trait ICapped { /// Returns the cap on the token's total supply. #[must_use] diff --git a/contracts/src/token/erc20/extensions/erc4626.rs b/contracts/src/token/erc20/extensions/erc4626.rs index ff78e15f7..5da3fcd2a 100644 --- a/contracts/src/token/erc20/extensions/erc4626.rs +++ b/contracts/src/token/erc20/extensions/erc4626.rs @@ -13,8 +13,6 @@ use alloy_primitives::{uint, Address, U256, U8}; use openzeppelin_stylus_proc::interface_id; pub use sol::*; use stylus_sdk::{ - call::{Call, MethodError}, - contract, evm, msg, prelude::*, storage::{StorageAddress, StorageU8}, }; @@ -178,7 +176,7 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -204,6 +202,7 @@ unsafe impl TopLevelStorage for Erc4626 {} /// ERC-4626 Tokenized Vault Standard Interface #[interface_id] +#[public] pub trait IErc4626: IErc20Metadata { /// The error type associated to the trait implementation. type Error: Into>; @@ -659,8 +658,9 @@ impl Erc4626 { pub fn total_assets(&self) -> Result { let asset = self.asset(); let erc20 = Erc20Interface::new(asset); + let contract_address = self.vm().contract_address(); erc20 - .balance_of(self, contract::address()) + .balance_of(self.vm(), Call::new(), contract_address) .map_err(|_| InvalidAsset { asset }.into()) } @@ -773,7 +773,7 @@ impl Erc4626 { let shares = self.preview_deposit(assets, erc20)?; - self._deposit(msg::sender(), receiver, assets, shares, erc20)?; + self._deposit(self.vm().msg_sender(), receiver, assets, shares, erc20)?; Ok(shares) } @@ -797,7 +797,7 @@ impl Erc4626 { } let assets = self.preview_mint(shares, erc20)?; - self._deposit(msg::sender(), receiver, assets, shares, erc20)?; + self._deposit(self.vm().msg_sender(), receiver, assets, shares, erc20)?; Ok(assets) } @@ -820,7 +820,14 @@ impl Erc4626 { } let shares = self.preview_withdraw(assets, erc20)?; - self._withdraw(msg::sender(), receiver, owner, assets, shares, erc20)?; + self._withdraw( + self.vm().msg_sender(), + receiver, + owner, + assets, + shares, + erc20, + )?; Ok(shares) } @@ -845,7 +852,14 @@ impl Erc4626 { let assets = self.preview_redeem(shares, erc20)?; - self._withdraw(msg::sender(), receiver, owner, assets, shares, erc20)?; + self._withdraw( + self.vm().msg_sender(), + receiver, + owner, + assets, + shares, + erc20, + )?; Ok(assets) } @@ -1034,13 +1048,18 @@ impl Erc4626 { self.safe_erc20.safe_transfer_from( self.asset(), caller, - contract::address(), + self.vm().contract_address(), assets, )?; erc20._mint(receiver, shares)?; - evm::log(Deposit { sender: caller, owner: receiver, assets, shares }); + self.vm().log(Deposit { + sender: caller, + owner: receiver, + assets, + shares, + }); Ok(()) } @@ -1092,7 +1111,13 @@ impl Erc4626 { self.safe_erc20.safe_transfer(self.asset(), receiver, assets)?; - evm::log(Withdraw { sender: caller, receiver, owner, assets, shares }); + self.vm().log(Withdraw { + sender: caller, + receiver, + owner, + assets, + shares, + }); Ok(()) } @@ -1112,8 +1137,8 @@ impl Erc4626 { /// Solidity's boolean tuple return. fn try_get_asset_decimals(&mut self, asset: Address) -> Option { let erc20 = Erc20MetadataInterface::new(asset); - let call = Call::new_in(self); - erc20.decimals(call).ok() + let call = Call::new(); + erc20.decimals(self.vm(), call).ok() } } @@ -1323,18 +1348,6 @@ mod tests { assert_eq!(vault.sender(alice).decimals(), uint!(18_U8)); } - #[storage] - struct Erc20ExcessDecimalsMock; - - unsafe impl TopLevelStorage for Erc20ExcessDecimalsMock {} - - #[public] - impl Erc20ExcessDecimalsMock { - fn decimals(&self) -> U256 { - U256::MAX - } - } - #[motsu::test] fn constructor( vault: Contract, @@ -1349,16 +1362,6 @@ mod tests { assert_eq!(vault.sender(alice).decimals(), uint!(30_U8)); } - #[motsu::test] - fn decimals_returns_default_value_when_underlying_decimals_exceeds_u8_max( - vault: Contract, - token: Contract, - alice: Address, - ) { - vault.sender(alice).constructor(token.address(), U8::ZERO); - assert_eq!(vault.sender(alice).decimals(), uint!(18_U8)); - } - #[motsu::test] #[should_panic = "Decimals should not be greater than `U8::MAX`"] fn decimals_revert_when_overflowing( diff --git a/contracts/src/token/erc20/extensions/flash_mint.rs b/contracts/src/token/erc20/extensions/flash_mint.rs index 0a2d5e9e4..df964c825 100644 --- a/contracts/src/token/erc20/extensions/flash_mint.rs +++ b/contracts/src/token/erc20/extensions/flash_mint.rs @@ -23,8 +23,6 @@ use alloy_primitives::{Address, B256, U256}; use openzeppelin_stylus_proc::interface_id; use stylus_sdk::{ abi::Bytes, - call::{Call, MethodError}, - contract, msg, prelude::*, storage::{StorageAddress, StorageU256}, }; @@ -113,13 +111,16 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } } -use crate::token::erc20::abi::Erc3156FlashBorrowerInterface; +use crate::{ + token::erc20::abi::Erc3156FlashBorrowerInterface, + utils::account::AccountAccessExt, +}; /// State of an [`Erc20FlashMint`] Contract. #[storage] @@ -141,6 +142,7 @@ unsafe impl TopLevelStorage for Erc20FlashMint {} /// Interface of the ERC-3156 Flash Borrower, as defined in /// [ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). +#[public] pub trait IErc3156FlashBorrower { /// Receive a flash loan. /// @@ -170,6 +172,7 @@ pub trait IErc3156FlashBorrower { /// /// [ERC-3156]: https://eips.ethereum.org/EIPS/eip-3156 #[interface_id] +#[public] pub trait IErc3156FlashLender { /// The error type associated to this trait implementation. type Error: Into>; @@ -228,8 +231,8 @@ pub trait IErc3156FlashLender { /// * `&mut self` - Write access to the contract's state. /// * `receiver` - The receiver of the flash loan. Should implement the /// [`Erc3156FlashBorrowerInterface::on_flash_loan`] interface. - /// * `token` - The token to be flash loaned. Only [`contract::address()`] - /// is supported. + /// * `token` - The token to be flash loaned. Only + /// [`self.vm().contract_address()`] is supported. /// * `value` - The amount of tokens to be loaned. /// * `data` - Arbitrary data that is passed to the receiver. /// @@ -265,7 +268,7 @@ impl Erc20FlashMint { /// See [`IErc3156FlashLender::max_flash_loan`]. #[must_use] pub fn max_flash_loan(&self, token: Address, erc20: &erc20::Erc20) -> U256 { - if token == contract::address() { + if token == self.vm().contract_address() { U256::MAX - erc20.total_supply() } else { U256::MIN @@ -279,7 +282,7 @@ impl Erc20FlashMint { token: Address, _value: U256, ) -> Result { - if token == contract::address() { + if token == self.vm().contract_address() { Ok(self.flash_fee_value.get()) } else { Err(Error::UnsupportedToken(ERC3156UnsupportedToken { token })) @@ -307,17 +310,19 @@ impl Erc20FlashMint { } let fee = self.flash_fee(token, value)?; - if !Address::has_code(&receiver) { + if !self.vm().has_code(receiver) { return Err(Error::ERC3156InvalidReceiver( ERC3156InvalidReceiver { receiver }, )); } erc20._mint(receiver, value)?; let loan_receiver = Erc3156FlashBorrowerInterface::new(receiver); + let call = Call::new_mutating(self); let loan_return = loan_receiver .on_flash_loan( - Call::new_in(self), - msg::sender(), + self.vm(), + call, + self.vm().msg_sender(), token, value, fee, @@ -337,7 +342,11 @@ impl Erc20FlashMint { let allowance = value .checked_add(fee) .expect("allowance should not exceed `U256::MAX`"); - erc20._spend_allowance(receiver, contract::address(), allowance)?; + erc20._spend_allowance( + receiver, + self.vm().contract_address(), + allowance, + )?; let flash_fee_receiver = self.flash_fee_receiver_address.get(); @@ -453,8 +462,8 @@ mod tests { .checked_add(fee) .expect("allowance should not exceed `U256::MAX`"); let token_iface = Erc20Interface::new(token); - let ok = - token_iface.approve(Call::new_in(self), token, allowance)?; + let call = Call::new_mutating(self); + let ok = token_iface.approve(self.vm(), call, token, allowance)?; if !ok { return Err(b"approve returned false".to_vec()); } diff --git a/contracts/src/token/erc20/extensions/metadata.rs b/contracts/src/token/erc20/extensions/metadata.rs index 18369807a..eb5b9859f 100644 --- a/contracts/src/token/erc20/extensions/metadata.rs +++ b/contracts/src/token/erc20/extensions/metadata.rs @@ -20,6 +20,7 @@ pub struct Erc20Metadata { /// Interface for the optional metadata functions from the ERC-20 standard. #[interface_id] +#[public] pub trait IErc20Metadata: IErc165 { /// Returns the name of the token. /// diff --git a/contracts/src/token/erc20/extensions/permit.rs b/contracts/src/token/erc20/extensions/permit.rs index 6191b8db2..a78bf6189 100644 --- a/contracts/src/token/erc20/extensions/permit.rs +++ b/contracts/src/token/erc20/extensions/permit.rs @@ -15,7 +15,7 @@ use alloc::{vec, vec::Vec}; use alloy_primitives::{aliases::B32, keccak256, Address, B256, U256, U8}; use alloy_sol_types::SolType; -use stylus_sdk::{block, call::MethodError, function_selector, prelude::*}; +use stylus_sdk::{function_selector, prelude::*}; use crate::{ token::{erc20, erc20::Erc20}, @@ -121,7 +121,7 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -140,6 +140,7 @@ pub struct Erc20Permit { unsafe impl TopLevelStorage for Erc20Permit {} /// Interface for [`Erc20Permit`] +#[public] pub trait IErc20Permit: INonces { /// The error type associated to this interface. type Error: Into>; @@ -236,7 +237,7 @@ impl Erc20Permit { erc20: &mut Erc20, nonces: &mut Nonces, ) -> Result<(), Error> { - if U256::from(block::timestamp()) > deadline { + if U256::from(self.vm().block_timestamp()) > deadline { return Err(ERC2612ExpiredSignature { deadline }.into()); } @@ -280,7 +281,6 @@ mod tests { }, }; - #[entrypoint] #[storage] struct Erc20PermitExample { erc20: Erc20, @@ -288,6 +288,8 @@ mod tests { permit: Erc20Permit, } + unsafe impl TopLevelStorage for Erc20PermitExample {} + #[storage] struct Eip712; diff --git a/contracts/src/token/erc20/extensions/wrapper.rs b/contracts/src/token/erc20/extensions/wrapper.rs index 17f071751..69c3b2419 100644 --- a/contracts/src/token/erc20/extensions/wrapper.rs +++ b/contracts/src/token/erc20/extensions/wrapper.rs @@ -16,12 +16,7 @@ use alloc::{vec, vec::Vec}; use alloy_primitives::{Address, U256, U8}; use openzeppelin_stylus_proc::interface_id; pub use sol::*; -use stylus_sdk::{ - call::{Call, MethodError}, - contract, msg, - prelude::*, - storage::StorageAddress, -}; +use stylus_sdk::{prelude::*, storage::StorageAddress}; use crate::token::erc20::{ self, @@ -111,7 +106,7 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -128,6 +123,7 @@ pub struct Erc20Wrapper { /// ERC-20 Wrapper Standard Interface #[interface_id] +#[public] pub trait IErc20Wrapper { /// The error type associated to the trait implementation. type Error: Into>; @@ -176,8 +172,8 @@ pub trait IErc20Wrapper { /// /// # Errors /// - /// * [`Error::InvalidSender`] - If the `msg::sender()`'s address is the - /// `contract:address()`. + /// * [`Error::InvalidSender`] - If the `self.vm().msg_sender()`'s address + /// is the `contract:address()`. /// * [`Error::InvalidReceiver`] - If the `account` address is a /// `contract:address()`. /// * [`Error::SafeErc20FailedOperation`] - If caller lacks sufficient @@ -231,7 +227,7 @@ impl Erc20Wrapper { pub fn decimals(&self) -> U8 { U8::from( Erc20MetadataInterface::new(self.underlying()) - .decimals(self) + .decimals(self.vm(), Call::new()) .unwrap_or(DEFAULT_DECIMALS), ) } @@ -250,8 +246,8 @@ impl Erc20Wrapper { value: U256, erc20: &mut Erc20, ) -> Result { - let contract_address = contract::address(); - let sender = msg::sender(); + let contract_address = self.vm().contract_address(); + let sender = self.vm().msg_sender(); if sender == contract_address { return Err(erc20::ERC20InvalidSender { sender }.into()); @@ -283,13 +279,13 @@ impl Erc20Wrapper { value: U256, erc20: &mut Erc20, ) -> Result { - if account == contract::address() { + if account == self.vm().contract_address() { return Err( erc20::ERC20InvalidReceiver { receiver: account }.into() ); } - erc20._burn(msg::sender(), value)?; + erc20._burn(self.vm().msg_sender(), value)?; self.safe_erc20.safe_transfer(self.underlying(), account, value)?; @@ -314,7 +310,7 @@ impl Erc20Wrapper { &mut self, underlying_token: Address, ) -> Result<(), Error> { - if underlying_token == contract::address() { + if underlying_token == self.vm().contract_address() { return Err(Error::InvalidUnderlying(ERC20InvalidUnderlying { token: underlying_token, })); @@ -351,12 +347,12 @@ impl Erc20Wrapper { account: Address, erc20: &mut Erc20, ) -> Result { - let contract_address = contract::address(); + let contract_address = self.vm().contract_address(); let underlying_token = Erc20Interface::new(self.underlying()); let underlying_balance = underlying_token - .balance_of(Call::new_in(self), contract_address) + .balance_of(self.vm(), Call::new(), contract_address) .map_err(|_| ERC20InvalidUnderlying { token: contract_address })?; let value = underlying_balance diff --git a/contracts/src/token/erc20/mod.rs b/contracts/src/token/erc20/mod.rs index c0c4635b7..2a3941999 100644 --- a/contracts/src/token/erc20/mod.rs +++ b/contracts/src/token/erc20/mod.rs @@ -9,8 +9,6 @@ use alloc::{vec, vec::Vec}; use alloy_primitives::{aliases::B32, Address, U256}; use openzeppelin_stylus_proc::interface_id; use stylus_sdk::{ - call::MethodError, - evm, msg, prelude::*, storage::{StorageMap, StorageU256}, }; @@ -121,7 +119,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -146,6 +144,7 @@ unsafe impl TopLevelStorage for Erc20 {} /// Required interface of an [`Erc20`] compliant contract. #[interface_id] +#[public] pub trait IErc20 { /// The error type associated to this ERC-20 trait implementation. type Error: Into>; @@ -294,7 +293,7 @@ impl IErc20 for Erc20 { to: Address, value: U256, ) -> Result { - let from = msg::sender(); + let from = self.vm().msg_sender(); self._transfer(from, to, value)?; Ok(true) } @@ -308,7 +307,7 @@ impl IErc20 for Erc20 { spender: Address, value: U256, ) -> Result { - let owner = msg::sender(); + let owner = self.vm().msg_sender(); self._approve(owner, spender, value, true) } @@ -318,7 +317,7 @@ impl IErc20 for Erc20 { to: Address, value: U256, ) -> Result { - let spender = msg::sender(); + let spender = self.vm().msg_sender(); self._spend_allowance(from, spender, value)?; self._transfer(from, to, value)?; Ok(true) @@ -366,7 +365,7 @@ impl Erc20 { self.allowances.setter(owner).insert(spender, value); if emit_event { - evm::log(Approval { owner, spender, value }); + self.vm().log(Approval { owner, spender, value }); } Ok(true) } @@ -506,7 +505,7 @@ impl Erc20 { self.balances.setter(to).add_assign_unchecked(value); } - evm::log(Transfer { from, to, value }); + self.vm().log(Transfer { from, to, value }); Ok(()) } @@ -585,6 +584,7 @@ impl Erc20 { } } +#[public] impl IErc165 for Erc20 { fn supports_interface(&self, interface_id: B32) -> bool { ::interface_id() == interface_id diff --git a/contracts/src/token/erc20/utils/safe_erc20.rs b/contracts/src/token/erc20/utils/safe_erc20.rs index 45a27cce0..f6d98aa41 100644 --- a/contracts/src/token/erc20/utils/safe_erc20.rs +++ b/contracts/src/token/erc20/utils/safe_erc20.rs @@ -15,13 +15,7 @@ use alloy_primitives::{aliases::B32, Address, U256}; use alloy_sol_types::{sol_data::Bool, SolCall, SolType}; use openzeppelin_stylus_proc::interface_id; pub use sol::*; -use stylus_sdk::{ - abi::Bytes, - call::{MethodError, RawCall}, - contract, - prelude::*, - types::AddressVM, -}; +use stylus_sdk::{abi::Bytes, call::RawCall, function_selector, prelude::*}; use crate::{ token::erc20::abi::Erc20Interface, utils::introspection::erc165::IErc165, @@ -66,13 +60,16 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } } -use crate::token::erc20::abi::{Erc1363Interface, Erc20Abi}; +use crate::{ + token::erc20::abi::{Erc1363Interface, Erc20Abi}, + utils::account::AccountAccessExt, +}; /// State of a [`SafeErc20`] Contract. #[storage] @@ -85,6 +82,7 @@ unsafe impl TopLevelStorage for SafeErc20 {} /// Required interface of a [`SafeErc20`] utility contract. #[interface_id] +#[public] pub trait ISafeErc20 { /// The error type associated to this trait implementation. type Error: Into>; @@ -353,7 +351,7 @@ impl ISafeErc20 for SafeErc20 { ) -> Result<(), Self::Error> { let call = Erc20Abi::transferCall { to, value }; - Self::call_optional_return(token, &call) + self.call_optional_return(token, &call) } fn safe_transfer_from( @@ -365,7 +363,7 @@ impl ISafeErc20 for SafeErc20 { ) -> Result<(), Self::Error> { let call = Erc20Abi::transferFromCall { from, to, value }; - Self::call_optional_return(token, &call) + self.call_optional_return(token, &call) } fn try_safe_transfer( @@ -433,7 +431,7 @@ impl ISafeErc20 for SafeErc20 { let approve_call = Erc20Abi::approveCall { spender, value }; // Try performing the approval with the desired value. - if Self::call_optional_return(token, &approve_call).is_ok() { + if self.call_optional_return(token, &approve_call).is_ok() { return Ok(()); } @@ -441,8 +439,8 @@ impl ISafeErc20 for SafeErc20 { // approval. let reset_approval_call = Erc20Abi::approveCall { spender, value: U256::ZERO }; - Self::call_optional_return(token, &reset_approval_call)?; - Self::call_optional_return(token, &approve_call) + self.call_optional_return(token, &reset_approval_call)?; + self.call_optional_return(token, &approve_call) } fn transfer_and_call_relaxed( @@ -452,18 +450,20 @@ impl ISafeErc20 for SafeErc20 { value: U256, data: Bytes, ) -> Result<(), Self::Error> { - if !to.has_code() { + if !self.vm().has_code(to) { return self.safe_transfer(token, to, value); } - if !token.has_code() { + if !self.vm().has_code(token) { return Err(Error::SafeErc20FailedOperation( SafeErc20FailedOperation { token }, )); } + let call = Call::new_mutating(self); match Erc1363Interface::new(token).transfer_and_call( - self, + self.vm(), + call, to, value, data.to_vec().into(), @@ -485,18 +485,20 @@ impl ISafeErc20 for SafeErc20 { value: U256, data: Bytes, ) -> Result<(), Self::Error> { - if !to.has_code() { + if !self.vm().has_code(to) { return self.safe_transfer_from(token, from, to, value); } - if !token.has_code() { + if !self.vm().has_code(token) { return Err(Error::SafeErc20FailedOperation( SafeErc20FailedOperation { token }, )); } + let call = Call::new_mutating(self); match Erc1363Interface::new(token).transfer_from_and_call( - self, + self.vm(), + call, from, to, value, @@ -518,18 +520,20 @@ impl ISafeErc20 for SafeErc20 { value: U256, data: Bytes, ) -> Result<(), Self::Error> { - if !spender.has_code() { + if !self.vm().has_code(spender) { return self.force_approve(token, spender, value); } - if !token.has_code() { + if !self.vm().has_code(token) { return Err(Error::SafeErc20FailedOperation( SafeErc20FailedOperation { token }, )); } + let call = Call::new_mutating(self); match Erc1363Interface::new(token).approve_and_call( - self, + self.vm(), + call, spender, value, data.to_vec().into(), @@ -560,17 +564,18 @@ impl SafeErc20 { /// contract, the contract fails to execute the call or the call returns /// value that is not `true`. fn call_optional_return( + &self, token: Address, call: &impl SolCall, ) -> Result<(), Error> { - if !token.has_code() { + if !self.vm().has_code(token) { return Err(Error::SafeErc20FailedOperation( SafeErc20FailedOperation { token }, )); } let result = unsafe { - RawCall::new() + RawCall::new(self.vm()) .limit_return_data(0, BOOL_TYPE_SIZE) .flush_storage_cache() .call(token, &call.abi_encode()) @@ -579,8 +584,7 @@ impl SafeErc20 { match result { Ok(data) if data.is_empty() - || Bool::abi_decode(&data, true) - .is_ok_and(|success| success) => + || Bool::abi_decode(&data).is_ok_and(|success| success) => { Ok(()) } @@ -606,17 +610,27 @@ impl SafeErc20 { token: Address, spender: Address, ) -> Result { - if !Address::has_code(&token) { + if !self.vm().has_code(token) { return Err(SafeErc20FailedOperation { token }.into()); } let erc20 = Erc20Interface::new(token); - erc20.allowance(self, contract::address(), spender).map_err(|_e| { - Error::SafeErc20FailedOperation(SafeErc20FailedOperation { token }) - }) + erc20 + .allowance( + self.vm(), + Call::new(), + self.vm().contract_address(), + spender, + ) + .map_err(|_e| { + Error::SafeErc20FailedOperation(SafeErc20FailedOperation { + token, + }) + }) } } +#[public] impl IErc165 for SafeErc20 { fn supports_interface(&self, interface_id: B32) -> bool { ::interface_id() == interface_id @@ -633,17 +647,17 @@ mod tests { use alloy_primitives::uint; use motsu::prelude::*; - use stylus_sdk::msg; use super::*; use crate::token::erc20::{Approval, Erc20, IErc20, Transfer}; #[storage] - #[entrypoint] struct SafeErc20Example { safe_erc20: SafeErc20, } + unsafe impl TopLevelStorage for SafeErc20Example {} + #[public] #[implements(ISafeErc20)] impl SafeErc20Example {} @@ -1525,7 +1539,7 @@ mod tests { spender: Address, amount: U256, ) -> Result> { - let owner = msg::sender(); + let owner = self.vm().msg_sender(); if amount.is_zero() || self.erc20.allowance(owner, spender).is_zero() { diff --git a/contracts/src/token/erc721/extensions/burnable.rs b/contracts/src/token/erc721/extensions/burnable.rs index 0f073bbbd..8b084f183 100644 --- a/contracts/src/token/erc721/extensions/burnable.rs +++ b/contracts/src/token/erc721/extensions/burnable.rs @@ -3,12 +3,13 @@ use alloc::vec::Vec; use alloy_primitives::{Address, U256}; use openzeppelin_stylus_proc::interface_id; -use stylus_sdk::{msg, prelude::*}; +use stylus_sdk::prelude::*; use crate::token::erc721::{self, Erc721}; /// An [`Erc721`] token that can be burned (destroyed). #[interface_id] +#[public] pub trait IErc721Burnable { /// The error type associated to this trait implementation. type Error: Into>; @@ -43,7 +44,7 @@ impl IErc721Burnable for Erc721 { // // Therefore, it is not needed to verify that the return value is not 0 // here. - self._update(Address::ZERO, token_id, msg::sender())?; + self._update(Address::ZERO, token_id, self.vm().msg_sender())?; Ok(()) } } diff --git a/contracts/src/token/erc721/extensions/consecutive.rs b/contracts/src/token/erc721/extensions/consecutive.rs index c4c65ff56..9871fcc49 100644 --- a/contracts/src/token/erc721/extensions/consecutive.rs +++ b/contracts/src/token/erc721/extensions/consecutive.rs @@ -23,7 +23,7 @@ use alloy_primitives::{ aliases::{B32, U96}, uint, Address, U256, }; -use stylus_sdk::{abi::Bytes, call::MethodError, evm, msg, prelude::*}; +use stylus_sdk::{abi::Bytes, prelude::*}; use crate::{ token::erc721::{ @@ -167,7 +167,7 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -236,7 +236,7 @@ impl IErc721 for Erc721Consecutive { ) -> Result<(), Self::Error> { self.transfer_from(from, to, token_id)?; Ok(self.erc721._check_on_erc721_received( - msg::sender(), + self.vm().msg_sender(), from, to, token_id, @@ -260,7 +260,8 @@ impl IErc721 for Erc721Consecutive { // Setting an "auth" argument enables the `_is_authorized` check which // verifies that the token exists (`!from.is_zero()`). Therefore, it is // not needed to verify that the return value is not 0 here. - let previous_owner = self._update(to, token_id, msg::sender())?; + let previous_owner = + self._update(to, token_id, self.vm().msg_sender())?; if previous_owner != from { return Err(erc721::Error::IncorrectOwner(ERC721IncorrectOwner { sender: from, @@ -277,7 +278,7 @@ impl IErc721 for Erc721Consecutive { to: Address, token_id: U256, ) -> Result<(), Self::Error> { - self._approve(to, token_id, msg::sender(), true) + self._approve(to, token_id, self.vm().msg_sender(), true) } fn set_approval_for_all( @@ -408,7 +409,7 @@ impl Erc721Consecutive { alloy_primitives::U128::from(batch_size), ); - evm::log(ConsecutiveTransfer { + self.vm().log(ConsecutiveTransfer { from_token_id: next.to::(), to_token_id: last.to::(), from_address: Address::ZERO, @@ -538,7 +539,7 @@ impl Erc721Consecutive { } self.erc721.owners.setter(token_id).set(to); - evm::log(Transfer { from, to, token_id }); + self.vm().log(Transfer { from, to, token_id }); Ok(from) } @@ -611,7 +612,7 @@ impl Erc721Consecutive { ) -> Result<(), Error> { self._mint(to, token_id)?; Ok(self.erc721._check_on_erc721_received( - msg::sender(), + self.vm().msg_sender(), Address::ZERO, to, token_id, @@ -652,7 +653,7 @@ impl Erc721Consecutive { /// Transfers `token_id` from `from` to `to`. /// /// As opposed to [`Self::transfer_from`], this imposes no restrictions on - /// `msg::sender`. + /// `msg_sender()`. /// /// # Arguments /// @@ -742,7 +743,7 @@ impl Erc721Consecutive { ) -> Result<(), Error> { self._transfer(from, to, token_id)?; Ok(self.erc721._check_on_erc721_received( - msg::sender(), + self.vm().msg_sender(), from, to, token_id, @@ -795,7 +796,7 @@ impl Erc721Consecutive { } if emit_event { - evm::log(Approval { owner, approved: to, token_id }); + self.vm().log(Approval { owner, approved: to, token_id }); } } diff --git a/contracts/src/token/erc721/extensions/enumerable.rs b/contracts/src/token/erc721/extensions/enumerable.rs index 7b9601205..96a7dc640 100644 --- a/contracts/src/token/erc721/extensions/enumerable.rs +++ b/contracts/src/token/erc721/extensions/enumerable.rs @@ -15,7 +15,6 @@ use alloy_primitives::{aliases::B32, Address, U256}; use openzeppelin_stylus_proc::interface_id; pub use sol::*; use stylus_sdk::{ - call::MethodError, prelude::*, storage::{StorageMap, StorageU256, StorageVec}, }; @@ -61,7 +60,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -83,6 +82,7 @@ pub struct Erc721Enumerable { /// This is the interface of the optional `Enumerable` extension /// of the ERC-721 standard. #[interface_id] +#[public] pub trait IErc721Enumerable { /// The error type associated to this ERC-721 enumerable trait /// implementation. diff --git a/contracts/src/token/erc721/extensions/metadata.rs b/contracts/src/token/erc721/extensions/metadata.rs index 6993fbfc5..608937bbb 100644 --- a/contracts/src/token/erc721/extensions/metadata.rs +++ b/contracts/src/token/erc721/extensions/metadata.rs @@ -1,10 +1,6 @@ //! Optional Metadata of the ERC-721 standard. -use alloc::{ - string::{String, ToString}, - vec, - vec::Vec, -}; +use alloc::{string::String, vec, vec::Vec}; use alloy_primitives::U256; use openzeppelin_stylus_proc::interface_id; @@ -28,6 +24,7 @@ pub struct Erc721Metadata { /// Interface for the optional metadata functions from the ERC-721 standard. #[interface_id] +#[public] pub trait IErc721Metadata: IErc165 { /// The error type associated to this trait implementation. type Error: Into>; @@ -109,16 +106,33 @@ impl Erc721Metadata { let token_uri = if base_uri.is_empty() { String::new() } else { - base_uri + &token_id.to_string() + base_uri + &fmt_u256(token_id) }; Ok(token_uri) } } +/// Format [`U256`] similar to [`ToString`] conversion. +/// +/// NOTE: +/// [`ToString`] implementation for [`U256`] contributes heavily to wasm size. +/// Current implementation of formatting can reduce wasm size by ~1.7kb. +fn fmt_u256(token_id: U256) -> String { + token_id + .to_base_be(10) + .map(|dgt| { + let dgt: u32 = dgt.try_into().expect("should convert digit"); + char::from_digit(dgt as u32, 10).expect("should convert digit") + }) + .collect::() +} + #[cfg(test)] mod tests { - use alloy_primitives::{aliases::B32, Address}; + use alloy_primitives::{ + aliases::B32, private::proptest::proptest, Address, + }; use motsu::prelude::*; use super::*; @@ -254,4 +268,13 @@ mod tests { let fake_interface_id: B32 = 0x12345678_u32.into(); assert!(!contract.sender(alice).supports_interface(fake_interface_id)); } + + #[test] + fn check_fmt_u256() { + proptest!(|(num: U256)| { + let actual = fmt_u256(num); + let expected = num.to_string(); + assert_eq!(actual, expected); + }); + } } diff --git a/contracts/src/token/erc721/extensions/uri_storage.rs b/contracts/src/token/erc721/extensions/uri_storage.rs index 93297ce57..24ffc9344 100644 --- a/contracts/src/token/erc721/extensions/uri_storage.rs +++ b/contracts/src/token/erc721/extensions/uri_storage.rs @@ -6,7 +6,6 @@ use alloc::{string::String, vec, vec::Vec}; use alloy_primitives::U256; pub use sol::*; use stylus_sdk::{ - evm, prelude::*, storage::{StorageMap, StorageString}, }; @@ -64,7 +63,7 @@ impl Erc721UriStorage { /// * [`MetadataUpdate`]. pub fn _set_token_uri(&mut self, token_id: U256, token_uri: String) { self.token_uris.setter(token_id).set_str(token_uri); - evm::log(MetadataUpdate { token_id }); + self.vm().log(MetadataUpdate { token_id }); } /// Check [`IErc721Metadata::token_uri()`] for more details. diff --git a/contracts/src/token/erc721/extensions/wrapper.rs b/contracts/src/token/erc721/extensions/wrapper.rs index a7d0e59ce..442914c2e 100644 --- a/contracts/src/token/erc721/extensions/wrapper.rs +++ b/contracts/src/token/erc721/extensions/wrapper.rs @@ -9,13 +9,7 @@ use alloy_primitives::{aliases::B32, Address, U256}; use alloy_sol_types::SolError; use openzeppelin_stylus_proc::interface_id; pub use sol::*; -use stylus_sdk::{ - abi::Bytes, - call::{self, Call, MethodError}, - contract, msg, - prelude::*, - storage::StorageAddress, -}; +use stylus_sdk::{abi::Bytes, prelude::*, storage::StorageAddress}; use crate::token::erc721::{ self, abi::Erc721Interface, receiver::IErc721Receiver, Erc721, @@ -99,7 +93,7 @@ impl From for Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -120,6 +114,7 @@ unsafe impl TopLevelStorage for Erc721Wrapper {} /// Interface of an extension of the ERC-721 token contract that supports token /// wrapping. #[interface_id] +#[public] pub trait IErc721Wrapper: IErc721Receiver { /// Allow a user to deposit underlying tokens and mint the corresponding /// `token_ids`. @@ -189,8 +184,8 @@ impl Erc721Wrapper { token_ids: Vec, erc721: &mut Erc721, ) -> Result> { - let sender = msg::sender(); - let contract_address = contract::address(); + let sender = self.vm().msg_sender(); + let contract_address = self.vm().contract_address(); let underlying = Erc721Interface::new(self.underlying()); for token_id in token_ids { @@ -198,19 +193,21 @@ impl Erc721Wrapper { // the receiver. With [`IErc721Wrapper::underlying()`] being trusted // (by design of this contract) and no other contracts expected to // be called from there, we are safe. + let call = Call::new_mutating(self); underlying .transfer_from( - Call::new_in(self), + self.vm(), + call, sender, contract_address, token_id, ) .map_err(|e| match e { - call::Error::Revert(reason) => { + errors::Error::Revert(reason) => { // Propagate underlying token errors directly. reason } - call::Error::AbiDecodingFailed(_) => { + errors::Error::AbiDecodingFailed(_) => { // For non-revert errors, return empty bytes to // indicate failure. vec![] @@ -231,7 +228,7 @@ impl Erc721Wrapper { token_ids: Vec, erc721: &mut Erc721, ) -> Result> { - let sender = msg::sender(); + let sender = self.vm().msg_sender(); let underlying = Erc721Interface::new(self.underlying()); for token_id in token_ids { @@ -241,20 +238,22 @@ impl Erc721Wrapper { // not 0 here. erc721._update(Address::ZERO, token_id, sender)?; + let call = Call::new_mutating(self); underlying .safe_transfer_from( - Call::new_in(self), - contract::address(), + self.vm(), + call, + self.vm().contract_address(), account, token_id, vec![].into(), ) .map_err(|e| match e { - call::Error::Revert(reason) => { + errors::Error::Revert(reason) => { // Propagate underlying token errors directly. reason } - call::Error::AbiDecodingFailed(_) => { + errors::Error::AbiDecodingFailed(_) => { // For non-revert errors, return empty bytes to // indicate failure. vec![] @@ -287,7 +286,7 @@ impl Erc721Wrapper { _data: &Bytes, erc721: &mut Erc721, ) -> Result> { - let sender = msg::sender(); + let sender = self.vm().msg_sender(); if self.underlying() != sender { return Err(ERC721UnsupportedToken { token: sender }.abi_encode()); } @@ -334,15 +333,15 @@ impl Erc721Wrapper { ) -> Result { let underlying = Erc721Interface::new(self.underlying()); - let owner = underlying.owner_of(Call::new_in(self), token_id).map_err( - |_| { + let owner = underlying + .owner_of(self.vm(), Call::new(), token_id) + .map_err(|_| { Error::Erc721FailedOperation(Erc721FailedOperation { token: self.underlying(), }) - }, - )?; + })?; - let contract_address = contract::address(); + let contract_address = self.vm().contract_address(); if owner != contract_address { return Err(erc721::Error::IncorrectOwner( erc721::ERC721IncorrectOwner { diff --git a/contracts/src/token/erc721/mod.rs b/contracts/src/token/erc721/mod.rs index b192f27cd..03f842376 100644 --- a/contracts/src/token/erc721/mod.rs +++ b/contracts/src/token/erc721/mod.rs @@ -9,8 +9,7 @@ use alloy_primitives::{aliases::B32, Address, U128, U256}; use openzeppelin_stylus_proc::interface_id; use stylus_sdk::{ abi::Bytes, - call::{self, Call, MethodError}, - evm, msg, + function_selector, prelude::*, storage::{StorageAddress, StorageBool, StorageMap, StorageU256}, }; @@ -28,6 +27,9 @@ pub mod utils; pub use abi::Erc721ReceiverInterface; pub use receiver::{IErc721Receiver, RECEIVER_FN_SELECTOR}; pub use sol::*; + +use crate::utils::account::AccountAccessExt; + #[cfg_attr(coverage_nightly, coverage(off))] mod sol { use alloy_sol_macro::sol; @@ -180,7 +182,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -207,6 +209,7 @@ unsafe impl TopLevelStorage for Erc721 {} /// Required interface of an [`Erc721`] compliant contract. #[interface_id] +#[public] pub trait IErc721: IErc165 { /// The error type associated to this ERC-721 trait implementation. type Error: Into>; @@ -370,7 +373,7 @@ pub trait IErc721: IErc165 { /// * `operator` - Account to add to the set of authorized operators. /// * `approved` - Flag that determines whether or not permission will be /// granted to `operator`. If true, this means `operator` will be allowed - /// to manage `msg::sender`'s assets. + /// to manage `msg_sender()`'s assets. /// /// # Errors /// @@ -445,7 +448,13 @@ impl IErc721 for Erc721 { data: Bytes, ) -> Result<(), Self::Error> { self.transfer_from(from, to, token_id)?; - self._check_on_erc721_received(msg::sender(), from, to, token_id, &data) + self._check_on_erc721_received( + self.vm().msg_sender(), + from, + to, + token_id, + &data, + ) } fn transfer_from( @@ -463,7 +472,8 @@ impl IErc721 for Erc721 { // Setting an "auth" argument enables the `_is_authorized` check which // verifies that the token exists (`from != 0`). Therefore, it is // not needed to verify that the return value is not 0 here. - let previous_owner = self._update(to, token_id, msg::sender())?; + let previous_owner = + self._update(to, token_id, self.vm().msg_sender())?; if previous_owner != from { return Err(ERC721IncorrectOwner { sender: from, @@ -480,7 +490,7 @@ impl IErc721 for Erc721 { to: Address, token_id: U256, ) -> Result<(), Self::Error> { - self._approve(to, token_id, msg::sender(), true) + self._approve(to, token_id, self.vm().msg_sender(), true) } fn set_approval_for_all( @@ -488,7 +498,7 @@ impl IErc721 for Erc721 { operator: Address, approved: bool, ) -> Result<(), Self::Error> { - self._set_approval_for_all(msg::sender(), operator, approved) + self._set_approval_for_all(self.vm().msg_sender(), operator, approved) } fn get_approved(&self, token_id: U256) -> Result { @@ -680,7 +690,7 @@ impl Erc721 { } self.owners.setter(token_id).set(to); - evm::log(Transfer { from, to, token_id }); + self.vm().log(Transfer { from, to, token_id }); Ok(from) } @@ -750,7 +760,7 @@ impl Erc721 { ) -> Result<(), Error> { self._mint(to, token_id)?; self._check_on_erc721_received( - msg::sender(), + self.vm().msg_sender(), Address::ZERO, to, token_id, @@ -788,7 +798,7 @@ impl Erc721 { /// Transfers `token_id` from `from` to `to`. /// /// As opposed to [`Self::transfer_from`], this imposes no restrictions on - /// `msg::sender`. + /// `msg_sender()`. /// /// # Arguments /// @@ -870,7 +880,13 @@ impl Erc721 { data: &Bytes, ) -> Result<(), Error> { self._transfer(from, to, token_id)?; - self._check_on_erc721_received(msg::sender(), from, to, token_id, data) + self._check_on_erc721_received( + self.vm().msg_sender(), + from, + to, + token_id, + data, + ) } /// Approve `to` to operate on `token_id`. @@ -917,7 +933,7 @@ impl Erc721 { } if emit_event { - evm::log(Approval { owner, approved: to, token_id }); + self.vm().log(Approval { owner, approved: to, token_id }); } } @@ -952,7 +968,7 @@ impl Erc721 { } self.operator_approvals.setter(owner).setter(operator).set(approved); - evm::log(ApprovalForAll { owner, operator, approved }); + self.vm().log(ApprovalForAll { owner, operator, approved }); Ok(()) } @@ -981,7 +997,7 @@ impl Erc721 { /// Performs an acceptance check for the provided `operator` by calling /// [`IErc721Receiver::on_erc721_received`] on the `to` address. The /// `operator` is generally the address that initiated the token transfer - /// (i.e. `msg::sender()`). + /// (i.e. `self.vm().msg_sender()`). /// /// The acceptance call is not executed and treated as a no-op if the /// target address doesn't contain code (i.e. an EOA). Otherwise, the @@ -1013,13 +1029,14 @@ impl Erc721 { token_id: U256, data: &Bytes, ) -> Result<(), Error> { - if !to.has_code() { + if !self.vm().has_code(to) { return Ok(()); } let receiver = Erc721ReceiverInterface::new(to); - let call = Call::new_in(self); + let call = Call::new_mutating(self); let result = receiver.on_erc_721_received( + self.vm(), call, operator, from, @@ -1030,7 +1047,7 @@ impl Erc721 { let id = match result { Ok(id) => id, Err(e) => { - if let call::Error::Revert(ref reason) = e { + if let errors::Error::Revert(ref reason) = e { if !reason.is_empty() { return Err(Error::InvalidReceiverWithReason( InvalidReceiverWithReason { diff --git a/contracts/src/token/erc721/receiver.rs b/contracts/src/token/erc721/receiver.rs index c6aebc3fe..0f0c7e730 100644 --- a/contracts/src/token/erc721/receiver.rs +++ b/contracts/src/token/erc721/receiver.rs @@ -6,7 +6,7 @@ use alloc::vec::Vec; use alloy_primitives::{aliases::B32, Address, U256}; use openzeppelin_stylus_proc::interface_id; -use stylus_sdk::{abi::Bytes, function_selector}; +use stylus_sdk::{abi::Bytes, function_selector, prelude::*}; /// The expected value returned from [`IErc721Receiver::on_erc721_received`]. pub const RECEIVER_FN_SELECTOR: B32 = B32::new(function_selector!( @@ -24,6 +24,7 @@ pub const RECEIVER_FN_SELECTOR: B32 = B32::new(function_selector!( /// and [`super::IErc721::safe_transfer_from_with_data`] from ERC-721 asset /// contracts. #[interface_id] +#[public] pub trait IErc721Receiver { /// This function is called whenever an [`super::Erc721`] `token_id` /// token is transferred to this contract via diff --git a/contracts/src/utils/account.rs b/contracts/src/utils/account.rs new file mode 100644 index 000000000..ffa9e56cb --- /dev/null +++ b/contracts/src/utils/account.rs @@ -0,0 +1,24 @@ +//! Provides additional access to account details of the host environment. + +use alloy_primitives::{Address, U256}; +use stylus_sdk::prelude::AccountAccess; + +pub trait AccountAccessExt: AccountAccess { + /// Gets the ETH balance in wei of the current program's account. + fn contract_balance(&self) -> U256 { + self.balance(self.contract_address()) + } + + /// Determines if an account has code. + /// Note that this is insufficient to determine if an address is an [`EOA`]. + /// During contract deployment, an account only gets its code at the very + /// end, meaning that this method will return `false` while the + /// constructor executing. + /// + /// [`EOA`]: https://ethereum.org/en/developers/docs/accounts/#types-of-account + fn has_code(&self, account: Address) -> bool { + self.code_size(account) > 0 + } +} + +impl AccountAccessExt for T {} diff --git a/contracts/src/utils/address.rs b/contracts/src/utils/address.rs index e4fcd9998..0136f25a5 100644 --- a/contracts/src/utils/address.rs +++ b/contracts/src/utils/address.rs @@ -1,14 +1,16 @@ //! A collection of utilities for working with [`Address`]. -use alloc::vec::Vec; +use alloc::{vec, vec::Vec}; use alloy_primitives::Address; pub use sol::*; use stylus_sdk::{ - call::{self, Call, MethodError}, - prelude::*, + call, + prelude::{errors::MethodError, *}, }; +use crate::utils::account::AccountAccessExt; + #[cfg_attr(coverage_nightly, coverage(off))] mod sol { use alloy_sol_macro::sol; @@ -51,15 +53,18 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } } /// A collection of utilities for working with [`Address`]. +#[storage] pub struct AddressUtils; +unsafe impl TopLevelStorage for AddressUtils {} + impl AddressUtils { /// Performs a delegate call to `target` with the given `data`. /// @@ -77,13 +82,15 @@ impl AddressUtils { /// fails with a revert reason or if the call fails for any other reason. /// * [`Error::EmptyCode`] - If the target contract has no code. pub fn function_delegate_call( - context: &mut impl TopLevelStorage, + &mut self, target: Address, data: &[u8], ) -> Result, Error> { - let result = - unsafe { call::delegate_call(Call::new_in(context), target, data) }; - Self::verify_call_result_from_target(target, result) + let result = unsafe { + let call = Call::new_mutating(self); + call::delegate_call(self.vm(), call, target, data) + }; + self.verify_call_result_from_target(target, result) } // TODO: Support more result types out of the box (e.g. `U256`, `U160`, @@ -108,12 +115,14 @@ impl AddressUtils { /// * [`Error::FailedCall`] - If the call to the target contract fails /// without a revert reason. pub fn verify_call_result_from_target>( + &self, target: Address, - result: Result, + result: Result, ) -> Result { match result { Ok(returndata) => { - if returndata.as_ref().is_empty() && !target.has_code() { + if returndata.as_ref().is_empty() && !self.vm().has_code(target) + { return Err(AddressEmptyCode { target }.into()); } Ok(returndata) @@ -131,9 +140,9 @@ impl AddressUtils { /// [Address.sol]. /// /// [Address.sol]: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol - fn revert(error: stylus_sdk::call::Error) -> Error { + fn revert(error: errors::Error) -> Error { match &error { - stylus_sdk::call::Error::Revert(data) if data.is_empty() => { + errors::Error::Revert(data) if data.is_empty() => { FailedCall {}.into() } _ => FailedCallWithReason { reason: error.encode().into() }.into(), @@ -149,14 +158,14 @@ mod tests { #[test] fn revert_returns_failed_call() { - let error = stylus_sdk::call::Error::Revert(vec![]); + let error = errors::Error::Revert(vec![]); let result = AddressUtils::revert(error); assert!(matches!(result, Error::FailedCall(FailedCall {}))); } #[test] fn revert_returns_failed_call_with_reason() { - let error = stylus_sdk::call::Error::Revert(vec![1, 2, 3]); + let error = errors::Error::Revert(vec![1, 2, 3]); let result = AddressUtils::revert(error); assert!(matches!( result, @@ -165,7 +174,9 @@ mod tests { } #[storage] - struct TargetMock; + struct TargetMock { + address_utils: AddressUtils, + } unsafe impl TopLevelStorage for TargetMock {} @@ -174,39 +185,50 @@ mod tests { #[motsu::test] fn verify_call_result_from_target_returns_empty_data_when_target_has_code( + alice: Address, target: Contract, ) { let empty_data: Vec = vec![]; - let result = AddressUtils::verify_call_result_from_target( - target.address(), - Ok(empty_data.clone()), - ) - .motsu_expect("should be able to verify call result"); + let result = target + .sender(alice) + .address_utils + .verify_call_result_from_target( + target.address(), + Ok(empty_data.clone()), + ) + .motsu_expect("should be able to verify call result"); assert_eq!(result, empty_data); } + #[public] + impl AddressUtils {} + #[cfg_attr(coverage_nightly, coverage(off))] - #[test] + #[motsu::test] #[ignore = "TODO: un-ignore when this is fixed: https://github.com/OpenZeppelin/stylus-test-helpers/issues/115"] - fn verify_call_result_from_target_returns_data_when_target_has_no_code() { + fn verify_call_result_from_target_returns_data_when_target_has_no_code( + alice: Address, + address_utils: Contract, + ) { let data: Vec = vec![1, 2, 3]; - let result = AddressUtils::verify_call_result_from_target( - Address::ZERO, - Ok(data.clone()), - ) - .motsu_expect("should be able to verify call result"); + let result = address_utils + .sender(alice) + .verify_call_result_from_target(Address::ZERO, Ok(data.clone())) + .motsu_expect("should be able to verify call result"); assert_eq!(result, data); } - #[test] - fn verify_call_result_from_target_returns_address_empty_code() { - let result = AddressUtils::verify_call_result_from_target( - Address::ZERO, - Ok(vec![]), - ); + #[motsu::test] + fn verify_call_result_from_target_returns_address_empty_code( + alice: Address, + address_utils: Contract, + ) { + let result = address_utils + .sender(alice) + .verify_call_result_from_target(Address::ZERO, Ok(vec![])); assert!(matches!( result, Err(Error::EmptyCode(AddressEmptyCode { target: Address::ZERO })) diff --git a/contracts/src/utils/cryptography/ecdsa.rs b/contracts/src/utils/cryptography/ecdsa.rs index 412a0a3fa..7681a4a24 100644 --- a/contracts/src/utils/cryptography/ecdsa.rs +++ b/contracts/src/utils/cryptography/ecdsa.rs @@ -6,10 +6,7 @@ use alloc::vec::Vec; use alloy_primitives::{address, uint, Address, B256, U256}; use alloy_sol_types::SolType; -use stylus_sdk::{ - call::{self, MethodError, StaticCallContext}, - prelude::*, -}; +use stylus_sdk::{call, prelude::*}; /// Address of the `ecRecover` EVM precompile. pub const ECRECOVER_ADDR: Address = @@ -65,7 +62,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -75,7 +72,7 @@ impl MethodError for Error { /// /// # Arguments /// -/// * `context` - Execution context for making static calls. +/// * `host` - Host access for external calls. /// * `hash` - Hash of the message. /// * `v` - `v` value from the signature. /// * `r` - `r` value from the signature. @@ -92,7 +89,7 @@ impl MethodError for Error { /// /// * If the `ecRecover` precompile fails to execute. pub fn recover( - context: impl StaticCallContext, + host: &impl HostAccess, hash: B256, v: u8, r: B256, @@ -100,7 +97,7 @@ pub fn recover( ) -> Result { check_if_malleable(&s)?; // If the signature is valid (and not malleable), return the signer address. - _recover(context, hash, v, r, s) + _recover(host, hash, v, r, s) } /// Calls `ecRecover` EVM precompile. @@ -111,7 +108,7 @@ pub fn recover( /// /// # Arguments /// -/// * `context` - Execution context for making static calls. +/// * `host` - Host access for external calls. /// * `hash` - Hash of the message. /// * `v` - `v` value from the signature. /// * `r` - `r` value from the signature. @@ -126,7 +123,7 @@ pub fn recover( /// /// * If the `ecRecover` precompile fails to execute. fn _recover( - context: impl StaticCallContext, + host: &impl HostAccess, hash: B256, v: u8, r: B256, @@ -141,8 +138,9 @@ fn _recover( return Err(ECDSAInvalidSignature {}.into()); } - let recovered = call::static_call(context, ECRECOVER_ADDR, &calldata) - .expect("should call `ecRecover` precompile"); + let recovered = + call::static_call(host.vm(), Call::new(), ECRECOVER_ADDR, &calldata) + .expect("should call `ecRecover` precompile"); let recovered = Address::from_slice(&recovered[12..]); diff --git a/contracts/src/utils/cryptography/eip712.rs b/contracts/src/utils/cryptography/eip712.rs index 0d7adaeca..efea1af03 100644 --- a/contracts/src/utils/cryptography/eip712.rs +++ b/contracts/src/utils/cryptography/eip712.rs @@ -14,7 +14,7 @@ use alloc::{borrow::ToOwned, string::String, vec::Vec}; use alloy_primitives::{keccak256, Address, B256, U256}; use alloy_sol_types::{sol, SolType}; -use stylus_sdk::{block, contract}; +use stylus_sdk::prelude::*; /// Keccak-256 hash of the EIP-712 domain separator type string. const TYPE_HASH: [u8; 32] = @@ -58,7 +58,7 @@ pub fn to_typed_data_hash( } /// EIP-712 Contract interface. -pub trait IEip712 { +pub trait IEip712: HostAccess { /// Immutable name of EIP-712 instance. const NAME: &'static str; /// Hashed name of EIP-712 instance. @@ -74,14 +74,14 @@ pub trait IEip712 { /// Returns chain id. #[must_use] - fn chain_id() -> U256 { - U256::from(block::chainid()) + fn chain_id(&self) -> U256 { + U256::from(self.vm().chain_id()) } /// Returns the contract's address. #[must_use] - fn contract_address() -> Address { - contract::address() + fn contract_address(&self) -> Address { + self.vm().contract_address() } /// Returns the fields and values that describe the domain separator used by @@ -97,8 +97,8 @@ pub trait IEip712 { FIELDS, Self::NAME.to_owned(), Self::VERSION.to_owned(), - Self::chain_id(), - Self::contract_address(), + self.chain_id(), + self.contract_address(), SALT, Vec::new(), ) @@ -114,8 +114,8 @@ pub trait IEip712 { TYPE_HASH, Self::HASHED_NAME, Self::HASHED_VERSION, - Self::chain_id(), - Self::contract_address(), + self.chain_id(), + self.contract_address(), )); keccak256(encoded) @@ -138,6 +138,7 @@ pub trait IEip712 { #[cfg(test)] mod tests { use alloy_primitives::{address, b256, uint, Address, U256}; + use stylus_sdk::{host::VM, prelude::HostAccess}; use super::{to_typed_data_hash, IEip712, FIELDS, SALT}; @@ -149,15 +150,23 @@ mod tests { #[derive(Default)] struct TestEIP712; + impl HostAccess for TestEIP712 { + type Host = VM; + + fn vm(&self) -> &Self::Host { + unimplemented!() + } + } + impl IEip712 for TestEIP712 { const NAME: &'static str = "A Name"; const VERSION: &'static str = "1"; - fn chain_id() -> U256 { + fn chain_id(&self) -> U256 { CHAIN_ID } - fn contract_address() -> Address { + fn contract_address(&self) -> Address { CONTRACT_ADDRESS } } diff --git a/contracts/src/utils/introspection/erc165.rs b/contracts/src/utils/introspection/erc165.rs index d3db5cc84..f2cdcbcc3 100644 --- a/contracts/src/utils/introspection/erc165.rs +++ b/contracts/src/utils/introspection/erc165.rs @@ -4,6 +4,7 @@ use alloy_primitives::aliases::B32; use openzeppelin_stylus_proc::interface_id; +use stylus_sdk::prelude::public; /// Interface of the ERC-165 standard, as defined in the [ERC]. /// @@ -23,6 +24,7 @@ use openzeppelin_stylus_proc::interface_id; /// /// [ERC]: https://eips.ethereum.org/EIPS/eip-165 #[interface_id] +#[public] pub trait IErc165 { /// Returns true if this contract implements the interface defined by /// `interface_id`. See the corresponding [ERC] to learn more about how diff --git a/contracts/src/utils/mod.rs b/contracts/src/utils/mod.rs index 8362ee348..0b9ea9368 100644 --- a/contracts/src/utils/mod.rs +++ b/contracts/src/utils/mod.rs @@ -1,4 +1,5 @@ //! Common Smart Contracts utilities. +pub mod account; pub mod address; pub mod cryptography; pub mod introspection; diff --git a/contracts/src/utils/nonces.rs b/contracts/src/utils/nonces.rs index bb4502554..cf15e67a8 100644 --- a/contracts/src/utils/nonces.rs +++ b/contracts/src/utils/nonces.rs @@ -7,7 +7,6 @@ use alloc::{vec, vec::Vec}; use alloy_primitives::{Address, U256}; pub use sol::*; use stylus_sdk::{ - call::MethodError, prelude::*, storage::{StorageMap, StorageU256}, }; @@ -34,7 +33,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -48,6 +47,7 @@ pub struct Nonces { } /// Interface for [`Nonces`] +#[public] pub trait INonces { /// Returns the unused nonce for the given account. /// diff --git a/contracts/src/utils/pausable.rs b/contracts/src/utils/pausable.rs index d3db0db33..7ec3c45fd 100644 --- a/contracts/src/utils/pausable.rs +++ b/contracts/src/utils/pausable.rs @@ -17,9 +17,7 @@ use alloc::{vec, vec::Vec}; pub use sol::*; -use stylus_sdk::{ - call::MethodError, evm, msg, prelude::*, storage::StorageBool, -}; +use stylus_sdk::{prelude::*, storage::StorageBool}; #[cfg_attr(coverage_nightly, coverage(off))] mod sol { @@ -64,7 +62,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } @@ -78,6 +76,7 @@ pub struct Pausable { } /// Pausable interface. +#[public] pub trait IPausable { /// Returns true if the contract is paused, and false otherwise. /// @@ -111,7 +110,7 @@ impl Pausable { pub fn pause(&mut self) -> Result<(), Error> { self.when_not_paused()?; self.paused.set(true); - evm::log(Paused { account: msg::sender() }); + self.vm().log(Paused { account: self.vm().msg_sender() }); Ok(()) } @@ -127,7 +126,7 @@ impl Pausable { pub fn unpause(&mut self) -> Result<(), Error> { self.when_paused()?; self.paused.set(false); - evm::log(Unpaused { account: msg::sender() }); + self.vm().log(Unpaused { account: self.vm().msg_sender() }); Ok(()) } diff --git a/contracts/src/utils/precompiles/mod.rs b/contracts/src/utils/precompiles/mod.rs index 1245c65a4..a8d9324f3 100644 --- a/contracts/src/utils/precompiles/mod.rs +++ b/contracts/src/utils/precompiles/mod.rs @@ -74,7 +74,7 @@ pub mod primitives { /// Precompile methods return `Result` types to handle both invalid inputs and /// precompile execution failures. Always handle these errors appropriately /// in your contract logic. -pub trait Precompiles: TopLevelStorage { +pub trait Precompiles: TopLevelStorage + HostAccess { /// Recovers the address that signed a hashed message (`hash`) using an /// ECDSA signature (v, r, s). /// @@ -130,7 +130,7 @@ pub trait Precompiles: TopLevelStorage { ) -> bool; } -impl Precompiles for T { +impl Precompiles for T { fn ec_recover( &self, hash: B256, diff --git a/contracts/src/utils/precompiles/p256_verify.rs b/contracts/src/utils/precompiles/p256_verify.rs index 06b84a859..79a86fa09 100644 --- a/contracts/src/utils/precompiles/p256_verify.rs +++ b/contracts/src/utils/precompiles/p256_verify.rs @@ -1,6 +1,6 @@ use alloy_primitives::{address, uint, Address, B256, U256}; use alloy_sol_types::SolValue; -use stylus_sdk::call::{self, StaticCallContext}; +use stylus_sdk::{call, prelude::*}; /// Address of the `P256VERIFY` EVM precompile as per [RIP-7212]. /// @@ -15,7 +15,7 @@ pub(crate) const HALF_N: U256 = uint!( ); pub(crate) fn p256_verify( - context: impl StaticCallContext, + storage: &impl HostAccess, hash: B256, r: B256, s: B256, @@ -31,8 +31,13 @@ pub(crate) fn p256_verify( // concatenate the input into the expected 160 bytes format let data = (hash, r, s, x, y).abi_encode(); - let result = call::static_call(context, P256_VERIFY_ADDRESS, &data) - .expect("P256VERIFY precompile should not fail"); + let result = call::static_call( + storage.vm(), + Call::new(), + P256_VERIFY_ADDRESS, + &data, + ) + .expect("P256VERIFY precompile should not fail"); // `P256VERIFY` returns an encoded boolean `true` for a successful // verification and an empty vector on a failed verification @@ -65,10 +70,11 @@ mod tests { const VALID_Y: B256 = b256!( "c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e" ); - #[entrypoint] #[storage] struct P256TestContract; + unsafe impl TopLevelStorage for P256TestContract {} + #[public] impl P256TestContract { fn secp256r1_verify( diff --git a/contracts/src/utils/storage_slot.rs b/contracts/src/utils/storage_slot.rs index 94c6f4e36..7fe70d129 100644 --- a/contracts/src/utils/storage_slot.rs +++ b/contracts/src/utils/storage_slot.rs @@ -1,6 +1,8 @@ //! Helper for reading and writing primitive types to specific storage slots. +use alloc::{vec, vec::Vec}; + use alloy_primitives::U256; -use stylus_sdk::{host::VM, prelude::*}; +use stylus_sdk::{host::VMAccess, prelude::*}; const SLOT_BYTE_SPACE: u8 = 32; @@ -20,27 +22,30 @@ const SLOT_BYTE_SPACE: u8 = 32; /// /// use alloc::{vec, vec::Vec}; /// use alloy_primitives::{b256, Address, B256}; -/// use openzeppelin_stylus::utils::storage_slot::StorageSlot; +/// use openzeppelin_stylus::utils::{storage_slot::StorageSlot, account::AccountAccessExt}; /// use stylus_sdk::{storage::StorageAddress, prelude::*}; /// /// const IMPLEMENTATION_SLOT: B256 = b256!("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"); /// /// #[storage] /// #[entrypoint] -/// pub struct Erc1967; +/// pub struct Erc1967{ +/// storage_slot: StorageSlot, +/// } /// /// #[public] /// impl Erc1967 { /// fn get_implementation(&self) -> Address { -/// return StorageSlot::get_slot::(IMPLEMENTATION_SLOT).get(); +/// return self.storage_slot.get_slot::(IMPLEMENTATION_SLOT).get(); /// } /// /// fn set_implementation(&mut self, new_implementation: Address) { -/// assert!(new_implementation.has_code()); -/// StorageSlot::get_slot::(IMPLEMENTATION_SLOT).set(new_implementation); +/// assert!(self.vm().has_code(new_implementation)); +/// self.storage_slot.get_slot::(IMPLEMENTATION_SLOT).set(new_implementation); /// } /// } /// ``` +#[storage] pub struct StorageSlot; impl StorageSlot { @@ -50,36 +55,17 @@ impl StorageSlot { /// /// * `slot` - The slot to get the address from. #[must_use] - pub fn get_slot(slot: impl Into) -> ST { - // TODO: Remove this once we have a proper way to inject the host for - // custom storage slot access. - // This has been implemented on Stylus SDK 0.10.0. - - // Priority order: - // 1. If wasm32 target -> always use tuple syntax (highest priority). - // 2. If reentrant feature enabled (on non-wasm32) -> use struct syntax. - // 3. If non-wasm32 without export-abi -> use struct syntax. - // 4. Everything else -> use tuple syntax. - - #[cfg(all( - not(target_arch = "wasm32"), - any(feature = "reentrant", not(feature = "export-abi")) - ))] - let host = - VM { host: alloc::boxed::Box::new(stylus_sdk::host::WasmVM {}) }; - - #[cfg(not(all( - not(target_arch = "wasm32"), - any(feature = "reentrant", not(feature = "export-abi")) - )))] - let host = VM(stylus_sdk::host::WasmVM {}); - + pub fn get_slot(&self, slot: impl Into) -> ST { // SAFETY: Truncation is safe here because ST::SLOT_BYTES is never // larger than 32, so the subtraction cannot underflow and the // cast is always valid. #[allow(clippy::cast_possible_truncation)] unsafe { - ST::new(slot.into(), SLOT_BYTE_SPACE - ST::SLOT_BYTES as u8, host) + ST::new( + slot.into(), + SLOT_BYTE_SPACE - ST::SLOT_BYTES as u8, + self.raw_vm(), + ) } } } @@ -97,19 +83,24 @@ mod tests { const IMPLEMENTATION_SLOT: U256 = uint!(12345_U256); #[storage] - #[entrypoint] pub struct Erc1967 { address: StorageAddress, + storage_slot: StorageSlot, } + unsafe impl TopLevelStorage for Erc1967 {} + #[public] impl Erc1967 { fn get_implementation(&self) -> Address { - StorageSlot::get_slot::(IMPLEMENTATION_SLOT).get() + self.storage_slot + .get_slot::(IMPLEMENTATION_SLOT) + .get() } fn set_implementation(&self, new_implementation: Address) { - StorageSlot::get_slot::(IMPLEMENTATION_SLOT) + self.storage_slot + .get_slot::(IMPLEMENTATION_SLOT) .set(new_implementation); } @@ -122,11 +113,12 @@ mod tests { } fn get_address_at_zero_slot(&self) -> Address { - StorageSlot::get_slot::(U256::ZERO).get() + self.storage_slot.get_slot::(U256::ZERO).get() } fn set_address_at_zero_slot(&mut self, new_address: Address) { - StorageSlot::get_slot::(U256::ZERO) + self.storage_slot + .get_slot::(U256::ZERO) .set(new_address); } } diff --git a/contracts/src/utils/structs/checkpoints/mod.rs b/contracts/src/utils/structs/checkpoints/mod.rs index 3307f7fe0..7dc01ec72 100644 --- a/contracts/src/utils/structs/checkpoints/mod.rs +++ b/contracts/src/utils/structs/checkpoints/mod.rs @@ -15,7 +15,6 @@ use alloy_primitives::{uint, U256, U32}; pub use generic_size::{Size, S160, S208, S224}; pub use sol::*; use stylus_sdk::{ - call::MethodError, prelude::*, storage::{StorageGuard, StorageGuardMut, StorageVec}, }; @@ -44,7 +43,7 @@ pub enum Error { } #[cfg_attr(coverage_nightly, coverage(off))] -impl MethodError for Error { +impl errors::MethodError for Error { fn encode(self) -> alloc::vec::Vec { self.into() } diff --git a/docs/modules/ROOT/pages/access-control.adoc b/docs/modules/ROOT/pages/access-control.adoc index 186dc9801..a769d037d 100644 --- a/docs/modules/ROOT/pages/access-control.adoc +++ b/docs/modules/ROOT/pages/access-control.adoc @@ -328,6 +328,6 @@ Every role has an associated admin role, which grants permission to call the `gr This mechanism can be used to create complex permissioning structures resembling organizational charts, but it also provides an easy way to manage simpler applications. `AccessControl` includes a special role, called `DEFAULT_ADMIN_ROLE`, which acts as the **default admin role for all roles**. An account with this role will be able to manage any other role, unless `_set_role_admin` is used to select a new admin role. -Note that, by default, no accounts are granted the 'minter' or 'burner' roles. We assume you use a constructor to set the default admin role as the role of the deployer, or have a different mechanism where you make sure that you are able to grant roles. However, because those roles' admin role is the default admin role, and _that_ role was granted to `msg::sender()`, that same account can call `grant_role` to give minting or burning permission, and `revoke_role` to remove it. +Note that, by default, no accounts are granted the 'minter' or 'burner' roles. We assume you use a constructor to set the default admin role as the role of the deployer, or have a different mechanism where you make sure that you are able to grant roles. However, because those roles' admin role is the default admin role, and _that_ role was granted to `self.vm().msg_sender()`, that same account can call `grant_role` to give minting or burning permission, and `revoke_role` to remove it. Dynamic role allocation is often a desirable property, for example in systems where trust in a participant may vary over time. It can also be used to support use cases such as https://en.wikipedia.org/wiki/Know_your_customer[KYC], where the list of role-bearers may not be known up-front, or may be prohibitively expensive to include in a single transaction. diff --git a/docs/modules/ROOT/pages/beacon-proxy.adoc b/docs/modules/ROOT/pages/beacon-proxy.adoc index 7c7226018..037fe06aa 100644 --- a/docs/modules/ROOT/pages/beacon-proxy.adoc +++ b/docs/modules/ROOT/pages/beacon-proxy.adoc @@ -190,11 +190,11 @@ impl MyCustomBeacon { /// Upgrade implementation (only admin) fn upgrade_implementation(&mut self, new_implementation: Address) -> Result<(), Vec> { - if self.admin.get() != msg::sender() { + if self.admin.get() != self.vm().msg_sender() { return Err("Only admin can upgrade".abi_encode()); } - if !new_implementation.has_code() { + if !self.vm().has_code(new_implementation) { return Err("Invalid implementation".abi_encode()); } diff --git a/docs/modules/ROOT/pages/proxy.adoc b/docs/modules/ROOT/pages/proxy.adoc index e7adf1c51..ac81f4346 100644 --- a/docs/modules/ROOT/pages/proxy.adoc +++ b/docs/modules/ROOT/pages/proxy.adoc @@ -119,7 +119,7 @@ impl MyUpgradeableProxy { /// Admin function to update the implementation fn upgrade_implementation(&mut self, new_implementation: Address) -> Result<(), Vec> { // Only admin can upgrade - if self.admin.get() != msg::sender() { + if self.admin.get() != self.vm().msg_sender() { return Err("Only admin can upgrade".abi_encode()); } @@ -129,7 +129,7 @@ impl MyUpgradeableProxy { /// Admin function to transfer admin rights fn transfer_admin(&mut self, new_admin: Address) -> Result<(), Vec> { - if self.admin.get() != msg::sender() { + if self.admin.get() != self.vm().msg_sender() { return Err("Only admin can transfer admin".abi_encode()); } diff --git a/examples/access-control/Cargo.toml b/examples/access-control/Cargo.toml index be3ab794e..cf23e541d 100644 --- a/examples/access-control/Cargo.toml +++ b/examples/access-control/Cargo.toml @@ -17,6 +17,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -24,6 +25,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "access-control-example" diff --git a/examples/access-control/src/lib.rs b/examples/access-control/src/lib.rs index 8fea804c9..3b4f251f0 100644 --- a/examples/access-control/src/lib.rs +++ b/examples/access-control/src/lib.rs @@ -14,7 +14,6 @@ use openzeppelin_stylus::{ }; use stylus_sdk::{ alloy_primitives::{aliases::B32, Address, B256, U256}, - msg, prelude::*, }; @@ -186,7 +185,7 @@ impl IAccessControl for AccessControlExample { role: B256, confirmation: Address, ) -> Result<(), Self::Error> { - if msg::sender() != confirmation { + if self.vm().msg_sender() != confirmation { return Err(control::Error::BadConfirmation( control::AccessControlBadConfirmation {}, )); diff --git a/examples/access-control/tests/access_control.rs b/examples/access-control/tests/access_control.rs index 1b4a4c831..10f86ca29 100644 --- a/examples/access-control/tests/access_control.rs +++ b/examples/access-control/tests/access_control.rs @@ -48,21 +48,21 @@ async fn constructs(alice: Account) -> Result<()> { sender: stylus_deployer })); - let AccessControl::hasRoleReturn { hasRole } = + let hasRole = contract.hasRole(DEFAULT_ADMIN_ROLE.into(), alice_addr).call().await?; assert!(hasRole); - let AccessControl::getRoleMemberReturn { member } = contract + let member = contract .getRoleMember(DEFAULT_ADMIN_ROLE.into(), U256::ZERO) .call() .await?; assert_eq!(member, alice_addr); - let AccessControl::getRoleMemberCountReturn { count } = + let count = contract.getRoleMemberCount(DEFAULT_ADMIN_ROLE.into()).call().await?; assert_eq!(count, U256::ONE); - let AccessControl::getRoleMembersReturn { members } = + let members = contract.getRoleMembers(DEFAULT_ADMIN_ROLE.into()).call().await?; assert_eq!(members, vec![alice_addr]); @@ -81,8 +81,7 @@ async fn other_roles_admin_is_the_default_admin_role( .contract_address; let contract = AccessControl::new(contract_addr, &alice.wallet); - let AccessControl::getRoleAdminReturn { role } = - contract.getRoleAdmin(ROLE.into()).call().await?; + let role = contract.getRoleAdmin(ROLE.into()).call().await?; assert_eq!(*role, DEFAULT_ADMIN_ROLE); Ok(()) @@ -98,12 +97,10 @@ async fn default_role_is_default_admin(alice: Account) -> Result<()> { .contract_address; let contract = AccessControl::new(contract_addr, &alice.wallet); - let AccessControl::getRoleAdminReturn { role } = - contract.getRoleAdmin(ROLE.into()).call().await?; + let role = contract.getRoleAdmin(ROLE.into()).call().await?; assert_eq!(*role, DEFAULT_ADMIN_ROLE); - let AccessControl::getRoleAdminReturn { role } = - contract.getRoleAdmin(DEFAULT_ADMIN_ROLE.into()).call().await?; + let role = contract.getRoleAdmin(DEFAULT_ADMIN_ROLE.into()).call().await?; assert_eq!(*role, DEFAULT_ADMIN_ROLE); Ok(()) @@ -163,16 +160,13 @@ async fn accounts_can_be_granted_roles_multiple_times( sender: alice_addr })); - let AccessControl::getRoleMemberReturn { member } = - contract.getRoleMember(ROLE.into(), U256::ZERO).call().await?; + let member = contract.getRoleMember(ROLE.into(), U256::ZERO).call().await?; assert_eq!(member, bob_addr); - let AccessControl::getRoleMemberCountReturn { count } = - contract.getRoleMemberCount(ROLE.into()).call().await?; + let count = contract.getRoleMemberCount(ROLE.into()).call().await?; assert_eq!(count, U256::ONE); - let AccessControl::getRoleMembersReturn { members } = - contract.getRoleMembers(ROLE.into()).call().await?; + let members = contract.getRoleMembers(ROLE.into()).call().await?; assert_eq!(members, vec![bob_addr]); Ok(()) @@ -189,8 +183,7 @@ async fn not_granted_roles_can_be_revoked(alice: Account) -> Result<()> { .contract_address; let contract = AccessControl::new(contract_addr, &alice.wallet); - let AccessControl::hasRoleReturn { hasRole } = - contract.hasRole(ROLE.into(), alice_addr).call().await?; + let hasRole = contract.hasRole(ROLE.into(), alice_addr).call().await?; assert!(!hasRole); let receipt = receipt!(contract.revokeRole(ROLE.into(), alice_addr))?; @@ -225,12 +218,10 @@ async fn admin_can_revoke_role(alice: Account, bob: Account) -> Result<()> { sender: alice_addr })); - let AccessControl::getRoleMemberCountReturn { count } = - contract.getRoleMemberCount(ROLE.into()).call().await?; + let count = contract.getRoleMemberCount(ROLE.into()).call().await?; assert!(count.is_zero()); - let AccessControl::getRoleMembersReturn { members } = - contract.getRoleMembers(ROLE.into()).call().await?; + let members = contract.getRoleMembers(ROLE.into()).call().await?; assert!(members.is_empty()); Ok(()) @@ -289,12 +280,10 @@ async fn roles_can_be_revoked_multiple_times( sender: alice_addr })); - let AccessControl::getRoleMemberCountReturn { count } = - contract.getRoleMemberCount(ROLE.into()).call().await?; + let count = contract.getRoleMemberCount(ROLE.into()).call().await?; assert!(count.is_zero()); - let AccessControl::getRoleMembersReturn { members } = - contract.getRoleMembers(ROLE.into()).call().await?; + let members = contract.getRoleMembers(ROLE.into()).call().await?; assert!(members.is_empty()); Ok(()) @@ -342,12 +331,10 @@ async fn bearer_can_renounce_role(alice: Account, bob: Account) -> Result<()> { sender: bob_addr })); - let AccessControl::getRoleMemberCountReturn { count } = - contract.getRoleMemberCount(ROLE.into()).call().await?; + let count = contract.getRoleMemberCount(ROLE.into()).call().await?; assert!(count.is_zero()); - let AccessControl::getRoleMembersReturn { members } = - contract.getRoleMembers(ROLE.into()).call().await?; + let members = contract.getRoleMembers(ROLE.into()).call().await?; assert!(members.is_empty()); Ok(()) } @@ -418,8 +405,7 @@ async fn a_roles_admin_role_can_change(alice: Account) -> Result<()> { newAdminRole: NEW_ADMIN_ROLE.into() })); - let AccessControl::getRoleAdminReturn { role } = - contract.getRoleAdmin(ROLE.into()).call().await?; + let role = contract.getRoleAdmin(ROLE.into()).call().await?; assert_eq!(*role, NEW_ADMIN_ROLE); Ok(()) @@ -459,16 +445,13 @@ async fn the_new_admin_can_grant_roles( sender: bob_addr })); - let AccessControl::getRoleMemberReturn { member } = - contract.getRoleMember(ROLE.into(), U256::ZERO).call().await?; + let member = contract.getRoleMember(ROLE.into(), U256::ZERO).call().await?; assert_eq!(member, alice_addr); - let AccessControl::getRoleMemberCountReturn { count } = - contract.getRoleMemberCount(ROLE.into()).call().await?; + let count = contract.getRoleMemberCount(ROLE.into()).call().await?; assert_eq!(count, U256::ONE); - let AccessControl::getRoleMembersReturn { members } = - contract.getRoleMembers(ROLE.into()).call().await?; + let members = contract.getRoleMembers(ROLE.into()).call().await?; assert_eq!(members, vec![alice_addr]); Ok(()) @@ -509,12 +492,10 @@ async fn the_new_admin_can_revoke_roles( sender: bob_addr })); - let AccessControl::getRoleMemberCountReturn { count } = - contract.getRoleMemberCount(ROLE.into()).call().await?; + let count = contract.getRoleMemberCount(ROLE.into()).call().await?; assert!(count.is_zero()); - let AccessControl::getRoleMembersReturn { members } = - contract.getRoleMembers(ROLE.into()).call().await?; + let members = contract.getRoleMembers(ROLE.into()).call().await?; assert!(members.is_empty()); Ok(()) diff --git a/examples/basic/token/Cargo.toml b/examples/basic/token/Cargo.toml index c6603cfb2..8bc5d1a9f 100644 --- a/examples/basic/token/Cargo.toml +++ b/examples/basic/token/Cargo.toml @@ -13,6 +13,7 @@ stylus-sdk.workspace = true [features] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/beacon-proxy/Cargo.toml b/examples/beacon-proxy/Cargo.toml index 1cd9a8154..8b21cbc88 100644 --- a/examples/beacon-proxy/Cargo.toml +++ b/examples/beacon-proxy/Cargo.toml @@ -17,6 +17,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -24,6 +25,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "beacon-proxy-example" diff --git a/examples/beacon-proxy/tests/beacon-proxy.rs b/examples/beacon-proxy/tests/beacon-proxy.rs index 889b2664d..d73572a7d 100644 --- a/examples/beacon-proxy/tests/beacon-proxy.rs +++ b/examples/beacon-proxy/tests/beacon-proxy.rs @@ -35,10 +35,10 @@ async fn constructs(alice: Account) -> Result<()> { .contract_address; let contract = BeaconProxyExample::new(contract_addr, &alice.wallet); - let implementation = contract.implementation().call().await?.implementation; + let implementation = contract.implementation().call().await?; assert_eq!(implementation, implementation_addr); - let beacon = contract.getBeacon().call().await?.beacon; + let beacon = contract.getBeacon().call().await?; assert_eq!(beacon, beacon_addr); Ok(()) @@ -69,17 +69,17 @@ async fn constructs_with_data(alice: Account) -> Result<()> { .contract_address; let contract = BeaconProxyExample::new(contract_addr, &alice.wallet); - let implementation = contract.implementation().call().await?.implementation; + let implementation = contract.implementation().call().await?; assert_eq!(implementation, implementation_addr); - let beacon = contract.getBeacon().call().await?.beacon; + let beacon = contract.getBeacon().call().await?; assert_eq!(beacon, beacon_addr); // check that the balance can be accurately fetched through the proxy. - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, amount); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, amount); Ok(()) @@ -104,10 +104,10 @@ async fn fallback(alice: Account, bob: Account) -> Result<()> { let contract = BeaconProxyExample::new(contract_addr, &alice.wallet); // verify initial balance is [`U256::ZERO`]. - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, U256::ZERO); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, U256::ZERO); // mint 1000 tokens. @@ -115,10 +115,10 @@ async fn fallback(alice: Account, bob: Account) -> Result<()> { watch!(contract.mint(alice.address(), amount))?; // check that the balance can be accurately fetched through the proxy. - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, amount); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, amount); // check that the balance can be transferred through the proxy. @@ -130,13 +130,13 @@ async fn fallback(alice: Account, bob: Account) -> Result<()> { value: amount, })); - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, U256::ZERO); - let balance = contract.balanceOf(bob.address()).call().await?.balance; + let balance = contract.balanceOf(bob.address()).call().await?; assert_eq!(balance, amount); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, amount); Ok(()) diff --git a/examples/eddsa/Cargo.toml b/examples/eddsa/Cargo.toml index c6649ed50..d079cae7d 100644 --- a/examples/eddsa/Cargo.toml +++ b/examples/eddsa/Cargo.toml @@ -16,6 +16,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -23,6 +24,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["stylus-sdk/export-abi"] +contract-client-gen = [] [[bin]] name = "eddsa-example" diff --git a/examples/eddsa/tests/eddsa.rs b/examples/eddsa/tests/eddsa.rs index 2a3a2abd2..ede5035e4 100644 --- a/examples/eddsa/tests/eddsa.rs +++ b/examples/eddsa/tests/eddsa.rs @@ -29,7 +29,7 @@ async fn eddsa_works(alice: Account) -> Result<()> { // Verify with signed message. let message = b"Sign me!"; let signature = signing_key.sign(message); - let EddsaExample::verifyReturn { is_valid } = contract + let is_valid = contract .verify( encode_verifying_key(signing_key.verifying_key()), encode_signature(signature), @@ -41,7 +41,7 @@ async fn eddsa_works(alice: Account) -> Result<()> { // Verify with a different message. let invalid_message = b"I'm not signed!"; - let EddsaExample::verifyReturn { is_valid } = contract + let is_valid = contract .verify( encode_verifying_key(signing_key.verifying_key()), encode_signature(signature), diff --git a/examples/erc1155-holder/Cargo.toml b/examples/erc1155-holder/Cargo.toml index b2934c2f1..28db04e01 100644 --- a/examples/erc1155-holder/Cargo.toml +++ b/examples/erc1155-holder/Cargo.toml @@ -17,10 +17,12 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc1155-holder/tests/erc1155-holder.rs b/examples/erc1155-holder/tests/erc1155-holder.rs index 5128fdd8c..2eed4f74b 100644 --- a/examples/erc1155-holder/tests/erc1155-holder.rs +++ b/examples/erc1155-holder/tests/erc1155-holder.rs @@ -27,8 +27,7 @@ async fn returns_correct_selector_for_single_transfer( let interface_selector = contract .onERC1155Received(operator, from, id, value, data) .call() - .await? - ._0; + .await?; assert_eq!(SINGLE_TRANSFER_FN_SELECTOR, interface_selector); @@ -51,8 +50,7 @@ async fn returns_correct_selector_for_batch_transfer( let interface_selector = contract .onERC1155BatchReceived(operator, from, ids, values, data) .call() - .await? - ._0; + .await?; assert_eq!(BATCH_TRANSFER_FN_SELECTOR, interface_selector); @@ -65,31 +63,15 @@ async fn supports_interface(alice: Account) -> Result<()> { let contract = Erc1155HolderExample::new(contract_addr, &alice.wallet); let invalid_interface_id: B32 = 0xffffffff_u32.into(); - assert!( - !contract - .supportsInterface(invalid_interface_id) - .call() - .await? - .supportsInterface - ); + assert!(!contract.supportsInterface(invalid_interface_id).call().await?); let erc1155_holder_interface_id: B32 = 0x4e2312e0_u32.into(); assert!( - contract - .supportsInterface(erc1155_holder_interface_id) - .call() - .await? - .supportsInterface + contract.supportsInterface(erc1155_holder_interface_id).call().await? ); let erc165_interface_id: B32 = 0x01ffc9a7_u32.into(); - assert!( - contract - .supportsInterface(erc165_interface_id) - .call() - .await? - .supportsInterface - ); + assert!(contract.supportsInterface(erc165_interface_id).call().await?); Ok(()) } diff --git a/examples/erc1155-metadata-uri/Cargo.toml b/examples/erc1155-metadata-uri/Cargo.toml index e80ea930c..bdb8b7878 100644 --- a/examples/erc1155-metadata-uri/Cargo.toml +++ b/examples/erc1155-metadata-uri/Cargo.toml @@ -16,10 +16,12 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc1155-metadata-uri/tests/erc1155-metadata-uri.rs b/examples/erc1155-metadata-uri/tests/erc1155-metadata-uri.rs index 3bd6d9941..ab1a2ad9a 100644 --- a/examples/erc1155-metadata-uri/tests/erc1155-metadata-uri.rs +++ b/examples/erc1155-metadata-uri/tests/erc1155-metadata-uri.rs @@ -32,7 +32,7 @@ async fn uri_returns_metadata_uri_when_token_uri_is_not_set( let token_id = U256::ONE; - let uri = contract.uri(token_id).call().await?.uri; + let uri = contract.uri(token_id).call().await?; assert_eq!(URI, uri); Ok(()) @@ -53,7 +53,7 @@ async fn uri_returns_empty_string_when_no_uri_is_set( let token_id = U256::ONE; - let uri = contract.uri(token_id).call().await?.uri; + let uri = contract.uri(token_id).call().await?; assert_eq!("", uri); @@ -85,7 +85,7 @@ async fn uri_returns_concatenated_base_uri_and_token_uri( assert!(receipt .emits(Erc1155::URI { value: expected_uri.clone(), id: token_id })); - let uri = contract.uri(token_id).call().await?.uri; + let uri = contract.uri(token_id).call().await?; assert_eq!(expected_uri, uri); @@ -114,7 +114,7 @@ async fn uri_returns_token_uri_when_base_uri_is_empty( assert!(receipt .emits(Erc1155::URI { value: token_uri.to_owned(), id: token_id })); - let uri = contract.uri(token_id).call().await?.uri; + let uri = contract.uri(token_id).call().await?; assert_eq!(token_uri, uri); @@ -146,7 +146,7 @@ async fn uri_ignores_metadata_uri_when_token_uri_is_set( assert!(receipt .emits(Erc1155::URI { value: expected_uri.clone(), id: token_id })); - let uri = contract.uri(token_id).call().await?.uri; + let uri = contract.uri(token_id).call().await?; assert_eq!(expected_uri, uri); diff --git a/examples/erc1155-supply/Cargo.toml b/examples/erc1155-supply/Cargo.toml index ddf8c656a..2329bf524 100644 --- a/examples/erc1155-supply/Cargo.toml +++ b/examples/erc1155-supply/Cargo.toml @@ -16,10 +16,12 @@ alloy.workspace = true eyre.workspace = true tokio.workspace = true e2e.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc1155-supply/tests/erc1155-supply.rs b/examples/erc1155-supply/tests/erc1155-supply.rs index dd36ce510..530227ce4 100644 --- a/examples/erc1155-supply/tests/erc1155-supply.rs +++ b/examples/erc1155-supply/tests/erc1155-supply.rs @@ -28,9 +28,9 @@ async fn constructs(alice: Account) -> eyre::Result<()> { let token_id = random_token_ids(1)[0]; - let total_supply = contract.totalSupply_0(token_id).call().await?._0; - let total_supply_all = contract.totalSupply_1().call().await?._0; - let token_exists = contract.exists(token_id).call().await?._0; + let total_supply = contract.totalSupply_0(token_id).call().await?; + let total_supply_all = contract.totalSupply_1().call().await?; + let token_exists = contract.exists(token_id).call().await?; assert_eq!(U256::ZERO, total_supply); assert_eq!(U256::ZERO, total_supply_all); @@ -59,11 +59,10 @@ async fn mint(alice: Account) -> eyre::Result<()> { value, })); - let balance = - contract.balanceOf(alice_addr, token_id).call().await?.balance; - let total_supply = contract.totalSupply_0(token_id).call().await?._0; - let total_supply_all = contract.totalSupply_1().call().await?._0; - let token_exists = contract.exists(token_id).call().await?._0; + let balance = contract.balanceOf(alice_addr, token_id).call().await?; + let total_supply = contract.totalSupply_0(token_id).call().await?; + let total_supply_all = contract.totalSupply_1().call().await?; + let token_exists = contract.exists(token_id).call().await?; assert_eq!(value, balance); assert_eq!(value, total_supply); @@ -87,7 +86,7 @@ async fn mint_to_receiver_contract(alice: Account) -> eyre::Result<()> { let value = random_values(1)[0]; let initial_receiver_balance = - contract.balanceOf(receiver_addr, token_id).call().await?.balance; + contract.balanceOf(receiver_addr, token_id).call().await?; let receipt = receipt!(contract.mint(receiver_addr, token_id, value, vec![].into()))?; @@ -109,10 +108,10 @@ async fn mint_to_receiver_contract(alice: Account) -> eyre::Result<()> { })); let receiver_balance = - contract.balanceOf(receiver_addr, token_id).call().await?.balance; - let total_supply = contract.totalSupply_0(token_id).call().await?._0; - let total_supply_all = contract.totalSupply_1().call().await?._0; - let token_exists = contract.exists(token_id).call().await?._0; + contract.balanceOf(receiver_addr, token_id).call().await?; + let total_supply = contract.totalSupply_0(token_id).call().await?; + let total_supply_all = contract.totalSupply_1().call().await?; + let token_exists = contract.exists(token_id).call().await?; assert_eq!(initial_receiver_balance + value, receiver_balance); assert_eq!(value, total_supply); @@ -153,8 +152,7 @@ async fn mint_batch(alice: Account, bob: Account) -> eyre::Result<()> { let balances = contract .balanceOfBatch(vec![account, account], token_ids.clone()) .call() - .await? - .balances; + .await?; assert_eq!(values, balances); } @@ -162,14 +160,14 @@ async fn mint_batch(alice: Account, bob: Account) -> eyre::Result<()> { let accounts_len = U256::from(accounts.len()); for (&token_id, &value) in token_ids.iter().zip(values.iter()) { - let token_exists = contract.exists(token_id).call().await?._0; - let total_supply = contract.totalSupply_0(token_id).call().await?._0; + let token_exists = contract.exists(token_id).call().await?; + let total_supply = contract.totalSupply_0(token_id).call().await?; assert_eq!(value * accounts_len, total_supply); assert!(token_exists); } - let total_supply_all = contract.totalSupply_1().call().await?._0; + let total_supply_all = contract.totalSupply_1().call().await?; assert_eq!(values.iter().sum::() * accounts_len, total_supply_all); Ok(()) @@ -193,8 +191,7 @@ async fn mint_batch_transfer_to_receiver_contract( let initial_receiver_balances = contract .balanceOfBatch(vec![receiver_addr, receiver_addr], token_ids.clone()) .call() - .await? - .balances; + .await?; let receipt = receipt!(contract.mintBatch( receiver_addr, @@ -222,14 +219,13 @@ async fn mint_batch_transfer_to_receiver_contract( let receiver_balances = contract .balanceOfBatch(vec![receiver_addr, receiver_addr], token_ids.clone()) .call() - .await? - .balances; + .await?; for (idx, (&token_id, &value)) in token_ids.iter().zip(values.iter()).enumerate() { - let token_exists = contract.exists(token_id).call().await?._0; - let total_supply = contract.totalSupply_0(token_id).call().await?._0; + let token_exists = contract.exists(token_id).call().await?; + let total_supply = contract.totalSupply_0(token_id).call().await?; assert_eq!( initial_receiver_balances[idx] + value, @@ -239,7 +235,7 @@ async fn mint_batch_transfer_to_receiver_contract( assert!(token_exists); } - let total_supply_all = contract.totalSupply_1().call().await?._0; + let total_supply_all = contract.totalSupply_1().call().await?; assert_eq!(values.iter().sum::(), total_supply_all); Ok(()) @@ -321,11 +317,10 @@ async fn burn(alice: Account) -> eyre::Result<()> { value, })); - let token_exists = contract.exists(token_id).call().await?._0; - let balance = - contract.balanceOf(alice_addr, token_id).call().await?.balance; - let total_supply = contract.totalSupply_0(token_id).call().await?._0; - let total_supply_all = contract.totalSupply_1().call().await?._0; + let token_exists = contract.exists(token_id).call().await?; + let balance = contract.balanceOf(alice_addr, token_id).call().await?; + let total_supply = contract.totalSupply_0(token_id).call().await?; + let total_supply_all = contract.totalSupply_1().call().await?; assert_eq!(U256::ZERO, balance); assert_eq!(U256::ZERO, total_supply); @@ -360,10 +355,10 @@ async fn burn_with_approval(alice: Account, bob: Account) -> eyre::Result<()> { value, })); - let token_exists = contract.exists(token_id).call().await?._0; - let balance = contract.balanceOf(bob_addr, token_id).call().await?.balance; - let total_supply = contract.totalSupply_0(token_id).call().await?._0; - let total_supply_all = contract.totalSupply_1().call().await?._0; + let token_exists = contract.exists(token_id).call().await?; + let balance = contract.balanceOf(bob_addr, token_id).call().await?; + let total_supply = contract.totalSupply_0(token_id).call().await?; + let total_supply_all = contract.totalSupply_1().call().await?; assert_eq!(U256::ZERO, balance); assert_eq!(U256::ZERO, total_supply); @@ -404,17 +399,16 @@ async fn burn_batch(alice: Account) -> eyre::Result<()> { })); for token_id in token_ids { - let balance = - contract.balanceOf(alice_addr, token_id).call().await?.balance; - let token_exists = contract.exists(token_id).call().await?._0; - let total_supply = contract.totalSupply_0(token_id).call().await?._0; + let balance = contract.balanceOf(alice_addr, token_id).call().await?; + let token_exists = contract.exists(token_id).call().await?; + let total_supply = contract.totalSupply_0(token_id).call().await?; assert_eq!(U256::ZERO, balance); assert_eq!(U256::ZERO, total_supply); assert!(!token_exists); } - let total_supply_all = contract.totalSupply_1().call().await?._0; + let total_supply_all = contract.totalSupply_1().call().await?; assert_eq!(U256::ZERO, total_supply_all); Ok(()) @@ -458,17 +452,16 @@ async fn burn_batch_with_approval( })); for token_id in token_ids { - let balance = - contract.balanceOf(bob_addr, token_id).call().await?.balance; - let token_exists = contract.exists(token_id).call().await?._0; - let total_supply = contract.totalSupply_0(token_id).call().await?._0; + let balance = contract.balanceOf(bob_addr, token_id).call().await?; + let token_exists = contract.exists(token_id).call().await?; + let total_supply = contract.totalSupply_0(token_id).call().await?; assert_eq!(U256::ZERO, balance); assert_eq!(U256::ZERO, total_supply); assert!(!token_exists); } - let total_supply_all = contract.totalSupply_1().call().await?._0; + let total_supply_all = contract.totalSupply_1().call().await?; assert_eq!(U256::ZERO, total_supply_all); Ok(()) @@ -490,18 +483,15 @@ async fn supply_unaffected_by_safe_transfer_from( watch!(contract.mint(alice_addr, token_id, value, vec![].into()))?; // assert balances as expected after mint - let alice_balance = - contract.balanceOf(alice_addr, token_id).call().await?.balance; - let bob_balance = - contract.balanceOf(bob_addr, token_id).call().await?.balance; + let alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; + let bob_balance = contract.balanceOf(bob_addr, token_id).call().await?; assert_eq!(value, alice_balance); assert_eq!(U256::ZERO, bob_balance); // total supplies (all) logic has been checked in other tests, assume valid - let initial_total_supply = - contract.totalSupply_0(token_id).call().await?._0; - let initial_total_supply_all = contract.totalSupply_1().call().await?._0; + let initial_total_supply = contract.totalSupply_0(token_id).call().await?; + let initial_total_supply_all = contract.totalSupply_1().call().await?; let receipt = receipt!(contract.safeTransferFrom( alice_addr, @@ -520,18 +510,16 @@ async fn supply_unaffected_by_safe_transfer_from( })); // assert balances updated as expected - let alice_balance = - contract.balanceOf(alice_addr, token_id).call().await?.balance; - let bob_balance = - contract.balanceOf(bob_addr, token_id).call().await?.balance; + let alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; + let bob_balance = contract.balanceOf(bob_addr, token_id).call().await?; assert_eq!(U256::ZERO, alice_balance); assert_eq!(value, bob_balance); // assert supply-related data remains unchanged - let total_supply = contract.totalSupply_0(token_id).call().await?._0; - let total_supply_all = contract.totalSupply_1().call().await?._0; - let token_exists = contract.exists(token_id).call().await?._0; + let total_supply = contract.totalSupply_0(token_id).call().await?; + let total_supply_all = contract.totalSupply_1().call().await?; + let token_exists = contract.exists(token_id).call().await?; assert_eq!(initial_total_supply, total_supply); assert_eq!(initial_total_supply_all, total_supply_all); @@ -563,9 +551,8 @@ async fn supply_unaffected_by_safe_transfer_from_batch( // assert balances as expected after mint for (&token_id, &value) in token_ids.iter().zip(values.iter()) { let alice_balance = - contract.balanceOf(alice_addr, token_id).call().await?.balance; - let bob_balance = - contract.balanceOf(bob_addr, token_id).call().await?.balance; + contract.balanceOf(alice_addr, token_id).call().await?; + let bob_balance = contract.balanceOf(bob_addr, token_id).call().await?; assert_eq!(value, alice_balance); assert_eq!(U256::ZERO, bob_balance); @@ -574,10 +561,10 @@ async fn supply_unaffected_by_safe_transfer_from_batch( // total supplies (all) logic has been checked in other tests, assume valid let mut initial_total_supplies: Vec = vec![]; for &token_id in &token_ids { - let supply = contract.totalSupply_0(token_id).call().await?._0; + let supply = contract.totalSupply_0(token_id).call().await?; initial_total_supplies.push(supply); } - let initial_total_supply_all = contract.totalSupply_1().call().await?._0; + let initial_total_supply_all = contract.totalSupply_1().call().await?; let receipt = receipt!(contract.safeBatchTransferFrom( alice_addr, @@ -598,9 +585,8 @@ async fn supply_unaffected_by_safe_transfer_from_batch( // assert balances updated as expected for (&token_id, &value) in token_ids.iter().zip(values.iter()) { let alice_balance = - contract.balanceOf(alice_addr, token_id).call().await?.balance; - let bob_balance = - contract.balanceOf(bob_addr, token_id).call().await?.balance; + contract.balanceOf(alice_addr, token_id).call().await?; + let bob_balance = contract.balanceOf(bob_addr, token_id).call().await?; assert_eq!(U256::ZERO, alice_balance); assert_eq!(value, bob_balance); @@ -610,14 +596,14 @@ async fn supply_unaffected_by_safe_transfer_from_batch( for (&token_id, &initial_total_supply) in token_ids.iter().zip(initial_total_supplies.iter()) { - let total_supply = contract.totalSupply_0(token_id).call().await?._0; - let token_exists = contract.exists(token_id).call().await?._0; + let total_supply = contract.totalSupply_0(token_id).call().await?; + let token_exists = contract.exists(token_id).call().await?; assert_eq!(initial_total_supply, total_supply); assert!(token_exists); } - let total_supply_all = contract.totalSupply_1().call().await?._0; + let total_supply_all = contract.totalSupply_1().call().await?; assert_eq!(initial_total_supply_all, total_supply_all); Ok(()) @@ -633,7 +619,7 @@ async fn balance_of_zero_balance(alice: Account) -> eyre::Result<()> { let contract = Erc1155Supply::new(contract_addr, &alice.wallet); let token_ids = random_token_ids(1); - let Erc1155Supply::balanceOfReturn { balance } = + let balance = contract.balanceOf(alice.address(), token_ids[0]).call().await?; assert_eq!(U256::ZERO, balance); @@ -653,8 +639,7 @@ async fn balance_of_batch_zero_balance( vec![alice.address(), bob.address(), dave.address(), charlie.address()]; let token_ids = random_token_ids(4); - let Erc1155Supply::balanceOfBatchReturn { balances } = - contract.balanceOfBatch(accounts, token_ids).call().await?; + let balances = contract.balanceOfBatch(accounts, token_ids).call().await?; assert_eq!(vec![U256::ZERO, U256::ZERO, U256::ZERO, U256::ZERO], balances); Ok(()) @@ -681,7 +666,7 @@ async fn set_approval_for_all( approved: approved_value, })); - let Erc1155Supply::isApprovedForAllReturn { approved } = + let approved = contract.isApprovedForAll(alice_addr, bob_addr).call().await?; assert_eq!(approved_value, approved); @@ -695,7 +680,7 @@ async fn set_approval_for_all( approved: approved_value, })); - let Erc1155Supply::isApprovedForAllReturn { approved } = + let approved = contract.isApprovedForAll(alice_addr, bob_addr).call().await?; assert_eq!(approved_value, approved); @@ -709,7 +694,7 @@ async fn is_approved_for_all_zero_address(alice: Account) -> eyre::Result<()> { let invalid_operator = Address::ZERO; - let Erc1155Supply::isApprovedForAllReturn { approved } = contract + let approved = contract .isApprovedForAll(alice.address(), invalid_operator) .call() .await?; @@ -735,9 +720,9 @@ async fn safe_transfer_from(alice: Account, bob: Account) -> eyre::Result<()> { vec![0, 1, 2, 3].into() ))?; - let Erc1155Supply::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; - let Erc1155Supply::balanceOfReturn { balance: initial_bob_balance } = + let initial_bob_balance = contract.balanceOf(bob_addr, token_id).call().await?; let receipt = receipt!(contract.safeTransferFrom( @@ -756,12 +741,10 @@ async fn safe_transfer_from(alice: Account, bob: Account) -> eyre::Result<()> { value })); - let Erc1155Supply::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr, token_id).call().await?; + let alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); - let Erc1155Supply::balanceOfReturn { balance: bob_balance } = - contract.balanceOf(bob_addr, token_id).call().await?; + let bob_balance = contract.balanceOf(bob_addr, token_id).call().await?; assert_eq!(initial_bob_balance + value, bob_balance); Ok(()) @@ -790,9 +773,9 @@ async fn safe_transfer_from_with_approval( watch!(contract_bob.setApprovalForAll(alice_addr, true))?; - let Erc1155Supply::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr, token_id).call().await?; - let Erc1155Supply::balanceOfReturn { balance: initial_bob_balance } = + let initial_bob_balance = contract_alice.balanceOf(bob_addr, token_id).call().await?; let receipt = receipt!(contract_alice.safeTransferFrom( @@ -811,11 +794,11 @@ async fn safe_transfer_from_with_approval( value })); - let Erc1155Supply::balanceOfReturn { balance: alice_balance } = + let alice_balance = contract_alice.balanceOf(alice_addr, token_id).call().await?; assert_eq!(initial_alice_balance + value, alice_balance); - let Erc1155Supply::balanceOfReturn { balance: bob_balance } = + let bob_balance = contract_alice.balanceOf(bob_addr, token_id).call().await?; assert_eq!(initial_bob_balance - value, bob_balance); @@ -844,9 +827,9 @@ async fn safe_transfer_to_receiver_contract( vec![0, 1, 2, 3].into() ))?; - let Erc1155Supply::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; - let Erc1155Supply::balanceOfReturn { balance: initial_receiver_balance } = + let initial_receiver_balance = contract.balanceOf(receiver_addr, token_id).call().await?; let receipt = receipt!(contract.safeTransferFrom( @@ -873,11 +856,10 @@ async fn safe_transfer_to_receiver_contract( data: vec![].into(), })); - let Erc1155Supply::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr, token_id).call().await?; + let alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); - let Erc1155Supply::balanceOfReturn { balance: receiver_balance } = + let receiver_balance = contract.balanceOf(receiver_addr, token_id).call().await?; assert_eq!(initial_receiver_balance + value, receiver_balance); @@ -904,18 +886,15 @@ async fn safe_batch_transfer_from( vec![].into() ))?; - let Erc1155Supply::balanceOfBatchReturn { - balances: initial_alice_balances, - } = contract_alice + let initial_alice_balances = contract_alice .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) .call() .await?; - let Erc1155Supply::balanceOfBatchReturn { balances: initial_bob_balances } = - contract_alice - .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) - .call() - .await?; + let initial_bob_balances = contract_alice + .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) + .call() + .await?; let receipt = receipt!(contract_alice.safeBatchTransferFrom( alice_addr, @@ -933,17 +912,15 @@ async fn safe_batch_transfer_from( values: values.clone() })); - let Erc1155Supply::balanceOfBatchReturn { balances: alice_balances } = - contract_alice - .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) - .call() - .await?; + let alice_balances = contract_alice + .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) + .call() + .await?; - let Erc1155Supply::balanceOfBatchReturn { balances: bob_balances } = - contract_alice - .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) - .call() - .await?; + let bob_balances = contract_alice + .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) + .call() + .await?; for (idx, value) in values.iter().enumerate() { assert_eq!(initial_alice_balances[idx] - value, alice_balances[idx]); @@ -975,16 +952,12 @@ async fn safe_batch_transfer_to_receiver_contract( vec![].into() ))?; - let Erc1155Supply::balanceOfBatchReturn { - balances: initial_alice_balances, - } = contract + let initial_alice_balances = contract .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) .call() .await?; - let Erc1155Supply::balanceOfBatchReturn { - balances: initial_receiver_balances, - } = contract + let initial_receiver_balances = contract .balanceOfBatch(vec![receiver_addr, receiver_addr], token_ids.clone()) .call() .await?; @@ -1013,20 +986,15 @@ async fn safe_batch_transfer_to_receiver_contract( data: vec![].into(), })); - let Erc1155Supply::balanceOfBatchReturn { balances: alice_balances } = - contract - .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) - .call() - .await?; + let alice_balances = contract + .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) + .call() + .await?; - let Erc1155Supply::balanceOfBatchReturn { balances: receiver_balances } = - contract - .balanceOfBatch( - vec![receiver_addr, receiver_addr], - token_ids.clone(), - ) - .call() - .await?; + let receiver_balances = contract + .balanceOfBatch(vec![receiver_addr, receiver_addr], token_ids.clone()) + .call() + .await?; for (idx, value) in values.iter().enumerate() { assert_eq!(initial_alice_balances[idx] - value, alice_balances[idx]); @@ -1064,17 +1032,15 @@ async fn safe_batch_transfer_from_with_approval( watch!(contract_bob.setApprovalForAll(alice_addr, true))?; - let Erc1155Supply::balanceOfBatchReturn { balances: initial_dave_balances } = - contract_alice - .balanceOfBatch(vec![dave_addr, dave_addr], token_ids.clone()) - .call() - .await?; + let initial_dave_balances = contract_alice + .balanceOfBatch(vec![dave_addr, dave_addr], token_ids.clone()) + .call() + .await?; - let Erc1155Supply::balanceOfBatchReturn { balances: initial_bob_balances } = - contract_alice - .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) - .call() - .await?; + let initial_bob_balances = contract_alice + .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) + .call() + .await?; let receipt = receipt!(contract_alice.safeBatchTransferFrom( bob_addr, @@ -1092,17 +1058,15 @@ async fn safe_batch_transfer_from_with_approval( values: values.clone() })); - let Erc1155Supply::balanceOfBatchReturn { balances: bob_balances } = - contract_alice - .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) - .call() - .await?; + let bob_balances = contract_alice + .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) + .call() + .await?; - let Erc1155Supply::balanceOfBatchReturn { balances: dave_balances } = - contract_alice - .balanceOfBatch(vec![dave_addr, dave_addr], token_ids.clone()) - .call() - .await?; + let dave_balances = contract_alice + .balanceOfBatch(vec![dave_addr, dave_addr], token_ids.clone()) + .call() + .await?; for (idx, value) in values.iter().enumerate() { assert_eq!(initial_bob_balances[idx] - value, bob_balances[idx]); @@ -1122,19 +1086,19 @@ async fn supports_interface(alice: Account) -> eyre::Result<()> { let contract = Erc1155Supply::new(contract_addr, &alice.wallet); let invalid_interface_id: B32 = 0xffffffff_u32.into(); let supports_interface = - contract.supportsInterface(invalid_interface_id).call().await?._0; + contract.supportsInterface(invalid_interface_id).call().await?; assert!(!supports_interface); let erc1155_interface_id: B32 = 0xd9b67a26_u32.into(); let supports_interface = - contract.supportsInterface(erc1155_interface_id).call().await?._0; + contract.supportsInterface(erc1155_interface_id).call().await?; assert!(supports_interface); let erc165_interface_id: B32 = 0x01ffc9a7_u32.into(); let supports_interface = - contract.supportsInterface(erc165_interface_id).call().await?._0; + contract.supportsInterface(erc165_interface_id).call().await?; assert!(supports_interface); diff --git a/examples/erc1155/Cargo.toml b/examples/erc1155/Cargo.toml index fe836508f..33042d50a 100644 --- a/examples/erc1155/Cargo.toml +++ b/examples/erc1155/Cargo.toml @@ -16,10 +16,12 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc1155/tests/erc1155.rs b/examples/erc1155/tests/erc1155.rs index 43544912b..304ab921b 100644 --- a/examples/erc1155/tests/erc1155.rs +++ b/examples/erc1155/tests/erc1155.rs @@ -65,7 +65,7 @@ async fn balance_of_zero_balance(alice: Account) -> eyre::Result<()> { let contract = Erc1155::new(contract_addr, &alice.wallet); let token_ids = random_token_ids(1); - let Erc1155::balanceOfReturn { balance } = + let balance = contract.balanceOf(alice.address(), token_ids[0]).call().await?; assert_eq!(U256::ZERO, balance); @@ -85,8 +85,7 @@ async fn balance_of_batch_zero_balance( vec![alice.address(), bob.address(), dave.address(), charlie.address()]; let token_ids = random_token_ids(4); - let Erc1155::balanceOfBatchReturn { balances } = - contract.balanceOfBatch(accounts, token_ids).call().await?; + let balances = contract.balanceOfBatch(accounts, token_ids).call().await?; assert_eq!(vec![U256::ZERO, U256::ZERO, U256::ZERO, U256::ZERO], balances); Ok(()) @@ -116,8 +115,7 @@ async fn mints(alice: Account) -> eyre::Result<()> { value })); - let Erc1155::balanceOfReturn { balance } = - contract.balanceOf(alice_addr, token_id).call().await?; + let balance = contract.balanceOf(alice_addr, token_id).call().await?; assert_eq!(value, balance); Ok(()) @@ -136,7 +134,7 @@ async fn mints_to_receiver_contract(alice: Account) -> eyre::Result<()> { let token_id = random_token_ids(1)[0]; let value = random_values(1)[0]; - let Erc1155::balanceOfReturn { balance: initial_receiver_balance } = + let initial_receiver_balance = contract.balanceOf(receiver_addr, token_id).call().await?; let receipt = @@ -158,7 +156,7 @@ async fn mints_to_receiver_contract(alice: Account) -> eyre::Result<()> { data: vec![].into(), })); - let Erc1155::balanceOfReturn { balance: receiver_balance } = + let receiver_balance = contract.balanceOf(receiver_addr, token_id).call().await?; assert_eq!(initial_receiver_balance + value, receiver_balance); @@ -311,12 +309,11 @@ async fn mint_batch(alice: Account) -> eyre::Result<()> { })); for (token_id, value) in token_ids.iter().zip(values.iter()) { - let Erc1155::balanceOfReturn { balance } = - contract.balanceOf(alice_addr, *token_id).call().await?; + let balance = contract.balanceOf(alice_addr, *token_id).call().await?; assert_eq!(*value, balance); } - let Erc1155::balanceOfBatchReturn { balances } = contract + let balances = contract .balanceOfBatch( vec![alice_addr, alice_addr, alice_addr], token_ids.clone(), @@ -343,14 +340,10 @@ async fn mint_batch_transfer_to_receiver_contract( let token_ids = random_token_ids(2); let values = random_values(2); - let Erc1155::balanceOfBatchReturn { balances: initial_receiver_balances } = - contract - .balanceOfBatch( - vec![receiver_addr, receiver_addr], - token_ids.clone(), - ) - .call() - .await?; + let initial_receiver_balances = contract + .balanceOfBatch(vec![receiver_addr, receiver_addr], token_ids.clone()) + .call() + .await?; let receipt = receipt!(contract.mintBatch( receiver_addr, @@ -375,14 +368,10 @@ async fn mint_batch_transfer_to_receiver_contract( data: vec![].into(), })); - let Erc1155::balanceOfBatchReturn { balances: receiver_balances } = - contract - .balanceOfBatch( - vec![receiver_addr, receiver_addr], - token_ids.clone(), - ) - .call() - .await?; + let receiver_balances = contract + .balanceOfBatch(vec![receiver_addr, receiver_addr], token_ids.clone()) + .call() + .await?; for (idx, value) in values.iter().enumerate() { assert_eq!( @@ -564,7 +553,7 @@ async fn set_approval_for_all( approved: approved_value, })); - let Erc1155::isApprovedForAllReturn { approved } = + let approved = contract.isApprovedForAll(alice_addr, bob_addr).call().await?; assert_eq!(approved_value, approved); @@ -578,7 +567,7 @@ async fn set_approval_for_all( approved: approved_value, })); - let Erc1155::isApprovedForAllReturn { approved } = + let approved = contract.isApprovedForAll(alice_addr, bob_addr).call().await?; assert_eq!(approved_value, approved); @@ -611,7 +600,7 @@ async fn is_approved_for_all_zero_address(alice: Account) -> eyre::Result<()> { let invalid_operator = Address::ZERO; - let Erc1155::isApprovedForAllReturn { approved } = contract + let approved = contract .isApprovedForAll(alice.address(), invalid_operator) .call() .await?; @@ -637,9 +626,9 @@ async fn safe_transfer_from(alice: Account, bob: Account) -> eyre::Result<()> { vec![0, 1, 2, 3].into() ))?; - let Erc1155::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; - let Erc1155::balanceOfReturn { balance: initial_bob_balance } = + let initial_bob_balance = contract.balanceOf(bob_addr, token_id).call().await?; let receipt = receipt!(contract.safeTransferFrom( @@ -658,12 +647,10 @@ async fn safe_transfer_from(alice: Account, bob: Account) -> eyre::Result<()> { value })); - let Erc1155::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr, token_id).call().await?; + let alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); - let Erc1155::balanceOfReturn { balance: bob_balance } = - contract.balanceOf(bob_addr, token_id).call().await?; + let bob_balance = contract.balanceOf(bob_addr, token_id).call().await?; assert_eq!(initial_bob_balance + value, bob_balance); Ok(()) @@ -692,9 +679,9 @@ async fn safe_transfer_from_with_approval( watch!(contract_bob.setApprovalForAll(alice_addr, true))?; - let Erc1155::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr, token_id).call().await?; - let Erc1155::balanceOfReturn { balance: initial_bob_balance } = + let initial_bob_balance = contract_alice.balanceOf(bob_addr, token_id).call().await?; let receipt = receipt!(contract_alice.safeTransferFrom( @@ -713,11 +700,11 @@ async fn safe_transfer_from_with_approval( value })); - let Erc1155::balanceOfReturn { balance: alice_balance } = + let alice_balance = contract_alice.balanceOf(alice_addr, token_id).call().await?; assert_eq!(initial_alice_balance + value, alice_balance); - let Erc1155::balanceOfReturn { balance: bob_balance } = + let bob_balance = contract_alice.balanceOf(bob_addr, token_id).call().await?; assert_eq!(initial_bob_balance - value, bob_balance); @@ -746,9 +733,9 @@ async fn safe_transfer_to_receiver_contract( vec![0, 1, 2, 3].into() ))?; - let Erc1155::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; - let Erc1155::balanceOfReturn { balance: initial_receiver_balance } = + let initial_receiver_balance = contract.balanceOf(receiver_addr, token_id).call().await?; let receipt = receipt!(contract.safeTransferFrom( @@ -775,11 +762,10 @@ async fn safe_transfer_to_receiver_contract( data: vec![].into(), })); - let Erc1155::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr, token_id).call().await?; + let alice_balance = contract.balanceOf(alice_addr, token_id).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); - let Erc1155::balanceOfReturn { balance: receiver_balance } = + let receiver_balance = contract.balanceOf(receiver_addr, token_id).call().await?; assert_eq!(initial_receiver_balance + value, receiver_balance); @@ -1061,17 +1047,15 @@ async fn safe_batch_transfer_from( vec![].into() ))?; - let Erc1155::balanceOfBatchReturn { balances: initial_alice_balances } = - contract_alice - .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) - .call() - .await?; + let initial_alice_balances = contract_alice + .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) + .call() + .await?; - let Erc1155::balanceOfBatchReturn { balances: initial_bob_balances } = - contract_alice - .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) - .call() - .await?; + let initial_bob_balances = contract_alice + .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) + .call() + .await?; let receipt = receipt!(contract_alice.safeBatchTransferFrom( alice_addr, @@ -1089,17 +1073,15 @@ async fn safe_batch_transfer_from( values: values.clone() })); - let Erc1155::balanceOfBatchReturn { balances: alice_balances } = - contract_alice - .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) - .call() - .await?; + let alice_balances = contract_alice + .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) + .call() + .await?; - let Erc1155::balanceOfBatchReturn { balances: bob_balances } = - contract_alice - .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) - .call() - .await?; + let bob_balances = contract_alice + .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) + .call() + .await?; for (idx, value) in values.iter().enumerate() { assert_eq!(initial_alice_balances[idx] - value, alice_balances[idx]); @@ -1131,20 +1113,15 @@ async fn safe_batch_transfer_to_receiver_contract( vec![].into() ))?; - let Erc1155::balanceOfBatchReturn { balances: initial_alice_balances } = - contract - .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) - .call() - .await?; + let initial_alice_balances = contract + .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) + .call() + .await?; - let Erc1155::balanceOfBatchReturn { balances: initial_receiver_balances } = - contract - .balanceOfBatch( - vec![receiver_addr, receiver_addr], - token_ids.clone(), - ) - .call() - .await?; + let initial_receiver_balances = contract + .balanceOfBatch(vec![receiver_addr, receiver_addr], token_ids.clone()) + .call() + .await?; let receipt = receipt!(contract.safeBatchTransferFrom( alice_addr, @@ -1170,19 +1147,15 @@ async fn safe_batch_transfer_to_receiver_contract( data: vec![].into(), })); - let Erc1155::balanceOfBatchReturn { balances: alice_balances } = contract + let alice_balances = contract .balanceOfBatch(vec![alice_addr, alice_addr], token_ids.clone()) .call() .await?; - let Erc1155::balanceOfBatchReturn { balances: receiver_balances } = - contract - .balanceOfBatch( - vec![receiver_addr, receiver_addr], - token_ids.clone(), - ) - .call() - .await?; + let receiver_balances = contract + .balanceOfBatch(vec![receiver_addr, receiver_addr], token_ids.clone()) + .call() + .await?; for (idx, value) in values.iter().enumerate() { assert_eq!(initial_alice_balances[idx] - value, alice_balances[idx]); @@ -1377,17 +1350,15 @@ async fn safe_batch_transfer_from_with_approval( watch!(contract_bob.setApprovalForAll(alice_addr, true))?; - let Erc1155::balanceOfBatchReturn { balances: initial_dave_balances } = - contract_alice - .balanceOfBatch(vec![dave_addr, dave_addr], token_ids.clone()) - .call() - .await?; + let initial_dave_balances = contract_alice + .balanceOfBatch(vec![dave_addr, dave_addr], token_ids.clone()) + .call() + .await?; - let Erc1155::balanceOfBatchReturn { balances: initial_bob_balances } = - contract_alice - .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) - .call() - .await?; + let initial_bob_balances = contract_alice + .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) + .call() + .await?; let receipt = receipt!(contract_alice.safeBatchTransferFrom( bob_addr, @@ -1405,17 +1376,15 @@ async fn safe_batch_transfer_from_with_approval( values: values.clone() })); - let Erc1155::balanceOfBatchReturn { balances: bob_balances } = - contract_alice - .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) - .call() - .await?; + let bob_balances = contract_alice + .balanceOfBatch(vec![bob_addr, bob_addr], token_ids.clone()) + .call() + .await?; - let Erc1155::balanceOfBatchReturn { balances: dave_balances } = - contract_alice - .balanceOfBatch(vec![dave_addr, dave_addr], token_ids.clone()) - .call() - .await?; + let dave_balances = contract_alice + .balanceOfBatch(vec![dave_addr, dave_addr], token_ids.clone()) + .call() + .await?; for (idx, value) in values.iter().enumerate() { assert_eq!(initial_bob_balances[idx] - value, bob_balances[idx]); @@ -1595,7 +1564,7 @@ async fn burns(alice: Account) -> eyre::Result<()> { watch!(contract.mint(alice_addr, token_ids[0], values[0], vec![].into()))?; let initial_balance = - contract.balanceOf(alice_addr, token_ids[0]).call().await?.balance; + contract.balanceOf(alice_addr, token_ids[0]).call().await?; assert_eq!(values[0], initial_balance); let receipt = receipt!(contract.burn(alice_addr, token_ids[0], values[0]))?; @@ -1608,8 +1577,7 @@ async fn burns(alice: Account) -> eyre::Result<()> { value: values[0], })); - let balance = - contract.balanceOf(alice_addr, token_ids[0]).call().await?.balance; + let balance = contract.balanceOf(alice_addr, token_ids[0]).call().await?; assert_eq!(U256::ZERO, balance); Ok(()) @@ -1629,7 +1597,7 @@ async fn burns_with_approval(alice: Account, bob: Account) -> eyre::Result<()> { watch!(contract.mint(bob_addr, token_ids[0], values[0], vec![].into()))?; let initial_balance = - contract.balanceOf(bob_addr, token_ids[0]).call().await?.balance; + contract.balanceOf(bob_addr, token_ids[0]).call().await?; assert_eq!(values[0], initial_balance); watch!(contract_bob.setApprovalForAll(alice_addr, true))?; @@ -1644,8 +1612,7 @@ async fn burns_with_approval(alice: Account, bob: Account) -> eyre::Result<()> { value: values[0], })); - let balance = - contract.balanceOf(bob_addr, token_ids[0]).call().await?.balance; + let balance = contract.balanceOf(bob_addr, token_ids[0]).call().await?; assert_eq!(U256::ZERO, balance); Ok(()) @@ -1721,7 +1688,7 @@ async fn burns_batch(alice: Account) -> eyre::Result<()> { ))?; for (&id, &value) in token_ids.iter().zip(values.iter()) { - let balance = contract.balanceOf(alice_addr, id).call().await?.balance; + let balance = contract.balanceOf(alice_addr, id).call().await?; assert_eq!(value, balance); } @@ -1740,7 +1707,7 @@ async fn burns_batch(alice: Account) -> eyre::Result<()> { })); for id in token_ids { - let balance = contract.balanceOf(alice_addr, id).call().await?.balance; + let balance = contract.balanceOf(alice_addr, id).call().await?; assert_eq!(U256::ZERO, balance); } @@ -1769,7 +1736,7 @@ async fn burns_batch_with_approval( ))?; for (&id, &value) in token_ids.iter().zip(values.iter()) { - let balance = contract.balanceOf(bob_addr, id).call().await?.balance; + let balance = contract.balanceOf(bob_addr, id).call().await?; assert_eq!(value, balance); } @@ -1790,7 +1757,7 @@ async fn burns_batch_with_approval( })); for id in token_ids { - let balance = contract.balanceOf(bob_addr, id).call().await?.balance; + let balance = contract.balanceOf(bob_addr, id).call().await?; assert_eq!(U256::ZERO, balance); } diff --git a/examples/erc1967-invalid/Cargo.toml b/examples/erc1967-invalid/Cargo.toml index e17ef64e8..21f7f4f0c 100644 --- a/examples/erc1967-invalid/Cargo.toml +++ b/examples/erc1967-invalid/Cargo.toml @@ -17,6 +17,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -24,6 +25,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "erc1967-invalid-example" diff --git a/examples/erc1967-invalid/src/lib.rs b/examples/erc1967-invalid/src/lib.rs index 53694b223..4c1f17071 100644 --- a/examples/erc1967-invalid/src/lib.rs +++ b/examples/erc1967-invalid/src/lib.rs @@ -21,6 +21,7 @@ use stylus_sdk::{ #[storage] struct Erc1967InvalidExample { implementation: StorageAddress, + address_utils: AddressUtils, } #[public] @@ -34,11 +35,8 @@ impl Erc1967InvalidExample { self.implementation.set(implementation); // "forget" to set the implementation address at the appropriate // implementation slot - AddressUtils::function_delegate_call( - self, - implementation, - data.as_slice(), - )?; + self.address_utils + .function_delegate_call(implementation, data.as_ref())?; Ok(()) } diff --git a/examples/erc1967/Cargo.toml b/examples/erc1967/Cargo.toml index 03a75b2dd..bb49e890a 100644 --- a/examples/erc1967/Cargo.toml +++ b/examples/erc1967/Cargo.toml @@ -17,6 +17,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -24,6 +25,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "erc1967-example" diff --git a/examples/erc1967/src/lib.rs b/examples/erc1967/src/lib.rs index eca6d4be0..0a951333d 100644 --- a/examples/erc1967/src/lib.rs +++ b/examples/erc1967/src/lib.rs @@ -26,7 +26,7 @@ impl Erc1967Example { implementation: Address, data: Bytes, ) -> Result<(), erc1967::utils::Error> { - self.erc1967.constructor(implementation, &data) + self.erc1967.constructor(implementation, data) } fn implementation(&self) -> Result> { diff --git a/examples/erc1967/tests/erc1967.rs b/examples/erc1967/tests/erc1967.rs index 50e30145e..23848e83b 100644 --- a/examples/erc1967/tests/erc1967.rs +++ b/examples/erc1967/tests/erc1967.rs @@ -30,7 +30,7 @@ async fn constructs(alice: Account) -> Result<()> { .contract_address; let contract = Erc1967Example::new(contract_addr, &alice.wallet); - let implementation = contract.implementation().call().await?.implementation; + let implementation = contract.implementation().call().await?; assert_eq!(implementation, implementation_addr); Ok(()) @@ -54,14 +54,14 @@ async fn constructs_with_data(alice: Account) -> Result<()> { .contract_address; let contract = Erc1967Example::new(contract_addr, &alice.wallet); - let implementation = contract.implementation().call().await?.implementation; + let implementation = contract.implementation().call().await?; assert_eq!(implementation, implementation_addr); // check that the balance can be accurately fetched through the proxy. - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, amount); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, amount); Ok(()) @@ -79,10 +79,10 @@ async fn fallback(alice: Account, bob: Account) -> Result<()> { let contract = Erc1967Example::new(contract_addr, &alice.wallet); // verify initial balance is [`U256::ZERO`]. - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, U256::ZERO); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, U256::ZERO); // mint 1000 tokens. @@ -90,10 +90,10 @@ async fn fallback(alice: Account, bob: Account) -> Result<()> { watch!(contract.mint(alice.address(), amount))?; // check that the balance can be accurately fetched through the proxy. - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, amount); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, amount); // check that the balance can be transferred through the proxy. @@ -105,13 +105,13 @@ async fn fallback(alice: Account, bob: Account) -> Result<()> { value: amount, })); - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, U256::ZERO); - let balance = contract.balanceOf(bob.address()).call().await?.balance; + let balance = contract.balanceOf(bob.address()).call().await?; assert_eq!(balance, amount); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, amount); Ok(()) diff --git a/examples/erc20-flash-mint/Cargo.toml b/examples/erc20-flash-mint/Cargo.toml index 2c675d381..00d9897f6 100644 --- a/examples/erc20-flash-mint/Cargo.toml +++ b/examples/erc20-flash-mint/Cargo.toml @@ -16,10 +16,12 @@ alloy.workspace = true eyre.workspace = true tokio.workspace = true e2e.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc20-flash-mint/tests/erc20_flash_mint.rs b/examples/erc20-flash-mint/tests/erc20_flash_mint.rs index 58d1d4579..2827eee67 100644 --- a/examples/erc20-flash-mint/tests/erc20_flash_mint.rs +++ b/examples/erc20-flash-mint/tests/erc20_flash_mint.rs @@ -21,8 +21,8 @@ async fn constructs(alice: Account) -> Result<()> { watch!(contract.setFlashFeeReceiver(FEE_RECEIVER))?; watch!(contract.setFlashFeeValue(FLASH_FEE_VALUE))?; - let max = contract.maxFlashLoan(contract_addr).call().await?.maxLoan; - let fee = contract.flashFee(contract_addr, U256::ONE).call().await?.fee; + let max = contract.maxFlashLoan(contract_addr).call().await?; + let fee = contract.flashFee(contract_addr, U256::ONE).call().await?; assert_eq!(max, U256::MAX); assert_eq!(fee, FLASH_FEE_VALUE); @@ -41,7 +41,7 @@ async fn max_flash_loan(alice: Account) -> Result<()> { let mint_amount = uint!(1_000_000_U256); watch!(contract.mint(alice_addr, mint_amount))?; - let max_loan = contract.maxFlashLoan(contract_addr).call().await?.maxLoan; + let max_loan = contract.maxFlashLoan(contract_addr).call().await?; assert_eq!(U256::MAX - mint_amount, max_loan); Ok(()) @@ -59,7 +59,7 @@ async fn max_flash_loan_return_zero_if_no_more_tokens_to_mint( let alice_addr = alice.address(); watch!(contract.mint(alice_addr, U256::MAX))?; - let max_loan = contract.maxFlashLoan(contract_addr).call().await?.maxLoan; + let max_loan = contract.maxFlashLoan(contract_addr).call().await?; assert_eq!(U256::MIN, max_loan); Ok(()) @@ -79,11 +79,11 @@ async fn max_flash_loan_returns_zero_on_invalid_address( watch!(contract.mint(alice_addr, mint_amount))?; // non-token address - let max_loan = contract.maxFlashLoan(alice_addr).call().await?.maxLoan; + let max_loan = contract.maxFlashLoan(alice_addr).call().await?; assert_eq!(U256::MIN, max_loan); // works for zero address too - let max_loan = contract.maxFlashLoan(Address::ZERO).call().await?.maxLoan; + let max_loan = contract.maxFlashLoan(Address::ZERO).call().await?; assert_eq!(U256::MIN, max_loan); Ok(()) @@ -103,7 +103,7 @@ async fn flash_fee_returns_same_value_regardless_of_amount( let amounts = &[U256::ZERO, U256::ONE, uint!(1000_U256), U256::MAX]; for &amount in amounts { - let fee = contract.flashFee(contract_addr, amount).call().await?.fee; + let fee = contract.flashFee(contract_addr, amount).call().await?; assert_eq!(fee, FLASH_FEE_VALUE); } @@ -153,8 +153,8 @@ async fn flash_loan_with_fee(alice: Account) -> Result<()> { watch!(erc20.mint(borrower_addr, FLASH_FEE_VALUE))?; let loan_amount = uint!(1_000_000_U256); - let borrower_balance = erc20.balanceOf(borrower_addr).call().await?.balance; - let total_supply = erc20.totalSupply().call().await?.totalSupply; + let borrower_balance = erc20.balanceOf(borrower_addr).call().await?; + let total_supply = erc20.totalSupply().call().await?; assert_eq!(FLASH_FEE_VALUE, borrower_balance); assert_eq!(FLASH_FEE_VALUE, total_supply); @@ -186,8 +186,8 @@ async fn flash_loan_with_fee(alice: Account) -> Result<()> { value: loan_amount + FLASH_FEE_VALUE, })); - let borrower_balance = erc20.balanceOf(borrower_addr).call().await?.balance; - let total_supply = erc20.totalSupply().call().await?.totalSupply; + let borrower_balance = erc20.balanceOf(borrower_addr).call().await?; + let total_supply = erc20.totalSupply().call().await?; assert_eq!(U256::ZERO, borrower_balance); assert_eq!(U256::ZERO, total_supply); @@ -205,10 +205,9 @@ async fn flash_loan_with_fee_receiver(alice: Account) -> Result<()> { let borrower_addr = borrower::deploy(&alice.wallet, true, true).await?; let loan_amount = uint!(1_000_000_U256); - let borrower_balance = erc20.balanceOf(borrower_addr).call().await?.balance; - let fee_receiver_balance = - erc20.balanceOf(FEE_RECEIVER).call().await?.balance; - let total_supply = erc20.totalSupply().call().await?.totalSupply; + let borrower_balance = erc20.balanceOf(borrower_addr).call().await?; + let fee_receiver_balance = erc20.balanceOf(FEE_RECEIVER).call().await?; + let total_supply = erc20.totalSupply().call().await?; assert_eq!(U256::ZERO, borrower_balance); assert_eq!(U256::ZERO, fee_receiver_balance); @@ -241,10 +240,9 @@ async fn flash_loan_with_fee_receiver(alice: Account) -> Result<()> { value: loan_amount, })); - let borrower_balance = erc20.balanceOf(borrower_addr).call().await?.balance; - let fee_receiver_balance = - erc20.balanceOf(FEE_RECEIVER).call().await?.balance; - let total_supply = erc20.totalSupply().call().await?.totalSupply; + let borrower_balance = erc20.balanceOf(borrower_addr).call().await?; + let fee_receiver_balance = erc20.balanceOf(FEE_RECEIVER).call().await?; + let total_supply = erc20.totalSupply().call().await?; assert_eq!(U256::ZERO, borrower_balance); assert_eq!(U256::ZERO, fee_receiver_balance); @@ -264,10 +262,9 @@ async fn flash_loan_with_fee_and_fee_receiver(alice: Account) -> Result<()> { watch!(erc20.mint(borrower_addr, FLASH_FEE_VALUE))?; let loan_amount = uint!(1_000_000_U256); - let borrower_balance = erc20.balanceOf(borrower_addr).call().await?.balance; - let fee_receiver_balance = - erc20.balanceOf(FEE_RECEIVER).call().await?.balance; - let total_supply = erc20.totalSupply().call().await?.totalSupply; + let borrower_balance = erc20.balanceOf(borrower_addr).call().await?; + let fee_receiver_balance = erc20.balanceOf(FEE_RECEIVER).call().await?; + let total_supply = erc20.totalSupply().call().await?; assert_eq!(FLASH_FEE_VALUE, borrower_balance); assert_eq!(U256::ZERO, fee_receiver_balance); @@ -305,10 +302,9 @@ async fn flash_loan_with_fee_and_fee_receiver(alice: Account) -> Result<()> { value: FLASH_FEE_VALUE, })); - let borrower_balance = erc20.balanceOf(borrower_addr).call().await?.balance; - let fee_receiver_balance = - erc20.balanceOf(FEE_RECEIVER).call().await?.balance; - let total_supply = erc20.totalSupply().call().await?.totalSupply; + let borrower_balance = erc20.balanceOf(borrower_addr).call().await?; + let fee_receiver_balance = erc20.balanceOf(FEE_RECEIVER).call().await?; + let total_supply = erc20.totalSupply().call().await?; assert_eq!(U256::ZERO, borrower_balance); assert_eq!(FLASH_FEE_VALUE, fee_receiver_balance); diff --git a/examples/erc20-permit/Cargo.toml b/examples/erc20-permit/Cargo.toml index fabb2c392..cd9215b63 100644 --- a/examples/erc20-permit/Cargo.toml +++ b/examples/erc20-permit/Cargo.toml @@ -17,10 +17,12 @@ alloy.workspace = true eyre.workspace = true tokio.workspace = true e2e.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc20-permit/tests/erc20_permit.rs b/examples/erc20-permit/tests/erc20_permit.rs index e941783c5..b764a8261 100644 --- a/examples/erc20-permit/tests/erc20_permit.rs +++ b/examples/erc20-permit/tests/erc20_permit.rs @@ -28,7 +28,7 @@ type PermitStructHashTuple = sol! { macro_rules! domain_separator { ($contract:expr) => {{ - let Erc20Permit::DOMAIN_SEPARATORReturn { domainSeparator } = $contract + let domainSeparator = $contract .DOMAIN_SEPARATOR() .call() .await @@ -148,10 +148,9 @@ async fn permit_works(alice: Account, bob: Account) -> Result<()> { )) .await; - let Erc20Permit::noncesReturn { nonce: initial_nonce } = - contract_alice.nonces(alice_addr).call().await?; + let initial_nonce = contract_alice.nonces(alice_addr).call().await?; - let Erc20Permit::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; let receipt = receipt!(contract_alice.permit( @@ -170,31 +169,27 @@ async fn permit_works(alice: Account, bob: Account) -> Result<()> { value: balance, })); - let Erc20Permit::allowanceReturn { allowance } = + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_allowance + balance, allowance); - let Erc20Permit::noncesReturn { nonce } = - contract_alice.nonces(alice_addr).call().await?; + let nonce = contract_alice.nonces(alice_addr).call().await?; assert_eq!(initial_nonce + U256::ONE, nonce); let contract_bob = Erc20Permit::new(contract_addr, &bob.wallet); let value = balance - U256::ONE; - let Erc20Permit::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20Permit::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; let receipt = receipt!(contract_bob.transferFrom(alice_addr, bob_addr, value))?; - let Erc20Permit::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20Permit::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20Permit::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert!(receipt.emits(Erc20Permit::Transfer { diff --git a/examples/erc20-wrapper/Cargo.toml b/examples/erc20-wrapper/Cargo.toml index 6dfe10f67..c81d562f3 100644 --- a/examples/erc20-wrapper/Cargo.toml +++ b/examples/erc20-wrapper/Cargo.toml @@ -16,10 +16,12 @@ alloy.workspace = true eyre.workspace = true tokio.workspace = true e2e.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc20-wrapper/tests/erc20_wrapper.rs b/examples/erc20-wrapper/tests/erc20_wrapper.rs index 887002cef..fd6da491a 100644 --- a/examples/erc20-wrapper/tests/erc20_wrapper.rs +++ b/examples/erc20-wrapper/tests/erc20_wrapper.rs @@ -50,10 +50,10 @@ async fn constructs(alice: Account) -> Result<()> { .contract_address; let contract = Erc20Wrapper::new(contract_addr, alice.wallet); - let underlying = contract.underlying().call().await?.underlying; + let underlying = contract.underlying().call().await?; assert_eq!(underlying, asset_address); - let decimals = contract.decimals().call().await?.decimals; + let decimals = contract.decimals().call().await?; assert_eq!(decimals, DECIMALS); Ok(()) @@ -70,9 +70,8 @@ async fn deposit_for_success(alice: Account) -> Result<()> { watch!(asset.approve(contract_addr, initial_supply))?; let initial_wrapped_balance = - contract.balanceOf(alice_address).call().await?.balance; - let initial_wrapped_supply = - contract.totalSupply().call().await?.totalSupply; + contract.balanceOf(alice_address).call().await?; + let initial_wrapped_supply = contract.totalSupply().call().await?; let value = initial_supply; let receipt = receipt!(contract.depositFor(alice_address, value))?; @@ -93,11 +92,10 @@ async fn deposit_for_success(alice: Account) -> Result<()> { value })); - let wrapped_balance = - contract.balanceOf(alice_address).call().await?.balance; + let wrapped_balance = contract.balanceOf(alice_address).call().await?; assert_eq!(initial_wrapped_balance + value, wrapped_balance); - let wrapped_supply = contract.totalSupply().call().await?.totalSupply; + let wrapped_supply = contract.totalSupply().call().await?; assert_eq!(initial_wrapped_supply + value, wrapped_supply); Ok(()) @@ -116,11 +114,10 @@ async fn withdraw_to_success(alice: Account) -> Result<()> { watch!(contract.depositFor(alice.address(), initial_tokens))?; let initial_wrapped_balance = - contract.balanceOf(alice.address()).call().await?.balance; + contract.balanceOf(alice.address()).call().await?; assert_eq!(initial_tokens, initial_wrapped_balance); - let initial_wrapped_supply = - contract.totalSupply().call().await?.totalSupply; + let initial_wrapped_supply = contract.totalSupply().call().await?; let value = uint!(10_U256); let receipt = receipt!(contract.withdrawTo(alice.address(), value))?; @@ -141,11 +138,10 @@ async fn withdraw_to_success(alice: Account) -> Result<()> { value })); - let wrapped_balance = - contract.balanceOf(alice.address()).call().await?.balance; + let wrapped_balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(initial_wrapped_balance - value, wrapped_balance); - let wrapped_supply = contract.totalSupply().call().await?.totalSupply; + let wrapped_supply = contract.totalSupply().call().await?; assert_eq!(initial_wrapped_supply - value, wrapped_supply); Ok(()) diff --git a/examples/erc20/Cargo.toml b/examples/erc20/Cargo.toml index 80ac120ad..12cfe7ead 100644 --- a/examples/erc20/Cargo.toml +++ b/examples/erc20/Cargo.toml @@ -16,10 +16,12 @@ alloy.workspace = true eyre.workspace = true tokio.workspace = true e2e.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc20/tests/erc20.rs b/examples/erc20/tests/erc20.rs index 01c40942a..1a6f27151 100644 --- a/examples/erc20/tests/erc20.rs +++ b/examples/erc20/tests/erc20.rs @@ -37,12 +37,12 @@ async fn constructs(alice: Account) -> Result<()> { .contract_address; let contract = Erc20::new(contract_addr, &alice.wallet); - let name = contract.name().call().await?.name; - let symbol = contract.symbol().call().await?.symbol; - let cap = contract.cap().call().await?.cap; - let decimals = contract.decimals().call().await?.decimals; - let total_supply = contract.totalSupply().call().await?.totalSupply; - let paused = contract.paused().call().await?.paused; + let name = contract.name().call().await?; + let symbol = contract.symbol().call().await?; + let cap = contract.cap().call().await?; + let decimals = contract.decimals().call().await?; + let total_supply = contract.totalSupply().call().await?; + let paused = contract.paused().call().await?; assert_eq!(name, TOKEN_NAME.to_owned()); assert_eq!(symbol, TOKEN_SYMBOL.to_owned()); @@ -65,10 +65,8 @@ async fn mints(alice: Account) -> Result<()> { let contract = Erc20::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); - let Erc20::balanceOfReturn { balance: initial_balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract.totalSupply().call().await?; + let initial_balance = contract.balanceOf(alice_addr).call().await?; + let initial_supply = contract.totalSupply().call().await?; assert_eq!(U256::ZERO, initial_balance); assert_eq!(U256::ZERO, initial_supply); @@ -81,10 +79,8 @@ async fn mints(alice: Account) -> Result<()> { value: one, })); - let Erc20::balanceOfReturn { balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: total_supply } = - contract.totalSupply().call().await?; + let balance = contract.balanceOf(alice_addr).call().await?; + let total_supply = contract.totalSupply().call().await?; assert_eq!(initial_balance + one, balance); assert_eq!(initial_supply + one, total_supply); @@ -102,10 +98,8 @@ async fn mints_rejects_invalid_receiver(alice: Account) -> Result<()> { let contract = Erc20::new(contract_addr, &alice.wallet); let invalid_receiver = Address::ZERO; - let Erc20::balanceOfReturn { balance: initial_balance } = - contract.balanceOf(invalid_receiver).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract.totalSupply().call().await?; + let initial_balance = contract.balanceOf(invalid_receiver).call().await?; + let initial_supply = contract.totalSupply().call().await?; let value = uint!(10_U256); let err = send!(contract.mint(invalid_receiver, value)) @@ -114,10 +108,8 @@ async fn mints_rejects_invalid_receiver(alice: Account) -> Result<()> { receiver: invalid_receiver })); - let Erc20::balanceOfReturn { balance } = - contract.balanceOf(invalid_receiver).call().await?; - let Erc20::totalSupplyReturn { totalSupply: total_supply } = - contract.totalSupply().call().await?; + let balance = contract.balanceOf(invalid_receiver).call().await?; + let total_supply = contract.totalSupply().call().await?; assert_eq!(initial_balance, balance); assert_eq!(initial_supply, total_supply); @@ -141,10 +133,8 @@ async fn mints_rejects_overflow(alice: Account) -> Result<()> { watch!(contract.mint(alice_addr, max_cap))?; - let Erc20::balanceOfReturn { balance: initial_balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract.totalSupply().call().await?; + let initial_balance = contract.balanceOf(alice_addr).call().await?; + let initial_supply = contract.totalSupply().call().await?; assert_eq!(initial_supply, max_cap); assert_eq!(initial_balance, max_cap); @@ -154,10 +144,8 @@ async fn mints_rejects_overflow(alice: Account) -> Result<()> { assert!(err.panicked()); - let Erc20::balanceOfReturn { balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: total_supply } = - contract.totalSupply().call().await?; + let balance = contract.balanceOf(alice_addr).call().await?; + let total_supply = contract.totalSupply().call().await?; assert_eq!(initial_balance, balance); assert_eq!(initial_supply, total_supply); @@ -181,21 +169,16 @@ async fn transfers(alice: Account, bob: Account) -> Result<()> { watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; let receipt = receipt!(contract_alice.transfer(bob_addr, value))?; - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; assert!(receipt.emits(Erc20::Transfer { from: alice_addr, @@ -230,12 +213,10 @@ async fn transfer_rejects_insufficient_balance( watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; let err = send!(contract_alice.transfer(bob_addr, value)) .expect_err("should not transfer when insufficient balance"); @@ -245,12 +226,9 @@ async fn transfer_rejects_insufficient_balance( needed: value })); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; assert_eq!(initial_alice_balance, alice_balance); assert_eq!(initial_bob_balance, bob_balance); @@ -276,12 +254,11 @@ async fn transfer_rejects_invalid_receiver(alice: Account) -> Result<()> { watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_receiver_balance } = + let initial_receiver_balance = contract_alice.balanceOf(invalid_receiver).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; let err = send!(contract_alice.transfer(invalid_receiver, value)) .expect_err("should not transfer to Address::ZERO"); @@ -289,12 +266,10 @@ async fn transfer_rejects_invalid_receiver(alice: Account) -> Result<()> { receiver: invalid_receiver })); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: receiver_balance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let receiver_balance = contract_alice.balanceOf(invalid_receiver).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; + let supply = contract_alice.totalSupply().call().await?; assert_eq!(initial_alice_balance, alice_balance); assert_eq!(initial_receiver_balance, receiver_balance); @@ -318,16 +293,13 @@ async fn approves(alice: Account, bob: Account) -> Result<()> { let one = U256::ONE; let ten = uint!(10_U256); - let Erc20::allowanceReturn { allowance: initial_alice_bob_allowance } = + let initial_alice_bob_allowance = contract.allowance(alice_addr, bob_addr).call().await?; - let Erc20::allowanceReturn { allowance: initial_bob_alice_allowance } = + let initial_bob_alice_allowance = contract.allowance(bob_addr, alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract.totalSupply().call().await?; + let initial_alice_balance = contract.balanceOf(alice_addr).call().await?; + let initial_bob_balance = contract.balanceOf(bob_addr).call().await?; + let initial_supply = contract.totalSupply().call().await?; assert_eq!(U256::ZERO, initial_alice_bob_allowance); assert_eq!(U256::ZERO, initial_bob_alice_allowance); @@ -339,9 +311,9 @@ async fn approves(alice: Account, bob: Account) -> Result<()> { value: one, })); - let Erc20::allowanceReturn { allowance: alice_bob_allowance } = + let alice_bob_allowance = contract.allowance(alice_addr, bob_addr).call().await?; - let Erc20::allowanceReturn { allowance: bob_alice_allowance } = + let bob_alice_allowance = contract.allowance(bob_addr, alice_addr).call().await?; assert_eq!(initial_alice_bob_allowance + one, alice_bob_allowance); @@ -354,17 +326,14 @@ async fn approves(alice: Account, bob: Account) -> Result<()> { value: ten, })); - let Erc20::allowanceReturn { allowance: alice_bob_allowance } = + let alice_bob_allowance = contract.allowance(alice_addr, bob_addr).call().await?; - let Erc20::allowanceReturn { allowance: bob_alice_allowance } = + let bob_alice_allowance = contract.allowance(bob_addr, alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract.totalSupply().call().await?; + let alice_balance = contract.balanceOf(alice_addr).call().await?; + let bob_balance = contract.balanceOf(bob_addr).call().await?; + let supply = contract.totalSupply().call().await?; assert_eq!(initial_alice_bob_allowance + ten, alice_bob_allowance); assert_eq!(initial_bob_alice_allowance, bob_alice_allowance); @@ -389,16 +358,14 @@ async fn approve_rejects_invalid_spender(alice: Account) -> Result<()> { let ten = uint!(10_U256); - let Erc20::allowanceReturn { allowance: initial_alice_spender_allowance } = + let initial_alice_spender_allowance = contract.allowance(alice_addr, invalid_spender).call().await?; - let Erc20::allowanceReturn { allowance: initial_spender_alice_allowance } = + let initial_spender_alice_allowance = contract.allowance(invalid_spender, alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_spender_balance } = + let initial_alice_balance = contract.balanceOf(alice_addr).call().await?; + let initial_spender_balance = contract.balanceOf(invalid_spender).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract.totalSupply().call().await?; + let initial_supply = contract.totalSupply().call().await?; assert_eq!(U256::ZERO, initial_alice_spender_allowance); assert_eq!(U256::ZERO, initial_spender_alice_allowance); @@ -410,16 +377,13 @@ async fn approve_rejects_invalid_spender(alice: Account) -> Result<()> { spender: invalid_spender })); - let Erc20::allowanceReturn { allowance: alice_spender_allowance } = + let alice_spender_allowance = contract.allowance(alice_addr, invalid_spender).call().await?; - let Erc20::allowanceReturn { allowance: spender_alice_allowance } = + let spender_alice_allowance = contract.allowance(invalid_spender, alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: spender_balance } = - contract.balanceOf(invalid_spender).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract.totalSupply().call().await?; + let alice_balance = contract.balanceOf(alice_addr).call().await?; + let spender_balance = contract.balanceOf(invalid_spender).call().await?; + let supply = contract.totalSupply().call().await?; assert_eq!(initial_alice_spender_allowance, alice_spender_allowance); assert_eq!(initial_spender_alice_allowance, spender_alice_allowance); @@ -449,28 +413,23 @@ async fn transfers_from(alice: Account, bob: Account) -> Result<()> { watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; watch!(contract_alice.approve(bob_addr, balance))?; - let Erc20::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; let receipt = receipt!(contract_bob.transferFrom(alice_addr, bob_addr, value))?; - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert!(receipt.emits(Erc20::Transfer { @@ -509,16 +468,14 @@ async fn transfer_from_reverts_insufficient_balance( watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; watch!(contract_alice.approve(bob_addr, value))?; - let Erc20::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; let err = send!(contract_bob.transferFrom(alice_addr, bob_addr, value)) @@ -530,13 +487,10 @@ async fn transfer_from_reverts_insufficient_balance( needed: value })); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); @@ -569,14 +523,12 @@ async fn transfer_from_rejects_insufficient_allowance( watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_allowance, U256::ZERO); @@ -590,13 +542,10 @@ async fn transfer_from_rejects_insufficient_allowance( needed: value })); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); @@ -630,16 +579,15 @@ async fn transfer_from_rejects_invalid_receiver( watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_receiver_balance } = + let initial_receiver_balance = contract_alice.balanceOf(invalid_receiver).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; watch!(contract_alice.approve(bob_addr, balance))?; - let Erc20::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; let err = @@ -650,13 +598,10 @@ async fn transfer_from_rejects_invalid_receiver( receiver: invalid_receiver })); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: receiver_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let receiver_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); @@ -687,17 +632,13 @@ async fn burns(alice: Account) -> Result<()> { watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_balance = contract_alice.balanceOf(alice_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; let receipt = receipt!(contract_alice.burn(value))?; - let Erc20::balanceOfReturn { balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; + let balance = contract_alice.balanceOf(alice_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; assert!(receipt.emits(Erc20::Transfer { from: alice_addr, @@ -727,10 +668,8 @@ async fn burn_rejects_insufficient_balance(alice: Account) -> Result<()> { watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_balance = contract_alice.balanceOf(alice_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; let err = send!(contract_alice.burn(value)) .expect_err("should not burn when insufficient balance"); @@ -740,10 +679,8 @@ async fn burn_rejects_insufficient_balance(alice: Account) -> Result<()> { needed: value })); - let Erc20::balanceOfReturn { balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; + let balance = contract_alice.balanceOf(alice_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; assert_eq!(initial_balance, balance); assert_eq!(initial_supply, supply); @@ -770,27 +707,22 @@ async fn burns_from(alice: Account, bob: Account) -> Result<()> { watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; watch!(contract_alice.approve(bob_addr, balance))?; - let Erc20::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; let receipt = receipt!(contract_bob.burnFrom(alice_addr, value))?; - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert!(receipt.emits(Erc20::Transfer { @@ -829,16 +761,14 @@ async fn burn_from_reverts_insufficient_balance( watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; watch!(contract_alice.approve(bob_addr, value))?; - let Erc20::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; let err = send!(contract_bob.burnFrom(alice_addr, value)) @@ -850,13 +780,10 @@ async fn burn_from_reverts_insufficient_balance( needed: value })); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); @@ -889,14 +816,12 @@ async fn burn_from_rejects_insufficient_allowance( watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_allowance, U256::ZERO); @@ -910,13 +835,10 @@ async fn burn_from_rejects_insufficient_allowance( needed: value })); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); @@ -949,10 +871,8 @@ async fn mint_rejects_exceeding_cap(alice: Account) -> Result<()> { watch!(contract_alice.mint(alice_addr, balance))?; - let Erc20::balanceOfReturn { balance: initial_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_balance = contract_alice.balanceOf(alice_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; let err = send!(contract_alice.mint(alice_addr, two)) .expect_err("should not mint when exceeding the cap"); @@ -961,10 +881,8 @@ async fn mint_rejects_exceeding_cap(alice: Account) -> Result<()> { cap })); - let Erc20::balanceOfReturn { balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; + let balance = contract_alice.balanceOf(alice_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; assert_eq!(initial_balance, balance); assert_eq!(initial_supply, supply); @@ -989,10 +907,8 @@ async fn mint_rejects_when_cap_reached(alice: Account) -> Result<()> { watch!(contract_alice.mint(alice_addr, balance))?; - let Erc20::balanceOfReturn { balance: initial_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_balance = contract_alice.balanceOf(alice_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; let err = send!(contract_alice.mint(alice_addr, one)) .expect_err("should not mint when the cap is reached"); @@ -1001,10 +917,8 @@ async fn mint_rejects_when_cap_reached(alice: Account) -> Result<()> { cap })); - let Erc20::balanceOfReturn { balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; + let balance = contract_alice.balanceOf(alice_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; assert_eq!(initial_balance, balance); assert_eq!(initial_supply, supply); @@ -1052,7 +966,7 @@ async fn pauses(alice: Account) -> eyre::Result<()> { assert!(receipt.emits(Erc20::Paused { account: alice.address() })); - let paused = contract.paused().call().await?.paused; + let paused = contract.paused().call().await?; assert!(paused); @@ -1096,7 +1010,7 @@ async fn unpauses(alice: Account) -> eyre::Result<()> { assert!(receipt.emits(Erc20::Unpaused { account: alice.address() })); - let paused = contract.paused().call().await?.paused; + let paused = contract.paused().call().await?; assert!(!paused); @@ -1114,7 +1028,7 @@ async fn unpause_reverts_in_unpaused_state(alice: Account) -> eyre::Result<()> { let contract = Erc20::new(contract_addr, &alice.wallet); - let paused = contract.paused().call().await?.paused; + let paused = contract.paused().call().await?; assert!(!paused); @@ -1142,10 +1056,8 @@ async fn error_when_burn_in_paused_state(alice: Account) -> Result<()> { watch!(contract.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract.totalSupply().call().await?; + let initial_balance = contract.balanceOf(alice_addr).call().await?; + let initial_supply = contract.totalSupply().call().await?; watch!(contract.pause())?; @@ -1153,10 +1065,8 @@ async fn error_when_burn_in_paused_state(alice: Account) -> Result<()> { send!(contract.burn(value)).expect_err("should return `EnforcedPause`"); assert!(err.reverted_with(Erc20::EnforcedPause {})); - let Erc20::balanceOfReturn { balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract.totalSupply().call().await?; + let balance = contract.balanceOf(alice_addr).call().await?; + let supply = contract.totalSupply().call().await?; assert_eq!(initial_balance, balance); assert_eq!(initial_supply, supply); @@ -1186,16 +1096,14 @@ async fn error_when_burn_from_in_paused_state( watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; watch!(contract_alice.approve(bob_addr, balance))?; - let Erc20::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; watch!(contract_alice.pause())?; @@ -1204,13 +1112,10 @@ async fn error_when_burn_from_in_paused_state( .expect_err("should return `EnforcedPause`"); assert!(err.reverted_with(Erc20::EnforcedPause {})); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); @@ -1232,10 +1137,8 @@ async fn error_when_mint_in_paused_state(alice: Account) -> Result<()> { let contract = Erc20::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); - let Erc20::balanceOfReturn { balance: initial_balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract.totalSupply().call().await?; + let initial_balance = contract.balanceOf(alice_addr).call().await?; + let initial_supply = contract.totalSupply().call().await?; assert_eq!(U256::ZERO, initial_balance); assert_eq!(U256::ZERO, initial_supply); @@ -1246,10 +1149,8 @@ async fn error_when_mint_in_paused_state(alice: Account) -> Result<()> { .expect_err("should return `EnforcedPause`"); assert!(err.reverted_with(Erc20::EnforcedPause {})); - let Erc20::balanceOfReturn { balance } = - contract.balanceOf(alice_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: total_supply } = - contract.totalSupply().call().await?; + let balance = contract.balanceOf(alice_addr).call().await?; + let total_supply = contract.totalSupply().call().await?; assert_eq!(initial_balance, balance); assert_eq!(initial_supply, total_supply); @@ -1275,12 +1176,10 @@ async fn error_when_transfer_in_paused_state( watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; watch!(contract_alice.pause())?; @@ -1288,12 +1187,9 @@ async fn error_when_transfer_in_paused_state( .expect_err("should return `EnforcedPause`"); assert!(err.reverted_with(Erc20::EnforcedPause {})); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; assert_eq!(initial_alice_balance, alice_balance); assert_eq!(initial_bob_balance, bob_balance); @@ -1320,16 +1216,14 @@ async fn error_when_transfer_from(alice: Account, bob: Account) -> Result<()> { watch!(contract_alice.mint(alice.address(), balance))?; - let Erc20::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: initial_bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: initial_supply } = - contract_alice.totalSupply().call().await?; + let initial_bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let initial_supply = contract_alice.totalSupply().call().await?; watch!(contract_alice.approve(bob_addr, balance))?; - let Erc20::allowanceReturn { allowance: initial_allowance } = + let initial_allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; watch!(contract_alice.pause())?; @@ -1338,13 +1232,10 @@ async fn error_when_transfer_from(alice: Account, bob: Account) -> Result<()> { .expect_err("should return `EnforcedPause`"); assert!(err.reverted_with(Erc20::EnforcedPause {})); - let Erc20::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; - let Erc20::balanceOfReturn { balance: bob_balance } = - contract_alice.balanceOf(bob_addr).call().await?; - let Erc20::totalSupplyReturn { totalSupply: supply } = - contract_alice.totalSupply().call().await?; - let Erc20::allowanceReturn { allowance } = + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; + let bob_balance = contract_alice.balanceOf(bob_addr).call().await?; + let supply = contract_alice.totalSupply().call().await?; + let allowance = contract_alice.allowance(alice_addr, bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); @@ -1370,38 +1261,26 @@ async fn supports_interface(alice: Account) -> Result<()> { let contract = Erc20::new(contract_addr, &alice.wallet); let invalid_interface_id: B32 = 0xffffffff_u32.into(); - let supports_interface = contract - .supportsInterface(invalid_interface_id) - .call() - .await? - .supportsInterface; + let supports_interface = + contract.supportsInterface(invalid_interface_id).call().await?; assert!(!supports_interface); let erc20_interface_id: B32 = 0x36372b07_u32.into(); - let supports_interface = contract - .supportsInterface(erc20_interface_id) - .call() - .await? - .supportsInterface; + let supports_interface = + contract.supportsInterface(erc20_interface_id).call().await?; assert!(supports_interface); let erc165_interface_id: B32 = 0x01ffc9a7_u32.into(); - let supports_interface = contract - .supportsInterface(erc165_interface_id) - .call() - .await? - .supportsInterface; + let supports_interface = + contract.supportsInterface(erc165_interface_id).call().await?; assert!(supports_interface); let erc20_metadata_interface_id: B32 = 0xa219a025_u32.into(); - let supports_interface = contract - .supportsInterface(erc20_metadata_interface_id) - .call() - .await? - .supportsInterface; + let supports_interface = + contract.supportsInterface(erc20_metadata_interface_id).call().await?; assert!(supports_interface); diff --git a/examples/erc4626/Cargo.toml b/examples/erc4626/Cargo.toml index 673165a15..7a74da6f6 100644 --- a/examples/erc4626/Cargo.toml +++ b/examples/erc4626/Cargo.toml @@ -16,10 +16,12 @@ alloy.workspace = true eyre.workspace = true tokio.workspace = true e2e.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc4626/tests/erc4626.rs b/examples/erc4626/tests/erc4626.rs index 01ccff168..e9b329841 100644 --- a/examples/erc4626/tests/erc4626.rs +++ b/examples/erc4626/tests/erc4626.rs @@ -75,10 +75,10 @@ mod constructor { let contract = Erc4626::new(contract_addr, &alice.wallet); - let decimals = contract.decimals().call().await?.decimals; + let decimals = contract.decimals().call().await?; assert_eq!(decimals, 18); - let asset = contract.asset().call().await?.asset; + let asset = contract.asset().call().await?; assert_eq!(asset, asset_address); Ok(()) @@ -95,7 +95,7 @@ mod total_assets { let (contract_addr, _) = deploy(&alice, U256::ZERO).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let total = contract.totalAssets().call().await?.totalAssets; + let total = contract.totalAssets().call().await?; assert_eq!(U256::ZERO, total); Ok(()) @@ -109,7 +109,7 @@ mod total_assets { let (contract_addr, _) = deploy(&alice, initial_deposit).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let total = contract.totalAssets().call().await?.totalAssets; + let total = contract.totalAssets().call().await?; assert_eq!(initial_deposit, total); Ok(()) @@ -128,7 +128,7 @@ mod total_assets { // Transfer additional tokens directly to the vault watch!(asset.mint(contract_addr, additional_amount))?; - let total = contract.totalAssets().call().await?.totalAssets; + let total = contract.totalAssets().call().await?; assert_eq!(initial_deposit + additional_amount, total); Ok(()) @@ -139,7 +139,7 @@ mod total_assets { let (contract_addr, _) = deploy(&alice, U256::MAX).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let total = contract.totalAssets().call().await?.totalAssets; + let total = contract.totalAssets().call().await?; assert_eq!(U256::MAX, total); Ok(()) @@ -209,7 +209,7 @@ mod total_assets { watch!(asset.regular_approve(contract_addr, alice_addr, withdrawal))?; watch!(asset.transferFrom(contract_addr, alice_addr, withdrawal))?; - let total = contract.totalAssets().call().await?.totalAssets; + let total = contract.totalAssets().call().await?; assert_eq!(initial_deposit - withdrawal, total); Ok(()) @@ -224,7 +224,7 @@ mod convert_to_shares { let (contract_addr, _) = deploy(&alice, uint!(1000_U256)).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let shares = contract.convertToShares(U256::ZERO).call().await?.shares; + let shares = contract.convertToShares(U256::ZERO).call().await?; assert_eq!(U256::ZERO, shares); Ok(()) @@ -239,8 +239,7 @@ mod convert_to_shares { let (contract_addr, _) = deploy(&alice, initial_assets).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let shares = - contract.convertToShares(assets_to_convert).call().await?.shares; + let shares = contract.convertToShares(assets_to_convert).call().await?; assert_eq!(U256::ZERO, shares); @@ -255,8 +254,7 @@ mod convert_to_shares { let (contract_addr, _) = deploy(&alice, U256::ZERO).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let shares = - contract.convertToShares(assets_to_convert).call().await?.shares; + let shares = contract.convertToShares(assets_to_convert).call().await?; assert_eq!(assets_to_convert, shares); @@ -273,8 +271,7 @@ mod convert_to_shares { let contract = Erc4626::new(contract_addr, &alice.wallet); let expected_shares = U256::ONE; - let shares = - contract.convertToShares(assets_to_convert).call().await?.shares; + let shares = contract.convertToShares(assets_to_convert).call().await?; assert_eq!(expected_shares, shares); @@ -355,7 +352,7 @@ mod convert_to_assets { let (contract_addr, _) = deploy(&alice, uint!(1000_U256)).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let assets = contract.convertToAssets(U256::ZERO).call().await?.assets; + let assets = contract.convertToAssets(U256::ZERO).call().await?; assert_eq!(U256::ZERO, assets); Ok(()) @@ -373,7 +370,7 @@ mod convert_to_assets { let shares = uint!(69_U256); let expected_assets = uint!(6969_U256); - let assets = contract.convertToAssets(shares).call().await?.assets; + let assets = contract.convertToAssets(shares).call().await?; assert_eq!(assets, expected_assets); @@ -401,7 +398,7 @@ mod convert_to_assets { ))?; watch!(contract.mint(shares, alice.address()))?; - let assets = contract.convertToAssets(shares).call().await?.assets; + let assets = contract.convertToAssets(shares).call().await?; assert_eq!(assets, expected_assets); @@ -467,10 +464,10 @@ mod max_deposit { let (contract_addr, _) = deploy(&alice, uint!(1000_U256)).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let max = contract.maxDeposit(alice.address()).call().await?.maxDeposit; + let max = contract.maxDeposit(alice.address()).call().await?; assert_eq!(U256::MAX, max); - let max = contract.maxDeposit(Address::ZERO).call().await?.maxDeposit; + let max = contract.maxDeposit(Address::ZERO).call().await?; assert_eq!(U256::MAX, max); Ok(()) @@ -485,7 +482,7 @@ mod preview_deposit { let (contract_addr, _) = deploy(&alice, uint!(1000_U256)).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let shares = contract.previewDeposit(U256::ZERO).call().await?.shares; + let shares = contract.previewDeposit(U256::ZERO).call().await?; assert_eq!(U256::ZERO, shares); Ok(()) @@ -500,8 +497,7 @@ mod preview_deposit { let (contract_addr, _) = deploy(&alice, initial_assets).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let shares = - contract.previewDeposit(assets_to_convert).call().await?.shares; + let shares = contract.previewDeposit(assets_to_convert).call().await?; assert_eq!(U256::ZERO, shares); @@ -516,8 +512,7 @@ mod preview_deposit { let (contract_addr, _) = deploy(&alice, U256::ZERO).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let shares = - contract.previewDeposit(assets_to_convert).call().await?.shares; + let shares = contract.previewDeposit(assets_to_convert).call().await?; assert_eq!(assets_to_convert, shares); @@ -534,8 +529,7 @@ mod preview_deposit { let contract = Erc4626::new(contract_addr, &alice.wallet); let expected_shares = U256::ONE; - let shares = - contract.previewDeposit(assets_to_convert).call().await?.shares; + let shares = contract.previewDeposit(assets_to_convert).call().await?; assert_eq!(expected_shares, shares); @@ -642,9 +636,9 @@ mod deposit { watch!(erc20_alice.mint(alice_address, uint!(1000_U256)))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_address).call().await?._0; + erc20_alice.balanceOf(alice_address).call().await?; let initial_alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + contract.balanceOf(alice_address).call().await?; let receipt = receipt!(contract.deposit(U256::ZERO, alice.address()))?; assert!(receipt.emits(Erc4626::Deposit { @@ -654,12 +648,10 @@ mod deposit { shares: U256::ZERO, })); - let alice_balance = - erc20_alice.balanceOf(alice_address).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_balance, alice_balance); - let alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + let alice_shares = contract.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_shares, alice_shares); Ok(()) @@ -680,9 +672,9 @@ mod deposit { watch!(erc20_alice.mint(alice_address, assets_to_convert))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_address).call().await?._0; + erc20_alice.balanceOf(alice_address).call().await?; let initial_alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + contract.balanceOf(alice_address).call().await?; watch!(erc20_alice.regular_approve( alice_address, @@ -700,12 +692,10 @@ mod deposit { shares: U256::ZERO, })); - let alice_balance = - erc20_alice.balanceOf(alice_address).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_balance - assets_to_convert, alice_balance); - let alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + let alice_shares = contract.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_shares, alice_shares); Ok(()) @@ -724,9 +714,9 @@ mod deposit { watch!(erc20_alice.mint(alice_address, assets_to_convert))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_address).call().await?._0; + erc20_alice.balanceOf(alice_address).call().await?; let initial_alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + contract.balanceOf(alice_address).call().await?; watch!(erc20_alice.regular_approve( alice_address, @@ -744,12 +734,10 @@ mod deposit { shares: assets_to_convert, })); - let alice_balance = - erc20_alice.balanceOf(alice_address).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_balance - assets_to_convert, alice_balance); - let alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + let alice_shares = contract.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_shares + assets_to_convert, alice_shares); Ok(()) @@ -775,9 +763,9 @@ mod deposit { ))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_address).call().await?._0; + erc20_alice.balanceOf(alice_address).call().await?; let initial_alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + contract.balanceOf(alice_address).call().await?; let receipt = receipt!(contract.deposit(assets_to_convert, alice.address()))?; @@ -791,12 +779,10 @@ mod deposit { shares: expected_shares, })); - let alice_balance = - erc20_alice.balanceOf(alice_address).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_balance - assets_to_convert, alice_balance); - let alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + let alice_shares = contract.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_shares + expected_shares, alice_shares); Ok(()) @@ -872,10 +858,10 @@ mod max_mint { let (contract_addr, _) = deploy(&alice, uint!(1000_U256)).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let max = contract.maxMint(alice.address()).call().await?.maxMint; + let max = contract.maxMint(alice.address()).call().await?; assert_eq!(U256::MAX, max); - let max = contract.maxMint(Address::ZERO).call().await?.maxMint; + let max = contract.maxMint(Address::ZERO).call().await?; assert_eq!(U256::MAX, max); Ok(()) @@ -890,7 +876,7 @@ mod preview_mint { let (contract_addr, _) = deploy(&alice, uint!(1000_U256)).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let assets = contract.previewMint(U256::ZERO).call().await?.assets; + let assets = contract.previewMint(U256::ZERO).call().await?; assert_eq!(U256::ZERO, assets); Ok(()) @@ -908,7 +894,7 @@ mod preview_mint { let shares = uint!(69_U256); let expected_assets = uint!(6969_U256); - let assets = contract.previewMint(shares).call().await?.assets; + let assets = contract.previewMint(shares).call().await?; assert_eq!(assets, expected_assets); @@ -1023,12 +1009,11 @@ mod mint { shares, })); - let alice_balance = - contract.balanceOf(alice_address).call().await?.balance; + let alice_balance = contract.balanceOf(alice_address).call().await?; assert_eq!(alice_balance, shares); let alice_assets_balance = - asset.balanceOf(alice_address).call().await?._0; + asset.balanceOf(alice_address).call().await?; assert_eq!(alice_assets_balance, alice_assets); Ok(()) @@ -1052,9 +1037,9 @@ mod mint { watch!(asset.regular_approve(alice_address, contract_addr, assets))?; let initial_alice_assets = - asset.balanceOf(alice_address).call().await?._0; + asset.balanceOf(alice_address).call().await?; let initial_alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + contract.balanceOf(alice_address).call().await?; let receipt = receipt!(contract.mint(shares, alice_address))?; @@ -1065,11 +1050,10 @@ mod mint { shares, })); - let alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + let alice_shares = contract.balanceOf(alice_address).call().await?; assert_eq!(alice_shares, shares + initial_alice_shares); - let alice_assets = asset.balanceOf(alice_address).call().await?._0; + let alice_assets = asset.balanceOf(alice_address).call().await?; assert_eq!(alice_assets, initial_alice_assets - assets); Ok(()) @@ -1151,8 +1135,7 @@ mod max_withdraw { let (contract_addr, _) = deploy(&alice, initial_assets).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let max = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + let max = contract.maxWithdraw(alice.address()).call().await?; assert_eq!(U256::ZERO, max); Ok(()) @@ -1163,8 +1146,7 @@ mod max_withdraw { let (contract_addr, _) = deploy(&alice, U256::ZERO).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let max = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + let max = contract.maxWithdraw(alice.address()).call().await?; assert_eq!(U256::ZERO, max); Ok(()) @@ -1193,11 +1175,10 @@ mod max_withdraw { ))?; watch!(contract.mint(shares_to_mint, alice.address()))?; - let max = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + let max = contract.maxWithdraw(alice.address()).call().await?; assert_eq!(assets_to_deposit, max); - let max = contract.maxWithdraw(bob.address()).call().await?.maxWithdraw; + let max = contract.maxWithdraw(bob.address()).call().await?; assert_eq!(U256::ZERO, max); Ok(()) @@ -1225,11 +1206,10 @@ mod max_withdraw { ))?; watch!(contract.mint(shares_to_mint, alice.address()))?; - let max = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + let max = contract.maxWithdraw(alice.address()).call().await?; assert_eq!(assets_to_deposit, max); - let max = contract.maxWithdraw(bob.address()).call().await?.maxWithdraw; + let max = contract.maxWithdraw(bob.address()).call().await?; assert_eq!(U256::ZERO, max); Ok(()) @@ -1268,11 +1248,10 @@ mod max_withdraw { ))?; watch!(contract_bob.mint(shares_to_mint, bob.address()))?; - let max = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + let max = contract.maxWithdraw(alice.address()).call().await?; assert_eq!(assets_to_deposit, max); - let max = contract.maxWithdraw(bob.address()).call().await?.maxWithdraw; + let max = contract.maxWithdraw(bob.address()).call().await?; assert_eq!(assets_to_deposit, max); Ok(()) @@ -1381,7 +1360,7 @@ mod preview_withdraw { let (contract_addr, _) = deploy(&alice, uint!(1000_U256)).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let shares = contract.previewWithdraw(U256::ZERO).call().await?.shares; + let shares = contract.previewWithdraw(U256::ZERO).call().await?; assert_eq!(U256::ZERO, shares); Ok(()) @@ -1396,8 +1375,7 @@ mod preview_withdraw { let (contract_addr, _) = deploy(&alice, initial_assets).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let shares = - contract.previewWithdraw(assets_to_convert).call().await?.shares; + let shares = contract.previewWithdraw(assets_to_convert).call().await?; assert_eq!(U256::ONE, shares); @@ -1412,8 +1390,7 @@ mod preview_withdraw { let (contract_addr, _) = deploy(&alice, U256::ZERO).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let shares = - contract.previewWithdraw(assets_to_convert).call().await?.shares; + let shares = contract.previewWithdraw(assets_to_convert).call().await?; assert_eq!(assets_to_convert, shares); @@ -1430,8 +1407,7 @@ mod preview_withdraw { let contract = Erc4626::new(contract_addr, &alice.wallet); let expected_shares = U256::ONE; - let shares = - contract.previewWithdraw(assets_to_convert).call().await?.shares; + let shares = contract.previewWithdraw(assets_to_convert).call().await?; assert_eq!(expected_shares, shares); @@ -1503,8 +1479,7 @@ mod withdraw { ))?; watch!(contract.mint(shares_to_mint, alice.address()))?; - let max_withdraw = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + let max_withdraw = contract.maxWithdraw(alice.address()).call().await?; let err = send!(contract.withdraw( assets_to_withdraw, @@ -1704,7 +1679,7 @@ mod withdraw { // Initial state check let initial_max_withdraw = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + contract.maxWithdraw(alice.address()).call().await?; assert_eq!(U256::ZERO, initial_max_withdraw); // Mint shares @@ -1716,8 +1691,8 @@ mod withdraw { ))?; watch!(contract.mint(shares_to_mint, alice.address()))?; - let alice_balance = asset.balanceOf(alice.address()).call().await?._0; - let bob_balance = asset.balanceOf(bob.address()).call().await?._0; + let alice_balance = asset.balanceOf(alice.address()).call().await?; + let bob_balance = asset.balanceOf(bob.address()).call().await?; assert_eq!(U256::ZERO, alice_balance); assert_eq!(U256::ZERO, bob_balance); @@ -1739,9 +1714,9 @@ mod withdraw { // Verify updated state let final_max_withdraw = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + contract.maxWithdraw(alice.address()).call().await?; let final_max_redeem = - contract.maxRedeem(alice.address()).call().await?.maxRedeem; + contract.maxRedeem(alice.address()).call().await?; assert_eq!(assets_to_deposit - assets_to_withdraw, final_max_withdraw); assert_eq!(shares_to_mint - assets_to_withdraw, final_max_redeem); @@ -1763,14 +1738,14 @@ mod withdraw { // Verify final state let final_max_withdraw = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + contract.maxWithdraw(alice.address()).call().await?; let final_max_redeem = - contract.maxRedeem(alice.address()).call().await?.maxRedeem; + contract.maxRedeem(alice.address()).call().await?; assert_eq!(U256::ZERO, final_max_withdraw); assert_eq!(U256::ZERO, final_max_redeem); - let alice_balance = asset.balanceOf(alice.address()).call().await?._0; - let bob_balance = asset.balanceOf(bob.address()).call().await?._0; + let alice_balance = asset.balanceOf(alice.address()).call().await?; + let bob_balance = asset.balanceOf(bob.address()).call().await?; assert_eq!(assets_to_withdraw, alice_balance); assert_eq!(assets_to_withdraw, bob_balance); @@ -1794,8 +1769,7 @@ mod withdraw { let asset = ERC20Mock::new(asset_addr, &alice.wallet); // Initial state check - let initial_total_assets = - contract.totalAssets().call().await?.totalAssets; + let initial_total_assets = contract.totalAssets().call().await?; assert_eq!(initial_assets, initial_total_assets); // Mint shares @@ -1807,13 +1781,12 @@ mod withdraw { ))?; watch!(contract.mint(shares_to_mint, alice.address()))?; - let alice_balance = asset.balanceOf(alice.address()).call().await?._0; - let bob_balance = asset.balanceOf(bob.address()).call().await?._0; + let alice_balance = asset.balanceOf(alice.address()).call().await?; + let bob_balance = asset.balanceOf(bob.address()).call().await?; assert_eq!(U256::ZERO, alice_balance); assert_eq!(U256::ZERO, bob_balance); - let pre_withdraw_assets = - contract.totalAssets().call().await?.totalAssets; + let pre_withdraw_assets = contract.totalAssets().call().await?; // Perform withdrawal let receipt = receipt!(contract.withdraw( @@ -1831,8 +1804,7 @@ mod withdraw { shares: shares_to_redeem, })); - let post_withdraw_assets = - contract.totalAssets().call().await?.totalAssets; + let post_withdraw_assets = contract.totalAssets().call().await?; assert_eq!( pre_withdraw_assets - assets_to_withdraw, post_withdraw_assets @@ -1857,17 +1829,16 @@ mod withdraw { })); // Verify the final state - let post_withdraw_assets = - contract.totalAssets().call().await?.totalAssets; + let post_withdraw_assets = contract.totalAssets().call().await?; assert_eq!( pre_withdraw_assets - assets_to_withdraw, post_withdraw_assets ); let final_max_withdraw = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + contract.maxWithdraw(alice.address()).call().await?; let final_max_redeem = - contract.maxRedeem(alice.address()).call().await?.maxRedeem; + contract.maxRedeem(alice.address()).call().await?; assert_eq!( assets_to_deposit - assets_to_withdraw - assets_to_withdraw, final_max_withdraw @@ -1877,8 +1848,8 @@ mod withdraw { final_max_redeem ); - let alice_balance = asset.balanceOf(alice.address()).call().await?._0; - let bob_balance = asset.balanceOf(bob.address()).call().await?._0; + let alice_balance = asset.balanceOf(alice.address()).call().await?; + let bob_balance = asset.balanceOf(bob.address()).call().await?; assert_eq!(assets_to_withdraw, alice_balance); assert_eq!(assets_to_withdraw, bob_balance); @@ -1957,23 +1928,15 @@ mod withdraw { // Verify final balances assert_eq!( uint!(50_U256), - contract_alice - .maxWithdraw(alice.address()) - .call() - .await? - .maxWithdraw + contract_alice.maxWithdraw(alice.address()).call().await? ); assert_eq!( uint!(100_U256), - contract_alice.maxWithdraw(bob.address()).call().await?.maxWithdraw + contract_alice.maxWithdraw(bob.address()).call().await? ); assert_eq!( U256::ZERO, - contract_alice - .maxWithdraw(charlie.address()) - .call() - .await? - .maxWithdraw + contract_alice.maxWithdraw(charlie.address()).call().await? ); Ok(()) @@ -1994,8 +1957,7 @@ mod withdraw { let asset = ERC20Mock::new(asset_addr, &alice.wallet); // Record initial total assets - let initial_total = - contract_alice.totalAssets().call().await?.totalAssets; + let initial_total = contract_alice.totalAssets().call().await?; // Mint and approve for all users for user in [&alice, &bob, &charlie] { @@ -2013,18 +1975,12 @@ mod withdraw { watch!(contract_charlie.mint(uint!(30_U256), charlie.address()))?; // Verify share distribution considers initial assets - let alice_assets_before = contract_alice - .maxWithdraw(alice.address()) - .call() - .await? - .maxWithdraw; + let alice_assets_before = + contract_alice.maxWithdraw(alice.address()).call().await?; let bob_assets_before = - contract_alice.maxWithdraw(bob.address()).call().await?.maxWithdraw; - let charlie_assets_before = contract_alice - .maxWithdraw(charlie.address()) - .call() - .await? - .maxWithdraw; + contract_alice.maxWithdraw(bob.address()).call().await?; + let charlie_assets_before = + contract_alice.maxWithdraw(charlie.address()).call().await?; // Each user withdraws watch!(contract_alice.withdraw( @@ -2045,12 +2001,11 @@ mod withdraw { // Verify proportional distribution of initial assets was maintained let remaining_bob = - contract_alice.maxWithdraw(bob.address()).call().await?.maxWithdraw; + contract_alice.maxWithdraw(bob.address()).call().await?; assert_eq!(bob_assets_before - uint!(1010_U256), remaining_bob); // Verify total assets consistency - let final_total = - contract_alice.totalAssets().call().await?.totalAssets; + let final_total = contract_alice.totalAssets().call().await?; let expected_remaining = initial_total + uint!(6060_U256) - alice_assets_before - uint!(1010_U256) @@ -2077,8 +2032,7 @@ mod withdraw { watch!(contract.mint(shares, alice.address()))?; // Record initial conversion rate - let initial_rate = - contract.convertToAssets(U256::ONE).call().await?.assets; + let initial_rate = contract.convertToAssets(U256::ONE).call().await?; // Perform partial withdrawal watch!(contract.withdraw( @@ -2088,8 +2042,7 @@ mod withdraw { ))?; // Verify conversion rate remains the same - let final_rate = - contract.convertToAssets(U256::ONE).call().await?.assets; + let final_rate = contract.convertToAssets(U256::ONE).call().await?; assert_eq!(initial_rate, final_rate); Ok(()) @@ -2119,11 +2072,10 @@ mod withdraw { watch!(contract.mint(shares_to_mint, alice.address()))?; // Record state before failed withdrawal - let pre_total_assets = contract.totalAssets().call().await?.totalAssets; + let pre_total_assets = contract.totalAssets().call().await?; let pre_max_withdraw = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; - let pre_max_redeem = - contract.maxRedeem(alice.address()).call().await?.maxRedeem; + contract.maxWithdraw(alice.address()).call().await?; + let pre_max_redeem = contract.maxRedeem(alice.address()).call().await?; // Attempt excessive withdrawal send!(contract.withdraw( @@ -2134,12 +2086,11 @@ mod withdraw { .expect_err("should fail due to exceeding max withdraw"); // Verify state remains unchanged - let post_total_assets = - contract.totalAssets().call().await?.totalAssets; + let post_total_assets = contract.totalAssets().call().await?; let post_max_withdraw = - contract.maxWithdraw(alice.address()).call().await?.maxWithdraw; + contract.maxWithdraw(alice.address()).call().await?; let post_max_redeem = - contract.maxRedeem(alice.address()).call().await?.maxRedeem; + contract.maxRedeem(alice.address()).call().await?; assert_eq!(pre_total_assets, post_total_assets); assert_eq!(pre_max_withdraw, post_max_withdraw); @@ -2185,7 +2136,7 @@ mod max_redeem { let (contract_addr, _) = deploy(&alice, initial_assets).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let max = contract.maxRedeem(alice.address()).call().await?.maxRedeem; + let max = contract.maxRedeem(alice.address()).call().await?; assert_eq!(U256::ZERO, max); Ok(()) @@ -2196,7 +2147,7 @@ mod max_redeem { let (contract_addr, _) = deploy(&alice, U256::ZERO).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let max = contract.maxRedeem(alice.address()).call().await?.maxRedeem; + let max = contract.maxRedeem(alice.address()).call().await?; assert_eq!(U256::ZERO, max); Ok(()) @@ -2224,7 +2175,7 @@ mod max_redeem { ))?; watch!(contract.mint(shares_to_mint, alice.address()))?; - let max = contract.maxRedeem(alice.address()).call().await?.maxRedeem; + let max = contract.maxRedeem(alice.address()).call().await?; assert_eq!(shares_to_mint, max); Ok(()) @@ -2257,9 +2208,8 @@ mod max_redeem { // Transfer some shares to bob watch!(contract.transfer(bob.address(), transfer_amount))?; - let alice_max = - contract.maxRedeem(alice.address()).call().await?.maxRedeem; - let bob_max = contract.maxRedeem(bob.address()).call().await?.maxRedeem; + let alice_max = contract.maxRedeem(alice.address()).call().await?; + let bob_max = contract.maxRedeem(bob.address()).call().await?; assert_eq!(shares_to_mint - transfer_amount, alice_max); assert_eq!(transfer_amount, bob_max); @@ -2290,7 +2240,7 @@ mod max_redeem { watch!(contract.mint(first_mint, alice.address()))?; let max_after_first = - contract.maxRedeem(alice.address()).call().await?.maxRedeem; + contract.maxRedeem(alice.address()).call().await?; assert_eq!(first_mint, max_after_first); // Second mint @@ -2303,7 +2253,7 @@ mod max_redeem { watch!(contract.mint(second_mint, alice.address()))?; let max_after_second = - contract.maxRedeem(alice.address()).call().await?.maxRedeem; + contract.maxRedeem(alice.address()).call().await?; assert_eq!(first_mint + second_mint, max_after_second); Ok(()) @@ -2343,7 +2293,7 @@ mod preview_redeem { let (contract_addr, _) = deploy(&alice, uint!(1000_U256)).await?; let contract = Erc4626::new(contract_addr, &alice.wallet); - let assets = contract.previewRedeem(U256::ZERO).call().await?.assets; + let assets = contract.previewRedeem(U256::ZERO).call().await?; assert_eq!(U256::ZERO, assets); Ok(()) @@ -2361,7 +2311,7 @@ mod preview_redeem { let shares = uint!(69_U256); let expected_assets = uint!(6969_U256); - let assets = contract.previewRedeem(shares).call().await?.assets; + let assets = contract.previewRedeem(shares).call().await?; assert_eq!(assets, expected_assets); @@ -2442,9 +2392,9 @@ mod redeem { let alice_address = alice.address(); let initial_alice_assets = - asset.balanceOf(alice_address).call().await?._0; + asset.balanceOf(alice_address).call().await?; let initial_alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + contract.balanceOf(alice_address).call().await?; let receipt = receipt!(contract.redeem( U256::ZERO, @@ -2460,11 +2410,10 @@ mod redeem { shares: U256::ZERO, })); - let alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + let alice_shares = contract.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_shares, alice_shares); - let alice_assets = asset.balanceOf(alice_address).call().await?._0; + let alice_assets = asset.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_assets, alice_assets); Ok(()) @@ -2488,9 +2437,9 @@ mod redeem { watch!(contract.mint(shares, alice.address()))?; let initial_alice_assets = - asset.balanceOf(alice_address).call().await?._0; + asset.balanceOf(alice_address).call().await?; let initial_alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + contract.balanceOf(alice_address).call().await?; let receipt = receipt!(contract.redeem(shares, alice_address, alice_address))?; @@ -2503,11 +2452,10 @@ mod redeem { shares })); - let alice_shares = - contract.balanceOf(alice_address).call().await?.balance; + let alice_shares = contract.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_shares - shares, alice_shares); - let alice_assets = asset.balanceOf(alice_address).call().await?._0; + let alice_assets = asset.balanceOf(alice_address).call().await?; assert_eq!(initial_alice_assets + assets, alice_assets); Ok(()) diff --git a/examples/erc721-consecutive/Cargo.toml b/examples/erc721-consecutive/Cargo.toml index 6b6a2293b..dcc63437c 100644 --- a/examples/erc721-consecutive/Cargo.toml +++ b/examples/erc721-consecutive/Cargo.toml @@ -18,10 +18,12 @@ e2e.workspace = true tokio.workspace = true eyre.workspace = true rand.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc721-consecutive/tests/erc721_consecutive.rs b/examples/erc721-consecutive/tests/erc721_consecutive.rs index 964bc0f4f..ae55afbb0 100644 --- a/examples/erc721-consecutive/tests/erc721_consecutive.rs +++ b/examples/erc721-consecutive/tests/erc721_consecutive.rs @@ -48,7 +48,7 @@ async fn constructs(alice: Account) -> eyre::Result<()> { .await?; let contract = Erc721::new(receipt.contract_address, &alice.wallet); - let balance = contract.balanceOf(alice_addr).call().await?.balance; + let balance = contract.balanceOf(alice_addr).call().await?; assert_eq!(balance, uint!(10_U256)); Ok(()) } @@ -72,15 +72,13 @@ async fn mints(alice: Account) -> eyre::Result<()> { toAddress: alice.address(), })); - let Erc721::balanceOfReturn { balance: balance1 } = - contract.balanceOf(alice.address()).call().await?; + let balance1 = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance1, U256::from(batch_size)); let token_id = random_token_id(); watch!(contract.mint(alice.address(), token_id))?; - let Erc721::balanceOfReturn { balance: balance2 } = - contract.balanceOf(alice.address()).call().await?; + let balance2 = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance2, balance1 + U256::ONE); Ok(()) @@ -154,29 +152,24 @@ async fn transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { first_consecutive_token_id ))?; - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(first_consecutive_token_id).call().await?; + let ownerOf = contract.ownerOf(first_consecutive_token_id).call().await?; assert_eq!(ownerOf, bob.address()); // Check that balances changed. - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice.address()).call().await?; + let alice_balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(alice_balance, uint!(1000_U256) - U256::ONE); - let Erc721::balanceOfReturn { balance: bob_balance } = - contract.balanceOf(bob.address()).call().await?; + let bob_balance = contract.balanceOf(bob.address()).call().await?; assert_eq!(bob_balance, uint!(1000_U256) + U256::ONE); // Test non-consecutive mint. let token_id = random_token_id(); watch!(contract.mint(alice.address(), token_id))?; - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice.address()).call().await?; + let alice_balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(alice_balance, uint!(1000_U256)); // Test transfer of the token that wasn't minted consecutive. watch!(contract.transferFrom(alice.address(), bob.address(), token_id))?; - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice.address()).call().await?; + let alice_balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(alice_balance, uint!(1000_U256) - U256::ONE); Ok(()) } @@ -204,8 +197,7 @@ async fn burns(alice: Account) -> eyre::Result<()> { tokenId: first_consecutive_token_id, })); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice.address()).call().await?; + let alice_balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(alice_balance, uint!(1000_U256) - U256::ONE); let err = contract @@ -221,11 +213,9 @@ async fn burns(alice: Account) -> eyre::Result<()> { // Check non-consecutive token burn. let non_consecutive_token_id = random_token_id(); watch!(contract.mint(alice.address(), non_consecutive_token_id))?; - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(non_consecutive_token_id).call().await?; + let ownerOf = contract.ownerOf(non_consecutive_token_id).call().await?; assert_eq!(ownerOf, alice.address()); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice.address()).call().await?; + let alice_balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(alice_balance, uint!(1000_U256)); let receipt = receipt!(contract.burn(non_consecutive_token_id))?; diff --git a/examples/erc721-holder/Cargo.toml b/examples/erc721-holder/Cargo.toml index 82be01342..07a6d13ef 100644 --- a/examples/erc721-holder/Cargo.toml +++ b/examples/erc721-holder/Cargo.toml @@ -17,10 +17,12 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc721-holder/tests/erc721-holder.rs b/examples/erc721-holder/tests/erc721-holder.rs index dcc5998a6..3167204ac 100644 --- a/examples/erc721-holder/tests/erc721-holder.rs +++ b/examples/erc721-holder/tests/erc721-holder.rs @@ -21,8 +21,7 @@ async fn returns_correct_selector(alice: Account) -> Result<()> { let interface_selector = contract .onERC721Received(operator, from, token_id, data) .call() - .await? - ._0; + .await?; assert_eq!(RECEIVER_FN_SELECTOR, interface_selector); diff --git a/examples/erc721-metadata/Cargo.toml b/examples/erc721-metadata/Cargo.toml index 18c2d7cb9..54c544cd5 100644 --- a/examples/erc721-metadata/Cargo.toml +++ b/examples/erc721-metadata/Cargo.toml @@ -17,10 +17,12 @@ e2e.workspace = true tokio.workspace = true eyre.workspace = true rand.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc721-metadata/tests/erc721_metadata.rs b/examples/erc721-metadata/tests/erc721_metadata.rs index 6b8399872..e7660bd33 100644 --- a/examples/erc721-metadata/tests/erc721_metadata.rs +++ b/examples/erc721-metadata/tests/erc721_metadata.rs @@ -41,8 +41,8 @@ async fn constructs(alice: Account) -> eyre::Result<()> { .contract_address; let contract = Erc721::new(contract_addr, &alice.wallet); - let Erc721::nameReturn { name } = contract.name().call().await?; - let Erc721::symbolReturn { symbol } = contract.symbol().call().await?; + let name = contract.name().call().await?; + let symbol = contract.symbol().call().await?; assert_eq!(TOKEN_NAME.to_owned(), name); assert_eq!(TOKEN_SYMBOL.to_owned(), symbol); @@ -98,8 +98,7 @@ async fn return_empty_token_uri_when_without_base_uri_and_token_uri( watch!(contract.mint(alice.address(), token_id))?; - let Erc721::tokenURIReturn { tokenURI } = - contract.tokenURI(token_id).call().await?; + let tokenURI = contract.tokenURI(token_id).call().await?; assert_eq!("", tokenURI); @@ -125,8 +124,7 @@ async fn return_token_uri_with_base_uri_and_without_token_uri( watch!(contract.mint(alice.address(), token_id))?; - let Erc721::tokenURIReturn { tokenURI } = - contract.tokenURI(token_id).call().await?; + let tokenURI = contract.tokenURI(token_id).call().await?; assert_eq!(base_uri.to_owned() + &token_id.to_string(), tokenURI); Ok(()) @@ -159,8 +157,7 @@ async fn return_token_uri_with_base_uri_and_token_uri( assert!(receipt.emits(Erc721::MetadataUpdate { tokenId: token_id })); - let Erc721::tokenURIReturn { tokenURI } = - contract.tokenURI(token_id).call().await?; + let tokenURI = contract.tokenURI(token_id).call().await?; assert_eq!(base_uri.to_owned() + &token_uri, tokenURI); @@ -202,8 +199,7 @@ async fn set_token_uri_before_mint(alice: Account) -> eyre::Result<()> { watch!(contract.mint(alice.address(), token_id))?; - let Erc721::tokenURIReturn { tokenURI } = - contract.tokenURI(token_id).call().await?; + let tokenURI = contract.tokenURI(token_id).call().await?; assert_eq!(base_uri.to_owned() + &token_uri, tokenURI); @@ -257,12 +253,10 @@ async fn return_token_uri_after_burn_and_remint( tokenId: token_id })); - let Erc721::ownerOfReturn { ownerOf: owner_of } = - contract.ownerOf(token_id).call().await?; + let owner_of = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, owner_of); - let Erc721::tokenURIReturn { tokenURI } = - contract.tokenURI(token_id).call().await?; + let tokenURI = contract.tokenURI(token_id).call().await?; assert_eq!(base_uri.to_owned() + &token_id.to_string(), tokenURI); Ok(()) @@ -285,29 +279,26 @@ async fn supports_interface(alice: Account) -> eyre::Result<()> { let contract = Erc721::new(contract_addr, &alice.wallet); let erc721_metadata_interface_id: B32 = 0x5b5e139f_u32.into(); - let supports_interface = contract - .supportsInterface(erc721_metadata_interface_id) - .call() - .await? - ._0; + let supports_interface = + contract.supportsInterface(erc721_metadata_interface_id).call().await?; assert!(supports_interface); let erc721_interface_id: B32 = 0x80ac58cd_u32.into(); let supports_interface = - contract.supportsInterface(erc721_interface_id).call().await?._0; + contract.supportsInterface(erc721_interface_id).call().await?; assert!(supports_interface); let erc165_interface_id: B32 = 0x01ffc9a7_u32.into(); let supports_interface = - contract.supportsInterface(erc165_interface_id).call().await?._0; + contract.supportsInterface(erc165_interface_id).call().await?; assert!(supports_interface); let invalid_interface_id: B32 = 0xffffffff_u32.into(); let supports_interface = - contract.supportsInterface(invalid_interface_id).call().await?._0; + contract.supportsInterface(invalid_interface_id).call().await?; assert!(!supports_interface); diff --git a/examples/erc721-wrapper/Cargo.toml b/examples/erc721-wrapper/Cargo.toml index ac5756cef..470a35239 100644 --- a/examples/erc721-wrapper/Cargo.toml +++ b/examples/erc721-wrapper/Cargo.toml @@ -16,10 +16,12 @@ alloy.workspace = true eyre.workspace = true tokio.workspace = true e2e.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc721-wrapper/tests/erc721_wrapper.rs b/examples/erc721-wrapper/tests/erc721_wrapper.rs index 97d72292c..e94055d01 100644 --- a/examples/erc721-wrapper/tests/erc721_wrapper.rs +++ b/examples/erc721-wrapper/tests/erc721_wrapper.rs @@ -39,7 +39,7 @@ async fn constructs(alice: Account) -> Result<()> { .contract_address; let contract = Erc721Wrapper::new(contract_addr, alice.wallet); - let underlying = contract.underlying().call().await?.underlying; + let underlying = contract.underlying().call().await?; assert_eq!(underlying, asset_address); Ok(()) @@ -56,11 +56,11 @@ async fn deposit_for_success(alice: Account) -> Result<()> { watch!(asset.safeMint(alice_address, token_id))?; watch!(asset.approve(contract_addr, token_id))?; - let initial_alice_balance = asset.balanceOf(alice_address).call().await?._0; + let initial_alice_balance = asset.balanceOf(alice_address).call().await?; let initial_contract_balance = - asset.balanceOf(contract_addr).call().await?._0; + asset.balanceOf(contract_addr).call().await?; let initial_wrapped_balance = - contract.balanceOf(alice_address).call().await?.balance; + contract.balanceOf(alice_address).call().await?; let receipt = receipt!(contract.depositFor(alice_address, vec![token_id]))?; @@ -76,25 +76,25 @@ async fn deposit_for_success(alice: Account) -> Result<()> { tokenId: token_id, })); - let wrapped_owner = contract.ownerOf(token_id).call().await?.owner; + let wrapped_owner = contract.ownerOf(token_id).call().await?; assert_eq!(wrapped_owner, alice_address); - let underlying_owner = asset.ownerOf(token_id).call().await?._0; + let underlying_owner = asset.ownerOf(token_id).call().await?; assert_eq!(underlying_owner, contract_addr); let one = U256::ONE; assert_eq!( initial_alice_balance - one, - asset.balanceOf(alice_address).call().await?._0 + asset.balanceOf(alice_address).call().await? ); assert_eq!( initial_contract_balance + one, - asset.balanceOf(contract_addr).call().await?._0 + asset.balanceOf(contract_addr).call().await? ); assert_eq!( initial_wrapped_balance + one, - contract.balanceOf(alice_address).call().await?.balance + contract.balanceOf(alice_address).call().await? ); Ok(()) @@ -112,11 +112,11 @@ async fn withdraw_to_success(alice: Account) -> Result<()> { watch!(asset.approve(contract_addr, token_id))?; watch!(contract.depositFor(alice_address, vec![token_id]))?; - let initial_alice_balance = asset.balanceOf(alice_address).call().await?._0; + let initial_alice_balance = asset.balanceOf(alice_address).call().await?; let initial_contract_balance = - asset.balanceOf(contract_addr).call().await?._0; + asset.balanceOf(contract_addr).call().await?; let initial_wrapped_balance = - contract.balanceOf(alice_address).call().await?.balance; + contract.balanceOf(alice_address).call().await?; let receipt = receipt!(contract.withdrawTo(alice_address, vec![token_id]))?; @@ -142,22 +142,22 @@ async fn withdraw_to_success(alice: Account) -> Result<()> { tokenId: token_id })); - let underlying_owner = asset.ownerOf(token_id).call().await?._0; + let underlying_owner = asset.ownerOf(token_id).call().await?; assert_eq!(underlying_owner, alice_address); let one = U256::ONE; assert_eq!( initial_alice_balance + one, - asset.balanceOf(alice_address).call().await?._0 + asset.balanceOf(alice_address).call().await? ); assert_eq!( initial_contract_balance - one, - asset.balanceOf(contract_addr).call().await?._0 + asset.balanceOf(contract_addr).call().await? ); assert_eq!( initial_wrapped_balance - one, - contract.balanceOf(alice_address).call().await?.balance + contract.balanceOf(alice_address).call().await? ); Ok(()) diff --git a/examples/erc721/Cargo.toml b/examples/erc721/Cargo.toml index 1d5636ee0..07690bdf0 100644 --- a/examples/erc721/Cargo.toml +++ b/examples/erc721/Cargo.toml @@ -17,10 +17,12 @@ e2e.workspace = true tokio.workspace = true eyre.workspace = true rand.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/erc721/tests/erc721.rs b/examples/erc721/tests/erc721.rs index 720825a63..c43490e11 100644 --- a/examples/erc721/tests/erc721.rs +++ b/examples/erc721/tests/erc721.rs @@ -57,8 +57,7 @@ async fn balance_of_zero_balance(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.contract_address; let contract = Erc721::new(contract_addr, &alice.wallet); - let Erc721::balanceOfReturn { balance } = - contract.balanceOf(alice.address()).call().await?; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(U256::ZERO, balance); Ok(()) @@ -100,12 +99,10 @@ async fn mints(alice: Account) -> eyre::Result<()> { tokenId: token_id })); - let Erc721::ownerOfReturn { ownerOf: owner_of } = - contract.ownerOf(token_id).call().await?; + let owner_of = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, owner_of); - let Erc721::balanceOfReturn { balance } = - contract.balanceOf(alice_addr).call().await?; + let balance = contract.balanceOf(alice_addr).call().await?; assert_eq!(U256::ONE, balance); Ok(()) @@ -157,11 +154,9 @@ async fn transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { let token_id = random_token_id(); watch!(contract.mint(alice_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let initial_alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_bob_balance } = - contract.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract.balanceOf(bob_addr).call().await?; let receipt = receipt!(contract.transferFrom(alice_addr, bob_addr, token_id))?; @@ -172,15 +167,12 @@ async fn transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(bob_addr, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: bob_balance } = - contract.balanceOf(bob_addr).call().await?; + let bob_balance = contract.balanceOf(bob_addr).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -205,11 +197,10 @@ async fn transfers_from_approved_token( watch!(contract_alice.mint(alice_addr, token_id))?; watch!(contract_alice.approve(bob_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let receipt = receipt!(contract_bob.transferFrom(alice_addr, bob_addr, token_id))?; @@ -220,15 +211,12 @@ async fn transfers_from_approved_token( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract_alice.ownerOf(token_id).call().await?; + let ownerOf = contract_alice.ownerOf(token_id).call().await?; assert_eq!(bob_addr, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -253,11 +241,10 @@ async fn transfers_from_approved_for_all( watch!(contract_alice.mint(alice_addr, token_id))?; watch!(contract_alice.setApprovalForAll(bob_addr, true))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let receipt = receipt!(contract_bob.transferFrom(alice_addr, bob_addr, token_id))?; @@ -268,15 +255,12 @@ async fn transfers_from_approved_for_all( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract_alice.ownerOf(token_id).call().await?; + let ownerOf = contract_alice.ownerOf(token_id).call().await?; assert_eq!(bob_addr, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -306,8 +290,7 @@ async fn error_when_transfer_to_invalid_receiver( receiver: invalid_receiver })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, ownerOf); Ok(()) @@ -339,8 +322,7 @@ async fn error_when_transfer_from_incorrect_owner( tokenId: token_id })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, ownerOf); Ok(()) @@ -368,8 +350,7 @@ async fn error_when_transfer_with_insufficient_approval( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, ownerOf); Ok(()) @@ -415,11 +396,9 @@ async fn safe_transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { let token_id = random_token_id(); watch!(contract.mint(alice_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let initial_alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_bob_balance } = - contract.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract.balanceOf(bob_addr).call().await?; let receipt = receipt!(contract.safeTransferFrom_0(alice_addr, bob_addr, token_id))?; @@ -430,15 +409,12 @@ async fn safe_transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(bob_addr, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: bob_balance } = - contract.balanceOf(bob_addr).call().await?; + let bob_balance = contract.balanceOf(bob_addr).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -463,10 +439,9 @@ async fn safe_transfers_to_receiver_contract( watch!(contract.mint(alice_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let initial_alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_receiver_balance } = + let initial_receiver_balance = contract.balanceOf(receiver_address).call().await?; let receipt = receipt!(contract.safeTransferFrom_0( @@ -488,15 +463,12 @@ async fn safe_transfers_to_receiver_contract( data: fixed_bytes!("").into(), })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(receiver_address, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: receiver_balance } = - contract.balanceOf(receiver_address).call().await?; + let receiver_balance = contract.balanceOf(receiver_address).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -521,11 +493,10 @@ async fn safe_transfers_from_approved_token( watch!(contract_alice.mint(alice_addr, token_id))?; watch!(contract_alice.approve(bob_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let receipt = receipt!( contract_bob.safeTransferFrom_0(alice_addr, bob_addr, token_id) @@ -537,15 +508,12 @@ async fn safe_transfers_from_approved_token( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract_alice.ownerOf(token_id).call().await?; + let ownerOf = contract_alice.ownerOf(token_id).call().await?; assert_eq!(bob_addr, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -570,11 +538,10 @@ async fn safe_transfers_from_approved_for_all( watch!(contract_alice.mint(alice_addr, token_id))?; watch!(contract_alice.setApprovalForAll(bob_addr, true))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let receipt = receipt!( contract_bob.safeTransferFrom_0(alice_addr, bob_addr, token_id) @@ -586,15 +553,12 @@ async fn safe_transfers_from_approved_for_all( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract_alice.ownerOf(token_id).call().await?; + let ownerOf = contract_alice.ownerOf(token_id).call().await?; assert_eq!(bob_addr, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -626,8 +590,7 @@ async fn error_when_safe_transfer_to_invalid_receiver( receiver: invalid_receiver })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, ownerOf); Ok(()) @@ -659,8 +622,7 @@ async fn error_when_safe_transfer_from_incorrect_owner( tokenId: token_id })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, ownerOf); Ok(()) @@ -690,8 +652,7 @@ async fn error_when_safe_transfer_with_insufficient_approval( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, ownerOf); Ok(()) @@ -741,11 +702,9 @@ async fn safe_transfers_from_with_data( let token_id = random_token_id(); watch!(contract.mint(alice_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let initial_alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_bob_balance } = - contract.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract.balanceOf(bob_addr).call().await?; let receipt = receipt!(contract.safeTransferFrom_1( alice_addr, @@ -760,15 +719,12 @@ async fn safe_transfers_from_with_data( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(bob_addr, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: bob_balance } = - contract.balanceOf(bob_addr).call().await?; + let bob_balance = contract.balanceOf(bob_addr).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -794,10 +750,9 @@ async fn safe_transfers_with_data_to_receiver_contract( watch!(contract.mint(alice_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let initial_alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_receiver_balance } = + let initial_receiver_balance = contract.balanceOf(receiver_address).call().await?; let receipt = receipt!(contract.safeTransferFrom_1( @@ -820,15 +775,12 @@ async fn safe_transfers_with_data_to_receiver_contract( data, })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(receiver_address, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract.balanceOf(alice_addr).call().await?; + let alice_balance = contract.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: receiver_balance } = - contract.balanceOf(receiver_address).call().await?; + let receiver_balance = contract.balanceOf(receiver_address).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -853,11 +805,10 @@ async fn safe_transfers_from_with_data_approved_token( watch!(contract_alice.mint(alice_addr, token_id))?; watch!(contract_alice.approve(bob_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let receipt = receipt!(contract_bob.safeTransferFrom_1( alice_addr, @@ -872,15 +823,12 @@ async fn safe_transfers_from_with_data_approved_token( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract_alice.ownerOf(token_id).call().await?; + let ownerOf = contract_alice.ownerOf(token_id).call().await?; assert_eq!(bob_addr, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -905,11 +853,10 @@ async fn safe_transfers_from_with_data_approved_for_all( watch!(contract_alice.mint(alice_addr, token_id))?; watch!(contract_alice.setApprovalForAll(bob_addr, true))?; - let Erc721::balanceOfReturn { balance: initial_alice_balance } = + let initial_alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: initial_bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let initial_bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let receipt = receipt!(contract_bob.safeTransferFrom_1( alice_addr, @@ -924,15 +871,12 @@ async fn safe_transfers_from_with_data_approved_for_all( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract_alice.ownerOf(token_id).call().await?; + let ownerOf = contract_alice.ownerOf(token_id).call().await?; assert_eq!(bob_addr, ownerOf); - let Erc721::balanceOfReturn { balance: alice_balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let alice_balance = contract_alice.balanceOf(alice_addr).call().await?; - let Erc721::balanceOfReturn { balance: bob_balance } = - contract_bob.balanceOf(bob_addr).call().await?; + let bob_balance = contract_bob.balanceOf(bob_addr).call().await?; let one = U256::ONE; assert_eq!(initial_alice_balance - one, alice_balance); @@ -965,8 +909,7 @@ async fn error_when_safe_transfer_with_data_to_invalid_receiver( receiver: invalid_receiver })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, ownerOf); Ok(()) @@ -1003,8 +946,7 @@ async fn error_when_safe_transfer_with_data_from_incorrect_owner( tokenId: token_id })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, ownerOf); Ok(()) @@ -1038,8 +980,7 @@ async fn error_when_safe_transfer_with_data_with_insufficient_approval( tokenId: token_id, })); - let Erc721::ownerOfReturn { ownerOf } = - contract.ownerOf(token_id).call().await?; + let ownerOf = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, ownerOf); Ok(()) @@ -1186,8 +1127,7 @@ async fn approves(alice: Account, bob: Account) -> eyre::Result<()> { watch!(contract.mint(alice_addr, token_id))?; - let Erc721::getApprovedReturn { approved } = - contract.getApproved(token_id).call().await?; + let approved = contract.getApproved(token_id).call().await?; assert_eq!(Address::ZERO, approved); let receipt = receipt!(contract.approve(bob_addr, token_id))?; @@ -1198,8 +1138,7 @@ async fn approves(alice: Account, bob: Account) -> eyre::Result<()> { tokenId: token_id, })); - let Erc721::getApprovedReturn { approved } = - contract.getApproved(token_id).call().await?; + let approved = contract.getApproved(token_id).call().await?; assert_eq!(bob_addr, approved); Ok(()) @@ -1248,8 +1187,7 @@ async fn error_when_approve_by_invalid_approver( err.reverted_with(Erc721::ERC721InvalidApprover { approver: bob_addr }) ); - let Erc721::getApprovedReturn { approved } = - contract_bob.getApproved(token_id).call().await?; + let approved = contract_bob.getApproved(token_id).call().await?; assert_eq!(Address::ZERO, approved); Ok(()) @@ -1297,7 +1235,7 @@ async fn sets_approval_for_all( approved: approved_value, })); - let Erc721::isApprovedForAllReturn { approved } = + let approved = contract.isApprovedForAll(alice_addr, bob_addr).call().await?; assert_eq!(approved_value, approved); @@ -1311,7 +1249,7 @@ async fn sets_approval_for_all( approved: approved_value, })); - let Erc721::isApprovedForAllReturn { approved } = + let approved = contract.isApprovedForAll(alice_addr, bob_addr).call().await?; assert_eq!(approved_value, approved); @@ -1346,7 +1284,7 @@ async fn is_approved_for_all_invalid_operator( let invalid_operator = Address::ZERO; - let Erc721::isApprovedForAllReturn { approved } = contract + let approved = contract .isApprovedForAll(alice.address(), invalid_operator) .call() .await?; @@ -1365,8 +1303,7 @@ async fn safe_mint_to_eoa_without_data(alice: Account) -> eyre::Result<()> { let token_id = random_token_id(); let data = Bytes::new(); - let initial_balance = - contract.balanceOf(alice.address()).call().await?.balance; + let initial_balance = contract.balanceOf(alice.address()).call().await?; let receipt = receipt!(contract.safeMint(alice_addr, token_id, data))?; assert!(receipt.emits(Erc721::Transfer { @@ -1375,10 +1312,10 @@ async fn safe_mint_to_eoa_without_data(alice: Account) -> eyre::Result<()> { tokenId: token_id, })); - let owner_of = contract.ownerOf(token_id).call().await?.ownerOf; + let owner_of = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, owner_of); - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, initial_balance + U256::ONE); Ok(()) @@ -1393,8 +1330,7 @@ async fn safe_mint_to_eoa_with_data(alice: Account) -> eyre::Result<()> { let token_id = random_token_id(); let data: Bytes = fixed_bytes!("deadbeef").into(); - let initial_balance = - contract.balanceOf(alice.address()).call().await?.balance; + let initial_balance = contract.balanceOf(alice.address()).call().await?; let receipt = receipt!(contract.safeMint(alice_addr, token_id, data))?; assert!(receipt.emits(Erc721::Transfer { @@ -1403,10 +1339,10 @@ async fn safe_mint_to_eoa_with_data(alice: Account) -> eyre::Result<()> { tokenId: token_id, })); - let owner_of = contract.ownerOf(token_id).call().await?.ownerOf; + let owner_of = contract.ownerOf(token_id).call().await?; assert_eq!(alice_addr, owner_of); - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, initial_balance + U256::ONE); Ok(()) @@ -1425,8 +1361,7 @@ async fn safe_mint_to_receiver_contract_without_data( let token_id = random_token_id(); let data = Bytes::new(); - let initial_balance = - contract.balanceOf(alice.address()).call().await?.balance; + let initial_balance = contract.balanceOf(alice.address()).call().await?; let receipt = receipt!(contract.safeMint(receiver_address, token_id, data.clone()))?; @@ -1444,10 +1379,10 @@ async fn safe_mint_to_receiver_contract_without_data( data, })); - let owner_of = contract.ownerOf(token_id).call().await?.ownerOf; + let owner_of = contract.ownerOf(token_id).call().await?; assert_eq!(receiver_address, owner_of); - let balance = contract.balanceOf(receiver_address).call().await?.balance; + let balance = contract.balanceOf(receiver_address).call().await?; assert_eq!(balance, initial_balance + U256::ONE); Ok(()) @@ -1466,8 +1401,7 @@ async fn safe_mint_to_receiver_contract_with_data( let token_id = random_token_id(); let data: Bytes = fixed_bytes!("deadbeef").into(); - let initial_balance = - contract.balanceOf(alice.address()).call().await?.balance; + let initial_balance = contract.balanceOf(alice.address()).call().await?; let receipt = receipt!(contract.safeMint(receiver_address, token_id, data.clone()))?; @@ -1485,10 +1419,10 @@ async fn safe_mint_to_receiver_contract_with_data( data, })); - let owner_of = contract.ownerOf(token_id).call().await?.ownerOf; + let owner_of = contract.ownerOf(token_id).call().await?; assert_eq!(receiver_address, owner_of); - let balance = contract.balanceOf(receiver_address).call().await?.balance; + let balance = contract.balanceOf(receiver_address).call().await?; assert_eq!(balance, initial_balance + U256::ONE); Ok(()) @@ -1630,8 +1564,7 @@ async fn burns(alice: Account) -> eyre::Result<()> { let token_id = random_token_id(); watch!(contract.mint(alice_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_balance } = - contract.balanceOf(alice_addr).call().await?; + let initial_balance = contract.balanceOf(alice_addr).call().await?; let receipt = receipt!(contract.burn(token_id))?; @@ -1641,8 +1574,7 @@ async fn burns(alice: Account) -> eyre::Result<()> { tokenId: token_id, })); - let Erc721::balanceOfReturn { balance } = - contract.balanceOf(alice_addr).call().await?; + let balance = contract.balanceOf(alice_addr).call().await?; assert_eq!(initial_balance - U256::ONE, balance); @@ -1675,8 +1607,7 @@ async fn burns_approved_token( watch!(contract_alice.mint(alice_addr, token_id))?; watch!(contract_alice.approve(bob_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let initial_balance = contract_alice.balanceOf(alice_addr).call().await?; let receipt = receipt!(contract_bob.burn(token_id))?; @@ -1686,8 +1617,7 @@ async fn burns_approved_token( tokenId: token_id, })); - let Erc721::balanceOfReturn { balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let balance = contract_alice.balanceOf(alice_addr).call().await?; assert_eq!(initial_balance - U256::ONE, balance); @@ -1720,8 +1650,7 @@ async fn burns_approved_for_all( watch!(contract_alice.mint(alice_addr, token_id))?; watch!(contract_alice.setApprovalForAll(bob_addr, true))?; - let Erc721::balanceOfReturn { balance: initial_balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let initial_balance = contract_alice.balanceOf(alice_addr).call().await?; let receipt = receipt!(contract_bob.burn(token_id))?; @@ -1731,8 +1660,7 @@ async fn burns_approved_for_all( tokenId: token_id, })); - let Erc721::balanceOfReturn { balance } = - contract_alice.balanceOf(alice_addr).call().await?; + let balance = contract_alice.balanceOf(alice_addr).call().await?; assert_eq!(initial_balance - U256::ONE, balance); @@ -1762,8 +1690,7 @@ async fn error_when_burn_with_insufficient_approval( let token_id = random_token_id(); watch!(contract.mint(alice_addr, token_id))?; - let Erc721::balanceOfReturn { balance: initial_balance } = - contract.balanceOf(alice_addr).call().await?; + let initial_balance = contract.balanceOf(alice_addr).call().await?; let contract = Erc721::new(contract_addr, &bob.wallet); let err = send!(contract.burn(token_id)) @@ -1774,8 +1701,7 @@ async fn error_when_burn_with_insufficient_approval( tokenId: token_id, })); - let Erc721::balanceOfReturn { balance } = - contract.balanceOf(alice_addr).call().await?; + let balance = contract.balanceOf(alice_addr).call().await?; assert_eq!(initial_balance, balance); @@ -1814,8 +1740,7 @@ async fn totally_supply_works(alice: Account) -> eyre::Result<()> { let token_2 = random_token_id(); watch!(contract.mint(alice_addr, token_2))?; - let Erc721::totalSupplyReturn { totalSupply } = - contract.totalSupply().call().await?; + let totalSupply = contract.totalSupply().call().await?; assert_eq!(uint!(2_U256), totalSupply); @@ -1888,11 +1813,11 @@ async fn token_of_owner_by_index_works(alice: Account) -> eyre::Result<()> { let token_1 = random_token_id(); watch!(contract.mint(alice_addr, token_1))?; - let Erc721::tokenOfOwnerByIndexReturn { tokenId } = + let tokenId = contract.tokenOfOwnerByIndex(alice_addr, U256::ZERO).call().await?; assert_eq!(token_0, tokenId); - let Erc721::tokenOfOwnerByIndexReturn { tokenId } = + let tokenId = contract.tokenOfOwnerByIndex(alice_addr, U256::ONE).call().await?; assert_eq!(token_1, tokenId); @@ -1921,8 +1846,7 @@ async fn token_of_owner_by_index_after_transfer_to_another_account( // should be in reverse order let index = U256::ZERO; - let Erc721::tokenOfOwnerByIndexReturn { tokenId } = - contract.tokenOfOwnerByIndex(bob_addr, index).call().await?; + let tokenId = contract.tokenOfOwnerByIndex(bob_addr, index).call().await?; assert_eq!(token_1, tokenId); let err = contract .tokenOfOwnerByIndex(alice_addr, index) @@ -1935,8 +1859,7 @@ async fn token_of_owner_by_index_after_transfer_to_another_account( })); let index = U256::ONE; - let Erc721::tokenOfOwnerByIndexReturn { tokenId } = - contract.tokenOfOwnerByIndex(bob_addr, index).call().await?; + let tokenId = contract.tokenOfOwnerByIndex(bob_addr, index).call().await?; assert_eq!(token_0, tokenId); let err = contract .tokenOfOwnerByIndex(alice_addr, index) @@ -1948,8 +1871,7 @@ async fn token_of_owner_by_index_after_transfer_to_another_account( index })); - let Erc721::totalSupplyReturn { totalSupply } = - contract.totalSupply().call().await?; + let totalSupply = contract.totalSupply().call().await?; assert_eq!(uint!(2_U256), totalSupply); @@ -2020,12 +1942,10 @@ async fn token_by_index_works(alice: Account) -> eyre::Result<()> { let token_1 = random_token_id(); watch!(contract.mint(alice_addr, token_1))?; - let Erc721::tokenByIndexReturn { tokenId } = - contract.tokenByIndex(U256::ZERO).call().await?; + let tokenId = contract.tokenByIndex(U256::ZERO).call().await?; assert_eq!(token_0, tokenId); - let Erc721::tokenByIndexReturn { tokenId } = - contract.tokenByIndex(U256::ONE).call().await?; + let tokenId = contract.tokenByIndex(U256::ONE).call().await?; assert_eq!(token_1, tokenId); Ok(()) @@ -2046,8 +1966,7 @@ async fn token_by_index_after_burn(alice: Account) -> eyre::Result<()> { watch!(contract.burn(token_1))?; - let Erc721::tokenByIndexReturn { tokenId } = - contract.tokenByIndex(U256::ZERO).call().await?; + let tokenId = contract.tokenByIndex(U256::ZERO).call().await?; assert_eq!(token_0, tokenId); let index_of_burnt_token = U256::ONE; @@ -2062,8 +1981,7 @@ async fn token_by_index_after_burn(alice: Account) -> eyre::Result<()> { index: index_of_burnt_token })); - let Erc721::totalSupplyReturn { totalSupply } = - contract.totalSupply().call().await?; + let totalSupply = contract.totalSupply().call().await?; assert_eq!(U256::ONE, totalSupply); @@ -2093,16 +2011,13 @@ async fn token_by_index_after_burn_and_some_mints( let token_3 = random_token_id(); watch!(contract.mint(alice_addr, token_3))?; - let Erc721::tokenByIndexReturn { tokenId } = - contract.tokenByIndex(U256::ZERO).call().await?; + let tokenId = contract.tokenByIndex(U256::ZERO).call().await?; assert_eq!(token_0, tokenId); - let Erc721::tokenByIndexReturn { tokenId } = - contract.tokenByIndex(U256::ONE).call().await?; + let tokenId = contract.tokenByIndex(U256::ONE).call().await?; assert_eq!(token_2, tokenId); - let Erc721::tokenByIndexReturn { tokenId } = - contract.tokenByIndex(uint!(2_U256)).call().await?; + let tokenId = contract.tokenByIndex(uint!(2_U256)).call().await?; assert_eq!(token_3, tokenId); Ok(()) @@ -2117,30 +2032,25 @@ async fn supports_interface(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.contract_address; let contract = Erc721::new(contract_addr, &alice.wallet); let invalid_interface_id: B32 = 0xffffffff_u32.into(); - let Erc721::supportsInterfaceReturn { - supportsInterface: supports_interface, - } = contract.supportsInterface(invalid_interface_id).call().await?; + let supports_interface = + contract.supportsInterface(invalid_interface_id).call().await?; assert!(!supports_interface); let erc721_interface_id: B32 = 0x80ac58cd_u32.into(); - let Erc721::supportsInterfaceReturn { - supportsInterface: supports_interface, - } = contract.supportsInterface(erc721_interface_id).call().await?; + let supports_interface = + contract.supportsInterface(erc721_interface_id).call().await?; assert!(supports_interface); let erc165_interface_id: B32 = 0x01ffc9a7_u32.into(); - let Erc721::supportsInterfaceReturn { - supportsInterface: supports_interface, - } = contract.supportsInterface(erc165_interface_id).call().await?; + let supports_interface = + contract.supportsInterface(erc165_interface_id).call().await?; assert!(supports_interface); let erc721_enumerable_interface_id: B32 = 0x780e9d63_u32.into(); - let Erc721::supportsInterfaceReturn { - supportsInterface: supports_interface, - } = contract + let supports_interface = contract .supportsInterface(erc721_enumerable_interface_id) .call() .await?; diff --git a/examples/merkle-proofs/Cargo.toml b/examples/merkle-proofs/Cargo.toml index bc53ad990..d5d2c1905 100644 --- a/examples/merkle-proofs/Cargo.toml +++ b/examples/merkle-proofs/Cargo.toml @@ -15,6 +15,7 @@ stylus-sdk.workspace = true [features] e2e = [] export-abi = ["stylus-sdk/export-abi"] +contract-client-gen = [] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/ownable-two-step/Cargo.toml b/examples/ownable-two-step/Cargo.toml index 29ef3fe7f..39509b662 100644 --- a/examples/ownable-two-step/Cargo.toml +++ b/examples/ownable-two-step/Cargo.toml @@ -16,6 +16,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -23,6 +24,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "ownable-two-step-example" diff --git a/examples/ownable-two-step/tests/ownable_two_step.rs b/examples/ownable-two-step/tests/ownable_two_step.rs index 8b53bc653..774896326 100644 --- a/examples/ownable-two-step/tests/ownable_two_step.rs +++ b/examples/ownable-two-step/tests/ownable_two_step.rs @@ -33,11 +33,10 @@ async fn constructs(alice: Account) -> Result<()> { newOwner: alice_addr, })); - let Ownable2Step::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, alice_addr); - let Ownable2Step::pendingOwnerReturn { pendingOwner } = - contract.pendingOwner().call().await?; + let pendingOwner = contract.pendingOwner().call().await?; assert_eq!(pendingOwner, Address::ZERO); Ok(()) @@ -88,12 +87,11 @@ async fn transfer_ownership_initiates_transfer( })); // Current owner is still Alice - let Ownable2Step::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, alice_addr); // Pending owner is Bob - let Ownable2Step::pendingOwnerReturn { pendingOwner } = - contract.pendingOwner().call().await?; + let pendingOwner = contract.pendingOwner().call().await?; assert_eq!(pendingOwner, bob_addr); Ok(()) @@ -146,11 +144,10 @@ async fn accept_ownership(alice: Account, bob: Account) -> Result<()> { newOwner: bob_addr, })); - let Ownable2Step::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, bob_addr); - let Ownable2Step::pendingOwnerReturn { pendingOwner } = - contract.pendingOwner().call().await?; + let pendingOwner = contract.pendingOwner().call().await?; assert_eq!(pendingOwner, Address::ZERO); Ok(()) @@ -179,8 +176,7 @@ async fn transfer_ownership_cancel_transfer( newOwner: Address::ZERO, })); - let Ownable2Step::pendingOwnerReturn { pendingOwner } = - contract.pendingOwner().call().await?; + let pendingOwner = contract.pendingOwner().call().await?; assert_eq!(pendingOwner, Address::ZERO); Ok(()) @@ -217,8 +213,7 @@ async fn overwrite_previous_transfer_ownership( newOwner: charlie_addr, })); - let Ownable2Step::pendingOwnerReturn { pendingOwner } = - contract.pendingOwner().call().await?; + let pendingOwner = contract.pendingOwner().call().await?; assert_eq!(pendingOwner, charlie_addr); // Connect as Bob and try to accept ownership @@ -238,11 +233,10 @@ async fn overwrite_previous_transfer_ownership( newOwner: charlie_addr, })); - let Ownable2Step::pendingOwnerReturn { pendingOwner } = - contract.pendingOwner().call().await?; + let pendingOwner = contract.pendingOwner().call().await?; assert_eq!(pendingOwner, Address::ZERO); - let Ownable2Step::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, charlie_addr); Ok(()) @@ -294,12 +288,11 @@ async fn renounce_ownership(alice: Account) -> Result<()> { newOwner: Address::ZERO, })); - let Ownable2Step::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, Address::ZERO); // Pending owner is set to zero - let Ownable2Step::pendingOwnerReturn { pendingOwner } = - contract.pendingOwner().call().await?; + let pendingOwner = contract.pendingOwner().call().await?; assert_eq!(pendingOwner, Address::ZERO); Ok(()) @@ -327,7 +320,7 @@ async fn renounce_ownership_reverts_when_not_owner( account: bob_addr, }); - let Ownable2Step::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, alice_addr); Ok(()) diff --git a/examples/ownable/Cargo.toml b/examples/ownable/Cargo.toml index f932f8138..cebd221d2 100644 --- a/examples/ownable/Cargo.toml +++ b/examples/ownable/Cargo.toml @@ -16,6 +16,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -23,6 +24,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "ownable-example" diff --git a/examples/ownable/tests/ownable.rs b/examples/ownable/tests/ownable.rs index f86f611fc..9486abfef 100644 --- a/examples/ownable/tests/ownable.rs +++ b/examples/ownable/tests/ownable.rs @@ -30,7 +30,7 @@ async fn constructs(alice: Account) -> Result<()> { newOwner: alice_addr, })); - let Ownable::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, alice_addr); Ok(()) } @@ -73,7 +73,7 @@ async fn transfers_ownership(alice: Account, bob: Account) -> Result<()> { newOwner: bob_addr, })); - let Ownable::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, bob_addr); Ok(()) @@ -119,7 +119,7 @@ async fn guards_against_stuck_state(alice: Account) -> Result<()> { .expect_err("should not transfer to Address::ZERO"); err.reverted_with(Ownable::OwnableInvalidOwner { owner: Address::ZERO }); - let Ownable::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, alice_addr); Ok(()) @@ -142,7 +142,7 @@ async fn loses_ownership_after_renouncement(alice: Account) -> Result<()> { newOwner: Address::ZERO, })); - let Ownable::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, Address::ZERO); Ok(()) @@ -170,7 +170,7 @@ async fn prevents_non_owners_from_renouncement( account: bob_addr, }); - let Ownable::ownerReturn { owner } = contract.owner().call().await?; + let owner = contract.owner().call().await?; assert_eq!(owner, alice_addr); Ok(()) diff --git a/examples/pedersen/Cargo.toml b/examples/pedersen/Cargo.toml index ab2027d1c..dd75b43c5 100644 --- a/examples/pedersen/Cargo.toml +++ b/examples/pedersen/Cargo.toml @@ -16,6 +16,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -23,6 +24,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["stylus-sdk/export-abi"] +contract-client-gen = [] [[bin]] name = "pedersen-example" diff --git a/examples/pedersen/tests/pedersen.rs b/examples/pedersen/tests/pedersen.rs index 120ac9113..113ea77cb 100644 --- a/examples/pedersen/tests/pedersen.rs +++ b/examples/pedersen/tests/pedersen.rs @@ -31,8 +31,7 @@ async fn pedersen_works(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.contract_address; let contract = PedersenExample::new(contract_addr, &alice.wallet); - let PedersenExample::hashReturn { hash } = - contract.hash([input_1, input_2]).call().await?; + let hash = contract.hash([input_1, input_2]).call().await?; assert_eq!(hash, expected); diff --git a/examples/poseidon/Cargo.toml b/examples/poseidon/Cargo.toml index 27f4ec7c1..7af115661 100644 --- a/examples/poseidon/Cargo.toml +++ b/examples/poseidon/Cargo.toml @@ -16,6 +16,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -23,6 +24,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["stylus-sdk/export-abi"] +contract-client-gen = [] [[bin]] name = "poseidon-example" diff --git a/examples/poseidon/tests/poseidon.rs b/examples/poseidon/tests/poseidon.rs index f948c6ed2..248355a8d 100644 --- a/examples/poseidon/tests/poseidon.rs +++ b/examples/poseidon/tests/poseidon.rs @@ -17,7 +17,7 @@ async fn poseidon_works(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.contract_address; let contract = PoseidonExample::new(contract_addr, &alice.wallet); - let PoseidonExample::hashReturn { hash } = + let hash = contract.hash([uint!(123_U256), uint!(123456_U256)]).call().await?; let expected = U256::from_be_slice(&hex!( diff --git a/examples/precompiles/Cargo.toml b/examples/precompiles/Cargo.toml index 51fcb7257..10f996339 100644 --- a/examples/precompiles/Cargo.toml +++ b/examples/precompiles/Cargo.toml @@ -16,6 +16,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -23,6 +24,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "precompiles-example" diff --git a/examples/precompiles/tests/precompiles.rs b/examples/precompiles/tests/precompiles.rs index ca036edd5..9feb9cd60 100644 --- a/examples/precompiles/tests/precompiles.rs +++ b/examples/precompiles/tests/precompiles.rs @@ -31,8 +31,7 @@ async fn ecrecover_works(alice: Account) -> Result<()> { let recovered = contract .ecRecoverExample(ECDSA_HASH, ECDSA_V, ECDSA_R, ECDSA_S) .call() - .await? - .recovered; + .await?; assert_eq!(ADDRESS, recovered); @@ -52,8 +51,7 @@ async fn different_hash_recovers_different_address( let recovered = contract .ecRecoverExample(hash, ECDSA_V, ECDSA_R, ECDSA_S) .call() - .await? - .recovered; + .await?; assert_ne!(ADDRESS, recovered); @@ -70,8 +68,7 @@ async fn different_v_recovers_different_address(alice: Account) -> Result<()> { let recovered = contract .ecRecoverExample(ECDSA_HASH, v, ECDSA_R, ECDSA_S) .call() - .await? - .recovered; + .await?; assert_ne!(ADDRESS, recovered); @@ -90,8 +87,7 @@ async fn different_r_recovers_different_address(alice: Account) -> Result<()> { let recovered = contract .ecRecoverExample(ECDSA_HASH, ECDSA_V, r, ECDSA_S) .call() - .await? - .recovered; + .await?; assert_ne!(ADDRESS, recovered); @@ -109,8 +105,7 @@ async fn different_s_recovers_different_address(alice: Account) -> Result<()> { let recovered = contract .ecRecoverExample(ECDSA_HASH, ECDSA_V, ECDSA_R, s) .call() - .await? - .recovered; + .await?; assert_ne!(ADDRESS, recovered); @@ -136,8 +131,7 @@ async fn recovers_from_v_r_s(alice: Account) -> Result<()> { signature.s().into(), ) .call() - .await? - .recovered; + .await?; assert_eq!(alice.address(), recovered); @@ -224,8 +218,7 @@ async fn p256_verify_returns_true_on_successful_verification( "c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e" ); - let result = - contract.p256VerifyExample(hash, r, s, x, y).call().await?.result; + let result = contract.p256VerifyExample(hash, r, s, x, y).call().await?; assert!(result); @@ -259,8 +252,7 @@ async fn p256_verify_returns_false_on_failed_verification( let result = contract .p256VerifyExample(hash, invalid_r, invalid_s, x, y) .call() - .await? - .result; + .await?; assert!(!result); diff --git a/examples/proxy/Cargo.toml b/examples/proxy/Cargo.toml index e3fa2e18b..d55bff4ac 100644 --- a/examples/proxy/Cargo.toml +++ b/examples/proxy/Cargo.toml @@ -17,6 +17,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -24,6 +25,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "proxy-example" diff --git a/examples/proxy/tests/proxy.rs b/examples/proxy/tests/proxy.rs index 11b14818f..9fec5567a 100644 --- a/examples/proxy/tests/proxy.rs +++ b/examples/proxy/tests/proxy.rs @@ -26,7 +26,7 @@ async fn constructs(alice: Account) -> Result<()> { .contract_address; let contract = ProxyExample::new(contract_addr, &alice.wallet); - let implementation = contract.implementation().call().await?.implementation; + let implementation = contract.implementation().call().await?; assert_eq!(implementation, implementation_addr); Ok(()) @@ -44,10 +44,10 @@ async fn fallback(alice: Account, bob: Account) -> Result<()> { let contract = ProxyExample::new(contract_addr, &alice.wallet); // verify initial balance is [`U256::ZERO`]. - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, U256::ZERO); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, U256::ZERO); // mint 1000 tokens. @@ -55,10 +55,10 @@ async fn fallback(alice: Account, bob: Account) -> Result<()> { watch!(contract.mint(alice.address(), amount))?; // check that the balance can be accurately fetched through the proxy. - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, amount); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, amount); // check that the balance can be transferred through the proxy. @@ -70,13 +70,13 @@ async fn fallback(alice: Account, bob: Account) -> Result<()> { value: amount, })); - let balance = contract.balanceOf(alice.address()).call().await?.balance; + let balance = contract.balanceOf(alice.address()).call().await?; assert_eq!(balance, U256::ZERO); - let balance = contract.balanceOf(bob.address()).call().await?.balance; + let balance = contract.balanceOf(bob.address()).call().await?; assert_eq!(balance, amount); - let total_supply = contract.totalSupply().call().await?.totalSupply; + let total_supply = contract.totalSupply().call().await?; assert_eq!(total_supply, amount); Ok(()) diff --git a/examples/safe-erc20/Cargo.toml b/examples/safe-erc20/Cargo.toml index eba21f4c6..2461cebcc 100644 --- a/examples/safe-erc20/Cargo.toml +++ b/examples/safe-erc20/Cargo.toml @@ -17,10 +17,12 @@ alloy.workspace = true eyre.workspace = true tokio.workspace = true e2e.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/safe-erc20/src/lib.rs b/examples/safe-erc20/src/lib.rs index 46490ab95..f0f1f798b 100644 --- a/examples/safe-erc20/src/lib.rs +++ b/examples/safe-erc20/src/lib.rs @@ -8,7 +8,6 @@ use openzeppelin_stylus::token::erc20::utils::safe_erc20::{ use stylus_sdk::{ abi::Bytes, alloy_primitives::{Address, U256}, - evm, prelude::*, }; @@ -65,10 +64,10 @@ impl ISafeErc20 for SafeErc20Example { // log the result so we can assert it in tests. if result { #[allow(deprecated)] - evm::log(True {}); + self.vm().log(True {}); } else { #[allow(deprecated)] - evm::log(False {}); + self.vm().log(False {}); } result } @@ -86,10 +85,10 @@ impl ISafeErc20 for SafeErc20Example { // log the result so we can assert it in tests. if result { #[allow(deprecated)] - evm::log(True {}); + self.vm().log(True {}); } else { #[allow(deprecated)] - evm::log(False {}); + self.vm().log(False {}); } result } diff --git a/examples/safe-erc20/tests/safe_erc20_erc1363.rs b/examples/safe-erc20/tests/safe_erc20_erc1363.rs index 9516a5520..b9b0732d6 100644 --- a/examples/safe-erc20/tests/safe_erc20_erc1363.rs +++ b/examples/safe-erc20/tests/safe_erc20_erc1363.rs @@ -33,9 +33,9 @@ mod transfers { watch!(erc20_alice.mint(safe_erc20_addr, balance))?; let initial_safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -52,8 +52,8 @@ mod transfers { })); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance - value, safe_erc20_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -77,9 +77,9 @@ mod transfers { let erc20_alice = ERC1363Mock::new(erc20_address, &alice.wallet); let initial_safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; let err = send!(safe_erc20_alice.safeTransfer( erc20_address, @@ -93,8 +93,8 @@ mod transfers { })); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance, safe_erc20_balance); assert_eq!(initial_bob_balance, bob_balance); @@ -123,9 +123,9 @@ mod transfers { watch!(erc20_alice.approve(safe_erc20_addr, value))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_addr).call().await?._0; + erc20_alice.balanceOf(alice_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -142,8 +142,8 @@ mod transfers { value })); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -170,9 +170,9 @@ mod transfers { watch!(erc20_alice.mint(safe_erc20_addr, balance))?; let initial_safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -191,8 +191,8 @@ mod transfers { })); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance - value, safe_erc20_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -219,9 +219,9 @@ mod transfers { watch!(erc20_alice.approve(safe_erc20_addr, value))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_addr).call().await?._0; + erc20_alice.balanceOf(alice_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; let err = send!(safe_erc20_alice.safeTransferFrom( erc20_address, @@ -235,8 +235,8 @@ mod transfers { token: erc20_address })); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); assert_eq!(initial_bob_balance, bob_balance); @@ -265,9 +265,9 @@ mod transfers { watch!(erc20_alice.approve(safe_erc20_addr, value))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_addr).call().await?._0; + erc20_alice.balanceOf(alice_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -286,8 +286,8 @@ mod transfers { value })); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -336,8 +336,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, value); Ok(()) @@ -377,8 +376,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, U256::ZERO); Ok(()) @@ -420,8 +418,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, value); Ok(()) @@ -540,8 +537,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, value); Ok(()) @@ -583,8 +579,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, U256::ZERO); Ok(()) @@ -628,8 +623,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, allowance + value); Ok(()) @@ -673,8 +667,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, allowance - value); Ok(()) @@ -759,8 +752,8 @@ mod transfer_and_call { // Verify balances let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(safe_erc20_balance, U256::ZERO); assert_eq!(bob_balance, value); @@ -811,9 +804,9 @@ mod transfer_and_call { // Verify balances let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let receiver_balance = - erc20_alice.balanceOf(receiver_address).call().await?._0; + erc20_alice.balanceOf(receiver_address).call().await?; assert_eq!(safe_erc20_balance, U256::ZERO); assert_eq!(receiver_balance, value); @@ -861,8 +854,8 @@ mod transfer_from_and_call { })); // Verify balances - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(alice_balance, U256::ZERO); assert_eq!(bob_balance, value); @@ -915,9 +908,9 @@ mod transfer_from_and_call { })); // Verify balances - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; let receiver_balance = - erc20_alice.balanceOf(receiver_address).call().await?._0; + erc20_alice.balanceOf(receiver_address).call().await?; assert_eq!(alice_balance, U256::ZERO); assert_eq!(receiver_balance, value); @@ -962,8 +955,7 @@ mod approve_and_call { let allowance = erc20_alice .allowance(safe_erc20_addr, erc1363_spender) .call() - .await? - ._0; + .await?; assert_eq!(allowance, value); Ok(()) @@ -1010,8 +1002,7 @@ mod approve_and_call { let allowance = erc20_alice .allowance(safe_erc20_addr, spender_address) .call() - .await? - ._0; + .await?; assert_eq!(allowance, value); Ok(()) diff --git a/examples/safe-erc20/tests/safe_erc20_erc1363_usdt_approval_behavior.rs b/examples/safe-erc20/tests/safe_erc20_erc1363_usdt_approval_behavior.rs index 14f2b686d..319290f84 100644 --- a/examples/safe-erc20/tests/safe_erc20_erc1363_usdt_approval_behavior.rs +++ b/examples/safe-erc20/tests/safe_erc20_erc1363_usdt_approval_behavior.rs @@ -40,11 +40,8 @@ mod without_initial_approval { DATA ))?; - let allowance = erc20_alice - .allowance(safe_erc20_addr, spender_addr) - .call() - .await? - ._0; + let allowance = + erc20_alice.allowance(safe_erc20_addr, spender_addr).call().await?; assert_eq!(allowance, value); Ok(()) @@ -78,8 +75,7 @@ mod without_initial_approval { let allowance = erc20_alice .allowance(safe_erc20_addr, spender_address) .call() - .await? - ._0; + .await?; assert_eq!(allowance, value); Ok(()) @@ -122,7 +118,7 @@ mod with_initial_approval { ))?; let allowance = - erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?._0; + erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?; assert_eq!(allowance, value); Ok(()) diff --git a/examples/safe-erc20/tests/safe_erc20_erc20.rs b/examples/safe-erc20/tests/safe_erc20_erc20.rs index 1d0508a60..3162644ed 100644 --- a/examples/safe-erc20/tests/safe_erc20_erc20.rs +++ b/examples/safe-erc20/tests/safe_erc20_erc20.rs @@ -31,9 +31,9 @@ mod transfers { watch!(erc20_alice.mint(safe_erc20_addr, balance))?; let initial_safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -50,8 +50,8 @@ mod transfers { })); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance - value, safe_erc20_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -75,9 +75,9 @@ mod transfers { let erc20_alice = ERC20Mock::new(erc20_address, &alice.wallet); let initial_safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; let err = send!(safe_erc20_alice.safeTransfer( erc20_address, @@ -91,8 +91,8 @@ mod transfers { })); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance, safe_erc20_balance); assert_eq!(initial_bob_balance, bob_balance); @@ -121,9 +121,9 @@ mod transfers { watch!(erc20_alice.approve(safe_erc20_addr, value))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_addr).call().await?._0; + erc20_alice.balanceOf(alice_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -140,8 +140,8 @@ mod transfers { value })); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -168,9 +168,9 @@ mod transfers { watch!(erc20_alice.mint(safe_erc20_addr, balance))?; let initial_safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -189,8 +189,8 @@ mod transfers { })); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance - value, safe_erc20_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -217,9 +217,9 @@ mod transfers { watch!(erc20_alice.approve(safe_erc20_addr, value))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_addr).call().await?._0; + erc20_alice.balanceOf(alice_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; let err = send!(safe_erc20_alice.safeTransferFrom( erc20_address, @@ -233,8 +233,8 @@ mod transfers { token: erc20_address })); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); assert_eq!(initial_bob_balance, bob_balance); @@ -263,9 +263,9 @@ mod transfers { watch!(erc20_alice.approve(safe_erc20_addr, value))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_addr).call().await?._0; + erc20_alice.balanceOf(alice_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -284,8 +284,8 @@ mod transfers { value })); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -334,8 +334,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, value); Ok(()) @@ -375,8 +374,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, U256::ZERO); Ok(()) @@ -418,8 +416,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, value); Ok(()) @@ -538,8 +535,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, value); Ok(()) @@ -581,8 +577,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, U256::ZERO); Ok(()) @@ -626,8 +621,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, allowance + value); Ok(()) @@ -671,8 +665,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, allowance - value); Ok(()) diff --git a/examples/safe-erc20/tests/safe_erc20_erc20_that_always_returns_false.rs b/examples/safe-erc20/tests/safe_erc20_erc20_that_always_returns_false.rs index d41e927ee..230b01a00 100644 --- a/examples/safe-erc20/tests/safe_erc20_erc20_that_always_returns_false.rs +++ b/examples/safe-erc20/tests/safe_erc20_erc20_that_always_returns_false.rs @@ -46,8 +46,8 @@ async fn returns_false_on_try_safe_transfer( watch!(erc20_alice.mint(safe_erc20_addr, balance))?; let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(safe_erc20_balance, balance); assert_eq!(bob_balance, U256::ZERO); @@ -61,8 +61,8 @@ async fn returns_false_on_try_safe_transfer( assert!(receipt.emits(SafeErc20::False {})); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(safe_erc20_balance, balance); assert_eq!(bob_balance, U256::ZERO); @@ -114,8 +114,8 @@ async fn returns_false_on_try_safe_transfer_from( watch!(erc20_alice.mint(alice_addr, balance))?; watch!(erc20_alice.approve(safe_erc20_addr, balance))?; - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(alice_balance, balance); assert_eq!(bob_balance, U256::ZERO); @@ -128,8 +128,8 @@ async fn returns_false_on_try_safe_transfer_from( assert!(receipt.emits(SafeErc20::False {})); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(alice_balance, balance); assert_eq!(bob_balance, U256::ZERO); diff --git a/examples/safe-erc20/tests/safe_erc20_erc20_that_does_not_return.rs b/examples/safe-erc20/tests/safe_erc20_erc20_that_does_not_return.rs index 4c8827f75..9a4558660 100644 --- a/examples/safe-erc20/tests/safe_erc20_erc20_that_does_not_return.rs +++ b/examples/safe-erc20/tests/safe_erc20_erc20_that_does_not_return.rs @@ -31,9 +31,9 @@ mod transfers { watch!(erc20_alice.mint(safe_erc20_addr, balance))?; let initial_safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -50,8 +50,8 @@ mod transfers { })); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance - value, safe_erc20_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -75,9 +75,9 @@ mod transfers { let erc20_alice = ERC20NoReturnMock::new(erc20_address, &alice.wallet); let initial_safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; let err = send!(safe_erc20_alice.safeTransfer( erc20_address, @@ -90,8 +90,8 @@ mod transfers { })); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance, safe_erc20_balance); assert_eq!(initial_bob_balance, bob_balance); @@ -118,9 +118,9 @@ mod transfers { watch!(erc20_alice.mint(safe_erc20_addr, balance))?; let initial_safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -139,8 +139,8 @@ mod transfers { })); let safe_erc20_balance = - erc20_alice.balanceOf(safe_erc20_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(safe_erc20_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_safe_erc20_balance - value, safe_erc20_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -169,9 +169,9 @@ mod transfers { watch!(erc20_alice.approve(safe_erc20_addr, value))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_addr).call().await?._0; + erc20_alice.balanceOf(alice_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -188,8 +188,8 @@ mod transfers { value, })); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -216,9 +216,9 @@ mod transfers { watch!(erc20_alice.approve(safe_erc20_addr, value))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_addr).call().await?._0; + erc20_alice.balanceOf(alice_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; let err = send!(safe_erc20_alice.safeTransferFrom( erc20_address, @@ -231,8 +231,8 @@ mod transfers { token: erc20_address })); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance, alice_balance); assert_eq!(initial_bob_balance, bob_balance); @@ -261,9 +261,9 @@ mod transfers { watch!(erc20_alice.approve(safe_erc20_addr, value))?; let initial_alice_balance = - erc20_alice.balanceOf(alice_addr).call().await?._0; + erc20_alice.balanceOf(alice_addr).call().await?; let initial_bob_balance = - erc20_alice.balanceOf(bob_addr).call().await?._0; + erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance, balance); assert_eq!(initial_bob_balance, U256::ZERO); @@ -282,8 +282,8 @@ mod transfers { value })); - let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?._0; - let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?._0; + let alice_balance = erc20_alice.balanceOf(alice_addr).call().await?; + let bob_balance = erc20_alice.balanceOf(bob_addr).call().await?; assert_eq!(initial_alice_balance - value, alice_balance); assert_eq!(initial_bob_balance + value, bob_balance); @@ -333,8 +333,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, value); Ok(()) @@ -375,8 +374,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, U256::ZERO); Ok(()) @@ -419,8 +417,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, value); Ok(()) @@ -542,8 +539,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, value); Ok(()) @@ -586,8 +582,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, U256::ZERO); Ok(()) @@ -632,8 +627,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, allowance + value); Ok(()) @@ -678,8 +672,7 @@ mod approvals { let spender_allowance = erc20_alice .allowance(safe_erc20_addr, spender_addr) .call() - .await? - ._0; + .await?; assert_eq!(spender_allowance, allowance - value); Ok(()) diff --git a/examples/safe-erc20/tests/safe_erc20_usdt_approval_behavior.rs b/examples/safe-erc20/tests/safe_erc20_usdt_approval_behavior.rs index e79d98aaa..95d065d52 100644 --- a/examples/safe-erc20/tests/safe_erc20_usdt_approval_behavior.rs +++ b/examples/safe-erc20/tests/safe_erc20_usdt_approval_behavior.rs @@ -26,7 +26,7 @@ async fn safe_increase_allowance_works( watch!(erc20_alice.forceApprove(safe_erc20_addr, bob_addr, init_approval))?; let initial_bob_allowance = - erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?._0; + erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?; assert_eq!(initial_bob_allowance, init_approval); let receipt = receipt!(safe_erc20_alice.safeIncreaseAllowance( @@ -42,7 +42,7 @@ async fn safe_increase_allowance_works( })); let bob_allowance = - erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?._0; + erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?; assert_eq!(bob_allowance, init_approval + value); Ok(()) @@ -66,7 +66,7 @@ async fn safe_decrease_allowance_works( watch!(erc20_alice.forceApprove(safe_erc20_addr, bob_addr, init_approval))?; let initial_bob_allowance = - erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?._0; + erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?; assert_eq!(initial_bob_allowance, init_approval); let receipt = receipt!(safe_erc20_alice.safeDecreaseAllowance( @@ -82,7 +82,7 @@ async fn safe_decrease_allowance_works( })); let bob_allowance = - erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?._0; + erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?; assert_eq!(bob_allowance, init_approval - value); Ok(()) @@ -103,7 +103,7 @@ async fn force_approve_works(alice: Account, bob: Account) -> eyre::Result<()> { watch!(erc20_alice.forceApprove(safe_erc20_addr, bob_addr, init_approval))?; let initial_bob_allowance = - erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?._0; + erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?; assert_eq!(initial_bob_allowance, init_approval); let receipt = receipt!(safe_erc20_alice.forceApprove( @@ -119,7 +119,7 @@ async fn force_approve_works(alice: Account, bob: Account) -> eyre::Result<()> { })); let bob_allowance = - erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?._0; + erc20_alice.allowance(safe_erc20_addr, bob_addr).call().await?; assert_eq!(bob_allowance, updated_approval); Ok(()) diff --git a/examples/upgradeable-beacon/Cargo.toml b/examples/upgradeable-beacon/Cargo.toml index fbd9cbd11..9ed82094a 100644 --- a/examples/upgradeable-beacon/Cargo.toml +++ b/examples/upgradeable-beacon/Cargo.toml @@ -17,6 +17,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -24,6 +25,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "upgradeable-beacon-example" diff --git a/examples/upgradeable-beacon/tests/upgradeable-beacon.rs b/examples/upgradeable-beacon/tests/upgradeable-beacon.rs index 1b09a93a5..c26a9f1c9 100644 --- a/examples/upgradeable-beacon/tests/upgradeable-beacon.rs +++ b/examples/upgradeable-beacon/tests/upgradeable-beacon.rs @@ -23,10 +23,10 @@ async fn upgrade_to(alice: Account, bob: Account) -> Result<()> { UpgradeableBeaconExample::new(receipt.contract_address, &bob.wallet); // check initial state. - let implementation = contract.implementation().call().await?.implementation; + let implementation = contract.implementation().call().await?; assert_eq!(implementation, implementation_addr); - let owner = contract.owner().call().await?.owner; + let owner = contract.owner().call().await?; assert_eq!(owner, alice.address()); assert!(receipt.emits(UpgradeableBeaconExample::Upgraded { @@ -56,7 +56,7 @@ async fn upgrade_to(alice: Account, bob: Account) -> Result<()> { implementation: new_implementation, })); - let implementation = contract.implementation().call().await?.implementation; + let implementation = contract.implementation().call().await?; assert_eq!(implementation, new_implementation); Ok(()) diff --git a/examples/uups-proxy-new-version/Cargo.toml b/examples/uups-proxy-new-version/Cargo.toml index 548594ba1..395952cf7 100644 --- a/examples/uups-proxy-new-version/Cargo.toml +++ b/examples/uups-proxy-new-version/Cargo.toml @@ -17,6 +17,7 @@ alloy.workspace = true e2e.workspace = true tokio.workspace = true eyre.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -24,6 +25,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "uups-proxy-new-version-example" diff --git a/examples/uups-proxy-new-version/src/lib.rs b/examples/uups-proxy-new-version/src/lib.rs index d177f5102..ceac9e91a 100644 --- a/examples/uups-proxy-new-version/src/lib.rs +++ b/examples/uups-proxy-new-version/src/lib.rs @@ -35,7 +35,6 @@ use openzeppelin_stylus::{ use stylus_sdk::{ abi::Bytes, alloy_primitives::{Address, B256, U256}, - call::Call, prelude::*, storage::{StorageBool, StorageU32}, }; @@ -109,6 +108,9 @@ struct UUPSProxyErc20ExampleNewVersion { erc20: Erc20, ownable: Ownable, version: StorageU32, + erc1967_utils: Erc1967Utils, + address_utils: AddressUtils, + storage_slot: StorageSlot, } #[public] @@ -170,15 +172,12 @@ impl IUUPSUpgradeable for UUPSProxyErc20ExampleNewVersion { self.ownable.only_owner()?; self.only_proxy()?; #[allow(clippy::used_underscore_items)] - self._upgrade_to_and_call_uups(new_implementation, &data)?; + self._upgrade_to_and_call_uups(new_implementation, data)?; let data_set_version = UUPSUpgradeableAbi::setVersionCall {}.abi_encode(); - AddressUtils::function_delegate_call( - self, - new_implementation, - &data_set_version, - )?; + self.address_utils + .function_delegate_call(new_implementation, &data_set_version)?; Ok(()) } @@ -186,7 +185,7 @@ impl IUUPSUpgradeable for UUPSProxyErc20ExampleNewVersion { impl UUPSProxyErc20ExampleNewVersion { pub fn logic_flag(&self) -> StorageBool { - StorageSlot::get_slot::(LOGIC_FLAG_SLOT) + self.storage_slot.get_slot::(LOGIC_FLAG_SLOT) } pub fn is_logic(&self) -> bool { @@ -195,7 +194,7 @@ impl UUPSProxyErc20ExampleNewVersion { pub fn only_proxy(&self) -> Result<(), Error> { if self.is_logic() - || Erc1967Utils::get_implementation().is_zero() + || self.erc1967_utils.get_implementation().is_zero() || U32::from(self.get_version()) != self.version.get() { Err(Error::UnauthorizedCallContext(UUPSUnauthorizedCallContext {})) @@ -226,11 +225,11 @@ impl UUPSProxyErc20ExampleNewVersion { fn _upgrade_to_and_call_uups( &mut self, new_implementation: Address, - data: &Bytes, + data: Bytes, ) -> Result<(), Error> { #[allow(deprecated)] let slot = Erc1822ProxiableInterface::new(new_implementation) - .proxiable_uuid(Call::new_in(self)) + .proxiable_uuid(self.vm(), Call::new()) .map_err(|_e| { Error::InvalidImplementation(ERC1967InvalidImplementation { implementation: new_implementation, @@ -238,7 +237,8 @@ impl UUPSProxyErc20ExampleNewVersion { })?; if slot == IMPLEMENTATION_SLOT { - Erc1967Utils::upgrade_to_and_call(self, new_implementation, data) + self.erc1967_utils + .upgrade_to_and_call(new_implementation, data) .map_err(uups_upgradeable::Error::from) .map_err(Error::from) } else { diff --git a/examples/uups-proxy/Cargo.toml b/examples/uups-proxy/Cargo.toml index d4edda75f..007fee14e 100644 --- a/examples/uups-proxy/Cargo.toml +++ b/examples/uups-proxy/Cargo.toml @@ -18,6 +18,7 @@ e2e.workspace = true tokio.workspace = true eyre.workspace = true uups-proxy-new-version-example = { path = "../uups-proxy-new-version" } +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [lib] crate-type = ["lib", "cdylib"] @@ -25,6 +26,7 @@ crate-type = ["lib", "cdylib"] [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [[bin]] name = "uups-proxy-example" diff --git a/examples/uups-proxy/tests/uups-proxy.rs b/examples/uups-proxy/tests/uups-proxy.rs index 39c78ccba..fc88a0731 100644 --- a/examples/uups-proxy/tests/uups-proxy.rs +++ b/examples/uups-proxy/tests/uups-proxy.rs @@ -72,25 +72,25 @@ async fn upgrade_through_valid_proxy_succeeds(alice: Account) -> Result<()> { let proxy = Erc1967Example::new(proxy_addr, &alice.wallet); // assert proxy and logic initialized correctly - assert_eq!(logic_addr, proxy.implementation().call().await?.implementation); + assert_eq!(logic_addr, proxy.implementation().call().await?); assert_eq!( UPGRADE_INTERFACE_VERSION, - proxy.UPGRADE_INTERFACE_VERSION().call().await?.version, + proxy.UPGRADE_INTERFACE_VERSION().call().await?, ); assert_eq!( UPGRADE_INTERFACE_VERSION, - logic.UPGRADE_INTERFACE_VERSION().call().await?.version, + logic.UPGRADE_INTERFACE_VERSION().call().await?, ); assert_eq!( uups_upgradeable::VERSION_NUMBER, - U32::from(proxy.getVersion().call().await?.version), + U32::from(proxy.getVersion().call().await?), ); assert_eq!( uups_upgradeable::VERSION_NUMBER, - U32::from(logic.getVersion().call().await?.version), + U32::from(logic.getVersion().call().await?), ); // check that state is set correctly - assert_eq!(alice.address(), proxy.owner().call().await?.owner); + assert_eq!(alice.address(), proxy.owner().call().await?); // deploy the new UUPS contract let new_logic_addr = @@ -105,25 +105,22 @@ async fn upgrade_through_valid_proxy_succeeds(alice: Account) -> Result<()> { assert!(receipt .emits(Erc1967Example::Upgraded { implementation: new_logic_addr })); - assert_eq!( - new_logic_addr, - proxy.implementation().call().await?.implementation - ); + assert_eq!(new_logic_addr, proxy.implementation().call().await?); assert_eq!( UPGRADE_INTERFACE_VERSION, - proxy.UPGRADE_INTERFACE_VERSION().call().await?.version, + proxy.UPGRADE_INTERFACE_VERSION().call().await?, ); assert_eq!( uups_proxy_new_version_example::VERSION_NUMBER, - U32::from(proxy.getVersion().call().await?.version), + U32::from(proxy.getVersion().call().await?), ); assert_eq!( uups_proxy_new_version_example::VERSION_NUMBER, - U32::from(new_logic.getVersion().call().await?.version), + U32::from(new_logic.getVersion().call().await?), ); // Alice should still be the owner - assert_eq!(alice.address(), proxy.owner().call().await?.owner); + assert_eq!(alice.address(), proxy.owner().call().await?); Ok(()) } @@ -193,7 +190,7 @@ async fn set_version_doesnt_revert_if_called_more_than_once( assert!(watch!(proxy.initialize(bob.address())).is_ok()); // CAUTION: Bob is now the owner - assert_eq!(bob.address(), proxy.owner().call().await?.owner); + assert_eq!(bob.address(), proxy.owner().call().await?); Ok(()) } @@ -211,19 +208,19 @@ async fn fallback_works(alice: Account, bob: Account) -> Result<()> { let proxy = Erc1967Example::new(proxy_addr, &alice.wallet); // verify initial balance is [`U256::ZERO`]. - assert_eq!(U256::ZERO, proxy.balanceOf(alice_addr).call().await?.balance); + assert_eq!(U256::ZERO, proxy.balanceOf(alice_addr).call().await?); - assert_eq!(U256::ZERO, proxy.totalSupply().call().await?.totalSupply); + assert_eq!(U256::ZERO, proxy.totalSupply().call().await?); // mint 1000 tokens. let amount = uint!(1000_U256); watch!(proxy.mint(alice_addr, amount))?; // check that the balance can be accurately fetched through the proxy. - assert_eq!(amount, proxy.balanceOf(alice_addr).call().await?.balance); + assert_eq!(amount, proxy.balanceOf(alice_addr).call().await?); // check that the total supply can be accurately fetched through the proxy. - assert_eq!(amount, proxy.totalSupply().call().await?.totalSupply); + assert_eq!(amount, proxy.totalSupply().call().await?); // check that the balance can be transferred through the proxy. let receipt = receipt!(proxy.transfer(bob_addr, amount))?; @@ -235,11 +232,11 @@ async fn fallback_works(alice: Account, bob: Account) -> Result<()> { })); // assert state was properly updated - assert_eq!(U256::ZERO, proxy.balanceOf(alice_addr).call().await?.balance); + assert_eq!(U256::ZERO, proxy.balanceOf(alice_addr).call().await?); - assert_eq!(amount, proxy.balanceOf(bob_addr).call().await?.balance); + assert_eq!(amount, proxy.balanceOf(bob_addr).call().await?); - assert_eq!(amount, proxy.totalSupply().call().await?.totalSupply); + assert_eq!(amount, proxy.totalSupply().call().await?); Ok(()) } @@ -328,8 +325,8 @@ async fn upgrade_preserves_storage(alice: Account) -> Result<()> { let amount = uint!(12345_U256); watch!(proxy.mint(alice_addr, amount))?; - let old_balance = proxy.balanceOf(alice_addr).call().await?.balance; - let old_total_supply = proxy.totalSupply().call().await?.totalSupply; + let old_balance = proxy.balanceOf(alice_addr).call().await?; + let old_total_supply = proxy.totalSupply().call().await?; assert_eq!(amount, old_balance); assert_eq!(amount, old_total_supply); @@ -345,8 +342,8 @@ async fn upgrade_preserves_storage(alice: Account) -> Result<()> { .emits(Erc1967Example::Upgraded { implementation: logic_v2_addr })); // verify storage consistency. - assert_eq!(old_balance, proxy.balanceOf(alice_addr).call().await?.balance); - assert_eq!(old_total_supply, proxy.totalSupply().call().await?.totalSupply); + assert_eq!(old_balance, proxy.balanceOf(alice_addr).call().await?); + assert_eq!(old_total_supply, proxy.totalSupply().call().await?); Ok(()) } @@ -363,7 +360,7 @@ async fn upgrade_to_same_implementation_succeeds(alice: Account) -> Result<()> { let proxy = Erc1967Example::new(proxy_addr, &alice.wallet); // sanity check: implementation is correct. - let current_impl = proxy.implementation().call().await?.implementation; + let current_impl = proxy.implementation().call().await?; assert_eq!(current_impl, logic_addr); // try re-upgrading to the same implementation. @@ -374,7 +371,7 @@ async fn upgrade_to_same_implementation_succeeds(alice: Account) -> Result<()> { ); // confirm implementation didn't change. - let new_impl = proxy.implementation().call().await?.implementation; + let new_impl = proxy.implementation().call().await?; assert_eq!(new_impl, logic_addr); Ok(()) @@ -396,11 +393,11 @@ async fn upgrade_to_implementation_with_same_version_succeeds( assert_eq!( uups_upgradeable::VERSION_NUMBER, - U32::from(proxy.getVersion().call().await?.version), + U32::from(proxy.getVersion().call().await?), ); assert_eq!( uups_upgradeable::VERSION_NUMBER, - U32::from(logic.getVersion().call().await?.version), + U32::from(logic.getVersion().call().await?), ); // sanity check: implementation is correct. @@ -415,16 +412,16 @@ async fn upgrade_to_implementation_with_same_version_succeeds( .emits(Erc1967Example::Upgraded { implementation: new_logic_addr })); // confirm implementation didn't change. - let new_impl = proxy.implementation().call().await?.implementation; + let new_impl = proxy.implementation().call().await?; assert_eq!(new_impl, new_logic_addr); assert_eq!( uups_upgradeable::VERSION_NUMBER, - U32::from(proxy.getVersion().call().await?.version), + U32::from(proxy.getVersion().call().await?), ); assert_eq!( uups_upgradeable::VERSION_NUMBER, - U32::from(new_logic.getVersion().call().await?.version), + U32::from(new_logic.getVersion().call().await?), ); Ok(()) @@ -462,7 +459,7 @@ async fn proxiable_uuid_can_only_be_called_directly_on_uups( let logic = UUPSProxyErc20Example::new(logic_addr, &alice.wallet); - assert_eq!(IMPLEMENTATION_SLOT, logic.proxiableUUID().call().await?.uuid); + assert_eq!(IMPLEMENTATION_SLOT, logic.proxiableUUID().call().await?); // calling through a proxy should revert let proxy_addr = diff --git a/examples/vesting-wallet/Cargo.toml b/examples/vesting-wallet/Cargo.toml index 400d84da4..69e4614cd 100644 --- a/examples/vesting-wallet/Cargo.toml +++ b/examples/vesting-wallet/Cargo.toml @@ -16,10 +16,12 @@ alloy.workspace = true eyre.workspace = true tokio.workspace = true e2e.workspace = true +alloy-primitives = { workspace = true, features = ["tiny-keccak"] } [features] e2e = [] export-abi = ["openzeppelin-stylus/export-abi"] +contract-client-gen = ["openzeppelin-stylus/contract-client-gen"] [lib] crate-type = ["lib", "cdylib"] diff --git a/examples/vesting-wallet/tests/vesting-wallet.rs b/examples/vesting-wallet/tests/vesting-wallet.rs index 060745c91..95a8dfed6 100644 --- a/examples/vesting-wallet/tests/vesting-wallet.rs +++ b/examples/vesting-wallet/tests/vesting-wallet.rs @@ -31,7 +31,7 @@ fn ctr( async fn block_timestamp(account: &Account) -> eyre::Result { let timestamp = account .wallet - .get_block(BlockId::latest(), BlockTransactionsKind::Hashes) + .get_block(BlockId::latest()) .await? .expect("latest block should exist") .header @@ -64,10 +64,10 @@ async fn constructs(alice: Account) -> eyre::Result<()> { .contract_address; let contract = VestingWallet::new(contract_addr, &alice.wallet); - let owner = contract.owner().call().await?.owner; - let start = contract.start().call().await?.start; - let duration = contract.duration().call().await?.duration; - let end = contract.end().call().await?.end; + let owner = contract.owner().call().await?; + let start = contract.start().call().await?; + let duration = contract.duration().call().await?; + let end = contract.end().call().await?; assert_eq!(alice.address(), owner); assert_eq!(U256::from(start_timestamp), start); @@ -144,8 +144,8 @@ mod ether_vesting { let old_contract_balance = alice.wallet.get_balance(contract_addr).await?; - let released = contract.released_0().call().await?.released; - let releasable = contract.releasable_0().call().await?.releasable; + let released = contract.released_0().call().await?; + let releasable = contract.releasable_0().call().await?; assert_eq!(U256::ZERO, released); assert_in_delta(expected_amount, releasable); @@ -153,13 +153,15 @@ mod ether_vesting { let alice_balance = alice.wallet.get_balance(alice.address()).await?; let contract_balance = alice.wallet.get_balance(contract_addr).await?; - let released = contract.released_0().call().await?.released; - let releasable = contract.releasable_0().call().await?.releasable; + let released = contract.released_0().call().await?; + let releasable = contract.releasable_0().call().await?; assert_in_delta(expected_amount, released); assert_in_delta(U256::ZERO, releasable); assert_in_delta( old_alice_balance + released - - U256::from(receipt.gas_used * receipt.effective_gas_price), + - U256::from( + receipt.gas_used as u128 * receipt.effective_gas_price, + ), alice_balance, ); assert_in_delta(old_contract_balance - released, contract_balance); @@ -213,7 +215,7 @@ mod ether_vesting { )); let vested_amount = - contract.vestedAmount_0(timestamp).call().await?.vestedAmount; + contract.vestedAmount_0(timestamp).call().await?; assert_eq!( expected_amount, vested_amount, "\n---\ni: {i}\nstart: {start}\ntimestamp: {timestamp}\n---\n" @@ -284,28 +286,21 @@ mod erc20_vesting { let contract = VestingWallet::new(contract_addr, &alice.wallet); let erc20 = ERC20Mock::new(erc20_address, &alice.wallet); - let old_alice_balance = - erc20.balanceOf(alice.address()).call().await?.balance; + let old_alice_balance = erc20.balanceOf(alice.address()).call().await?; let old_contract_balance = - erc20.balanceOf(contract_addr).call().await?.balance; + erc20.balanceOf(contract_addr).call().await?; - let released = - contract.released_1(erc20_address).call().await?.released; - let releasable = - contract.releasable_1(erc20_address).call().await?.releasable; + let released = contract.released_1(erc20_address).call().await?; + let releasable = contract.releasable_1(erc20_address).call().await?; assert_eq!(U256::ZERO, released); assert_in_delta(expected_amount, releasable); let receipt = receipt!(contract.release_1(erc20_address))?; - let alice_balance = - erc20.balanceOf(alice.address()).call().await?.balance; - let contract_balance = - erc20.balanceOf(contract_addr).call().await?.balance; - let released = - contract.released_1(erc20_address).call().await?.released; - let releasable = - contract.releasable_1(erc20_address).call().await?.releasable; + let alice_balance = erc20.balanceOf(alice.address()).call().await?; + let contract_balance = erc20.balanceOf(contract_addr).call().await?; + let released = contract.released_1(erc20_address).call().await?; + let releasable = contract.releasable_1(erc20_address).call().await?; assert_in_delta(expected_amount, released); assert_in_delta(U256::ZERO, releasable); assert_in_delta(old_alice_balance + released, alice_balance); @@ -365,8 +360,7 @@ mod erc20_vesting { let vested_amount = contract .vestedAmount_1(erc20_address, timestamp) .call() - .await? - .vestedAmount; + .await?; assert_eq!( expected_amount, vested_amount, "\n---\ni: {i}\nstart: {start}\ntimestamp: {timestamp}\n---\n" diff --git a/lib/e2e/README.md b/lib/e2e/README.md index 83473466b..211c80279 100644 --- a/lib/e2e/README.md +++ b/lib/e2e/README.md @@ -93,8 +93,8 @@ async fn constructs(alice: Account) -> eyre::Result<()> { .contract_address; let contract = Erc20::new(contract_addr, &alice.wallet); - let name = contract.name().call().await?.name; - let symbol = contract.symbol().call().await?.symbol; + let name = contract.name().call().await?; + let symbol = contract.symbol().call().await?; assert_eq!(name, TOKEN_NAME.to_owned()); assert_eq!(symbol, TOKEN_SYMBOL.to_owned()); diff --git a/lib/e2e/src/account.rs b/lib/e2e/src/account.rs index a6bab8fd7..8848c8ea6 100644 --- a/lib/e2e/src/account.rs +++ b/lib/e2e/src/account.rs @@ -1,20 +1,20 @@ use alloy::{ network::EthereumWallet, primitives::{Address, B256}, - providers::{Provider, ProviderBuilder}, + providers::ProviderBuilder, signers::{local::PrivateKeySigner, Signature, Signer}, }; use tokio::sync::{Mutex, MutexGuard}; use crate::{ deploy::Deployer, - system::{fund_account, Wallet, RPC_URL_ENV_VAR_NAME}, + system::{fund_account, get_rpc_url, Wallet}, }; const DEFAULT_FUNDING_ETH: u32 = 100; /// Type that corresponds to a test account. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct Account { /// The account's local private key wrapper. pub signer: PrivateKeySigner, @@ -44,12 +44,6 @@ impl Account { self.signer.address() } - /// The rpc endpoint this account's provider is connect to. - #[must_use] - pub fn url(&self) -> &str { - self.wallet.client().transport().url() - } - /// Sign the given hash. /// /// # Panics @@ -73,7 +67,7 @@ impl Account { /// Create a configurable smart contract deployer on behalf of this account. #[must_use] pub fn as_deployer(&self) -> Deployer { - Deployer::new(self.url().to_string(), self.pk()) + Deployer::new(get_rpc_url(), self.pk()) } } @@ -107,14 +101,11 @@ impl AccountFactory { let addr = signer.address(); fund_account(addr, DEFAULT_FUNDING_ETH)?; - let rpc_url = std::env::var(RPC_URL_ENV_VAR_NAME) - .expect("failed to load RPC_URL var from env") - .parse() - .expect("failed to parse RPC_URL string into a URL"); + let rpc_url = get_rpc_url(); let wallet = ProviderBuilder::new() - .with_recommended_fillers() + .with_simple_nonce_management() .wallet(EthereumWallet::from(signer.clone())) - .on_http(rpc_url); + .connect_http(rpc_url); Ok(Account { signer, wallet }) } diff --git a/lib/e2e/src/deploy.rs b/lib/e2e/src/deploy.rs index 63b520c5b..26e972a70 100644 --- a/lib/e2e/src/deploy.rs +++ b/lib/e2e/src/deploy.rs @@ -15,10 +15,12 @@ use stylus_sdk::{abi::Bytes, alloy_primitives, function_selector}; use crate::{ project::{get_wasm, Crate}, - system::DEPLOYER_ADDRESS, Constructor, Receipt, }; +/// `StylusDeployer` contract address. +pub const DEPLOYER_ADDRESS: &str = "DEPLOYER_ADDRESS"; + const CONTRACT_INITIALIZATION_ERROR_SELECTOR: [u8; 4] = function_selector!("ContractInitializationError", Address, Bytes); @@ -82,14 +84,14 @@ impl std::error::Error for ContractDeploymentError {} /// A basic smart contract deployer. pub struct Deployer { - rpc_url: String, + rpc_url: Url, private_key: String, ctor: Option, example_name: Option, } impl Deployer { - pub fn new(rpc_url: String, private_key: String) -> Self { + pub fn new(rpc_url: Url, private_key: String) -> Self { Self { rpc_url, private_key, ctor: None, example_name: None } } @@ -147,7 +149,7 @@ impl Deployer { let mut command = Command::new("cargo"); command .args(["stylus", "deploy"]) - .args(["-e", &self.rpc_url]) + .args(["-e", self.rpc_url.as_str()]) .args(["--private-key", &self.private_key]) .args(["--wasm-file", wasm_path]) .args(["--no-verify"]); @@ -240,13 +242,10 @@ impl Deployer { .context("Failed to parse transaction hash")?; let provider = ProviderBuilder::new() - .with_recommended_fillers() .wallet(EthereumWallet::from( self.private_key.parse::()?, )) - .on_http( - Url::from_str(&self.rpc_url).expect("invalid Url"), - ); + .connect_http(self.rpc_url.clone()); // We extract the address of the contract that was supposed to // be activated by `StylusDeployer` by getting the transaction @@ -333,7 +332,7 @@ impl Deployer { "Failed to parse contract address from string: {contract_addr}" ))?; - // Now we extract the transaction hash to fetch to receipt + // Now we extract the transaction hash to fetch to receipt. let tx_hash_regex = Regex::new(r"0x[a-fA-F0-9]{64}") .context("Failed to create tx hash regex")?; @@ -347,14 +346,13 @@ impl Deployer { let tx_hash = TxHash::from_str(tx_hash) .context("Failed to parse transaction hash")?; - // Finally we can fetch the receipt + // Finally, we can fetch the receipt. let provider = ProviderBuilder::new() - .with_recommended_fillers() .wallet(EthereumWallet::from( self.private_key.parse::()?, )) - .on_http(Url::from_str(&self.rpc_url).expect("invalid Url")); + .connect_http(self.rpc_url.clone()); let receipt = provider .get_transaction_receipt(tx_hash) diff --git a/lib/e2e/src/error.rs b/lib/e2e/src/error.rs index f218369d6..354c97eb7 100644 --- a/lib/e2e/src/error.rs +++ b/lib/e2e/src/error.rs @@ -3,7 +3,7 @@ use alloy::{ sol_types::SolError, transports::{RpcError, TransportErrorKind}, }; -use stylus_sdk::call::MethodError; +use stylus_sdk::prelude::errors::MethodError; /// JSON-RPC error code for execution reverted. const EXECUTION_REVERTED_CODE: i64 = 3; diff --git a/lib/e2e/src/lib.rs b/lib/e2e/src/lib.rs index 6eee688d5..0f43fe88b 100644 --- a/lib/e2e/src/lib.rs +++ b/lib/e2e/src/lib.rs @@ -11,12 +11,14 @@ mod system; pub use account::Account; pub use constructor_macro::{AbiTypeToString, Constructor}; -pub use deploy::{ContractDeploymentError, ContractInitializationError}; +pub use deploy::{ + ContractDeploymentError, ContractInitializationError, DEPLOYER_ADDRESS, +}; pub use e2e_proc::test; pub use error::{Panic, PanicCode, Revert, RustPanic}; pub use event::Ext as EventExt; pub use receipt::Receipt; -pub use system::{fund_account, Wallet, DEPLOYER_ADDRESS}; +pub use system::{fund_account, get_rpc_url, Wallet}; /// This macro provides a shorthand for broadcasting the transaction to the /// network. diff --git a/lib/e2e/src/system.rs b/lib/e2e/src/system.rs index 265da1c93..d4de41bfd 100644 --- a/lib/e2e/src/system.rs +++ b/lib/e2e/src/system.rs @@ -4,35 +4,54 @@ use alloy::{ providers::{ fillers::{ BlobGasFiller, ChainIdFiller, FillProvider, GasFiller, JoinFill, - NonceFiller, WalletFiller, + NonceFiller, SimpleNonceManager, WalletFiller, }, Identity, RootProvider, }, - transports::http::{Client, Http}, + transports::http::reqwest::Url, }; use eyre::bail; use crate::environment::get_node_path; -pub(crate) const RPC_URL_ENV_VAR_NAME: &str = "RPC_URL"; -/// `StylusDeployer` contract address. -pub const DEPLOYER_ADDRESS: &str = "DEPLOYER_ADDRESS"; +const RPC_URL_ENV_VAR_NAME: &str = "RPC_URL"; + +/// Loads the rpc url from the environment variable. +/// +/// # Panics +/// +/// When environment variable doesn't exist. +#[must_use] +pub fn get_rpc_url() -> Url { + std::env::var(RPC_URL_ENV_VAR_NAME) + .unwrap_or_else(|_| { + panic!("failed to load {RPC_URL_ENV_VAR_NAME} var from env"); + }) + .parse() + .unwrap_or_else(|_| { + panic!("failed to parse {RPC_URL_ENV_VAR_NAME} string into a URL"); + }) +} /// Convenience type alias that represents an Ethereum wallet. pub type Wallet = FillProvider< JoinFill< JoinFill< - Identity, JoinFill< - GasFiller, - JoinFill>, + Identity, + JoinFill< + GasFiller, + JoinFill< + BlobGasFiller, + JoinFill, + >, + >, >, + NonceFiller, >, WalletFiller, >, - RootProvider>, - Http, - Ethereum, + RootProvider, >; /// Send `amount` eth to `address` in the nitro-tesnode. diff --git a/scripts/bench.sh b/scripts/bench.sh index 9a64b85fa..f82ebe6a3 100755 --- a/scripts/bench.sh +++ b/scripts/bench.sh @@ -14,7 +14,7 @@ opt_wasm() { echo echo "Optimizing $CONTRACT_CRATE_NAME WASM binary" # https://rustwasm.github.io/book/reference/code-size.html#use-the-wasm-opt-tool - wasm-opt --enable-bulk-memory -O3 -o ./target/wasm32-unknown-unknown/release/"$CONTRACT_OPT_BIN_NAME" ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" + wasm-opt --enable-bulk-memory -O4 -o ./target/wasm32-unknown-unknown/release/"$CONTRACT_OPT_BIN_NAME" ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" } # Retrieve all alphanumeric contract's crate names in `./examples` directory. diff --git a/scripts/check-wasm.sh b/scripts/check-wasm.sh index 9cdf2dd7a..ef335e0e6 100755 --- a/scripts/check-wasm.sh +++ b/scripts/check-wasm.sh @@ -9,10 +9,14 @@ cd .. check_wasm() { local CONTRACT_CRATE_NAME=$1 local CONTRACT_BIN_NAME="${CONTRACT_CRATE_NAME//-/_}.wasm" + local CONTRACT_OPT_BIN_NAME="${CONTRACT_CRATE_NAME//-/_}_opt.wasm" echo echo "Checking contract $CONTRACT_CRATE_NAME" cargo stylus check -e https://sepolia-rollup.arbitrum.io/rpc --wasm-file ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" + echo "Checking wasm-opt binary" + wasm-opt --enable-bulk-memory -O4 -o ./target/wasm32-unknown-unknown/release/"$CONTRACT_OPT_BIN_NAME" ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" + cargo stylus check -e https://sepolia-rollup.arbitrum.io/rpc --wasm-file ./target/wasm32-unknown-unknown/release/"$CONTRACT_OPT_BIN_NAME" } # Retrieve all alphanumeric contract's crate names in `./examples` directory. @@ -28,5 +32,4 @@ cargo build --release --target wasm32-unknown-unknown \ for CRATE_NAME in $(get_example_crate_names); do check_wasm "$CRATE_NAME" - sleep 2 done