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 ea52800..9ce2719 100644
Binary files a/src14/owned_proxy/contract/out/release/src14_owned_proxy.bin and b/src14/owned_proxy/contract/out/release/src14_owned_proxy.bin differ
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