From 9b10f24806b1dda79054cfcf92c23edf0b5e6a79 Mon Sep 17 00:00:00 2001 From: K1-R1 <77465250+K1-R1@users.noreply.github.com> Date: Mon, 9 Sep 2024 07:49:10 +0100 Subject: [PATCH] Owned Proxy - update to support forc deploy proxy feature (#17) * Use current nightly forc * chore: update contract to forc 0.63.1 * chore: update scripts * chore: updated tests and removed copied test * docs: updated badges and replace version message with badge * chore: changelog * chore: update CI rust ver * feat: update to latest deps, pin owner slot * docs: updated forc version * chore: updated forc ver in tests * Resolve failed to run custom build command for fuel-core-upgradable-executor v0.33.0 error * Use master branch of Sway-Libs * Update to Sway-Libs v0.24.0 * Udpate Forc.lock * chore: updated script dependencies * chore: updated test dependencies * chore: fix clippy lint * chore: fix spelling * chore: use default node and chain config * chore: use latest nightly chain * fix ci * chore: update CI rust version * chore: updated owned proxy forc version * chore: updated owned_proxy scripts fuel-rs version * chore: updated test harness forc and fuels-rs versions --------- Co-authored-by: Sophie Co-authored-by: bitzoic --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 1 + README.md | 7 +- src14/owned_proxy/README.md | 6 + src14/owned_proxy/contract/Forc.lock | 17 +- src14/owned_proxy/contract/Forc.toml | 4 +- .../owned_proxy/contract/fuel-toolchain.toml | 6 +- .../out/release/src14_owned_proxy-abi.json | 308 ++++++++---------- .../out/release/src14_owned_proxy.bin | Bin 16680 -> 13832 bytes src14/owned_proxy/contract/src/main.sw | 45 +-- src14/owned_proxy/scripts/Cargo.toml | 6 +- .../scripts/src/deploy_and_init.rs | 2 +- .../scripts/src/set_proxy_owner.rs | 10 +- .../scripts/src/set_proxy_target.rs | 10 +- src14/owned_proxy/scripts/src/utils.rs | 2 +- tests/Cargo.toml | 30 +- tests/Forc.lock | 4 +- tests/fuel-toolchain.toml | 6 +- .../tests/functions/initialize_proxy.rs | 36 +- .../src14/owned_proxy/tests/functions/mod.rs | 2 +- .../tests/functions/only_proxy_owner.rs | 55 ---- .../tests/functions/proxy_owner.rs | 26 +- .../tests/functions/proxy_target.rs | 13 +- .../tests/functions/set_proxy_owner.rs | 84 +++-- .../tests/functions/set_proxy_target.rs | 52 ++- ...tact_calls.rs => target_contract_calls.rs} | 78 +++-- .../src/src14/owned_proxy/tests/utils/mod.rs | 100 +++--- 27 files changed, 434 insertions(+), 478 deletions(-) delete mode 100644 tests/src/src14/owned_proxy/tests/functions/only_proxy_owner.rs rename tests/src/src14/owned_proxy/tests/functions/{target_contact_calls.rs => target_contract_calls.rs} (68%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db4e244..be2062c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ concurrency: env: CARGO_TERM_COLOR: always REGISTRY: ghcr.io - RUST_VERSION: 1.79.0 + RUST_VERSION: 1.81.0 jobs: build-projects: diff --git a/CHANGELOG.md b/CHANGELOG.md index 30c51e7..25eef77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Description of the upcoming release here. - [#1](https://github.com/FuelLabs/sway-standard-implementations/pull/1) Adds an implementation of SRC-14: Owned Proxy. - [#8](https://github.com/FuelLabs/sway-standard-implementations/pull/8) Adds SRC-14 owned proxy usage scripts and docs. - [#10](https://github.com/FuelLabs/sway-standard-implementations/pull/10) Sets owned_proxy sway-libs dependency to version v0.23.0. +- [#17](https://github.com/FuelLabs/sway-standard-implementations/pull/17) Update Owned Proxy to support `forc`'s deploy proxy feature. ### Changed diff --git a/README.md b/README.md index 23f95de..62f10c9 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ - - + + @@ -34,6 +34,3 @@ cd tests && forc test --release --locked && cargo test > **NOTE:** > This may take a while depending on your hardware, future improvements to Sway will decrease build times. After this has been run once, individual test projects may be built on their own to save time. - -> **NOTE:** -> All projects currently use `forc v0.60.0`, `fuels-rs v0.63.0` and `fuel-core v0.27.0`. Versions are locked via `fuel-toolchain.toml` files. diff --git a/src14/owned_proxy/README.md b/src14/owned_proxy/README.md index 3661559..9c7f564 100644 --- a/src14/owned_proxy/README.md +++ b/src14/owned_proxy/README.md @@ -1,5 +1,11 @@ # SRC-14: Owned Proxy Contract +

+ + + +

+ - The [Owned Proxy Contract](./contract/src/main.sw) is an opinionated implementation of the [extended SRC-14 standard](https://docs.fuel.network/docs/sway-standards/src-14-simple-upgradeable-proxies/). It utilises the [Upgradability library from sway-libs](https://github.com/FuelLabs/sway-libs) and includes initialization functionality that allows for secure ownership upon deployment. ## Usage instructions diff --git a/src14/owned_proxy/contract/Forc.lock b/src14/owned_proxy/contract/Forc.lock index d70cbfb..1b3a7c8 100644 --- a/src14/owned_proxy/contract/Forc.lock +++ b/src14/owned_proxy/contract/Forc.lock @@ -1,35 +1,30 @@ [[package]] name = "core" -source = "path+from-root-E19CE48B3E858B72" +source = "path+from-root-4BB20845430AF9CF" [[package]] name = "src14_owned_proxy" source = "member" dependencies = [ - "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.5.1#e2d5ac40a1d11a9e38e0a662d35141076515319f", + "standards", "std", "sway_libs", ] [[package]] name = "standards" -source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.5.0#348f7175df4c012b23c86cdb18aab79025ca1f18" -dependencies = ["std"] - -[[package]] -name = "standards" -source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.5.1#e2d5ac40a1d11a9e38e0a662d35141076515319f" +source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c" dependencies = ["std"] [[package]] name = "std" -source = "git+https://github.com/fuellabs/sway?tag=v0.60.0#2f0392ee35a1e4dd80bd8034962d5b4083dfb8b6" +source = "git+https://github.com/fuellabs/sway?tag=v0.63.5#31a1d6f98395f571cd3674b492d9bf4773c55f65" dependencies = ["core"] [[package]] name = "sway_libs" -source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.23.0#9987d8ae11b1d82d42524794829c216b607916c5" +source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.24.0#e19f96f85ae12426d20adc176b70aa38fd9a2a5b" dependencies = [ - "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.5.0#348f7175df4c012b23c86cdb18aab79025ca1f18", + "standards", "std", ] diff --git a/src14/owned_proxy/contract/Forc.toml b/src14/owned_proxy/contract/Forc.toml index 76d5ef5..ef84cfd 100644 --- a/src14/owned_proxy/contract/Forc.toml +++ b/src14/owned_proxy/contract/Forc.toml @@ -5,5 +5,5 @@ license = "Apache-2.0" name = "src14_owned_proxy" [dependencies] -standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.1" } -sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.23.0" } +standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.0" } +sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.0" } diff --git a/src14/owned_proxy/contract/fuel-toolchain.toml b/src14/owned_proxy/contract/fuel-toolchain.toml index ce69623..e7cb45b 100644 --- a/src14/owned_proxy/contract/fuel-toolchain.toml +++ b/src14/owned_proxy/contract/fuel-toolchain.toml @@ -1,6 +1,6 @@ [toolchain] -channel = "testnet" +channel = "testnet-2024-09-06" [components] -fuel-core = "0.27.0" -forc = "0.60.0" +forc = "0.63.5" +fuel-core = "0.35.0" diff --git a/src14/owned_proxy/contract/out/release/src14_owned_proxy-abi.json b/src14/owned_proxy/contract/out/release/src14_owned_proxy-abi.json index 10ad2ee..9fa09e5 100644 --- a/src14/owned_proxy/contract/out/release/src14_owned_proxy-abi.json +++ b/src14/owned_proxy/contract/out/release/src14_owned_proxy-abi.json @@ -1,188 +1,194 @@ { - "encoding": "1", - "types": [ + "programType": "contract", + "specVersion": "1", + "encodingVersion": "1", + "concreteTypes": [ { - "typeId": 0, "type": "()", - "components": [], - "typeParameters": null + "concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" }, { - "typeId": 1, + "type": "enum standards::src5::AccessError", + "concreteTypeId": "3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d", + "metadataTypeId": 1 + }, + { + "type": "enum standards::src5::State", + "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", + "metadataTypeId": 2 + }, + { + "type": "enum std::option::Option", + "concreteTypeId": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", + "metadataTypeId": 4, + "typeArguments": [ + "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54" + ] + }, + { + "type": "enum sway_libs::ownership::errors::InitializationError", + "concreteTypeId": "1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893", + "metadataTypeId": 5 + }, + { + "type": "enum sway_libs::upgradability::errors::SetProxyOwnerError", + "concreteTypeId": "3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74", + "metadataTypeId": 6 + }, + { + "type": "str", + "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" + }, + { + "type": "struct std::contract_id::ContractId", + "concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54", + "metadataTypeId": 9 + }, + { + "type": "struct sway_libs::upgradability::events::ProxyOwnerSet", + "concreteTypeId": "96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247", + "metadataTypeId": 10 + }, + { + "type": "struct sway_libs::upgradability::events::ProxyTargetSet", + "concreteTypeId": "1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8", + "metadataTypeId": 11 + } + ], + "metadataTypes": [ + { "type": "b256", - "components": null, - "typeParameters": null + "metadataTypeId": 0 }, { - "typeId": 2, - "type": "enum AccessError", + "type": "enum standards::src5::AccessError", + "metadataTypeId": 1, "components": [ { "name": "NotOwner", - "type": 0, - "typeArguments": null + "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" } - ], - "typeParameters": null + ] }, { - "typeId": 3, - "type": "enum Identity", + "type": "enum standards::src5::State", + "metadataTypeId": 2, "components": [ { - "name": "Address", - "type": 10, - "typeArguments": null + "name": "Uninitialized", + "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" }, { - "name": "ContractId", - "type": 11, - "typeArguments": null + "name": "Initialized", + "typeId": 3 + }, + { + "name": "Revoked", + "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" } - ], - "typeParameters": null + ] }, { - "typeId": 4, - "type": "enum InitializationError", + "type": "enum std::identity::Identity", + "metadataTypeId": 3, "components": [ { - "name": "CannotReinitialized", - "type": 0, - "typeArguments": null + "name": "Address", + "typeId": 8 + }, + { + "name": "ContractId", + "typeId": 9 } - ], - "typeParameters": null + ] }, { - "typeId": 5, - "type": "enum Option", + "type": "enum std::option::Option", + "metadataTypeId": 4, "components": [ { "name": "None", - "type": 0, - "typeArguments": null + "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" }, { "name": "Some", - "type": 8, - "typeArguments": null + "typeId": 7 } ], "typeParameters": [ - 8 + 7 ] }, { - "typeId": 6, - "type": "enum SetProxyOwnerError", + "type": "enum sway_libs::ownership::errors::InitializationError", + "metadataTypeId": 5, "components": [ { - "name": "CannotUninitialize", - "type": 0, - "typeArguments": null + "name": "CannotReinitialized", + "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" } - ], - "typeParameters": null + ] }, { - "typeId": 7, - "type": "enum State", + "type": "enum sway_libs::upgradability::errors::SetProxyOwnerError", + "metadataTypeId": 6, "components": [ { - "name": "Uninitialized", - "type": 0, - "typeArguments": null - }, - { - "name": "Initialized", - "type": 3, - "typeArguments": null - }, - { - "name": "Revoked", - "type": 0, - "typeArguments": null + "name": "CannotUninitialize", + "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" } - ], - "typeParameters": null + ] }, { - "typeId": 8, "type": "generic T", - "components": null, - "typeParameters": null - }, - { - "typeId": 9, - "type": "str", - "components": null, - "typeParameters": null + "metadataTypeId": 7 }, { - "typeId": 10, - "type": "struct Address", + "type": "struct std::address::Address", + "metadataTypeId": 8, "components": [ { "name": "bits", - "type": 1, - "typeArguments": null + "typeId": 0 } - ], - "typeParameters": null + ] }, { - "typeId": 11, - "type": "struct ContractId", + "type": "struct std::contract_id::ContractId", + "metadataTypeId": 9, "components": [ { "name": "bits", - "type": 1, - "typeArguments": null + "typeId": 0 } - ], - "typeParameters": null + ] }, { - "typeId": 12, - "type": "struct ProxyOwnerSet", + "type": "struct sway_libs::upgradability::events::ProxyOwnerSet", + "metadataTypeId": 10, "components": [ { "name": "new_proxy_owner", - "type": 7, - "typeArguments": null + "typeId": 2 } - ], - "typeParameters": null + ] }, { - "typeId": 13, - "type": "struct ProxyTargetSet", + "type": "struct sway_libs::upgradability::events::ProxyTargetSet", + "metadataTypeId": 11, "components": [ { "name": "new_target", - "type": 11, - "typeArguments": null + "typeId": 9 } - ], - "typeParameters": null + ] } ], "functions": [ { "inputs": [], "name": "proxy_target", - "output": { - "name": "", - "type": 5, - "typeArguments": [ - { - "name": "", - "type": 11, - "typeArguments": null - } - ] - }, + "output": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", "attributes": [ { "name": "doc-comment", @@ -250,16 +256,11 @@ "inputs": [ { "name": "new_target", - "type": 11, - "typeArguments": null + "concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54" } ], "name": "set_proxy_target", - "output": { - "name": "", - "type": 0, - "typeArguments": null - }, + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", "attributes": [ { "name": "doc-comment", @@ -381,11 +382,7 @@ { "inputs": [], "name": "proxy_owner", - "output": { - "name": "", - "type": 7, - "typeArguments": null - }, + "output": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", "attributes": [ { "name": "doc-comment", @@ -452,11 +449,7 @@ { "inputs": [], "name": "initialize_proxy", - "output": { - "name": "", - "type": 0, - "typeArguments": null - }, + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", "attributes": [ { "name": "doc-comment", @@ -521,7 +514,7 @@ { "name": "doc-comment", "arguments": [ - " * When `storage.proxy_owner` is not [State::Uninitialized]." + " * When `storage::SRC14.proxy_owner` is not [State::Uninitialized]." ] }, { @@ -560,16 +553,11 @@ "inputs": [ { "name": "new_proxy_owner", - "type": 7, - "typeArguments": null + "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c" } ], "name": "set_proxy_owner", - "output": { - "name": "", - "type": 0, - "typeArguments": null - }, + "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", "attributes": [ { "name": "doc-comment", @@ -697,78 +685,40 @@ "loggedTypes": [ { "logId": "4571204900286667806", - "loggedType": { - "name": "", - "type": 2, - "typeArguments": [] - } + "concreteTypeId": "3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d" }, { "logId": "2151606668983994881", - "loggedType": { - "name": "", - "type": 13, - "typeArguments": [] - } + "concreteTypeId": "1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8" }, { "logId": "2161305517876418151", - "loggedType": { - "name": "", - "type": 4, - "typeArguments": [] - } + "concreteTypeId": "1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893" }, { "logId": "4354576968059844266", - "loggedType": { - "name": "", - "type": 6, - "typeArguments": [] - } + "concreteTypeId": "3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74" }, { "logId": "10870989709723147660", - "loggedType": { - "name": "", - "type": 12, - "typeArguments": [] - } + "concreteTypeId": "96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247" }, { "logId": "10098701174489624218", - "loggedType": { - "name": "", - "type": 9, - "typeArguments": null - } + "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" } ], "messagesTypes": [], "configurables": [ { "name": "INITIAL_TARGET", - "configurableType": { - "name": "", - "type": 5, - "typeArguments": [ - { - "name": "", - "type": 11, - "typeArguments": [] - } - ] - }, - "offset": 16224 + "concreteTypeId": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", + "offset": 13368 }, { "name": "INITIAL_OWNER", - "configurableType": { - "name": "", - "type": 7, - "typeArguments": [] - }, - "offset": 16264 + "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", + "offset": 13320 } ] } \ No newline at end of file diff --git a/src14/owned_proxy/contract/out/release/src14_owned_proxy.bin b/src14/owned_proxy/contract/out/release/src14_owned_proxy.bin index ea52800465d15de0e1ecd19085568823d1b464c6..9ce271962505b89385ca747bc4da888810e76c15 100644 GIT binary patch literal 13832 zcmdU#d2k!oea9a_P=e%ZZILn!Nfw++G91SWB2f<}BNBGIX6z-SilMm*}JidSphOq*G=lhnmJMHH}*;5nI-cGg93~ z{ruj(#V!uY&NTg_oZ;-l?t8!Yd%xrRJ9c9$Np(!Au+o2>(fpN4$hvYxeNw3*=Z7oG z`Mydzi?)hi+O39OSqwX`EJlv0@WVVy@+`r#WbLz-4bW4uiw-o_+4=O!o2-VShn5(y}O)j z$r|fnex|eNfPt*+&Ir;{#U($7-ccy^|zIxl;sqQ{vC`^8o4 z#RhrAW9bET!VVore!E0|oHya*rV`N2K;Po}pp%~J3eaB&&|iEN`cap@x&Zy%0s1}A z?S=j|Tpxn|P=Nl5Pk&xroql-5(El*>I|KAbpxbBoe;f2q`t;{5pZ;vetI$7Z=sybm zJpuZsp+5lq8@N6U{RyA`t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Qg_`O1xLl<{Wz8-wB_ko`IR?fD!TRIv&&3MKWEbXF&Z5I7US7W0SgHz&>?-7FzTVUHHqsJIWm_pzI`z06}jTkh1~{eYjV z_dX6l5BYaRupHAPaq$US9`GV zTFD;2v3i-_kh(d#ZV~T~n>yZQAfLwr{0eK`lH`sX2-gcI10Wkgu=j`kbUXMT2oSn6ZIuSW%*L6Y7A%EvQ ziuT(}#G@Q=B6FjQKPVbtU-KBd+r_-kW$tRqx3@T~;EpgW)yy7EvG~LIPQ1?+)QzYd zF%)4tL;0o3$%vn&h^Ho%U$t1u!Pl^V+(CUncY|K?2C^;sP~w9w?tMVduku|!gJz+) zhUQh^i8PO9Lt1`QIYIY3U_uy)dWHOknUNFX5%Hy3e&bvl@j+Zk!4Z1bD# z)DsmiOnsD*FIIy<4 zP4Razm>uM7yqjWPbjY^IDX!w}%C->?6J zht~e7`1!$MaeQDx9=qgmjX2(qH`nRkee(DFO8g`1J}Hj(o{`6Cc|0eNGxB&$9({TI lhB&VOkvMjpl}A?|yT$RIA#uFxyW+S^UU#D-KF5Fme*sN7MkD|L diff --git a/src14/owned_proxy/contract/src/main.sw b/src14/owned_proxy/contract/src/main.sw index 73734bd..71911db 100644 --- a/src14/owned_proxy/contract/src/main.sw +++ b/src14/owned_proxy/contract/src/main.sw @@ -17,26 +17,27 @@ use standards::{src14::{SRC14, SRC14Extension}, src5::State}; use std::execution::run_external; configurable { - /// The initial value of `storage.target`. + /// The initial value of `storage::SRC14.target`. INITIAL_TARGET: Option = None, - /// The initial value of `storage.proxy_owner`. + /// The initial value of `storage::SRC14.proxy_owner`. INITIAL_OWNER: State = State::Uninitialized, } -#[namespace(SRC14)] storage { - /// The [ContractId] of the target contract. - /// - /// # Additional Information - /// - /// `target` is stored at sha256("storage_SRC14_0") - target: Option = None, - /// The [State] of the proxy owner. - /// - /// # Additional Information - /// - // `proxy_owner` is stored at sha256("storage_SRC14_1") - proxy_owner: State = State::Uninitialized, + SRC14 { + /// The [ContractId] of the target contract. + /// + /// # Additional Information + /// + /// `target` is stored at sha256("storage_SRC14_0") + target in 0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55: Option = None, + /// The [State] of the proxy owner. + /// + /// # Additional Information + /// + /// `proxy_owner` is stored at sha256("storage_SRC14_1") + proxy_owner in 0xbb79927b15d9259ea316f2ecb2297d6cc8851888a98278c0a2e03e1a091ea754: State = State::Uninitialized, + }, } impl SRC14 for Contract { @@ -60,7 +61,7 @@ impl SRC14 for Contract { /// * Write: `1` #[storage(read, write)] fn set_proxy_target(new_target: ContractId) { - only_proxy_owner(storage.proxy_owner); + only_proxy_owner(); _set_proxy_target(new_target); } @@ -91,7 +92,7 @@ impl SRC14Extension for Contract { /// * Reads: `1` #[storage(read)] fn proxy_owner() -> State { - _proxy_owner(storage.proxy_owner) + _proxy_owner() } } @@ -106,7 +107,7 @@ impl OwnedProxy for Contract { /// /// # Reverts /// - /// * When `storage.proxy_owner` is not [State::Uninitialized]. + /// * When `storage::SRC14.proxy_owner` is not [State::Uninitialized]. /// /// # Number of Storage Accesses /// @@ -114,12 +115,12 @@ impl OwnedProxy for Contract { #[storage(write)] fn initialize_proxy() { require( - _proxy_owner(storage.proxy_owner) == State::Uninitialized, + _proxy_owner() == State::Uninitialized, InitializationError::CannotReinitialized, ); - storage.target.write(INITIAL_TARGET); - storage.proxy_owner.write(INITIAL_OWNER); + storage::SRC14.target.write(INITIAL_TARGET); + storage::SRC14.proxy_owner.write(INITIAL_OWNER); } /// Changes proxy ownership to the passed State. @@ -143,7 +144,7 @@ impl OwnedProxy for Contract { /// * Writes: `1` #[storage(write)] fn set_proxy_owner(new_proxy_owner: State) { - _set_proxy_owner(new_proxy_owner, storage.proxy_owner); + _set_proxy_owner(new_proxy_owner); } } diff --git a/src14/owned_proxy/scripts/Cargo.toml b/src14/owned_proxy/scripts/Cargo.toml index e26422c..100fc8b 100644 --- a/src14/owned_proxy/scripts/Cargo.toml +++ b/src14/owned_proxy/scripts/Cargo.toml @@ -6,9 +6,9 @@ edition = "2021" license = "Apache-2.0" [dependencies] -clap = { version = "4.5", features = ["env"] } -fuels = { version = "0.65", features = ["fuel-core-lib"] } -tokio = { version = "1.39", features = ["rt", "macros"] } +clap = { version = "4.5.17", features = ["env", "derive"] } +fuels = { version = "0.66.4" } +tokio = { version = "1.39.3", features = ["rt", "macros"] } [lib] name = "proxy_script_utils" diff --git a/src14/owned_proxy/scripts/src/deploy_and_init.rs b/src14/owned_proxy/scripts/src/deploy_and_init.rs index 36278a3..2918700 100644 --- a/src14/owned_proxy/scripts/src/deploy_and_init.rs +++ b/src14/owned_proxy/scripts/src/deploy_and_init.rs @@ -15,7 +15,7 @@ struct Args { /// Signing key #[arg(short, long, required = true, env = "SIGNING_KEY")] signing_key: String, - /// Initial target ContractId + /// Initial target `ContractId` #[arg(long, required = true)] initial_target: String, /// Initial owner Id diff --git a/src14/owned_proxy/scripts/src/set_proxy_owner.rs b/src14/owned_proxy/scripts/src/set_proxy_owner.rs index f5f4378..c34fab5 100644 --- a/src14/owned_proxy/scripts/src/set_proxy_owner.rs +++ b/src14/owned_proxy/scripts/src/set_proxy_owner.rs @@ -1,5 +1,5 @@ use clap::Parser; -use fuels::types::Address; +use fuels::{programs::calls::Execution, types::Address}; use proxy_script_utils::{get_proxy_instance, setup_signing_wallet, State}; use std::str::FromStr; @@ -33,11 +33,11 @@ async fn main() { let current_owner = proxy_contract .methods() .proxy_owner() - .simulate() + .simulate(Execution::Realistic) .await .unwrap() .value; - println!("\n - The current proxy owner: {:?}", current_owner); + println!("\n - The current proxy owner: {current_owner:?}"); let new_owner = State::Initialized( Address::from_str(&args.new_owner) @@ -56,9 +56,9 @@ async fn main() { let new_owner = proxy_contract .methods() .proxy_owner() - .simulate() + .simulate(Execution::Realistic) .await .unwrap() .value; - println!(" - The new proxy owner: {:?}\n", new_owner); + println!(" - The new proxy owner: {new_owner:?}\n"); } diff --git a/src14/owned_proxy/scripts/src/set_proxy_target.rs b/src14/owned_proxy/scripts/src/set_proxy_target.rs index c4d1f9e..3619e54 100644 --- a/src14/owned_proxy/scripts/src/set_proxy_target.rs +++ b/src14/owned_proxy/scripts/src/set_proxy_target.rs @@ -1,5 +1,5 @@ use clap::Parser; -use fuels::types::ContractId; +use fuels::{programs::calls::Execution, types::ContractId}; use proxy_script_utils::{get_proxy_instance, setup_signing_wallet}; use std::str::FromStr; @@ -33,11 +33,11 @@ async fn main() { let current_target = proxy_contract .methods() .proxy_target() - .simulate() + .simulate(Execution::Realistic) .await .unwrap() .value; - println!("\n - The current target contract ID: {:?}", current_target); + println!("\n - The current target contract ID: {current_target:?}"); let new_target = ContractId::from_str(&args.new_target_id).expect("New Target Id could not be parsed"); @@ -53,9 +53,9 @@ async fn main() { let new_target = proxy_contract .methods() .proxy_target() - .simulate() + .simulate(Execution::Realistic) .await .unwrap() .value; - println!(" - The new target contract ID: {:?}\n", new_target); + println!(" - The new target contract ID: {new_target:?}\n"); } diff --git a/src14/owned_proxy/scripts/src/utils.rs b/src14/owned_proxy/scripts/src/utils.rs index f19705d..808b12e 100644 --- a/src14/owned_proxy/scripts/src/utils.rs +++ b/src14/owned_proxy/scripts/src/utils.rs @@ -14,7 +14,7 @@ abigen!(Contract( pub mod proxy_abi_calls { - use super::*; + use super::{CallResponse, ContractId, ProxyContract, State, WalletUnlocked}; pub async fn set_proxy_target( contract: &ProxyContract, diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 51bebee..0a6e79b 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -1,15 +1,15 @@ -[package] -name = "sway-standard-implementations-tests" -version = "0.0.0" -authors = ["Fuel Labs "] -edition = "2021" -license = "Apache-2.0" - -[dependencies] -fuels = { version = "0.63.0", features = ["fuel-core-lib"] } -tokio = { version = "1.39", features = ["rt", "macros"] } - -[[test]] -harness = true -name = "sway-standard-implementations-tests" -path = "src/harness.rs" +[package] +name = "sway-standard-implementations-tests" +version = "0.0.0" +authors = ["Fuel Labs "] +edition = "2021" +license = "Apache-2.0" + +[dependencies] +fuels = { version = "0.66.4" } +tokio = { version = "1.39.3", features = ["rt", "macros"] } + +[[test]] +harness = true +name = "sway-standard-implementations-tests" +path = "src/harness.rs" diff --git a/tests/Forc.lock b/tests/Forc.lock index 737ff52..24918a9 100644 --- a/tests/Forc.lock +++ b/tests/Forc.lock @@ -1,10 +1,10 @@ [[package]] name = "core" -source = "path+from-root-E19CE48B3E858B72" +source = "path+from-root-4BB20845430AF9CF" [[package]] name = "std" -source = "git+https://github.com/fuellabs/sway?tag=v0.60.0#2f0392ee35a1e4dd80bd8034962d5b4083dfb8b6" +source = "git+https://github.com/fuellabs/sway?tag=v0.63.5#31a1d6f98395f571cd3674b492d9bf4773c55f65" dependencies = ["core"] [[package]] diff --git a/tests/fuel-toolchain.toml b/tests/fuel-toolchain.toml index ce69623..e7cb45b 100644 --- a/tests/fuel-toolchain.toml +++ b/tests/fuel-toolchain.toml @@ -1,6 +1,6 @@ [toolchain] -channel = "testnet" +channel = "testnet-2024-09-06" [components] -fuel-core = "0.27.0" -forc = "0.60.0" +forc = "0.63.5" +fuel-core = "0.35.0" diff --git a/tests/src/src14/owned_proxy/tests/functions/initialize_proxy.rs b/tests/src/src14/owned_proxy/tests/functions/initialize_proxy.rs index 6d70d67..f878e78 100644 --- a/tests/src/src14/owned_proxy/tests/functions/initialize_proxy.rs +++ b/tests/src/src14/owned_proxy/tests/functions/initialize_proxy.rs @@ -4,41 +4,51 @@ use crate::src14::owned_proxy::tests::utils::{ State, }; +use fuels::types::errors::Result; + mod success { use super::*; #[tokio::test] - async fn only_owner_may_call() { - let (_deployer, owner1, _owner2, _initial_target_id) = setup().await; + async fn only_owner_may_call() -> Result<()> { + let (_deployer, owner1, _owner2, _initial_target_id) = setup().await?; - assert_eq!(proxy_target(&owner1.proxy_contract).await.value, None); + assert_eq!(proxy_target(&owner1.proxy_contract).await?.value, None); assert_eq!( - proxy_owner(&owner1.proxy_contract).await.value, + proxy_owner(&owner1.proxy_contract).await?.value, State::Uninitialized ); - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; - assert_ne!(proxy_target(&owner1.proxy_contract).await.value, None); + assert_ne!(proxy_target(&owner1.proxy_contract).await?.value, None); assert_ne!( - proxy_owner(&owner1.proxy_contract).await.value, + proxy_owner(&owner1.proxy_contract).await?.value, State::Uninitialized ); + + Ok(()) } } mod reverts { - use super::*; + use fuels::prelude::Error; + use fuels::types::errors::transaction::Reason; #[tokio::test] - #[should_panic(expected = "CannotReinitialized")] - async fn when_not_owner() { - let (_deployer, owner1, _owner2, _initial_target_id) = setup().await; + async fn when_not_owner() -> Result<()> { + let (_deployer, owner1, _owner2, _initial_target_id) = setup().await?; + + initialize_proxy(&owner1.proxy_contract).await?; - initialize_proxy(&owner1.proxy_contract).await; + let err = initialize_proxy(&owner1.proxy_contract).await; - initialize_proxy(&owner1.proxy_contract).await; + assert!(matches!( + err.unwrap_err(), + Error::Transaction(Reason::Reverted { reason, .. } ) if reason == "CannotReinitialized" + )); + Ok(()) } } diff --git a/tests/src/src14/owned_proxy/tests/functions/mod.rs b/tests/src/src14/owned_proxy/tests/functions/mod.rs index 4f93540..5aaa52e 100644 --- a/tests/src/src14/owned_proxy/tests/functions/mod.rs +++ b/tests/src/src14/owned_proxy/tests/functions/mod.rs @@ -3,4 +3,4 @@ mod proxy_owner; mod proxy_target; mod set_proxy_owner; mod set_proxy_target; -mod target_contact_calls; +mod target_contract_calls; diff --git a/tests/src/src14/owned_proxy/tests/functions/only_proxy_owner.rs b/tests/src/src14/owned_proxy/tests/functions/only_proxy_owner.rs deleted file mode 100644 index 900e1f7..0000000 --- a/tests/src/src14/owned_proxy/tests/functions/only_proxy_owner.rs +++ /dev/null @@ -1,55 +0,0 @@ -use crate::upgradeability::tests::utils::{ - abi_calls::{only_proxy_owner, set_proxy_owner}, - test_helpers::setup, - State, -}; - -mod success { - - use super::*; - - #[tokio::test] - async fn only_owner_may_call() { - let (_deployer, owner1, _owner2) = setup().await; - - only_proxy_owner(&owner1.contract).await; - } - - #[tokio::test] - async fn only_owner_after_transfer() { - let (_deployer, owner1, owner2) = setup().await; - - only_proxy_owner(&owner1.contract).await; - - set_proxy_owner( - &owner1.contract, - State::Initialized(owner2.wallet.address().into()), - ) - .await; - - only_proxy_owner(&owner2.contract).await; - } -} - -mod reverts { - - use super::*; - - #[tokio::test] - #[should_panic(expected = "NotOwner")] - async fn when_not_owner() { - let (_deployer, _owner1, owner2) = setup().await; - - only_proxy_owner(&owner2.contract).await; - } - - #[tokio::test] - #[should_panic(expected = "NotOwner")] - async fn when_no_owner() { - let (_deployer, owner1, _owner2) = setup().await; - - set_proxy_owner(&owner1.contract, State::Revoked).await; - - only_proxy_owner(&owner1.contract).await; - } -} diff --git a/tests/src/src14/owned_proxy/tests/functions/proxy_owner.rs b/tests/src/src14/owned_proxy/tests/functions/proxy_owner.rs index 69816a4..8223940 100644 --- a/tests/src/src14/owned_proxy/tests/functions/proxy_owner.rs +++ b/tests/src/src14/owned_proxy/tests/functions/proxy_owner.rs @@ -5,35 +5,39 @@ mod success { test_helpers::setup, State, }; - + use fuels::types::errors::Result; #[tokio::test] - async fn returns_initialized_owner() { - let (_deployer, owner1, _owner2, _initial_target_id) = setup().await; + async fn returns_initialized_owner() -> Result<()> { + let (_deployer, owner1, _owner2, _initial_target_id) = setup().await?; assert_eq!( - proxy_owner(&owner1.proxy_contract).await.value, + proxy_owner(&owner1.proxy_contract).await?.value, State::Uninitialized ); - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; assert_eq!( - proxy_owner(&owner1.proxy_contract).await.value, + proxy_owner(&owner1.proxy_contract).await?.value, State::Initialized(owner1.wallet.address().into()) ); + + Ok(()) } #[tokio::test] - async fn returns_owner_on_state_change() { - let (_deployer, owner1, _owner2, _initial_target_id) = setup().await; + async fn returns_owner_on_state_change() -> Result<()> { + let (_deployer, owner1, _owner2, _initial_target_id) = setup().await?; - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; - set_proxy_owner(&owner1.proxy_contract, State::Revoked).await; + set_proxy_owner(&owner1.proxy_contract, State::Revoked).await?; assert_eq!( - proxy_owner(&owner1.proxy_contract).await.value, + proxy_owner(&owner1.proxy_contract).await?.value, State::Revoked ); + + Ok(()) } } diff --git a/tests/src/src14/owned_proxy/tests/functions/proxy_target.rs b/tests/src/src14/owned_proxy/tests/functions/proxy_target.rs index 14cc4ee..de4b9d2 100644 --- a/tests/src/src14/owned_proxy/tests/functions/proxy_target.rs +++ b/tests/src/src14/owned_proxy/tests/functions/proxy_target.rs @@ -4,18 +4,19 @@ mod success { proxy_abi_calls::{initialize_proxy, proxy_target}, test_helpers::setup, }; - + use fuels::types::errors::Result; #[tokio::test] - async fn returns_initialized_target() { - let (_deployer, owner1, _owner2, initial_target_id) = setup().await; + async fn returns_initialized_target() -> Result<()> { + let (_deployer, owner1, _owner2, initial_target_id) = setup().await?; - assert_eq!(proxy_target(&owner1.proxy_contract).await.value, None); + assert_eq!(proxy_target(&owner1.proxy_contract).await?.value, None); - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; assert_eq!( - proxy_target(&owner1.proxy_contract).await.value, + proxy_target(&owner1.proxy_contract).await?.value, Some(initial_target_id) ); + Ok(()) } } diff --git a/tests/src/src14/owned_proxy/tests/functions/set_proxy_owner.rs b/tests/src/src14/owned_proxy/tests/functions/set_proxy_owner.rs index 97bcebd..a72bb38 100644 --- a/tests/src/src14/owned_proxy/tests/functions/set_proxy_owner.rs +++ b/tests/src/src14/owned_proxy/tests/functions/set_proxy_owner.rs @@ -4,18 +4,20 @@ use crate::src14::owned_proxy::tests::utils::{ State, }; +use fuels::types::errors::Result; + mod success { use super::*; #[tokio::test] - async fn sets_a_new_owner() { - let (_deployer, owner1, owner2, _initial_target_id) = setup().await; + async fn sets_a_new_owner() -> Result<()> { + let (_deployer, owner1, owner2, _initial_target_id) = setup().await?; - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; assert_eq!( - proxy_owner(&owner1.proxy_contract).await.value, + proxy_owner(&owner1.proxy_contract).await?.value, State::Initialized(owner1.wallet.address().into()) ); @@ -23,67 +25,95 @@ mod success { &owner1.proxy_contract, State::Initialized(owner2.wallet.address().into()), ) - .await; + .await?; assert_eq!( - proxy_owner(&owner1.proxy_contract).await.value, + proxy_owner(&owner1.proxy_contract).await?.value, State::Initialized(owner2.wallet.address().into()) ); + + Ok(()) } #[tokio::test] - async fn revokes_ownership() { - let (_deployer, owner1, _owner2, _initial_target_id) = setup().await; + async fn revokes_ownership() -> Result<()> { + let (_deployer, owner1, _owner2, _initial_target_id) = setup().await?; - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; assert_eq!( - proxy_owner(&owner1.proxy_contract).await.value, + proxy_owner(&owner1.proxy_contract).await?.value, State::Initialized(owner1.wallet.address().into()) ); - set_proxy_owner(&owner1.proxy_contract, State::Revoked).await; + set_proxy_owner(&owner1.proxy_contract, State::Revoked).await?; assert_eq!( - proxy_owner(&owner1.proxy_contract).await.value, + proxy_owner(&owner1.proxy_contract).await?.value, State::Revoked ); + Ok(()) } } mod reverts { - use super::*; + use fuels::prelude::Error; + use fuels::types::errors::transaction::Reason; #[tokio::test] - #[should_panic(expected = "NotOwner")] - async fn when_called_by_non_owner() { - let (_deployer, _owner1, owner2, _initial_target_id) = setup().await; + async fn when_called_by_non_owner() -> Result<()> { + let (_deployer, _owner1, owner2, _initial_target_id) = setup().await?; - initialize_proxy(&owner2.proxy_contract).await; + initialize_proxy(&owner2.proxy_contract).await?; - set_proxy_owner( + let err = set_proxy_owner( &owner2.proxy_contract, State::Initialized(owner2.wallet.address().into()), ) .await; + + assert!(matches!( + err.unwrap_err(), + Error::Transaction( + Reason::Reverted { reason, .. } + ) if reason == "NotOwner" + )); + + Ok(()) } #[tokio::test] - #[should_panic(expected = "CannotUninitialize")] - async fn when_setting_the_new_state_to_uninitialized() { - let (_deployer, owner1, _owner2, _initial_target_id) = setup().await; + async fn when_setting_the_new_state_to_uninitialized() -> Result<()> { + let (_deployer, owner1, _owner2, _initial_target_id) = setup().await?; + + initialize_proxy(&owner1.proxy_contract).await?; + + let err = set_proxy_owner(&owner1.proxy_contract, State::Uninitialized).await; - initialize_proxy(&owner1.proxy_contract).await; + assert!(matches!( + err.unwrap_err(), + Error::Transaction( + Reason::Reverted { reason, .. } + ) if reason == "CannotUninitialize" + )); - set_proxy_owner(&owner1.proxy_contract, State::Uninitialized).await; + Ok(()) } #[tokio::test] - #[should_panic(expected = "NotOwner")] - async fn when_not_initialized() { - let (_deployer, owner1, _owner2, _initial_target_id) = setup().await; + async fn when_not_initialized() -> Result<()> { + let (_deployer, owner1, _owner2, _initial_target_id) = setup().await?; + + let err = set_proxy_owner(&owner1.proxy_contract, State::Revoked).await; + + assert!(matches!( + err.unwrap_err(), + Error::Transaction( + Reason::Reverted { reason, .. } + ) if reason == "NotOwner" + )); - set_proxy_owner(&owner1.proxy_contract, State::Revoked).await; + Ok(()) } } diff --git a/tests/src/src14/owned_proxy/tests/functions/set_proxy_target.rs b/tests/src/src14/owned_proxy/tests/functions/set_proxy_target.rs index dca0521..fc585df 100644 --- a/tests/src/src14/owned_proxy/tests/functions/set_proxy_target.rs +++ b/tests/src/src14/owned_proxy/tests/functions/set_proxy_target.rs @@ -2,55 +2,71 @@ use crate::src14::owned_proxy::tests::utils::{ proxy_abi_calls::{initialize_proxy, proxy_target, set_proxy_target}, test_helpers::{deploy_target_contract, setup, INITIAL_INCREMENT_AMOUNT}, }; - +use fuels::types::errors::Result; mod success { use super::*; #[tokio::test] - async fn sets_a_new_target() { - let (deployer, owner1, _owner2, initial_target_id) = setup().await; + async fn sets_a_new_target() -> Result<()> { + let (deployer, owner1, _owner2, initial_target_id) = setup().await?; - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; assert_eq!( - proxy_target(&owner1.proxy_contract).await.value, + proxy_target(&owner1.proxy_contract).await?.value, Some(initial_target_id) ); let second_target_id = - deploy_target_contract(&deployer.wallet, 100 * INITIAL_INCREMENT_AMOUNT).await; + deploy_target_contract(&deployer.wallet, 100 * INITIAL_INCREMENT_AMOUNT).await?; assert_ne!(initial_target_id, second_target_id); - set_proxy_target(&owner1.proxy_contract, second_target_id).await; + set_proxy_target(&owner1.proxy_contract, second_target_id).await?; assert_eq!( - proxy_target(&owner1.proxy_contract).await.value, + proxy_target(&owner1.proxy_contract).await?.value, Some(second_target_id) ); + Ok(()) } } mod reverts { - use super::*; + use fuels::prelude::Error; + use fuels::types::errors::transaction::Reason; #[tokio::test] - #[should_panic(expected = "NotOwner")] - async fn when_called_by_non_owner() { - let (_deployer, _owner1, owner2, initial_target_id) = setup().await; + async fn when_called_by_non_owner() -> Result<()> { + let (_deployer, _owner1, owner2, initial_target_id) = setup().await?; + + initialize_proxy(&owner2.proxy_contract).await?; - initialize_proxy(&owner2.proxy_contract).await; + let err = set_proxy_target(&owner2.proxy_contract, initial_target_id).await; - set_proxy_target(&owner2.proxy_contract, initial_target_id).await; + assert!(matches!( + err.unwrap_err(), + Error::Transaction( + Reason::Reverted { reason, .. } ) if reason == "NotOwner" + )); + + Ok(()) } #[tokio::test] - #[should_panic(expected = "NotOwner")] - async fn when_not_initialized() { - let (_deployer, owner1, _owner2, initial_target_id) = setup().await; + async fn when_not_initialized() -> Result<()> { + let (_deployer, owner1, _owner2, initial_target_id) = setup().await?; + + let err = set_proxy_target(&owner1.proxy_contract, initial_target_id).await; + + assert!(matches!( + err.unwrap_err(), + Error::Transaction( + Reason::Reverted { reason, .. } ) if reason == "NotOwner" + )); - set_proxy_target(&owner1.proxy_contract, initial_target_id).await; + Ok(()) } } diff --git a/tests/src/src14/owned_proxy/tests/functions/target_contact_calls.rs b/tests/src/src14/owned_proxy/tests/functions/target_contract_calls.rs similarity index 68% rename from tests/src/src14/owned_proxy/tests/functions/target_contact_calls.rs rename to tests/src/src14/owned_proxy/tests/functions/target_contract_calls.rs index 7254e23..014130e 100644 --- a/tests/src/src14/owned_proxy/tests/functions/target_contact_calls.rs +++ b/tests/src/src14/owned_proxy/tests/functions/target_contract_calls.rs @@ -4,6 +4,8 @@ use crate::src14::owned_proxy::tests::utils::{ test_helpers::{deploy_target_contract, setup, INITIAL_INCREMENT_AMOUNT}, }; +use fuels::types::errors::Result; + mod success { use super::*; @@ -11,111 +13,125 @@ mod success { const SECOND_INCREMENT_AMOUNT: u64 = 20 * INITIAL_INCREMENT_AMOUNT; #[tokio::test] - async fn calls_pure_method_with_initial_target() { - let (_deployer, owner1, _owner2, initial_target_id) = setup().await; + async fn calls_pure_method_with_initial_target() -> Result<()> { + let (_deployer, owner1, _owner2, initial_target_id) = setup().await?; - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; // Use target contract method at proxy contract ID assert_eq!( sum(&owner1.target_contract, initial_target_id.into(), 1, 2) - .await + .await? .value, 3 ); + + Ok(()) } #[tokio::test] - async fn calls_read_and_write_methods_with_initial_target() { - let (_deployer, owner1, _owner2, initial_target_id) = setup().await; + async fn calls_read_and_write_methods_with_initial_target() -> Result<()> { + let (_deployer, owner1, _owner2, initial_target_id) = setup().await?; - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; // Use target contract methods at proxy contract ID - increment_amount(&owner1.target_contract, initial_target_id.into()).await; + increment_amount(&owner1.target_contract, initial_target_id.into()).await?; assert_eq!( read_amount(&owner1.target_contract, initial_target_id.into()) - .await + .await? .value, INITIAL_INCREMENT_AMOUNT ); - increment_amount(&owner1.target_contract, initial_target_id.into()).await; + increment_amount(&owner1.target_contract, initial_target_id.into()).await?; assert_eq!( read_amount(&owner1.target_contract, initial_target_id.into()) - .await + .await? .value, 2 * INITIAL_INCREMENT_AMOUNT ); + + Ok(()) } #[tokio::test] - async fn calls_pure_method_with_second_target() { - let (deployer, owner1, _owner2, initial_target_id) = setup().await; + async fn calls_pure_method_with_second_target() -> Result<()> { + let (deployer, owner1, _owner2, initial_target_id) = setup().await?; - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; let second_target_id = - deploy_target_contract(&deployer.wallet, SECOND_INCREMENT_AMOUNT).await; + deploy_target_contract(&deployer.wallet, SECOND_INCREMENT_AMOUNT).await?; assert_ne!(initial_target_id, second_target_id); - set_proxy_target(&owner1.proxy_contract, second_target_id).await; + set_proxy_target(&owner1.proxy_contract, second_target_id).await?; // Use target contract method at proxy contract ID assert_eq!( sum(&owner1.target_contract, second_target_id.into(), 1, 2) - .await + .await? .value, 3 ); + + Ok(()) } #[tokio::test] - async fn calls_read_and_write_methods_with_second_target() { - let (deployer, owner1, _owner2, initial_target_id) = setup().await; + async fn calls_read_and_write_methods_with_second_target() -> Result<()> { + let (deployer, owner1, _owner2, initial_target_id) = setup().await?; - initialize_proxy(&owner1.proxy_contract).await; + initialize_proxy(&owner1.proxy_contract).await?; let second_target_id = - deploy_target_contract(&deployer.wallet, SECOND_INCREMENT_AMOUNT).await; + deploy_target_contract(&deployer.wallet, SECOND_INCREMENT_AMOUNT).await?; assert_ne!(initial_target_id, second_target_id); - set_proxy_target(&owner1.proxy_contract, second_target_id).await; + set_proxy_target(&owner1.proxy_contract, second_target_id).await?; // Use target contract methods at proxy contract ID - increment_amount(&owner1.target_contract, second_target_id.into()).await; + increment_amount(&owner1.target_contract, second_target_id.into()).await?; assert_eq!( read_amount(&owner1.target_contract, second_target_id.into()) - .await + .await? .value, SECOND_INCREMENT_AMOUNT ); - increment_amount(&owner1.target_contract, second_target_id.into()).await; + increment_amount(&owner1.target_contract, second_target_id.into()).await?; assert_eq!( read_amount(&owner1.target_contract, second_target_id.into()) - .await + .await? .value, 2 * SECOND_INCREMENT_AMOUNT ); + Ok(()) } } mod reverts { - use super::*; + use fuels::prelude::Error; + use fuels::types::errors::transaction::Reason; #[tokio::test] - #[should_panic(expected = "Revert(0)")] - async fn when_target_is_not_set() { - let (_deployer, owner1, _owner2, initial_target_id) = setup().await; + async fn when_target_is_not_set() -> Result<()> { + let (_deployer, owner1, _owner2, initial_target_id) = setup().await?; + + let err = read_amount(&owner1.target_contract, initial_target_id.into()).await; + + assert!(matches!( + err.unwrap_err(), + Error::Transaction(Reason::Reverted { reason, .. } ) if reason == "Revert(0)" + )); - read_amount(&owner1.target_contract, initial_target_id.into()).await; + Ok(()) } } diff --git a/tests/src/src14/owned_proxy/tests/utils/mod.rs b/tests/src/src14/owned_proxy/tests/utils/mod.rs index 81ceebc..c9d28e5 100644 --- a/tests/src/src14/owned_proxy/tests/utils/mod.rs +++ b/tests/src/src14/owned_proxy/tests/utils/mod.rs @@ -3,9 +3,12 @@ use fuels::{ abigen, launch_custom_provider_and_get_wallets, Contract, ContractId, LoadConfiguration, StorageConfiguration, TxPolicies, WalletUnlocked, WalletsConfig, }, - programs::call_response::FuelCallResponse, + programs::responses::CallResponse, + types::bech32::Bech32ContractId, }; +use fuels::types::errors::Result; + // Load abi from json abigen!(Contract( name = "ProxyContract", @@ -29,48 +32,42 @@ pub mod proxy_abi_calls { pub async fn set_proxy_target( contract: &ProxyContract, new_target: ContractId, - ) -> FuelCallResponse<()> { - contract - .methods() - .set_proxy_target(new_target) - .call() - .await - .unwrap() + ) -> Result> { + contract.methods().set_proxy_target(new_target).call().await } pub async fn proxy_target( contract: &ProxyContract, - ) -> FuelCallResponse> { - contract.methods().proxy_target().call().await.unwrap() + ) -> Result>> { + contract.methods().proxy_target().call().await } - pub async fn proxy_owner(contract: &ProxyContract) -> FuelCallResponse { - contract.methods().proxy_owner().call().await.unwrap() + pub async fn proxy_owner( + contract: &ProxyContract, + ) -> Result> { + contract.methods().proxy_owner().call().await } pub async fn initialize_proxy( contract: &ProxyContract, - ) -> FuelCallResponse<()> { - contract.methods().initialize_proxy().call().await.unwrap() + ) -> Result> { + contract.methods().initialize_proxy().call().await } pub async fn set_proxy_owner( contract: &ProxyContract, new_proxy_owner: State, - ) -> FuelCallResponse<()> { + ) -> Result> { contract .methods() .set_proxy_owner(new_proxy_owner) .call() .await - .unwrap() } } pub mod target_abi_calls { - use fuels::types::bech32::Bech32ContractId; - use super::*; pub async fn sum( @@ -78,90 +75,83 @@ pub mod target_abi_calls { implementation_contract_id: Bech32ContractId, a: u64, b: u64, - ) -> FuelCallResponse { + ) -> Result> { contract .methods() .sum(a, b) .with_contract_ids(&[implementation_contract_id]) .call() .await - .unwrap() } pub async fn read_amount( contract: &TargetContract, implementation_contract_id: Bech32ContractId, - ) -> FuelCallResponse { + ) -> Result> { contract .methods() .read_amount() .with_contract_ids(&[implementation_contract_id]) .call() .await - .unwrap() } pub async fn increment_amount( contract: &TargetContract, implementation_contract_id: Bech32ContractId, - ) -> FuelCallResponse<()> { + ) -> Result> { contract .methods() .increment_amount() .with_contract_ids(&[implementation_contract_id]) .call() .await - .unwrap() } } pub mod test_helpers { use super::*; + use fuels::test_helpers::{ChainConfig, NodeConfig}; pub const INITIAL_INCREMENT_AMOUNT: u64 = 1; pub async fn deploy_target_contract( deployer_wallet: &WalletUnlocked, increment_amount: u64, - ) -> ContractId { + ) -> Result { let storage_configuration = StorageConfiguration::default() .add_slot_overrides_from_file( "src/src14/owned_proxy/test_artifacts/target_contract/out/release/target_contract-storage_slots.json", - ) - .unwrap(); + )?; - let configurables = TargetContractConfigurables::default() - .with_INCREMENT_AMOUNT(increment_amount) - .unwrap(); + let configurables = + TargetContractConfigurables::default().with_INCREMENT_AMOUNT(increment_amount)?; let configuration = LoadConfiguration::default() .with_storage_configuration(storage_configuration) .with_configurables(configurables); - Contract::load_from( + Ok(Contract::load_from( "src/src14/owned_proxy/test_artifacts/target_contract/out/release/target_contract.bin", configuration, - ) - .unwrap() + )? .deploy(deployer_wallet, TxPolicies::default()) - .await - .unwrap() - .into() + .await? + .into()) } - pub async fn setup() -> (Metadata, Metadata, Metadata, ContractId) { + pub async fn setup() -> Result<(Metadata, Metadata, Metadata, ContractId)> { let num_wallets = 3; let coins_per_wallet = 1; let coin_amount = 1_000_000; + let mut wallets = launch_custom_provider_and_get_wallets( WalletsConfig::new(Some(num_wallets), Some(coins_per_wallet), Some(coin_amount)), - None, - None, + Some(NodeConfig::default()), + Some(ChainConfig::default()), ) - .await - .unwrap(); - + .await?; // Get the wallets from that provider let deploy_wallet = wallets.pop().unwrap(); let owner1 = wallets.pop().unwrap(); @@ -169,20 +159,16 @@ pub mod test_helpers { // deploy initial target contract let initial_target_id = - deploy_target_contract(&deploy_wallet, INITIAL_INCREMENT_AMOUNT).await; + deploy_target_contract(&deploy_wallet, INITIAL_INCREMENT_AMOUNT).await?; // deploy proxy that targets the initial target contract - let storage_configuration = StorageConfiguration::default() - .add_slot_overrides_from_file( - "../src14/owned_proxy/contract/out/release/src14_owned_proxy-storage_slots.json", - ) - .unwrap(); + let storage_configuration = StorageConfiguration::default().add_slot_overrides_from_file( + "../src14/owned_proxy/contract/out/release/src14_owned_proxy-storage_slots.json", + )?; let configurables = ProxyContractConfigurables::default() - .with_INITIAL_TARGET(Some(initial_target_id)) - .unwrap() - .with_INITIAL_OWNER(State::Initialized(owner1.address().into())) - .unwrap(); + .with_INITIAL_TARGET(Some(initial_target_id))? + .with_INITIAL_OWNER(State::Initialized(owner1.address().into()))?; let configuration = LoadConfiguration::default() .with_storage_configuration(storage_configuration) @@ -191,11 +177,9 @@ pub mod test_helpers { let proxy_id = Contract::load_from( "../src14/owned_proxy/contract/out/release/src14_owned_proxy.bin", configuration, - ) - .unwrap() + )? .deploy(&deploy_wallet, TxPolicies::default()) - .await - .unwrap(); + .await?; // Use the proxy_id for both contracts; ensuring that all calls go to the proxy. let deployer = Metadata { @@ -212,10 +196,10 @@ pub mod test_helpers { let owner2 = Metadata { proxy_contract: ProxyContract::new(proxy_id.clone(), owner2.clone()), - target_contract: TargetContract::new(proxy_id.clone(), owner2.clone()), + target_contract: TargetContract::new(proxy_id, owner2.clone()), wallet: owner2.clone(), }; - (deployer, owner1, owner2, initial_target_id) + Ok((deployer, owner1, owner2, initial_target_id)) } }