diff --git a/crates/codegen/tests/fixtures/erc20.fe b/crates/codegen/tests/fixtures/erc20.fe index 3b8696812d..9a73e25477 100644 --- a/crates/codegen/tests/fixtures/erc20.fe +++ b/crates/codegen/tests/fixtures/erc20.fe @@ -1,6 +1,5 @@ use std::evm::{Address, Ctx, StorageMap, assert} use std::evm::effects::Log -use std::abi::sol // roles const MINTER: u256 = 1 diff --git a/crates/fe/tests/fixtures/build_foundry/erc20.fe b/crates/fe/tests/fixtures/build_foundry/erc20.fe index 91225df90a..724acdbdd5 100644 --- a/crates/fe/tests/fixtures/build_foundry/erc20.fe +++ b/crates/fe/tests/fixtures/build_foundry/erc20.fe @@ -1,5 +1,4 @@ use std::evm::{Ctx, Log, StorageMap} -use std::abi::sol msg Erc20 { #[selector = sol("name()")] diff --git a/crates/fe/tests/fixtures/cli_output/emit_abi/abi_contract.fe b/crates/fe/tests/fixtures/cli_output/emit_abi/abi_contract.fe index f560d0aa5c..15869df2b8 100644 --- a/crates/fe/tests/fixtures/cli_output/emit_abi/abi_contract.fe +++ b/crates/fe/tests/fixtures/cli_output/emit_abi/abi_contract.fe @@ -1,5 +1,3 @@ -use std::abi::sol - msg FooMsg { #[selector = sol("ping(uint256)")] Ping { value: u256 } -> u256, diff --git a/crates/fe/tests/fixtures/fe_test/abi_dynamic_payload.fe b/crates/fe/tests/fixtures/fe_test/abi_dynamic_payload.fe index fec79e5e6a..ef0132de66 100644 --- a/crates/fe/tests/fixtures/fe_test/abi_dynamic_payload.fe +++ b/crates/fe/tests/fixtures/fe_test/abi_dynamic_payload.fe @@ -1,4 +1,3 @@ -use std::abi::Bytes use std::evm::encode_abi_payload #[test] diff --git a/crates/fe/tests/fixtures/fe_test/address_call_method.fe b/crates/fe/tests/fixtures/fe_test/address_call_method.fe index 7bc3939cbc..ef240444b1 100644 --- a/crates/fe/tests/fixtures/fe_test/address_call_method.fe +++ b/crates/fe/tests/fixtures/fe_test/address_call_method.fe @@ -2,8 +2,6 @@ /// Address that references the Call trait) must not trigger a Salsa cycle crash /// in `collect_methods`. -use std::abi::sol - msg CounterMsg { #[selector = sol("increment()")] Increment, diff --git a/crates/fe/tests/fixtures/fe_test/ctx.fe b/crates/fe/tests/fixtures/fe_test/ctx.fe index 0de0bea708..02d3f6b33f 100644 --- a/crates/fe/tests/fixtures/fe_test/ctx.fe +++ b/crates/fe/tests/fixtures/fe_test/ctx.fe @@ -1,5 +1,4 @@ use std::evm::{Evm, Ctx, Address} -use std::abi::sol msg CtxMsg { #[selector = 0x01] diff --git a/crates/fe/tests/fixtures/fe_test/erc20.fe b/crates/fe/tests/fixtures/fe_test/erc20.fe index 76f78c1f4c..02cf67c63e 100644 --- a/crates/fe/tests/fixtures/fe_test/erc20.fe +++ b/crates/fe/tests/fixtures/fe_test/erc20.fe @@ -1,5 +1,3 @@ -use std::abi::sol - msg Erc20 { #[selector = sol("name()")] Name -> u256, diff --git a/crates/fe/tests/fixtures/fe_test/never_returning_recv_returns.fe b/crates/fe/tests/fixtures/fe_test/never_returning_recv_returns.fe index 8453a8683d..b8cf397f6c 100644 --- a/crates/fe/tests/fixtures/fe_test/never_returning_recv_returns.fe +++ b/crates/fe/tests/fixtures/fe_test/never_returning_recv_returns.fe @@ -1,4 +1,3 @@ -use core::abi::Bytes use std::evm::{Evm, assert} msg AbortMsg { diff --git a/crates/fe/tests/fixtures/fe_test/payable.fe b/crates/fe/tests/fixtures/fe_test/payable.fe index 9c3229c0cc..0c3a0acf4a 100644 --- a/crates/fe/tests/fixtures/fe_test/payable.fe +++ b/crates/fe/tests/fixtures/fe_test/payable.fe @@ -1,5 +1,4 @@ use std::evm::{Evm, Ctx, Address} -use std::abi::sol pub contract PayableBox uses (ctx: Ctx) { #[payable] diff --git a/crates/fe/tests/fixtures/fe_test/storage_bytes_encode_return.fe b/crates/fe/tests/fixtures/fe_test/storage_bytes_encode_return.fe index 512fe186f5..38cdba83f9 100644 --- a/crates/fe/tests/fixtures/fe_test/storage_bytes_encode_return.fe +++ b/crates/fe/tests/fixtures/fe_test/storage_bytes_encode_return.fe @@ -1,4 +1,3 @@ -use core::abi::Bytes use std::evm::{Address, Call, Create, Evm, RawMem, StorageBytes, assert, decode_returndata, last_returndata, mem} type Blobs = StorageBytes diff --git a/crates/fe/tests/fixtures/fe_test/storage_nested_array_stride.fe b/crates/fe/tests/fixtures/fe_test/storage_nested_array_stride.fe index ed9cfcf76e..05656d2e6f 100644 --- a/crates/fe/tests/fixtures/fe_test/storage_nested_array_stride.fe +++ b/crates/fe/tests/fixtures/fe_test/storage_nested_array_stride.fe @@ -1,7 +1,5 @@ use std::evm::{Call, Evm} use std::evm::effects::assert -use core::abi::{Abi, AbiEncoder, AbiSize, Encode} -use std::abi::Sol msg StrideMsg { #[selector = 0x3bde36f4] diff --git a/crates/fe/tests/fixtures/fe_test_runner/cross_ingot_create2/ingots/provider/src/lib.fe b/crates/fe/tests/fixtures/fe_test_runner/cross_ingot_create2/ingots/provider/src/lib.fe index 1ac921b386..7f4e6a56f2 100644 --- a/crates/fe/tests/fixtures/fe_test_runner/cross_ingot_create2/ingots/provider/src/lib.fe +++ b/crates/fe/tests/fixtures/fe_test_runner/cross_ingot_create2/ingots/provider/src/lib.fe @@ -1,5 +1,3 @@ -use std::abi::sol - pub msg GreetMsg { #[selector = sol("greet()")] Greet -> u256, diff --git a/crates/fe/tests/fixtures/fe_test_runner/dependency_diagnostic_gating/ingots/dep/src/lib.fe b/crates/fe/tests/fixtures/fe_test_runner/dependency_diagnostic_gating/ingots/dep/src/lib.fe index 7b34b7334e..5e0d97fc07 100644 --- a/crates/fe/tests/fixtures/fe_test_runner/dependency_diagnostic_gating/ingots/dep/src/lib.fe +++ b/crates/fe/tests/fixtures/fe_test_runner/dependency_diagnostic_gating/ingots/dep/src/lib.fe @@ -1,5 +1,3 @@ -use core::abi::{Abi, AbiEncoder, AbiSize, Encode} - pub enum Error { Oops, } diff --git a/crates/fe/tests/fixtures/fe_test_runner/revert_and_unwrap_or_revert.fe b/crates/fe/tests/fixtures/fe_test_runner/revert_and_unwrap_or_revert.fe index 40fd8eff23..325a526e63 100644 --- a/crates/fe/tests/fixtures/fe_test_runner/revert_and_unwrap_or_revert.fe +++ b/crates/fe/tests/fixtures/fe_test_runner/revert_and_unwrap_or_revert.fe @@ -1,5 +1,3 @@ -use core::abi::{Abi, AbiEncoder, AbiSize, Encode} - enum MyError { NotAllowed, OutOfBounds, diff --git a/crates/fe/tests/fixtures/fe_test_runner/storage_bytes_encode_return_multi_word.fe b/crates/fe/tests/fixtures/fe_test_runner/storage_bytes_encode_return_multi_word.fe index 1903134883..a71d840301 100644 --- a/crates/fe/tests/fixtures/fe_test_runner/storage_bytes_encode_return_multi_word.fe +++ b/crates/fe/tests/fixtures/fe_test_runner/storage_bytes_encode_return_multi_word.fe @@ -1,4 +1,3 @@ -use core::abi::Bytes use std::evm::{Evm, StorageBytes, assert, mem} type Blobs = StorageBytes diff --git a/crates/hir/test_files/ty_check/recv_fallback.fe b/crates/hir/test_files/ty_check/recv_fallback.fe index f2e2aea41a..f44187dead 100644 --- a/crates/hir/test_files/ty_check/recv_fallback.fe +++ b/crates/hir/test_files/ty_check/recv_fallback.fe @@ -1,5 +1,3 @@ -use std::abi::sol - msg CounterMsg { #[selector = sol("count()")] Count -> u256, diff --git a/crates/hir/test_files/ty_check/recv_fallback.snap b/crates/hir/test_files/ty_check/recv_fallback.snap index 7b682bc725..6ea5e2e8ea 100644 --- a/crates/hir/test_files/ty_check/recv_fallback.snap +++ b/crates/hir/test_files/ty_check/recv_fallback.snap @@ -4,61 +4,61 @@ expression: res input_file: test_files/ty_check/recv_fallback.fe --- note: - ┌─ recv_fallback.fe:5:5 + ┌─ recv_fallback.fe:3:5 │ -5 │ Count -> u256, +3 │ Count -> u256, │ ^^^^^ () | Count | invalid(Other) | u256 note: - ┌─ recv_fallback.fe:12:9 + ┌─ recv_fallback.fe:10:9 │ -12 │ CounterMsg::Count {} -> u256 uses (count) { +10 │ CounterMsg::Count {} -> u256 uses (count) { │ ^^^^^^^^^^^^^^^^^^^^ Count note: - ┌─ recv_fallback.fe:12:51 + ┌─ recv_fallback.fe:10:51 │ -12 │ CounterMsg::Count {} -> u256 uses (count) { +10 │ CounterMsg::Count {} -> u256 uses (count) { │ ╭───────────────────────────────────────────────────^ -13 │ │ count -14 │ │ } +11 │ │ count +12 │ │ } │ ╰─────────^ u256 note: - ┌─ recv_fallback.fe:13:13 + ┌─ recv_fallback.fe:11:13 │ -13 │ count +11 │ count │ ^^^^^ u256 note: - ┌─ recv_fallback.fe:16:9 + ┌─ recv_fallback.fe:14:9 │ -16 │ _ uses (mut count) { +14 │ _ uses (mut count) { │ ^ () note: - ┌─ recv_fallback.fe:16:28 + ┌─ recv_fallback.fe:14:28 │ -16 │ _ uses (mut count) { +14 │ _ uses (mut count) { │ ╭────────────────────────────^ -17 │ │ count += 1 -18 │ │ } +15 │ │ count += 1 +16 │ │ } │ ╰─────────^ () note: - ┌─ recv_fallback.fe:17:13 + ┌─ recv_fallback.fe:15:13 │ -17 │ count += 1 +15 │ count += 1 │ ^^^^^ u256 note: - ┌─ recv_fallback.fe:17:13 + ┌─ recv_fallback.fe:15:13 │ -17 │ count += 1 +15 │ count += 1 │ ^^^^^^^^^^ () note: - ┌─ recv_fallback.fe:17:22 + ┌─ recv_fallback.fe:15:22 │ -17 │ count += 1 +15 │ count += 1 │ ^ u256 diff --git a/crates/language-server/test_files/completion.snap b/crates/language-server/test_files/completion.snap index 55fd5a5711..bb4564a36a 100644 --- a/crates/language-server/test_files/completion.snap +++ b/crates/language-server/test_files/completion.snap @@ -11,14 +11,17 @@ note: completions: - Abi (Interface) + - AbiDecoder (Interface) - AbiEncoder (Interface) - AbiSize (Interface) - Address (Struct) + - Bytes (Struct) - Call (Interface) - Clone (Interface) - Copy (Interface) - Create (Interface) - Ctx (Interface) + - Decode (Interface) - Default (Interface) - Drawable (Interface) - Encode (Interface) @@ -56,6 +59,7 @@ completions: - revert_error (Function) -> "revert_error(${1:error})$0" [fn revert_error(error: T) -> !] - self (Variable) [self: Point] - shadow_test (Module) -> "shadow_test::" + - sol (Function) -> "sol(${1:sig})$0" [fn sol(sig: T) -> u32] - test_expression_context (Function) -> "test_expression_context()$0" [fn test_expression_context()] - test_locals (Function) -> "test_locals(${1:param})$0" [fn test_locals(param: i32)] - test_member_completion (Function) -> "test_member_completion()$0" [fn test_member_completion()] @@ -87,6 +91,7 @@ note: completions: - Address (Struct) + - Bytes (Struct) - Evm (Struct) - Helpable (Interface) [use utils::Helpable [Helpable]] {+0:use utils::Helpable} - Helper (Struct) [use utils::Helper [Helper]] {+0:use utils::Helper} @@ -122,6 +127,7 @@ completions: - result (Variable) [result: _] - revert (Function) -> "revert(${1:value})$0" [fn revert(value: T) -> !] - revert_error (Function) -> "revert_error(${1:error})$0" [fn revert_error(error: T) -> !] + - sol (Function) -> "sol(${1:sig})$0" [fn sol(sig: T) -> u32] - test_expression_context (Function) -> "test_expression_context()$0" [fn test_expression_context()] - test_locals (Function) -> "test_locals(${1:param})$0" [fn test_locals(param: i32)] - test_member_completion (Function) -> "test_member_completion()$0" [fn test_member_completion()] @@ -151,6 +157,7 @@ note: completions: - Address (Struct) + - Bytes (Struct) - Evm (Struct) - Helpable (Interface) [use utils::Helpable [Helpable]] {+0:use utils::Helpable} - Helper (Struct) [use utils::Helper [Helper]] {+0:use utils::Helper} @@ -187,6 +194,7 @@ completions: - param (Variable) [param: i32] - revert (Function) -> "revert(${1:value})$0" [fn revert(value: T) -> !] - revert_error (Function) -> "revert_error(${1:error})$0" [fn revert_error(error: T) -> !] + - sol (Function) -> "sol(${1:sig})$0" [fn sol(sig: T) -> u32] - test_expression_context (Function) -> "test_expression_context()$0" [fn test_expression_context()] - test_locals (Function) -> "test_locals(${1:param})$0" [fn test_locals(param: i32)] - test_member_completion (Function) -> "test_member_completion()$0" [fn test_member_completion()] @@ -205,6 +213,7 @@ note: completions: - Address (Struct) + - Bytes (Struct) - Evm (Struct) - Helper (Struct) - Option (Enum) @@ -225,6 +234,7 @@ note: completions: - Address (Struct) + - Bytes (Struct) - Evm (Struct) - Helpable (Interface) [use utils::Helpable [Helpable]] {+104:use utils::Helpable} - Helper (Struct) [use utils::Helper [Helper]] {+104:use utils::Helper} diff --git a/crates/uitest/fixtures/ty_check/msg_duplicate_selector_const_expr.fe b/crates/uitest/fixtures/ty_check/msg_duplicate_selector_const_expr.fe index 7cf17ef4b9..b9e3506653 100644 --- a/crates/uitest/fixtures/ty_check/msg_duplicate_selector_const_expr.fe +++ b/crates/uitest/fixtures/ty_check/msg_duplicate_selector_const_expr.fe @@ -1,8 +1,6 @@ // Test that selector attributes accept const expressions and are CTFE-evaluated // before checking for duplicates. -use std::abi::sol - msg TokenMsg { #[selector = sol("transfer(address,uint256)")] Transfer { to: u64, amount: u64 } -> bool, diff --git a/crates/uitest/fixtures/ty_check/msg_duplicate_selector_const_expr.snap b/crates/uitest/fixtures/ty_check/msg_duplicate_selector_const_expr.snap index 6a74804a34..7625b3bb51 100644 --- a/crates/uitest/fixtures/ty_check/msg_duplicate_selector_const_expr.snap +++ b/crates/uitest/fixtures/ty_check/msg_duplicate_selector_const_expr.snap @@ -4,23 +4,23 @@ expression: diags input_file: fixtures/ty_check/msg_duplicate_selector_const_expr.fe --- error[9-0004]: duplicate selector in msg block - ┌─ msg_duplicate_selector_const_expr.fe:10:5 - │ - 7 │ #[selector = sol("transfer(address,uint256)")] - │ ---------------------------------------------- `Transfer` with selector 0xa9059cbb declared here - · -10 │ #[selector = sol("many_msg_babbage(bytes1)")] - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Approve` has selector 0xa9059cbb which conflicts with `Transfer` - │ - = each variant in a msg block must have a unique selector + ┌─ msg_duplicate_selector_const_expr.fe:8:5 + │ +5 │ #[selector = sol("transfer(address,uint256)")] + │ ---------------------------------------------- `Transfer` with selector 0xa9059cbb declared here + · +8 │ #[selector = sol("many_msg_babbage(bytes1)")] + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Approve` has selector 0xa9059cbb which conflicts with `Transfer` + │ + = each variant in a msg block must have a unique selector error[9-0004]: duplicate selector in msg block - ┌─ msg_duplicate_selector_const_expr.fe:13:5 + ┌─ msg_duplicate_selector_const_expr.fe:11:5 │ - 7 │ #[selector = sol("transfer(address,uint256)")] + 5 │ #[selector = sol("transfer(address,uint256)")] │ ---------------------------------------------- `Transfer` with selector 0xa9059cbb declared here · -13 │ #[selector = 0xa9059cbb] +11 │ #[selector = 0xa9059cbb] │ ^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` has selector 0xa9059cbb which conflicts with `Transfer` │ = each variant in a msg block must have a unique selector diff --git a/crates/uitest/fixtures/ty_check/payable_on_msg_variant.fe b/crates/uitest/fixtures/ty_check/payable_on_msg_variant.fe index bc662fdbb0..3ea3d13685 100644 --- a/crates/uitest/fixtures/ty_check/payable_on_msg_variant.fe +++ b/crates/uitest/fixtures/ty_check/payable_on_msg_variant.fe @@ -1,5 +1,3 @@ -use std::abi::sol - msg M { #[payable] #[selector = sol("ping()")] diff --git a/crates/uitest/fixtures/ty_check/payable_on_msg_variant.snap b/crates/uitest/fixtures/ty_check/payable_on_msg_variant.snap index 035e98d37f..9f11b57d37 100644 --- a/crates/uitest/fixtures/ty_check/payable_on_msg_variant.snap +++ b/crates/uitest/fixtures/ty_check/payable_on_msg_variant.snap @@ -4,7 +4,7 @@ expression: diags input_file: fixtures/ty_check/payable_on_msg_variant.fe --- error[13-0003]: `#[payable]` must be placed on the corresponding `recv` arm, not the `msg` variant - ┌─ payable_on_msg_variant.fe:4:5 + ┌─ payable_on_msg_variant.fe:2:5 │ -4 │ #[payable] +2 │ #[payable] │ ^^^^^^^^^^ move this attribute to the matching `recv` arm diff --git a/crates/uitest/fixtures/ty_check/payable_on_recv_block.fe b/crates/uitest/fixtures/ty_check/payable_on_recv_block.fe index 272aa241ca..4e61ebc26b 100644 --- a/crates/uitest/fixtures/ty_check/payable_on_recv_block.fe +++ b/crates/uitest/fixtures/ty_check/payable_on_recv_block.fe @@ -1,5 +1,3 @@ -use std::abi::sol - msg M { #[selector = sol("ping()")] Ping, diff --git a/crates/uitest/fixtures/ty_check/payable_on_recv_block.snap b/crates/uitest/fixtures/ty_check/payable_on_recv_block.snap index c4e20b0c85..2372187e27 100644 --- a/crates/uitest/fixtures/ty_check/payable_on_recv_block.snap +++ b/crates/uitest/fixtures/ty_check/payable_on_recv_block.snap @@ -4,7 +4,7 @@ expression: diags input_file: fixtures/ty_check/payable_on_recv_block.fe --- error[13-0001]: `#[payable]` is only valid on `init` blocks and `recv` arms (found on recv block) - ┌─ payable_on_recv_block.fe:9:5 + ┌─ payable_on_recv_block.fe:7:5 │ -9 │ #[payable] +7 │ #[payable] │ ^^^^^^^^^^ move this attribute to an `init` block or `recv` arm diff --git a/crates/uitest/fixtures/ty_check/payable_unknown_attr_on_recv_block.fe b/crates/uitest/fixtures/ty_check/payable_unknown_attr_on_recv_block.fe index f32372860c..16eedd2db4 100644 --- a/crates/uitest/fixtures/ty_check/payable_unknown_attr_on_recv_block.fe +++ b/crates/uitest/fixtures/ty_check/payable_unknown_attr_on_recv_block.fe @@ -1,5 +1,3 @@ -use std::abi::sol - msg M { #[selector = sol("ping()")] Ping, diff --git a/crates/uitest/fixtures/ty_check/payable_unknown_attr_on_recv_block.snap b/crates/uitest/fixtures/ty_check/payable_unknown_attr_on_recv_block.snap index 8514de857e..cdd3c34ee7 100644 --- a/crates/uitest/fixtures/ty_check/payable_unknown_attr_on_recv_block.snap +++ b/crates/uitest/fixtures/ty_check/payable_unknown_attr_on_recv_block.snap @@ -1,11 +1,10 @@ --- source: crates/uitest/tests/ty_check.rs -assertion_line: 27 expression: diags input_file: fixtures/ty_check/payable_unknown_attr_on_recv_block.fe --- error[13-0004]: unknown attribute `#[payble]` on recv block - ┌─ payable_unknown_attr_on_recv_block.fe:9:5 + ┌─ payable_unknown_attr_on_recv_block.fe:7:5 │ -9 │ #[payble] +7 │ #[payble] │ ^^^^^^^^^ remove this attribute; `recv` blocks do not support normal attributes diff --git a/ingots/std/src/prelude.fe b/ingots/std/src/prelude.fe index b77e41ab3e..1c4d9ec488 100644 --- a/ingots/std/src/prelude.fe +++ b/ingots/std/src/prelude.fe @@ -2,8 +2,9 @@ pub use core::prelude::* // ABI encoding traits and the Solidity ABI provider. -pub use core::abi::{Abi, AbiEncoder, AbiSize, Encode} -pub use super::abi::{Sol, Text, Vec} +pub use core::abi::{Abi, AbiDecoder, AbiEncoder, AbiSize, Decode, Encode} +pub use super::abi::{Bytes, Sol, Text, Vec} +pub use super::abi::sol::sol // Common EVM types. pub use super::evm::{Evm, Address, Call, Ctx, StorageMap, Create, Log, Panic, assert, revert, revert_error} diff --git a/newsfragments/1417.feature.md b/newsfragments/1417.feature.md new file mode 100644 index 0000000000..57192931cf --- /dev/null +++ b/newsfragments/1417.feature.md @@ -0,0 +1 @@ +The standard prelude now includes `sol`, `Bytes`, `Decode`, and `AbiDecoder`, so common Solidity selector and ABI decoding code no longer needs explicit imports.