From 7eab0cfc4a3c8d53c47e6b52f31e29cdf7aa5db8 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Wed, 24 Apr 2024 16:06:51 +0100 Subject: [PATCH 1/4] set new encoding as true by default and allow it to be disabled --- forc-plugins/forc-client/src/cmd/deploy.rs | 3 ++- forc-plugins/forc-client/src/cmd/run.rs | 3 ++- forc-plugins/forc-client/src/op/deploy.rs | 2 +- forc-plugins/forc-client/src/op/run/mod.rs | 2 +- forc-plugins/forc-doc/src/cli.rs | 3 ++- forc-plugins/forc-doc/src/main.rs | 2 +- forc/src/cli/commands/build.rs | 4 ++-- forc/src/cli/commands/check.rs | 4 ++-- forc/src/cli/commands/contract_id.rs | 4 ++-- forc/src/cli/commands/predicate_root.rs | 4 ++-- forc/src/cli/commands/test.rs | 6 +++--- forc/src/ops/forc_build.rs | 2 +- forc/src/ops/forc_check.rs | 4 ++-- forc/src/ops/forc_contract_id.rs | 2 +- forc/src/ops/forc_predicate_root.rs | 2 +- test/src/e2e_vm_tests/harness.rs | 4 ++-- test/src/ir_generation/mod.rs | 2 +- test/src/main.rs | 6 +++--- 18 files changed, 31 insertions(+), 28 deletions(-) diff --git a/forc-plugins/forc-client/src/cmd/deploy.rs b/forc-plugins/forc-client/src/cmd/deploy.rs index 33336d135d8..01f97dad4a3 100644 --- a/forc-plugins/forc-client/src/cmd/deploy.rs +++ b/forc-plugins/forc-client/src/cmd/deploy.rs @@ -81,6 +81,7 @@ pub struct Command { #[clap(long, verbatim_doc_comment, name = "JSON_FILE_PATH")] pub override_storage_slots: Option, + /// Disable the "new encoding" feature #[clap(long)] - pub experimental_new_encoding: bool, + pub no_experimental_new_encoding: bool, } diff --git a/forc-plugins/forc-client/src/cmd/run.rs b/forc-plugins/forc-client/src/cmd/run.rs index 5a1e4f6ec34..872b96dbb61 100644 --- a/forc-plugins/forc-client/src/cmd/run.rs +++ b/forc-plugins/forc-client/src/cmd/run.rs @@ -59,6 +59,7 @@ pub struct Command { #[clap(long)] pub args: Option>, + /// Disable the "new encoding" feature #[clap(long)] - pub experimental_new_encoding: bool, + pub no_experimental_new_encoding: bool, } diff --git a/forc-plugins/forc-client/src/op/deploy.rs b/forc-plugins/forc-client/src/op/deploy.rs index 8c2259adaf0..ee2f2bef3c2 100644 --- a/forc-plugins/forc-client/src/op/deploy.rs +++ b/forc-plugins/forc-client/src/op/deploy.rs @@ -348,7 +348,7 @@ fn build_opts_from_cmd(cmd: &cmd::Deploy) -> pkg::BuildOpts { tests: false, member_filter: pkg::MemberFilter::only_contracts(), experimental: ExperimentalFlags { - new_encoding: cmd.experimental_new_encoding, + new_encoding: !cmd.no_experimental_new_encoding, }, } } diff --git a/forc-plugins/forc-client/src/op/run/mod.rs b/forc-plugins/forc-client/src/op/run/mod.rs index 4d87cca8f53..523f9dcd4e8 100644 --- a/forc-plugins/forc-client/src/op/run/mod.rs +++ b/forc-plugins/forc-client/src/op/run/mod.rs @@ -240,7 +240,7 @@ fn build_opts_from_cmd(cmd: &cmd::Run) -> pkg::BuildOpts { tests: false, member_filter: pkg::MemberFilter::only_scripts(), experimental: ExperimentalFlags { - new_encoding: cmd.experimental_new_encoding, + new_encoding: !cmd.no_experimental_new_encoding, }, } } diff --git a/forc-plugins/forc-doc/src/cli.rs b/forc-plugins/forc-doc/src/cli.rs index e35d0271576..220ef038bfd 100644 --- a/forc-plugins/forc-doc/src/cli.rs +++ b/forc-plugins/forc-doc/src/cli.rs @@ -53,6 +53,7 @@ pub struct Command { #[cfg(test)] pub(crate) doc_path: Option, + /// Disable the "new encoding" feature #[clap(long)] - pub experimental_new_encoding: bool, + pub no_experimental_new_encoding: bool, } diff --git a/forc-plugins/forc-doc/src/main.rs b/forc-plugins/forc-doc/src/main.rs index 38c9204bee9..fedaaa412d3 100644 --- a/forc-plugins/forc-doc/src/main.rs +++ b/forc-plugins/forc-doc/src/main.rs @@ -57,7 +57,7 @@ pub fn main() -> Result<()> { &build_instructions, &get_doc_dir, sway_core::ExperimentalFlags { - new_encoding: build_instructions.experimental_new_encoding, + new_encoding: !build_instructions.no_experimental_new_encoding, }, )?; diff --git a/forc/src/cli/commands/build.rs b/forc/src/cli/commands/build.rs index f92a73aebb3..85b6936a188 100644 --- a/forc/src/cli/commands/build.rs +++ b/forc/src/cli/commands/build.rs @@ -33,9 +33,9 @@ pub struct Command { #[clap(long)] pub tests: bool, + /// Disable the "new encoding" feature #[clap(long)] - /// Experimental flag for the "new encoding" feature - pub experimental_new_encoding: bool, + pub no_experimental_new_encoding: bool, } pub(crate) fn exec(command: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/check.rs b/forc/src/cli/commands/check.rs index c25e05a478e..92808481fa1 100644 --- a/forc/src/cli/commands/check.rs +++ b/forc/src/cli/commands/check.rs @@ -45,9 +45,9 @@ pub struct Command { #[clap(long)] pub ipfs_node: Option, - /// Set of experimental flags + /// Disable the "new encoding" feature #[clap(long)] - pub experimental_new_encoding: bool, + pub no_experimental_new_encoding: bool, } pub(crate) fn exec(command: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/contract_id.rs b/forc/src/cli/commands/contract_id.rs index f84771d30cf..23e1cfc02f8 100644 --- a/forc/src/cli/commands/contract_id.rs +++ b/forc/src/cli/commands/contract_id.rs @@ -29,9 +29,9 @@ pub struct Command { #[clap(flatten)] pub salt: Salt, + /// Disable the "new encoding" feature #[clap(long)] - /// Experimental flag for the "new encoding" feature - pub experimental_new_encoding: bool, + pub no_experimental_new_encoding: bool, } pub(crate) fn exec(cmd: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/predicate_root.rs b/forc/src/cli/commands/predicate_root.rs index 93e948e3f5d..0bfa9a489d4 100644 --- a/forc/src/cli/commands/predicate_root.rs +++ b/forc/src/cli/commands/predicate_root.rs @@ -26,9 +26,9 @@ pub struct Command { #[clap(flatten)] pub build_profile: BuildProfile, + /// Disable the "new encoding" feature #[clap(long)] - /// Experimental flag for the "new encoding" feature - pub experimental_new_encoding: bool, + pub no_experimental_new_encoding: bool, } pub(crate) fn exec(cmd: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/test.rs b/forc/src/cli/commands/test.rs index 2625b949b69..c9b99b1d7f9 100644 --- a/forc/src/cli/commands/test.rs +++ b/forc/src/cli/commands/test.rs @@ -50,9 +50,9 @@ pub struct Command { /// threads available in your system. pub test_threads: Option, + /// Disable the "new encoding" feature #[clap(long)] - /// Experimental flag for the "new encoding" feature - pub experimental_new_encoding: bool, + pub no_experimental_new_encoding: bool, } /// The set of options provided for controlling output of a test. @@ -232,7 +232,7 @@ fn opts_from_cmd(cmd: Command) -> forc_test::TestOpts { debug_outfile: cmd.build.output.debug_file, build_target: cmd.build.build_target, experimental: ExperimentalFlags { - new_encoding: cmd.experimental_new_encoding, + new_encoding: !cmd.no_experimental_new_encoding, }, } } diff --git a/forc/src/ops/forc_build.rs b/forc/src/ops/forc_build.rs index f350ebe1c00..f66fb46bb5e 100644 --- a/forc/src/ops/forc_build.rs +++ b/forc/src/ops/forc_build.rs @@ -44,7 +44,7 @@ fn opts_from_cmd(cmd: BuildCommand) -> pkg::BuildOpts { tests: cmd.tests, member_filter: Default::default(), experimental: ExperimentalFlags { - new_encoding: cmd.experimental_new_encoding, + new_encoding: !cmd.no_experimental_new_encoding, }, } } diff --git a/forc/src/ops/forc_check.rs b/forc/src/ops/forc_check.rs index 3236d16ab54..5bbb2959bae 100644 --- a/forc/src/ops/forc_check.rs +++ b/forc/src/ops/forc_check.rs @@ -16,7 +16,7 @@ pub fn check(command: CheckCommand, engines: &Engines) -> Result<(Option Result<(Option pkg::BuildOpts { tests: false, member_filter: pkg::MemberFilter::only_contracts(), experimental: ExperimentalFlags { - new_encoding: cmd.experimental_new_encoding, + new_encoding: !cmd.no_experimental_new_encoding, }, } } diff --git a/forc/src/ops/forc_predicate_root.rs b/forc/src/ops/forc_predicate_root.rs index aeb84291e14..cb5ab336f7a 100644 --- a/forc/src/ops/forc_predicate_root.rs +++ b/forc/src/ops/forc_predicate_root.rs @@ -48,7 +48,7 @@ fn build_opts_from_cmd(cmd: PredicateRootCommand) -> pkg::BuildOpts { tests: false, member_filter: pkg::MemberFilter::only_predicates(), experimental: ExperimentalFlags { - new_encoding: cmd.experimental_new_encoding, + new_encoding: !cmd.no_experimental_new_encoding, }, } } diff --git a/test/src/e2e_vm_tests/harness.rs b/test/src/e2e_vm_tests/harness.rs index eb3844ced69..c59aec4d34b 100644 --- a/test/src/e2e_vm_tests/harness.rs +++ b/test/src/e2e_vm_tests/harness.rs @@ -82,7 +82,7 @@ pub(crate) async fn deploy_contract(file_name: &str, run_config: &RunConfig) -> true => BuildProfile::RELEASE.to_string(), false => BuildProfile::DEBUG.to_string(), }, - experimental_new_encoding: run_config.experimental.new_encoding, + no_experimental_new_encoding: !run_config.experimental.new_encoding, ..Default::default() }) .await @@ -125,7 +125,7 @@ pub(crate) async fn runs_on_node( }, contract: Some(contracts), signing_key: Some(SecretKey::from_str(SECRET_KEY).unwrap()), - experimental_new_encoding: run_config.experimental.new_encoding, + no_experimental_new_encoding: !run_config.experimental.new_encoding, ..Default::default() }; run(command).await.map(|ran_scripts| { diff --git a/test/src/ir_generation/mod.rs b/test/src/ir_generation/mod.rs index 131e64ff40d..e209eca3e62 100644 --- a/test/src/ir_generation/mod.rs +++ b/test/src/ir_generation/mod.rs @@ -535,7 +535,7 @@ fn compile_core( disable_tests: false, locked: false, ipfs_node: None, - experimental_new_encoding: experimental.new_encoding, + no_experimental_new_encoding: !experimental.new_encoding, }; let res = match forc::test::forc_check::check(check_cmd, engines) { diff --git a/test/src/main.rs b/test/src/main.rs index 4841ed4cc05..196500976fa 100644 --- a/test/src/main.rs +++ b/test/src/main.rs @@ -52,9 +52,9 @@ struct Cli { #[arg(long, visible_alias = "target")] build_target: Option, - /// Experimental flag for new encoding + /// Disable the "new encoding" feature #[arg(long)] - experimental_new_encoding: bool, + no_experimental_new_encoding: bool, /// Update all output files #[arg(long)] @@ -108,7 +108,7 @@ async fn main() -> Result<()> { release: cli.release, build_target, experimental: sway_core::ExperimentalFlags { - new_encoding: cli.experimental_new_encoding, + new_encoding: !cli.no_experimental_new_encoding, }, update_output_files: cli.update_output_files, }; From daab9e61c6e54fb129cb86cc02f208311afbe68b Mon Sep 17 00:00:00 2001 From: xunilrj Date: Wed, 24 Apr 2024 16:08:44 +0100 Subject: [PATCH 2/4] better flag name --- forc-plugins/forc-client/src/cmd/deploy.rs | 2 +- forc-plugins/forc-client/src/cmd/run.rs | 2 +- forc-plugins/forc-client/src/op/deploy.rs | 2 +- forc-plugins/forc-client/src/op/run/mod.rs | 2 +- forc-plugins/forc-doc/src/cli.rs | 2 +- forc-plugins/forc-doc/src/main.rs | 2 +- forc/src/cli/commands/build.rs | 2 +- forc/src/cli/commands/check.rs | 2 +- forc/src/cli/commands/contract_id.rs | 2 +- forc/src/cli/commands/predicate_root.rs | 2 +- forc/src/cli/commands/test.rs | 4 ++-- forc/src/ops/forc_build.rs | 2 +- forc/src/ops/forc_check.rs | 4 ++-- forc/src/ops/forc_contract_id.rs | 2 +- forc/src/ops/forc_predicate_root.rs | 2 +- test/src/e2e_vm_tests/harness.rs | 4 ++-- test/src/ir_generation/mod.rs | 2 +- test/src/main.rs | 4 ++-- 18 files changed, 22 insertions(+), 22 deletions(-) diff --git a/forc-plugins/forc-client/src/cmd/deploy.rs b/forc-plugins/forc-client/src/cmd/deploy.rs index 01f97dad4a3..cf0e8cc67a2 100644 --- a/forc-plugins/forc-client/src/cmd/deploy.rs +++ b/forc-plugins/forc-client/src/cmd/deploy.rs @@ -83,5 +83,5 @@ pub struct Command { /// Disable the "new encoding" feature #[clap(long)] - pub no_experimental_new_encoding: bool, + pub no_encoding_v1: bool, } diff --git a/forc-plugins/forc-client/src/cmd/run.rs b/forc-plugins/forc-client/src/cmd/run.rs index 872b96dbb61..e23d9f6cb43 100644 --- a/forc-plugins/forc-client/src/cmd/run.rs +++ b/forc-plugins/forc-client/src/cmd/run.rs @@ -61,5 +61,5 @@ pub struct Command { /// Disable the "new encoding" feature #[clap(long)] - pub no_experimental_new_encoding: bool, + pub no_encoding_v1: bool, } diff --git a/forc-plugins/forc-client/src/op/deploy.rs b/forc-plugins/forc-client/src/op/deploy.rs index ee2f2bef3c2..79658af5b95 100644 --- a/forc-plugins/forc-client/src/op/deploy.rs +++ b/forc-plugins/forc-client/src/op/deploy.rs @@ -348,7 +348,7 @@ fn build_opts_from_cmd(cmd: &cmd::Deploy) -> pkg::BuildOpts { tests: false, member_filter: pkg::MemberFilter::only_contracts(), experimental: ExperimentalFlags { - new_encoding: !cmd.no_experimental_new_encoding, + new_encoding: !cmd.no_encoding_v1, }, } } diff --git a/forc-plugins/forc-client/src/op/run/mod.rs b/forc-plugins/forc-client/src/op/run/mod.rs index 523f9dcd4e8..19f0cf981ee 100644 --- a/forc-plugins/forc-client/src/op/run/mod.rs +++ b/forc-plugins/forc-client/src/op/run/mod.rs @@ -240,7 +240,7 @@ fn build_opts_from_cmd(cmd: &cmd::Run) -> pkg::BuildOpts { tests: false, member_filter: pkg::MemberFilter::only_scripts(), experimental: ExperimentalFlags { - new_encoding: !cmd.no_experimental_new_encoding, + new_encoding: !cmd.no_encoding_v1, }, } } diff --git a/forc-plugins/forc-doc/src/cli.rs b/forc-plugins/forc-doc/src/cli.rs index 220ef038bfd..d3cc76f8e40 100644 --- a/forc-plugins/forc-doc/src/cli.rs +++ b/forc-plugins/forc-doc/src/cli.rs @@ -55,5 +55,5 @@ pub struct Command { /// Disable the "new encoding" feature #[clap(long)] - pub no_experimental_new_encoding: bool, + pub no_encoding_v1: bool, } diff --git a/forc-plugins/forc-doc/src/main.rs b/forc-plugins/forc-doc/src/main.rs index fedaaa412d3..c3034c96b05 100644 --- a/forc-plugins/forc-doc/src/main.rs +++ b/forc-plugins/forc-doc/src/main.rs @@ -57,7 +57,7 @@ pub fn main() -> Result<()> { &build_instructions, &get_doc_dir, sway_core::ExperimentalFlags { - new_encoding: !build_instructions.no_experimental_new_encoding, + new_encoding: !build_instructions.no_encoding_v1, }, )?; diff --git a/forc/src/cli/commands/build.rs b/forc/src/cli/commands/build.rs index 85b6936a188..ae88dfebfdc 100644 --- a/forc/src/cli/commands/build.rs +++ b/forc/src/cli/commands/build.rs @@ -35,7 +35,7 @@ pub struct Command { /// Disable the "new encoding" feature #[clap(long)] - pub no_experimental_new_encoding: bool, + pub no_encoding_v1: bool, } pub(crate) fn exec(command: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/check.rs b/forc/src/cli/commands/check.rs index 92808481fa1..4d5f41e76a3 100644 --- a/forc/src/cli/commands/check.rs +++ b/forc/src/cli/commands/check.rs @@ -47,7 +47,7 @@ pub struct Command { /// Disable the "new encoding" feature #[clap(long)] - pub no_experimental_new_encoding: bool, + pub no_encoding_v1: bool, } pub(crate) fn exec(command: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/contract_id.rs b/forc/src/cli/commands/contract_id.rs index 23e1cfc02f8..55848428aa8 100644 --- a/forc/src/cli/commands/contract_id.rs +++ b/forc/src/cli/commands/contract_id.rs @@ -31,7 +31,7 @@ pub struct Command { /// Disable the "new encoding" feature #[clap(long)] - pub no_experimental_new_encoding: bool, + pub no_encoding_v1: bool, } pub(crate) fn exec(cmd: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/predicate_root.rs b/forc/src/cli/commands/predicate_root.rs index 0bfa9a489d4..5c9cbb6bf04 100644 --- a/forc/src/cli/commands/predicate_root.rs +++ b/forc/src/cli/commands/predicate_root.rs @@ -28,7 +28,7 @@ pub struct Command { /// Disable the "new encoding" feature #[clap(long)] - pub no_experimental_new_encoding: bool, + pub no_encoding_v1: bool, } pub(crate) fn exec(cmd: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/test.rs b/forc/src/cli/commands/test.rs index c9b99b1d7f9..3c36d628ffe 100644 --- a/forc/src/cli/commands/test.rs +++ b/forc/src/cli/commands/test.rs @@ -52,7 +52,7 @@ pub struct Command { /// Disable the "new encoding" feature #[clap(long)] - pub no_experimental_new_encoding: bool, + pub no_encoding_v1: bool, } /// The set of options provided for controlling output of a test. @@ -232,7 +232,7 @@ fn opts_from_cmd(cmd: Command) -> forc_test::TestOpts { debug_outfile: cmd.build.output.debug_file, build_target: cmd.build.build_target, experimental: ExperimentalFlags { - new_encoding: !cmd.no_experimental_new_encoding, + new_encoding: !cmd.no_encoding_v1, }, } } diff --git a/forc/src/ops/forc_build.rs b/forc/src/ops/forc_build.rs index f66fb46bb5e..6dc5afba490 100644 --- a/forc/src/ops/forc_build.rs +++ b/forc/src/ops/forc_build.rs @@ -44,7 +44,7 @@ fn opts_from_cmd(cmd: BuildCommand) -> pkg::BuildOpts { tests: cmd.tests, member_filter: Default::default(), experimental: ExperimentalFlags { - new_encoding: !cmd.no_experimental_new_encoding, + new_encoding: !cmd.no_encoding_v1, }, } } diff --git a/forc/src/ops/forc_check.rs b/forc/src/ops/forc_check.rs index 5bbb2959bae..7fdb7778e77 100644 --- a/forc/src/ops/forc_check.rs +++ b/forc/src/ops/forc_check.rs @@ -16,7 +16,7 @@ pub fn check(command: CheckCommand, engines: &Engines) -> Result<(Option Result<(Option pkg::BuildOpts { tests: false, member_filter: pkg::MemberFilter::only_contracts(), experimental: ExperimentalFlags { - new_encoding: !cmd.no_experimental_new_encoding, + new_encoding: !cmd.no_encoding_v1, }, } } diff --git a/forc/src/ops/forc_predicate_root.rs b/forc/src/ops/forc_predicate_root.rs index cb5ab336f7a..79c925100f6 100644 --- a/forc/src/ops/forc_predicate_root.rs +++ b/forc/src/ops/forc_predicate_root.rs @@ -48,7 +48,7 @@ fn build_opts_from_cmd(cmd: PredicateRootCommand) -> pkg::BuildOpts { tests: false, member_filter: pkg::MemberFilter::only_predicates(), experimental: ExperimentalFlags { - new_encoding: !cmd.no_experimental_new_encoding, + new_encoding: !cmd.no_encoding_v1, }, } } diff --git a/test/src/e2e_vm_tests/harness.rs b/test/src/e2e_vm_tests/harness.rs index c59aec4d34b..68187b18492 100644 --- a/test/src/e2e_vm_tests/harness.rs +++ b/test/src/e2e_vm_tests/harness.rs @@ -82,7 +82,7 @@ pub(crate) async fn deploy_contract(file_name: &str, run_config: &RunConfig) -> true => BuildProfile::RELEASE.to_string(), false => BuildProfile::DEBUG.to_string(), }, - no_experimental_new_encoding: !run_config.experimental.new_encoding, + no_encoding_v1: !run_config.experimental.new_encoding, ..Default::default() }) .await @@ -125,7 +125,7 @@ pub(crate) async fn runs_on_node( }, contract: Some(contracts), signing_key: Some(SecretKey::from_str(SECRET_KEY).unwrap()), - no_experimental_new_encoding: !run_config.experimental.new_encoding, + no_encoding_v1: !run_config.experimental.new_encoding, ..Default::default() }; run(command).await.map(|ran_scripts| { diff --git a/test/src/ir_generation/mod.rs b/test/src/ir_generation/mod.rs index e209eca3e62..5ec90c3a3c8 100644 --- a/test/src/ir_generation/mod.rs +++ b/test/src/ir_generation/mod.rs @@ -535,7 +535,7 @@ fn compile_core( disable_tests: false, locked: false, ipfs_node: None, - no_experimental_new_encoding: !experimental.new_encoding, + no_encoding_v1: !experimental.new_encoding, }; let res = match forc::test::forc_check::check(check_cmd, engines) { diff --git a/test/src/main.rs b/test/src/main.rs index 196500976fa..f9fbc31c8c7 100644 --- a/test/src/main.rs +++ b/test/src/main.rs @@ -54,7 +54,7 @@ struct Cli { /// Disable the "new encoding" feature #[arg(long)] - no_experimental_new_encoding: bool, + no_encoding_v1: bool, /// Update all output files #[arg(long)] @@ -108,7 +108,7 @@ async fn main() -> Result<()> { release: cli.release, build_target, experimental: sway_core::ExperimentalFlags { - new_encoding: !cli.no_experimental_new_encoding, + new_encoding: !cli.no_encoding_v1, }, update_output_files: cli.update_output_files, }; From ecfe5005321d4c49e8b70a62e14a7b60539466db Mon Sep 17 00:00:00 2001 From: xunilrj Date: Wed, 24 Apr 2024 16:35:35 +0100 Subject: [PATCH 3/4] fix examples to compile with encoding v1 --- examples/Forc.lock | 147 ++++++++++++++---- examples/Forc.toml | 2 +- examples/abi_supertraits/Forc.toml | 1 - examples/advanced_storage_variables/Forc.toml | 1 + examples/arrays/Forc.toml | 1 + examples/asm_return_tuple_pointer/Forc.toml | 1 + examples/basic_storage_variables/Forc.toml | 1 + examples/cei_analysis/Forc.toml | 1 + examples/configurable_constants/Forc.toml | 1 + examples/converting_types/Forc.toml | 1 + examples/counter/Forc.toml | 1 + examples/fizzbuzz/Forc.toml | 1 + examples/hashing/Forc.toml | 1 + examples/identity/Forc.toml | 1 + examples/liquidity_pool/Forc.toml | 1 + examples/match_expressions/Forc.toml | 1 + .../Forc.toml | 1 + examples/msg_sender/Forc.toml | 1 + .../multi_contract_calls/callee/Forc.toml | 1 + .../multi_contract_calls/caller/Forc.toml | 1 + examples/native_asset/Forc.toml | 1 + examples/nested_storage_variables/Forc.toml | 1 + examples/option/Forc.toml | 1 + examples/ownership/Forc.toml | 1 + examples/ref_mut_params/Forc.toml | 1 + examples/result/Forc.toml | 1 + examples/signatures/Forc.toml | 1 + examples/storage_example/Forc.toml | 1 + examples/storage_map/Forc.toml | 1 + examples/storage_namespace/Forc.toml | 1 + examples/storage_vec/Forc.toml | 1 + examples/struct_storage_variables/Forc.toml | 1 + examples/type_aliases/Forc.toml | 1 + examples/vec/Forc.toml | 1 + examples/wallet_abi/Forc.toml | 1 + .../wallet_contract_caller_script/Forc.toml | 1 + examples/wallet_smart_contract/Forc.toml | 1 + test/src/e2e_vm_tests/harness.rs | 2 +- 38 files changed, 151 insertions(+), 35 deletions(-) diff --git a/examples/Forc.lock b/examples/Forc.lock index 53da5a74a63..e48bfc248f0 100644 --- a/examples/Forc.lock +++ b/examples/Forc.lock @@ -1,26 +1,34 @@ -[[package]] -name = "abi_supertraits" -source = "member" - [[package]] name = "advanced_storage_variables" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "array" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "asm_return_tuple_pointer" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "basic_storage_variables" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "break_and_continue" @@ -30,16 +38,23 @@ dependencies = ["core"] [[package]] name = "cei_analysis" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "configurable_constants" source = "member" +dependencies = ["core"] [[package]] name = "converting_types" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "core" @@ -48,7 +63,10 @@ source = "path+from-root-70EE78029FACCEF1" [[package]] name = "counter" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "enums" @@ -57,72 +75,114 @@ source = "member" [[package]] name = "fizzbuzz" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "hashing" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "identity" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "liquidity_pool" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "match_expressions" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "methods_and_associated_functions" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "msg_sender" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "mut_ref_params" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "native_asset" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "nested_storage_variables" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "option" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "ownership" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "result" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "signatures" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "std" @@ -132,22 +192,34 @@ dependencies = ["core"] [[package]] name = "storage_example" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "storage_map" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "storage_vec" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "struct_storage_variables" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "structs" @@ -160,22 +232,32 @@ source = "member" [[package]] name = "type_aliases" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "vec" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "wallet_abi" source = "member" -dependencies = ["std"] +dependencies = [ + "core", + "std", +] [[package]] name = "wallet_contract_caller_script" source = "member" dependencies = [ + "core", "std", "wallet_abi", ] @@ -184,6 +266,7 @@ dependencies = [ name = "wallet_smart_contract" source = "member" dependencies = [ + "core", "std", "wallet_abi", ] diff --git a/examples/Forc.toml b/examples/Forc.toml index 164c580642e..22ad5196594 100644 --- a/examples/Forc.toml +++ b/examples/Forc.toml @@ -2,7 +2,7 @@ # in the Sway repo, where each example is a package member of the workspace. [workspace] members = [ - "abi_supertraits", + # "abi_supertraits", "advanced_storage_variables", "arrays", "methods_and_associated_functions", diff --git a/examples/abi_supertraits/Forc.toml b/examples/abi_supertraits/Forc.toml index 395d01a3046..20866fe9816 100644 --- a/examples/abi_supertraits/Forc.toml +++ b/examples/abi_supertraits/Forc.toml @@ -1,6 +1,5 @@ [project] authors = ["Fuel Labs "] entry = "main.sw" -implicit-std = false license = "Apache-2.0" name = "abi_supertraits" diff --git a/examples/advanced_storage_variables/Forc.toml b/examples/advanced_storage_variables/Forc.toml index 0969100ab32..48a765d460c 100644 --- a/examples/advanced_storage_variables/Forc.toml +++ b/examples/advanced_storage_variables/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "advanced_storage_variables" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/arrays/Forc.toml b/examples/arrays/Forc.toml index 988014ff958..fcf0b2a6588 100644 --- a/examples/arrays/Forc.toml +++ b/examples/arrays/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "array" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/asm_return_tuple_pointer/Forc.toml b/examples/asm_return_tuple_pointer/Forc.toml index ecc279d34aa..db3a4b1de2b 100644 --- a/examples/asm_return_tuple_pointer/Forc.toml +++ b/examples/asm_return_tuple_pointer/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "asm_return_tuple_pointer" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/basic_storage_variables/Forc.toml b/examples/basic_storage_variables/Forc.toml index 35a74c95d94..04fc13b74d3 100644 --- a/examples/basic_storage_variables/Forc.toml +++ b/examples/basic_storage_variables/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "basic_storage_variables" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/cei_analysis/Forc.toml b/examples/cei_analysis/Forc.toml index 5b539dfbb58..879f26ec02a 100644 --- a/examples/cei_analysis/Forc.toml +++ b/examples/cei_analysis/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "cei_analysis" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/configurable_constants/Forc.toml b/examples/configurable_constants/Forc.toml index 77093087307..a01d719609c 100644 --- a/examples/configurable_constants/Forc.toml +++ b/examples/configurable_constants/Forc.toml @@ -6,3 +6,4 @@ license = "Apache-2.0" name = "configurable_constants" [dependencies] +core = { path = "../../sway-lib-core" } diff --git a/examples/converting_types/Forc.toml b/examples/converting_types/Forc.toml index d5278ed445b..11051b2f56f 100644 --- a/examples/converting_types/Forc.toml +++ b/examples/converting_types/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "converting_types" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/counter/Forc.toml b/examples/counter/Forc.toml index dc50d3fe1f1..c06a112e05f 100644 --- a/examples/counter/Forc.toml +++ b/examples/counter/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "counter" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/fizzbuzz/Forc.toml b/examples/fizzbuzz/Forc.toml index 147999d0e1b..c5a80ddf4b2 100644 --- a/examples/fizzbuzz/Forc.toml +++ b/examples/fizzbuzz/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "fizzbuzz" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/hashing/Forc.toml b/examples/hashing/Forc.toml index a2637d5c84d..1d1ca9a3abf 100644 --- a/examples/hashing/Forc.toml +++ b/examples/hashing/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "hashing" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/identity/Forc.toml b/examples/identity/Forc.toml index dfeb9804136..f6e642d51c1 100644 --- a/examples/identity/Forc.toml +++ b/examples/identity/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "identity" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/liquidity_pool/Forc.toml b/examples/liquidity_pool/Forc.toml index 7f1561c5fbd..7a7e147313d 100644 --- a/examples/liquidity_pool/Forc.toml +++ b/examples/liquidity_pool/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "liquidity_pool" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/match_expressions/Forc.toml b/examples/match_expressions/Forc.toml index b3935ba1183..13a8e058163 100644 --- a/examples/match_expressions/Forc.toml +++ b/examples/match_expressions/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "match_expressions" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/methods_and_associated_functions/Forc.toml b/examples/methods_and_associated_functions/Forc.toml index afcb203f4d9..eb1a10d72d3 100644 --- a/examples/methods_and_associated_functions/Forc.toml +++ b/examples/methods_and_associated_functions/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "methods_and_associated_functions" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/msg_sender/Forc.toml b/examples/msg_sender/Forc.toml index f1e8a739b36..395cd8d0450 100644 --- a/examples/msg_sender/Forc.toml +++ b/examples/msg_sender/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "msg_sender" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/multi_contract_calls/callee/Forc.toml b/examples/multi_contract_calls/callee/Forc.toml index 9959c9fcb97..01c38ee3ab8 100644 --- a/examples/multi_contract_calls/callee/Forc.toml +++ b/examples/multi_contract_calls/callee/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "callee" [dependencies] +core = { path = "../../../sway-lib-core" } std = { path = "../../../sway-lib-std/" } diff --git a/examples/multi_contract_calls/caller/Forc.toml b/examples/multi_contract_calls/caller/Forc.toml index ec9ddce7d28..ca6bfbb8c31 100644 --- a/examples/multi_contract_calls/caller/Forc.toml +++ b/examples/multi_contract_calls/caller/Forc.toml @@ -6,6 +6,7 @@ license = "Apache-2.0" name = "caller" [dependencies] +core = { path = "../../../sway-lib-core" } std = { path = "../../../sway-lib-std/" } [contract-dependencies] diff --git a/examples/native_asset/Forc.toml b/examples/native_asset/Forc.toml index 9dffa5014ae..06e4057cf04 100644 --- a/examples/native_asset/Forc.toml +++ b/examples/native_asset/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "native_asset" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/nested_storage_variables/Forc.toml b/examples/nested_storage_variables/Forc.toml index 580a41a66dd..a73e93d79d2 100644 --- a/examples/nested_storage_variables/Forc.toml +++ b/examples/nested_storage_variables/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "nested_storage_variables" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/option/Forc.toml b/examples/option/Forc.toml index 293c23f4068..f8228bf3f7a 100644 --- a/examples/option/Forc.toml +++ b/examples/option/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "option" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/ownership/Forc.toml b/examples/ownership/Forc.toml index c4965df213e..ebc10743324 100644 --- a/examples/ownership/Forc.toml +++ b/examples/ownership/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "ownership" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/ref_mut_params/Forc.toml b/examples/ref_mut_params/Forc.toml index ad341c0b52c..e70e57a9004 100644 --- a/examples/ref_mut_params/Forc.toml +++ b/examples/ref_mut_params/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "mut_ref_params" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/result/Forc.toml b/examples/result/Forc.toml index f3aef8f1410..2fba8a0665f 100644 --- a/examples/result/Forc.toml +++ b/examples/result/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "result" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/signatures/Forc.toml b/examples/signatures/Forc.toml index 9323308b4a3..27548df1fb7 100644 --- a/examples/signatures/Forc.toml +++ b/examples/signatures/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "signatures" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/storage_example/Forc.toml b/examples/storage_example/Forc.toml index d6b710f9bb6..bd285a88d1b 100644 --- a/examples/storage_example/Forc.toml +++ b/examples/storage_example/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "storage_example" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/storage_map/Forc.toml b/examples/storage_map/Forc.toml index ff297be54bc..60b8db1f392 100644 --- a/examples/storage_map/Forc.toml +++ b/examples/storage_map/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "storage_map" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/storage_namespace/Forc.toml b/examples/storage_namespace/Forc.toml index 35de0d1b073..cf85f8cce64 100644 --- a/examples/storage_namespace/Forc.toml +++ b/examples/storage_namespace/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "storage_namespace" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/storage_vec/Forc.toml b/examples/storage_vec/Forc.toml index fb4b3b88dbb..0cd00b7f471 100644 --- a/examples/storage_vec/Forc.toml +++ b/examples/storage_vec/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "storage_vec" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/struct_storage_variables/Forc.toml b/examples/struct_storage_variables/Forc.toml index 2112c2708ff..3f2997e49f8 100644 --- a/examples/struct_storage_variables/Forc.toml +++ b/examples/struct_storage_variables/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "struct_storage_variables" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/type_aliases/Forc.toml b/examples/type_aliases/Forc.toml index 26c78d2c01d..29ece587331 100644 --- a/examples/type_aliases/Forc.toml +++ b/examples/type_aliases/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "type_aliases" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/vec/Forc.toml b/examples/vec/Forc.toml index eab8e351288..62afd0c6ddf 100644 --- a/examples/vec/Forc.toml +++ b/examples/vec/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "vec" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/wallet_abi/Forc.toml b/examples/wallet_abi/Forc.toml index 81436867576..957d2c314ab 100644 --- a/examples/wallet_abi/Forc.toml +++ b/examples/wallet_abi/Forc.toml @@ -5,4 +5,5 @@ license = "Apache-2.0" name = "wallet_abi" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } diff --git a/examples/wallet_contract_caller_script/Forc.toml b/examples/wallet_contract_caller_script/Forc.toml index f26b7b4ee1a..4b8d87ed804 100644 --- a/examples/wallet_contract_caller_script/Forc.toml +++ b/examples/wallet_contract_caller_script/Forc.toml @@ -5,5 +5,6 @@ license = "Apache-2.0" name = "wallet_contract_caller_script" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } wallet_abi = { path = "../wallet_abi" } diff --git a/examples/wallet_smart_contract/Forc.toml b/examples/wallet_smart_contract/Forc.toml index 8abfa09f6eb..0b26e317149 100644 --- a/examples/wallet_smart_contract/Forc.toml +++ b/examples/wallet_smart_contract/Forc.toml @@ -5,5 +5,6 @@ license = "Apache-2.0" name = "wallet_smart_contract" [dependencies] +core = { path = "../../sway-lib-core" } std = { path = "../../sway-lib-std" } wallet_abi = { path = "../wallet_abi" } diff --git a/test/src/e2e_vm_tests/harness.rs b/test/src/e2e_vm_tests/harness.rs index 68187b18492..34cd7a680e1 100644 --- a/test/src/e2e_vm_tests/harness.rs +++ b/test/src/e2e_vm_tests/harness.rs @@ -82,7 +82,7 @@ pub(crate) async fn deploy_contract(file_name: &str, run_config: &RunConfig) -> true => BuildProfile::RELEASE.to_string(), false => BuildProfile::DEBUG.to_string(), }, - no_encoding_v1: !run_config.experimental.new_encoding, + no_encoding_v1: !dbg!(run_config.experimental.new_encoding), ..Default::default() }) .await From a476069eac05c264b8ee1a423f4bac2378e819f3 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Wed, 24 Apr 2024 17:00:34 +0100 Subject: [PATCH 4/4] fix abi with super traits for encoding v1 --- .../ast_node/declaration/declaration.rs | 36 +++++++++++-------- sway-core/src/type_system/info.rs | 4 +++ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs b/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs index cc94a7f3003..764c2b74299 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs @@ -278,20 +278,12 @@ impl TyDecl { Err(err) => return Ok(ty::TyDecl::ErrorRecovery(span, err)), }; - // if this ImplTrait implements a trait and not an ABI, - // we insert its methods into the context - // otherwise, if it implements an ABI, - // we insert its methods with a prefix - let emp_vec = vec![]; - let impl_trait_items = if let Ok(ty::TyDecl::TraitDecl { .. }) = - ctx.namespace().resolve_call_path_typed( - &Handler::default(), - engines, - &impl_trait.trait_name, - ctx.self_type(), - ) { - &impl_trait.items - } else { + // Insert prefixed symbols when implementing_for is Contract + let is_contract = engines + .te() + .get(impl_trait.implementing_for.type_id) + .is_contract(); + if is_contract { for i in &impl_trait.items { if let ty::TyTraitItem::Fn(f) = i { let decl = engines.de().get(f.id()); @@ -314,8 +306,22 @@ impl TyDecl { }); } } + } - &emp_vec + // Choose which items are going to be visible depending if this is an abi impl + // or trait impl + let t = ctx.namespace().resolve_call_path_typed( + &Handler::default(), + engines, + &impl_trait.trait_name, + ctx.self_type(), + ); + + let empty_vec = vec![]; + let impl_trait_items = if let Ok(ty::TyDecl::TraitDecl { .. }) = t { + &impl_trait.items + } else { + &empty_vec }; ctx.insert_trait_implementation( diff --git a/sway-core/src/type_system/info.rs b/sway-core/src/type_system/info.rs index 430278d9eb2..aab9c217b72 100644 --- a/sway-core/src/type_system/info.rs +++ b/sway-core/src/type_system/info.rs @@ -1164,6 +1164,10 @@ impl TypeInfo { matches!(self, TypeInfo::Array(_, _)) } + pub fn is_contract(&self) -> bool { + matches!(self, TypeInfo::Contract) + } + pub fn is_struct(&self) -> bool { matches!(self, TypeInfo::Struct(_)) }