From ada94074108e3c9500d490ca1304eadc5a65e1e6 Mon Sep 17 00:00:00 2001 From: DefiCake Date: Mon, 11 Dec 2023 22:50:43 +0100 Subject: [PATCH] test: adapt tests to fuels v0.53 and fuel-core v0.21 --- Cargo.lock | 398 +++++++----------- Cargo.toml | 6 +- Forc.lock | 4 +- .../tests/functions/bridge/mod.rs | 33 +- .../tests/functions/message_receiver/mod.rs | 81 ++-- .../tests/utils/builder.rs | 9 +- .../tests/utils/interface/bridge/mod.rs | 6 +- .../tests/utils/setup.rs | 36 +- .../contract-message-predicate/Cargo.toml | 1 + .../contract-message-predicate/build.rs | 8 +- .../contract-message-predicate/src/lib.rs | 6 +- .../contract-message-predicate/src/main.rs | 4 +- .../tests/harness.rs | 21 +- .../tests/utils/builder.rs | 40 +- .../tests/utils/environment.rs | 14 +- 15 files changed, 302 insertions(+), 365 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a161fc32..b2deecfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -327,6 +327,7 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", + "serde", ] [[package]] @@ -385,6 +386,9 @@ name = "bitflags" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +dependencies = [ + "serde", +] [[package]] name = "bitvec" @@ -426,17 +430,11 @@ dependencies = [ "generic-array", ] -[[package]] -name = "borrown" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "008b57b368e638ed60664350ea4f2f3647a0192173478df2736cc255a025a796" - [[package]] name = "bridge-fungible-token-contract" version = "0.3.0" dependencies = [ - "fuel-core-types 0.21.0", + "fuel-core-types", "fuels", "primitive-types", "sha3", @@ -1165,7 +1163,7 @@ dependencies = [ "sha2 0.10.8", "sha3", "thiserror", - "uuid", + "uuid 0.8.2", ] [[package]] @@ -1255,28 +1253,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "fuel-asm" -version = "0.35.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac38b692cf1d259c4576e96969ddc1b21880f3059744a730d1677b6f9fd4df" -dependencies = [ - "bitflags 1.3.2", - "serde", - "strum", -] - -[[package]] -name = "fuel-asm" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73bc3c43b0b6e55857fcdc135333e9199ca8baf257aeba64ada0b91a33dac19a" -dependencies = [ - "bitflags 1.3.2", - "serde", - "strum", -] - [[package]] name = "fuel-asm" version = "0.43.1" @@ -1284,7 +1260,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2a78a31d8c15dc8139bc8d2074d09be4c8e7ca4735707996ed8bb96f20dd29e" dependencies = [ "bitflags 2.4.0", - "fuel-types 0.43.1", + "fuel-types", + "serde", "strum", ] @@ -1292,8 +1269,9 @@ dependencies = [ name = "fuel-contract-message-predicate" version = "0.3.0" dependencies = [ - "fuel-asm 0.36.1", - "fuel-tx 0.35.4", + "fuel-asm", + "fuel-core-types", + "fuel-tx", "fuels", "hex", "insta", @@ -1303,9 +1281,9 @@ dependencies = [ [[package]] name = "fuel-core" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a14d81697373e65bd96b5a9cf030cf341aa2dc4e2c350d9ef4e94cedccf2394" +checksum = "c545fd12c8b5bbc495fd37a4fdf2548450b07b3fb26ac8ea20a10436c311e1d0" dependencies = [ "anyhow", "async-graphql", @@ -1325,7 +1303,7 @@ dependencies = [ "fuel-core-services", "fuel-core-storage", "fuel-core-txpool", - "fuel-core-types 0.20.7", + "fuel-core-types", "futures", "hex", "hyper", @@ -1343,22 +1321,22 @@ dependencies = [ "tokio-stream", "tower-http", "tracing", + "uuid 1.6.1", ] [[package]] name = "fuel-core-chain-config" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96368c110286532d74ca5e8e1a64c6753bb1762daae4ff80128f7ac6817dae8a" +checksum = "84319b8e7a3b422b0f38c6ad4abd29f48b923797b7555c3bb53151322779f9bf" dependencies = [ "anyhow", "bech32 0.9.1", "fuel-core-storage", - "fuel-core-types 0.20.7", + "fuel-core-types", "hex", "itertools 0.10.5", "postcard", - "rand", "serde", "serde_json", "serde_with 1.14.0", @@ -1367,20 +1345,21 @@ dependencies = [ [[package]] name = "fuel-core-client" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0550be44fac434cbb6a3f26a7be183b02f08fe318e6de9cc0beedf2ee1b78d15" +checksum = "ed3555027c1362e8ff1b03783399b0baa62911ffcf4254c533f3f32c98982562" dependencies = [ "anyhow", "cynic", "derive_more", "eventsource-client", - "fuel-core-types 0.20.7", + "fuel-core-types", "futures", "hex", "hyper-rustls 0.24.1", "itertools 0.10.5", "reqwest", + "schemafy_lib", "serde", "serde_json", "tai64", @@ -1390,61 +1369,61 @@ dependencies = [ [[package]] name = "fuel-core-consensus-module" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91f7bcd585fc824714f2c86575d24f6982b4a6b56d3812317d382c775d39d9c" +checksum = "50fd6d90df194b5970bf16681bfad9f917ff3f837e00c6538a8b95d2e0a6fdf9" dependencies = [ "anyhow", "fuel-core-chain-config", "fuel-core-poa", - "fuel-core-types 0.20.7", + "fuel-core-types", "tokio", ] [[package]] name = "fuel-core-database" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f065c0929817430913d666feb7a5cc6db5aa56813fc781615932e4d23eef12bc" +checksum = "fb7b7cd46a2de1df8c71b4541bf19e09870965cb6ac72ee564170f9bcc8df909" dependencies = [ "anyhow", + "derive_more", "fuel-core-storage", - "fuel-core-types 0.20.7", - "thiserror", + "fuel-core-types", ] [[package]] name = "fuel-core-executor" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d7df26df9865afcaf909992d0598287ddc8143749df306eb8d84f2c73256f0" +checksum = "f4a5ed529258ded68048806b150e190ab03dc399bdd5547096525c3419cca188" dependencies = [ "anyhow", "fuel-core-chain-config", "fuel-core-storage", - "fuel-core-types 0.20.7", + "fuel-core-types", ] [[package]] name = "fuel-core-importer" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dcb41fb3b4978817dad3b47b5c66ce52b503a94a35cdbc3f1611589c092820" +checksum = "acd700b679be3cda7561f46778aa136ba4af1048570e116d8eb1d3e0f0a316a9" dependencies = [ "anyhow", + "derive_more", "fuel-core-metrics", "fuel-core-storage", - "fuel-core-types 0.20.7", - "thiserror", + "fuel-core-types", "tokio", "tracing", ] [[package]] name = "fuel-core-metrics" -version = "0.20.8" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1098234b4e1db6ba9d7abddd72bb8f3148018991dae3050422bd407f126889" +checksum = "0f87fec36f415dd9cdc2f723f018c30985bbeeadbc7e066e27fc79f3a3e2e6f3" dependencies = [ "axum", "once_cell", @@ -1457,16 +1436,16 @@ dependencies = [ [[package]] name = "fuel-core-poa" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0af9ef2c095bec8109e9cac8a607147b0ae24b882b403ca9d49488dd473c8" +checksum = "93ef8dd121e59450d695435af4dea14d60acb41195cdd2dc64d3980aef42fbd9" dependencies = [ "anyhow", "async-trait", "fuel-core-chain-config", "fuel-core-services", "fuel-core-storage", - "fuel-core-types 0.20.7", + "fuel-core-types", "tokio", "tokio-stream", "tracing", @@ -1474,15 +1453,15 @@ dependencies = [ [[package]] name = "fuel-core-producer" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469b6f2acb428c95304669e01ba402d4cfa2339c16762db83b569de6cf91029b" +checksum = "e85951fa8159a4698a6d523fc44fd3659b9db63800fcfd9619f4283a568296ce" dependencies = [ "anyhow", "async-trait", + "derive_more", "fuel-core-storage", - "fuel-core-types 0.20.7", - "thiserror", + "fuel-core-types", "tokio", "tokio-rayon", "tracing", @@ -1490,9 +1469,9 @@ dependencies = [ [[package]] name = "fuel-core-services" -version = "0.20.8" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fed9fd24eb93aef5f4fb4b66a5f47c04501c62a8a95e738aeb61c47f7553a7" +checksum = "f2a3a0ed906c332d13802209ab5839d81e464abd14307b75f58550cf0de30430" dependencies = [ "anyhow", "async-trait", @@ -1505,21 +1484,21 @@ dependencies = [ [[package]] name = "fuel-core-storage" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4661ce0cf503bce58d5c8097851ae3f0673fcf817a6f448bb2b57cd5cd67cc25" +checksum = "33b84df7585c184d79c342833321db43c610d38bccf913acdf526e64fd292ab2" dependencies = [ "anyhow", - "fuel-core-types 0.20.7", - "fuel-vm 0.35.4", - "thiserror", + "derive_more", + "fuel-core-types", + "fuel-vm", ] [[package]] name = "fuel-core-txpool" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27a4c88f60d28c4929d1d6bf354f0285b855d23489f7fbbe8ebaa1d866923bee" +checksum = "943dec1ff13cd4fcd3c0f9ae826be09de1520bab5565916ec91cb31429c59f9a" dependencies = [ "anyhow", "async-trait", @@ -1527,7 +1506,7 @@ dependencies = [ "fuel-core-metrics", "fuel-core-services", "fuel-core-storage", - "fuel-core-types 0.20.7", + "fuel-core-types", "futures", "parking_lot", "tokio", @@ -1536,22 +1515,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "fuel-core-types" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5bbcb3d4e0e4632838ebd66e4b0b0bd50a72a045b038a3d6c20f7fe59ccd0b" -dependencies = [ - "anyhow", - "derive_more", - "fuel-vm 0.35.4", - "secrecy", - "serde", - "tai64", - "thiserror", - "zeroize", -] - [[package]] name = "fuel-core-types" version = "0.21.0" @@ -1560,8 +1523,9 @@ checksum = "91b55088841f6211b3ba452687c301fee4b9d1cf52dc6fc47f940a6681336cff" dependencies = [ "anyhow", "derive_more", - "fuel-vm 0.43.1", + "fuel-vm", "secrecy", + "serde", "tai64", "thiserror", "zeroize", @@ -1569,16 +1533,16 @@ dependencies = [ [[package]] name = "fuel-crypto" -version = "0.35.4" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b934310e10a975ae3698c54e973125345c5f77a246bb8700e1658d8c4d12cf" +checksum = "33bea0932fec1e3c77be1fd54439ee9947d8d05870631d1c83782e5b1bd8eb0a" dependencies = [ - "borrown", "coins-bip32", "coins-bip39", "ecdsa", "ed25519-dalek", - "fuel-types 0.35.4", + "fuel-types", + "k256", "lazy_static", "p256", "rand", @@ -1588,21 +1552,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "fuel-crypto" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33bea0932fec1e3c77be1fd54439ee9947d8d05870631d1c83782e5b1bd8eb0a" -dependencies = [ - "ecdsa", - "ed25519-dalek", - "fuel-types 0.43.1", - "k256", - "p256", - "sha2 0.10.8", - "zeroize", -] - [[package]] name = "fuel-derive" version = "0.43.1" @@ -1615,20 +1564,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "fuel-merkle" -version = "0.35.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9ccc8b3db24d152e88b84709c151f0b647bb213ec8fa10303ab6d55bc6e39b" -dependencies = [ - "digest 0.10.7", - "fuel-storage 0.35.4", - "hashbrown 0.13.2", - "hex", - "sha2 0.10.8", - "thiserror", -] - [[package]] name = "fuel-merkle" version = "0.43.1" @@ -1637,44 +1572,19 @@ checksum = "5a68333d5e0869ad89fcd4284b2790ba60edd5c0c63cec30713289cc820ed7ab" dependencies = [ "derive_more", "digest 0.10.7", - "fuel-storage 0.43.1", + "fuel-storage", "hashbrown 0.13.2", "hex", + "serde", "sha2 0.10.8", ] -[[package]] -name = "fuel-storage" -version = "0.35.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae188b019be59dea7f6a036c46daca5de8414906df1bfb0009dd379810d1976d" - [[package]] name = "fuel-storage" version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f20bd8cac585ccd5c51478c341b7e9807942d80e1c0e00a9b2cec8a3fb3879b" -[[package]] -name = "fuel-tx" -version = "0.35.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55b1cdcad2b54eefed5c695b8408cfc82002ea3a7529114bf6917164f757a00" -dependencies = [ - "derivative", - "fuel-asm 0.35.4", - "fuel-crypto 0.35.4", - "fuel-merkle 0.35.4", - "fuel-types 0.35.4", - "itertools 0.10.5", - "num-integer", - "rand", - "serde", - "serde_json", - "strum", - "strum_macros", -] - [[package]] name = "fuel-tx" version = "0.43.1" @@ -1684,25 +1594,17 @@ dependencies = [ "bitflags 2.4.0", "derivative", "derive_more", - "fuel-asm 0.43.1", - "fuel-crypto 0.43.1", - "fuel-merkle 0.43.1", - "fuel-types 0.43.1", + "fuel-asm", + "fuel-crypto", + "fuel-merkle", + "fuel-types", "hashbrown 0.14.0", "itertools 0.10.5", - "strum", - "strum_macros", -] - -[[package]] -name = "fuel-types" -version = "0.35.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d467a3b9deae49d7b4272b4a191b0e4b87c6ed9030a846c2d0d2c6394772832" -dependencies = [ - "hex", "rand", "serde", + "serde_json", + "strum", + "strum_macros", ] [[package]] @@ -1713,32 +1615,8 @@ checksum = "ee3eda536ec1c1c7b0e06bf4a2d7b22980a79108c66ab8f81661433b2211e21e" dependencies = [ "fuel-derive", "hex", -] - -[[package]] -name = "fuel-vm" -version = "0.35.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "781255b35b145fc39a136abfaeec15bc4556b8dbee37610d6b3eb8abe29d378b" -dependencies = [ - "async-trait", - "bitflags 1.3.2", - "derivative", - "ethnum", - "fuel-asm 0.35.4", - "fuel-crypto 0.35.4", - "fuel-merkle 0.35.4", - "fuel-storage 0.35.4", - "fuel-tx 0.35.4", - "fuel-types 0.35.4", - "itertools 0.10.5", - "paste", - "primitive-types", "rand", "serde", - "sha3", - "tai64", - "thiserror", ] [[package]] @@ -1748,22 +1626,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fef3adfffe707feb335819119351a8f0c83b2113ab010714e262f60e87959546" dependencies = [ "async-trait", + "backtrace", "bitflags 2.4.0", "derivative", "derive_more", "ethnum", - "fuel-asm 0.43.1", - "fuel-crypto 0.43.1", - "fuel-merkle 0.43.1", - "fuel-storage 0.43.1", - "fuel-tx 0.43.1", - "fuel-types 0.43.1", + "fuel-asm", + "fuel-crypto", + "fuel-merkle", + "fuel-storage", + "fuel-tx", + "fuel-types", "hashbrown 0.14.0", "itertools 0.10.5", "libm", "paste", "percent-encoding", "primitive-types", + "serde", "sha3", "static_assertions", "strum", @@ -1772,13 +1652,13 @@ dependencies = [ [[package]] name = "fuels" -version = "0.50.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e44490a7d415295059f37a92c6f02f060d13b0293d4dd6c27b2f24d73321a0f" +checksum = "d8ad2e6a398d3ea13edd540c29d9e6452bc3e690ab763f5373ba960f17cdae4d" dependencies = [ "fuel-core", "fuel-core-client", - "fuel-tx 0.35.4", + "fuel-tx", "fuels-accounts", "fuels-core", "fuels-macros", @@ -1788,19 +1668,19 @@ dependencies = [ [[package]] name = "fuels-accounts" -version = "0.50.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "905e1b22d5c7b6ab01f05285ea61cb7e15cdcce762263db2019c192213b03c53" +checksum = "fa6f6435a6631577fa20aedbd88c4e59d9f1541a6bbb3a7b63715e40c15790f0" dependencies = [ "async-trait", "chrono", "elliptic-curve", "eth-keystore", "fuel-core-client", - "fuel-crypto 0.35.4", - "fuel-tx 0.35.4", - "fuel-types 0.35.4", - "fuel-vm 0.35.4", + "fuel-crypto", + "fuel-tx", + "fuel-types", + "fuel-vm", "fuels-core", "hex", "rand", @@ -1814,13 +1694,13 @@ dependencies = [ [[package]] name = "fuels-code-gen" -version = "0.50.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ee789e15eaff668fa41efbcd1b6e52daa1ae195c204e1c55b64dcbfc007823" +checksum = "7a76d2517cebc47be8723312e80634b6389e0c5db34663bd1360afee504f0cfb" dependencies = [ "Inflector", "fuel-abi-types", - "itertools 0.11.0", + "itertools 0.12.0", "proc-macro2", "quote", "regex", @@ -1830,23 +1710,24 @@ dependencies = [ [[package]] name = "fuels-core" -version = "0.50.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8528f854c0e914445cefc3e5eefa7a494dd550f28b83ed965b8f9d94b5df8beb" +checksum = "c9a98b3217932b1f8f639fd4c1268923f0862166fecf7a897c3c2bd5bae8706d" dependencies = [ + "async-trait", "bech32 0.9.1", "chrono", "fuel-abi-types", - "fuel-asm 0.35.4", + "fuel-asm", "fuel-core-chain-config", "fuel-core-client", - "fuel-crypto 0.35.4", - "fuel-tx 0.35.4", - "fuel-types 0.35.4", - "fuel-vm 0.35.4", + "fuel-crypto", + "fuel-tx", + "fuel-types", + "fuel-vm", "fuels-macros", "hex", - "itertools 0.11.0", + "itertools 0.12.0", "serde", "serde_json", "sha2 0.10.8", @@ -1857,12 +1738,12 @@ dependencies = [ [[package]] name = "fuels-macros" -version = "0.50.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "708b35dbbbc6167f7f9821e3eaad803af1327ca987f1190dc9e87b5c4872c571" +checksum = "e1cb90a892ac4b1acfd6f383a7505ce5f33764495adcf9c34371bbcabf9a4042" dependencies = [ "fuels-code-gen", - "itertools 0.11.0", + "itertools 0.12.0", "proc-macro2", "quote", "rand", @@ -1871,19 +1752,19 @@ dependencies = [ [[package]] name = "fuels-programs" -version = "0.50.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "612d79594053a247146b2fabb8a32a4c32a22e4d8fd9f57671d3ed5c3bfdd952" +checksum = "3d9fd3a7722685ba45a6794374f44530732f4f2f43f507eb1ec6fd0656abacf8" dependencies = [ "async-trait", "bytes", "fuel-abi-types", - "fuel-asm 0.35.4", - "fuel-tx 0.35.4", - "fuel-types 0.35.4", + "fuel-asm", + "fuel-tx", + "fuel-types", "fuels-accounts", "fuels-core", - "itertools 0.11.0", + "itertools 0.12.0", "rand", "serde_json", "tokio", @@ -1891,17 +1772,17 @@ dependencies = [ [[package]] name = "fuels-test-helpers" -version = "0.50.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff7c621bafd44735cdd5c1b3f73b7e1a153743ffcf035471fe30a63d23ddea2" +checksum = "d5742db9887960bbd58bf0b7cb3b0adaa5e29ce4bd667d1063bbe12491c52852" dependencies = [ "fuel-core", "fuel-core-chain-config", "fuel-core-client", "fuel-core-poa", "fuel-core-services", - "fuel-tx 0.35.4", - "fuel-types 0.35.4", + "fuel-tx", + "fuel-types", "fuels-accounts", "fuels-core", "futures", @@ -2113,6 +1994,7 @@ checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" dependencies = [ "ahash", "allocator-api2", + "serde", ] [[package]] @@ -2429,9 +2311,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" dependencies = [ "either", ] @@ -2591,16 +2473,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.16" @@ -3261,6 +3133,32 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "schemafy_core" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41781ae092f4fd52c9287efb74456aea0d3b90032d2ecad272bd14dbbcb0511b" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "schemafy_lib" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e953db32579999ca98c451d80801b6f6a7ecba6127196c5387ec0774c528befa" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "schemafy_core", + "serde", + "serde_derive", + "serde_json", + "syn 1.0.109", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -4047,6 +3945,15 @@ dependencies = [ "serde", ] +[[package]] +name = "uuid" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +dependencies = [ + "getrandom", +] + [[package]] name = "version_check" version = "0.9.4" @@ -4190,14 +4097,15 @@ dependencies = [ [[package]] name = "which" -version = "4.4.2" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" dependencies = [ "either", "home", "once_cell", "rustix", + "windows-sys 0.48.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index abedb323..0b376846 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,14 +18,14 @@ rust-version = "1.72.0" [workspace.dependencies] # Dependencies from fuel-vm repository: -fuel-asm = "0.36.0" -fuel-tx = "0.35.3" +fuel-asm = "0.43.1" +fuel-tx = "0.43.1" # Dependencies from fuel-core repository: fuel-core-types = { version = "0.21.0", default-features = false } # Dependencies from fuels-rs repository: -fuels = { version = "0.50.1", features = ["fuel-core-lib"] } +fuels = { version = "0.53.0", features = ["fuel-core-lib"] } # Third-party dependencies tokio = { version = "1.32.0", features = ["rt", "macros"] } diff --git a/Forc.lock b/Forc.lock index 88defd33..24b097e3 100644 --- a/Forc.lock +++ b/Forc.lock @@ -23,7 +23,7 @@ dependencies = [ [[package]] name = "core" -source = "path+from-root-B77DA2F383183718" +source = "path+from-root-AC247AEA3D39B916" [[package]] name = "reentrancy" @@ -37,7 +37,7 @@ dependencies = ["std"] [[package]] name = "std" -source = "git+https://github.com/fuellabs/sway?tag=v0.48.1#6886ef050ce62afd3fe3186ed562fd33bd76bffa" +source = "git+https://github.com/fuellabs/sway?tag=v0.47.0#34265301c6037d51444899a99df1cfc563df6016" dependencies = ["core"] [[package]] diff --git a/packages/fungible-token/bridge-fungible-token/tests/functions/bridge/mod.rs b/packages/fungible-token/bridge-fungible-token/tests/functions/bridge/mod.rs index 463eed2d..868e8366 100644 --- a/packages/fungible-token/bridge-fungible-token/tests/functions/bridge/mod.rs +++ b/packages/fungible-token/bridge-fungible-token/tests/functions/bridge/mod.rs @@ -47,7 +47,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -57,12 +57,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -186,7 +187,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -196,12 +197,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -213,6 +215,9 @@ mod success { .expect("Could not obtain transaction status") .take_receipts(); + dbg!(&receipts); + + let refund_registered_event = bridge .log_decoder() .decode_logs_with_type::(&receipts) @@ -312,7 +317,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -322,12 +327,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -424,7 +430,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -434,12 +440,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let _tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -565,7 +572,7 @@ mod revert { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -575,12 +582,13 @@ mod revert { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let _tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -626,7 +634,7 @@ mod revert { ) .await; - let (bridge, _, _) = setup_environment( + let (bridge, _) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -670,7 +678,7 @@ mod revert { ) .await; - let (bridge, utxo_inputs, _) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -685,7 +693,6 @@ mod revert { &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; diff --git a/packages/fungible-token/bridge-fungible-token/tests/functions/message_receiver/mod.rs b/packages/fungible-token/bridge-fungible-token/tests/functions/message_receiver/mod.rs index bb6a1653..e9feff5e 100644 --- a/packages/fungible-token/bridge-fungible-token/tests/functions/message_receiver/mod.rs +++ b/packages/fungible-token/bridge-fungible-token/tests/functions/message_receiver/mod.rs @@ -43,7 +43,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -53,12 +53,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let _receipts = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -91,7 +92,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -101,12 +102,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let _receipts = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -154,7 +156,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![first_deposit_message, second_deposit_message], @@ -164,6 +166,8 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + let asset_id = get_asset_id(bridge.contract_id()); // Get the balance for the deposit contract before @@ -178,7 +182,6 @@ mod success { &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract.clone(), - &utxo_inputs.coin[..], ) .await; @@ -204,7 +207,6 @@ mod success { &wallet, utxo_inputs.message[1].clone(), utxo_inputs.contract.clone(), - &utxo_inputs.coin[..], ) .await; @@ -248,7 +250,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![first_deposit_message, second_deposit_message], @@ -258,6 +260,8 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + let asset_id = get_asset_id(bridge.contract_id()); // Get the balance for the deposit contract before @@ -272,7 +276,6 @@ mod success { &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract.clone(), - &utxo_inputs.coin[..], ) .await; @@ -298,7 +301,6 @@ mod success { &wallet, utxo_inputs.message[1].clone(), utxo_inputs.contract.clone(), - &utxo_inputs.coin[..], ) .await; @@ -366,7 +368,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -376,6 +378,8 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + let deposit_contract = create_recipient_contract(wallet.clone()).await; let asset_id = get_asset_id(bridge.contract_id()); @@ -388,7 +392,6 @@ mod success { &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -421,7 +424,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -431,6 +434,8 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + let deposit_contract = create_recipient_contract(wallet.clone()).await; let asset_id = get_asset_id(bridge.contract_id()); @@ -443,7 +448,6 @@ mod success { &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -476,7 +480,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -486,6 +490,8 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + let deposit_contract = create_recipient_contract(wallet.clone()).await; let asset_id = get_asset_id(bridge.contract_id()); @@ -498,7 +504,6 @@ mod success { &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -531,7 +536,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -541,6 +546,8 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + let deposit_contract = create_recipient_contract(wallet.clone()).await; let asset_id = get_asset_id(bridge.contract_id()); @@ -553,7 +560,6 @@ mod success { &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -593,7 +599,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -603,12 +609,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -668,7 +675,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -678,12 +685,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -743,7 +751,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -753,12 +761,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -818,7 +827,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -828,12 +837,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -896,7 +906,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -906,12 +916,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bride contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -976,7 +987,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -986,12 +997,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; @@ -1067,7 +1079,7 @@ mod success { ) .await; - let (bridge, utxo_inputs, provider) = setup_environment( + let (bridge, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message, message2], @@ -1077,12 +1089,13 @@ mod success { ) .await; + let provider = wallet.provider().expect("Needs provider"); + // Relay the test message to the bridge contract let tx_id = relay_message_to_contract( &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract.clone(), - &utxo_inputs.coin[..], ) .await; @@ -1099,7 +1112,6 @@ mod success { &wallet, utxo_inputs.message[1].clone(), utxo_inputs.contract.clone(), - &utxo_inputs.coin[..], ) .await; @@ -1183,7 +1195,7 @@ mod revert { ) .await; - let (_test_contract, utxo_inputs, _provider) = setup_environment( + let (_test_contract, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -1198,7 +1210,6 @@ mod revert { &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; diff --git a/packages/fungible-token/bridge-fungible-token/tests/utils/builder.rs b/packages/fungible-token/bridge-fungible-token/tests/utils/builder.rs index 431da3ac..903ab8fa 100644 --- a/packages/fungible-token/bridge-fungible-token/tests/utils/builder.rs +++ b/packages/fungible-token/bridge-fungible-token/tests/utils/builder.rs @@ -22,7 +22,7 @@ pub async fn build_contract_message_tx( contracts: Vec, gas_coins: &[Input], optional_outputs: &[Output], - params: TxParameters, + tx_policies: TxPolicies, network_info: NetworkInfo, wallet: &WalletUnlocked, ) -> ScriptTransaction { @@ -31,7 +31,9 @@ pub async fn build_contract_message_tx( let number_of_contracts = contracts.len(); let mut tx_inputs: Vec = Vec::with_capacity(1 + number_of_contracts + gas_coins.len()); let mut tx_outputs: Vec = Vec::new(); + let provider = wallet.provider().expect("Need to attach a provider to the wallet"); + // Start building tx list of inputs tx_inputs.push(message); for contract in contracts { @@ -58,10 +60,9 @@ pub async fn build_contract_message_tx( let mut builder = ScriptTransactionBuilder::new(network_info) .with_inputs(tx_inputs.clone()) .with_outputs(tx_outputs.clone()) - .with_tx_params(params) + .with_tx_policies(tx_policies) .with_script(script_bytecode); wallet.sign_transaction(&mut builder); - - builder.build().unwrap() + builder.build(provider).await.unwrap() } diff --git a/packages/fungible-token/bridge-fungible-token/tests/utils/interface/bridge/mod.rs b/packages/fungible-token/bridge-fungible-token/tests/utils/interface/bridge/mod.rs index 1afe6342..df8c65aa 100644 --- a/packages/fungible-token/bridge-fungible-token/tests/utils/interface/bridge/mod.rs +++ b/packages/fungible-token/bridge-fungible-token/tests/utils/interface/bridge/mod.rs @@ -1,7 +1,7 @@ use crate::utils::setup::{get_asset_id, BridgeFungibleTokenContract}; use fuels::{ accounts::wallet::WalletUnlocked, - prelude::{CallParameters, TxParameters}, + prelude::{CallParameters, TxPolicies}, programs::call_response::FuelCallResponse, types::Bits256, }; @@ -26,7 +26,7 @@ pub(crate) async fn withdraw( amount: u64, gas: u64, ) -> FuelCallResponse<()> { - let tx_params = TxParameters::new(Some(0), Some(gas), 0); + let tx_policies = TxPolicies::new(Some(0), None, Some(0), None, Some(gas)); let contract_id = contract.contract_id(); let asset_id = get_asset_id(contract_id); let call_params = CallParameters::new(amount, asset_id, gas); @@ -34,7 +34,7 @@ pub(crate) async fn withdraw( contract .methods() .withdraw(to) - .tx_params(tx_params) + .with_tx_policies(tx_policies) .call_params(call_params) .expect("Call param Error") .call() diff --git a/packages/fungible-token/bridge-fungible-token/tests/utils/setup.rs b/packages/fungible-token/bridge-fungible-token/tests/utils/setup.rs index 0650c236..76ed165e 100644 --- a/packages/fungible-token/bridge-fungible-token/tests/utils/setup.rs +++ b/packages/fungible-token/bridge-fungible-token/tests/utils/setup.rs @@ -18,8 +18,8 @@ use fuels::{ }, prelude::{ abigen, launch_provider_and_get_wallet, setup_custom_assets_coins, setup_test_provider, - Address, AssetConfig, AssetId, Bech32ContractId, Config, Contract, ContractId, - LoadConfiguration, Provider, TxParameters, + Address, AssetConfig, AssetId, Bech32ContractId, Contract, ContractId, + LoadConfiguration, Provider, TxPolicies, }, test_helpers::{setup_single_message, DEFAULT_COIN_AMOUNT}, types::{input::Input, message::Message, Bits256}, @@ -175,7 +175,6 @@ pub(crate) async fn setup_environment( ) -> ( BridgeFungibleTokenContract, UTXOInputs, - Provider, ) { // Generate coins for wallet let asset_configs: Vec = coins @@ -214,13 +213,13 @@ pub(crate) async fn setup_environment( let provider = setup_test_provider( all_coins.clone(), all_messages.clone(), - Some(Config::local_node()), None, + None ) .await .unwrap(); - wallet.set_provider(provider.clone()); + wallet.set_provider(provider); // Set up the bridge contract instance let load_configuration = match configurables { @@ -231,7 +230,7 @@ pub(crate) async fn setup_environment( let test_contract_id = Contract::load_from(BRIDGE_FUNGIBLE_TOKEN_CONTRACT_BINARY, load_configuration) .unwrap() - .deploy(&wallet.clone(), TxParameters::default()) + .deploy(&wallet.clone(), TxPolicies::default()) .await .unwrap(); @@ -280,8 +279,7 @@ pub(crate) async fn setup_environment( contract: contract_inputs, coin: coin_inputs, message: message_inputs, - }, - provider, + } ) } @@ -290,19 +288,26 @@ pub(crate) async fn relay_message_to_contract( wallet: &WalletUnlocked, message: Input, contracts: Vec, - gas_coins: &[Input], ) -> TxId { let provider = wallet.provider().expect("Wallet has no provider"); let network_info = provider.network_info().await.unwrap(); let gas_price = network_info.min_gas_price; - let params: TxParameters = TxParameters::new(Some(gas_price), Some(30_000), 0); + let tx_policies = TxPolicies::new(Some(gas_price), None, Some(0), None, Some(30_000)); + + let fetched_gas_coins: Vec = provider.get_coins(wallet.address(), Default::default()) + .await + .unwrap() + .iter() + .map(|el| { Input::resource_signed(fuels::types::coin_type::CoinType::Coin(el.clone())) }) + .collect(); + let tx = builder::build_contract_message_tx( message, contracts, - gas_coins, + &fetched_gas_coins, &[Output::variable(Address::zeroed(), 0, AssetId::default())], - params, + tx_policies, network_info, wallet, ) @@ -360,7 +365,7 @@ pub(crate) async fn create_token() -> BridgeFungibleTokenContract (BridgeFungibleTokenContract ) .await; - let (contract, utxo_inputs, _) = setup_environment( + let (contract, utxo_inputs) = setup_environment( &mut wallet, vec![coin], vec![message], @@ -515,7 +520,6 @@ pub(crate) async fn setup_test() -> (BridgeFungibleTokenContract &wallet, utxo_inputs.message[0].clone(), utxo_inputs.contract, - &utxo_inputs.coin[..], ) .await; diff --git a/packages/message-predicates/contract-message-predicate/Cargo.toml b/packages/message-predicates/contract-message-predicate/Cargo.toml index d6ce161e..9a74a32b 100644 --- a/packages/message-predicates/contract-message-predicate/Cargo.toml +++ b/packages/message-predicates/contract-message-predicate/Cargo.toml @@ -17,6 +17,7 @@ fuel-tx = { workspace = true } sha2 = "0.10.6" [dev-dependencies] +fuel-core-types = { workspace = true } fuels = { workspace = true, features = ["fuel-core-lib"] } hex = { workspace = true } insta = "1.28" diff --git a/packages/message-predicates/contract-message-predicate/build.rs b/packages/message-predicates/contract-message-predicate/build.rs index 9f5b6ca1..56b72132 100644 --- a/packages/message-predicates/contract-message-predicate/build.rs +++ b/packages/message-predicates/contract-message-predicate/build.rs @@ -1,4 +1,4 @@ -use fuel_tx::{ConsensusParameters, Input}; +use fuel_tx::Input; use sha2::{Digest, Sha256}; use std::{env, fs, path::Path}; @@ -19,9 +19,9 @@ pub fn script_hash() -> [u8; 32] { } // Gets the root of the message-to-contract predicate -pub fn predicate_root(cparams: &ConsensusParameters) -> [u8; 32] { +pub fn predicate_root() -> [u8; 32] { let predicate = predicate_asm::bytecode(); - let root = Input::predicate_owner(predicate, &cparams.chain_id); + let root = Input::predicate_owner(predicate); root.into() } @@ -34,7 +34,7 @@ fn main() { // output to console and build files let script_hash = script_hash(); - let predicate_root = predicate_root(&ConsensusParameters::default()); + let predicate_root = predicate_root(); let script_build_path = out_dir.join(SCRIPT_BUILD_PATH); let script_hash_path = out_dir.join(SCRIPT_HASH_PATH); diff --git a/packages/message-predicates/contract-message-predicate/src/lib.rs b/packages/message-predicates/contract-message-predicate/src/lib.rs index 94a175b5..a7065145 100644 --- a/packages/message-predicates/contract-message-predicate/src/lib.rs +++ b/packages/message-predicates/contract-message-predicate/src/lib.rs @@ -1,4 +1,4 @@ -use fuel_tx::{ConsensusParameters, Input}; +use fuel_tx::Input; pub const SCRIPT_HASH: &[u8] = include_bytes!(concat!( env!("CARGO_MANIFEST_DIR"), @@ -35,8 +35,8 @@ pub fn script_hash() -> [u8; 32] { } // Gets the root of the message-to-contract predicate -pub fn predicate_root(cparams: &ConsensusParameters) -> [u8; 32] { - let root = Input::predicate_owner(PREDICATE_BYTECODE, &cparams.chain_id); +pub fn predicate_root() -> [u8; 32] { + let root = Input::predicate_owner(PREDICATE_BYTECODE); root.into() } diff --git a/packages/message-predicates/contract-message-predicate/src/main.rs b/packages/message-predicates/contract-message-predicate/src/main.rs index b8c1a8e6..e37b125a 100644 --- a/packages/message-predicates/contract-message-predicate/src/main.rs +++ b/packages/message-predicates/contract-message-predicate/src/main.rs @@ -1,4 +1,4 @@ -use fuel_tx::{Address, Bytes32, ConsensusParameters}; +use fuel_tx::{Address, Bytes32}; fn main() { //get predicate and script bytecode @@ -8,7 +8,7 @@ fn main() { //output to console and build files let script_hash = fuel_contract_message_predicate::script_hash(); let predicate_root = - fuel_contract_message_predicate::predicate_root(&ConsensusParameters::default()); + fuel_contract_message_predicate::predicate_root(); println!("Script bytecode size is {} bytes.", script.len()); println!("Script hash: 0x{}", Bytes32::from(script_hash)); println!("Predicate bytecode size is {} bytes.", predicate.len()); diff --git a/packages/message-predicates/contract-message-predicate/tests/harness.rs b/packages/message-predicates/contract-message-predicate/tests/harness.rs index b7dd0617..6f1f75ff 100644 --- a/packages/message-predicates/contract-message-predicate/tests/harness.rs +++ b/packages/message-predicates/contract-message-predicate/tests/harness.rs @@ -10,7 +10,7 @@ mod success { use crate::utils::{builder, environment as env}; use fuels::{ - prelude::{Address, AssetId, ContractId, TxParameters}, + prelude::{Address, AssetId, ContractId, TxPolicies}, test_helpers::DEFAULT_COIN_AMOUNT, tx::Bytes32, types::Bits256, @@ -92,7 +92,7 @@ mod success { coin_inputs[0].clone(), ], &[], - TxParameters::default(), + TxPolicies::default(), provider.network_info().await.unwrap(), &wallet, ) @@ -136,7 +136,7 @@ mod fail { use fuel_tx::{PanicReason, Receipt}; use fuels::{ accounts::Account, - prelude::{Address, AssetId, Salt, TxParameters}, + prelude::{Address, AssetId, Salt, TxPolicies}, test_helpers::DEFAULT_COIN_AMOUNT, types::{ coin::{Coin, CoinStatus::Unspent}, @@ -165,15 +165,14 @@ mod fail { // Transfer coins to a coin with the predicate as an owner let predicate_bytecode = fuel_contract_message_predicate::predicate_bytecode(); - let cparams = provider.consensus_parameters(); let predicate_root = - Address::from(fuel_contract_message_predicate::predicate_root(&cparams)); + Address::from(fuel_contract_message_predicate::predicate_root()); let _receipt = wallet .transfer( &predicate_root.into(), 100, AssetId::default(), - TxParameters::default(), + TxPolicies::default(), ) .await .unwrap(); @@ -202,7 +201,7 @@ mod fail { coin_as_message, &vec![contract_input.clone(), coin_inputs[0].clone()], &[], - TxParameters::default(), + TxPolicies::default(), provider.network_info().await.unwrap(), &wallet, ) @@ -239,7 +238,7 @@ mod fail { message_inputs[0].clone(), &vec![coin_inputs[0].clone()], &[], - TxParameters::default(), + TxPolicies::default(), provider.network_info().await.unwrap(), &wallet, ) @@ -277,7 +276,7 @@ mod fail { message_inputs[0].clone(), &vec![contract_input.clone(), coin_inputs[0].clone()], &[], - TxParameters::default(), + TxPolicies::default(), provider.network_info().await.unwrap(), &wallet, ) @@ -324,7 +323,7 @@ mod fail { coin_inputs[0].clone(), ], &[], - TxParameters::default(), + TxPolicies::default(), provider.network_info().await.unwrap(), &wallet, ) @@ -347,7 +346,7 @@ mod fail { message_inputs[0].clone(), &vec![contract_input.clone(), coin_inputs[0].clone()], &[], - TxParameters::default(), + TxPolicies::default(), provider.network_info().await.unwrap(), &wallet, ) diff --git a/packages/message-predicates/contract-message-predicate/tests/utils/builder.rs b/packages/message-predicates/contract-message-predicate/tests/utils/builder.rs index 5f2d36b8..957d22f9 100644 --- a/packages/message-predicates/contract-message-predicate/tests/utils/builder.rs +++ b/packages/message-predicates/contract-message-predicate/tests/utils/builder.rs @@ -1,14 +1,16 @@ use std::collections::HashMap; -use fuel_tx::{Address, AssetId, Output}; +// use fuel_tx::{Address, AssetId, Output}; +use fuel_core_types::{fuel_tx::Output, fuel_types::{Address, AssetId, Bytes32}}; + +use fuel_tx::output::contract::Contract; use fuels::{ accounts::{fuel_crypto::fuel_types::Word, wallet::WalletUnlocked, Signer}, - prelude::{ScriptTransaction, TxParameters}, - tx::Bytes32, + prelude::{ScriptTransaction, TxPolicies}, types::{ coin_type::CoinType, input::Input, - transaction_builders::{NetworkInfo, ScriptTransactionBuilder, TransactionBuilder}, + transaction_builders::{NetworkInfo, ScriptTransactionBuilder, TransactionBuilder, BuildableTransaction}, }, }; @@ -18,7 +20,7 @@ pub async fn build_contract_message_tx( message: Input, inputs: &[Input], outputs: &[Output], - params: TxParameters, + tx_policies: TxPolicies, network_info: NetworkInfo, wallet: &WalletUnlocked, ) -> ScriptTransaction { @@ -37,11 +39,13 @@ pub async fn build_contract_message_tx( } } Input::Contract { .. } => { - tx_outputs.push(Output::Contract { + let contract_output = Contract { input_index: tx_inputs.len() as u8, balance_root: Bytes32::zeroed(), - state_root: Bytes32::zeroed(), - }); + state_root: Bytes32::zeroed(), + }; + + tx_outputs.push(Output::Contract(contract_output)); } } tx_inputs.push(input.clone()); @@ -63,12 +67,13 @@ pub async fn build_contract_message_tx( let mut builder = ScriptTransactionBuilder::new(network_info) .with_inputs(tx_inputs.clone()) .with_outputs(tx_outputs.clone()) - .with_tx_params(params) + .with_tx_policies(tx_policies) .with_script(script_bytecode); wallet.sign_transaction(&mut builder); - builder.build().unwrap() + let provider = wallet.provider().expect("Needs provider"); + builder.build(provider).await.unwrap() } /// Build a message-to-contract transaction with the given input coins and outputs, but invalid script bytecode @@ -77,7 +82,7 @@ pub async fn build_invalid_contract_message_tx( message: Input, inputs: &[Input], outputs: &[Output], - params: TxParameters, + tx_policies: TxPolicies, network_info: NetworkInfo, wallet: &WalletUnlocked, ) -> ScriptTransaction { @@ -95,11 +100,13 @@ pub async fn build_invalid_contract_message_tx( } } Input::Contract { .. } => { - tx_outputs.push(Output::Contract { + let contract_output = Contract { input_index: tx_inputs.len() as u8, balance_root: Bytes32::zeroed(), - state_root: Bytes32::zeroed(), - }); + state_root: Bytes32::zeroed(), + }; + + tx_outputs.push(Output::Contract(contract_output)); } } tx_inputs.push(input.clone()); @@ -121,10 +128,11 @@ pub async fn build_invalid_contract_message_tx( let mut builder = ScriptTransactionBuilder::new(network_info) .with_inputs(tx_inputs.clone()) .with_outputs(tx_outputs.clone()) - .with_tx_params(params) + .with_tx_policies(tx_policies) .with_script(invalid_script_bytecode); wallet.sign_transaction(&mut builder); - builder.build().unwrap() + let provider = wallet.provider().expect("Needs provider"); + builder.build(provider).await.unwrap() } diff --git a/packages/message-predicates/contract-message-predicate/tests/utils/environment.rs b/packages/message-predicates/contract-message-predicate/tests/utils/environment.rs index 8a453ef8..a95c3d8c 100644 --- a/packages/message-predicates/contract-message-predicate/tests/utils/environment.rs +++ b/packages/message-predicates/contract-message-predicate/tests/utils/environment.rs @@ -4,7 +4,7 @@ use fuels::{ accounts::{fuel_crypto::SecretKey, wallet::WalletUnlocked}, prelude::{ abigen, setup_custom_assets_coins, Address, AssetConfig, AssetId, Contract, - LoadConfiguration, TxParameters, + LoadConfiguration, TxPolicies, }, test_helpers::{setup_single_message, setup_test_provider}, tx::Bytes32, @@ -14,7 +14,7 @@ use fuels::{ }, }; -use fuel_tx::{ConsensusParameters, TxId, Word}; +use fuel_tx::{TxId, Word}; use super::builder; @@ -65,9 +65,7 @@ pub async fn setup_environment( // Generate messages let message_sender = Address::from_str(MESSAGE_SENDER_ADDRESS).unwrap(); let predicate_bytecode = fuel_contract_message_predicate::predicate_bytecode(); - let predicate_root = Address::from(fuel_contract_message_predicate::predicate_root( - &ConsensusParameters::default(), - )); + let predicate_root = Address::from(fuel_contract_message_predicate::predicate_root()); let all_messages: Vec = messages .iter() @@ -95,7 +93,7 @@ pub async fn setup_environment( let test_contract_id = Contract::load_from(TEST_RECEIVER_CONTRACT_BINARY, LoadConfiguration::default()) .unwrap() - .deploy(&wallet, TxParameters::default()) + .deploy(&wallet, TxPolicies::default()) .await .unwrap(); @@ -147,7 +145,7 @@ pub async fn relay_message_to_contract( let provider = wallet.provider().expect("Wallet has no provider"); let network_info = provider.network_info().await.unwrap(); let gas_price = network_info.min_gas_price; - let params: TxParameters = TxParameters::new(Some(gas_price), Some(30_000), 0); + let tx_policies: TxPolicies = TxPolicies::new(Some(gas_price), None, Some(0), None, Some(30_000)); let inputs = [gas_coins, contracts.as_slice()].concat(); @@ -155,7 +153,7 @@ pub async fn relay_message_to_contract( message, inputs.as_slice(), &[], - params, + tx_policies, network_info, wallet, )