Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/codegen/tests/fixtures/erc20.fe
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion crates/fe/tests/fixtures/build_foundry/erc20.fe
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::evm::{Ctx, Log, StorageMap}
use std::abi::sol

msg Erc20 {
#[selector = sol("name()")]
Expand Down
2 changes: 0 additions & 2 deletions crates/fe/tests/fixtures/cli_output/emit_abi/abi_contract.fe
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::abi::sol

msg FooMsg {
#[selector = sol("ping(uint256)")]
Ping { value: u256 } -> u256,
Expand Down
1 change: 0 additions & 1 deletion crates/fe/tests/fixtures/fe_test/abi_dynamic_payload.fe
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::abi::Bytes
use std::evm::encode_abi_payload

#[test]
Expand Down
2 changes: 0 additions & 2 deletions crates/fe/tests/fixtures/fe_test/address_call_method.fe
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion crates/fe/tests/fixtures/fe_test/ctx.fe
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::evm::{Evm, Ctx, Address}
use std::abi::sol

msg CtxMsg {
#[selector = 0x01]
Expand Down
2 changes: 0 additions & 2 deletions crates/fe/tests/fixtures/fe_test/erc20.fe
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::abi::sol

msg Erc20 {
#[selector = sol("name()")]
Name -> u256,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use core::abi::Bytes
use std::evm::{Evm, assert}

msg AbortMsg {
Expand Down
1 change: 0 additions & 1 deletion crates/fe/tests/fixtures/fe_test/payable.fe
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::evm::{Evm, Ctx, Address}
use std::abi::sol

pub contract PayableBox uses (ctx: Ctx) {
#[payable]
Expand Down
Original file line number Diff line number Diff line change
@@ -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<u256, 0, 1>
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::abi::sol

pub msg GreetMsg {
#[selector = sol("greet()")]
Greet -> u256,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use core::abi::{Abi, AbiEncoder, AbiSize, Encode}

pub enum Error {
Oops,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use core::abi::{Abi, AbiEncoder, AbiSize, Encode}

enum MyError {
NotAllowed,
OutOfBounds,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use core::abi::Bytes
use std::evm::{Evm, StorageBytes, assert, mem}

type Blobs = StorageBytes<u256, 0, 1>
Expand Down
2 changes: 0 additions & 2 deletions crates/hir/test_files/ty_check/recv_fallback.fe
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::abi::sol

msg CounterMsg {
#[selector = sol("count()")]
Count -> u256,
Expand Down
44 changes: 22 additions & 22 deletions crates/hir/test_files/ty_check/recv_fallback.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions crates/language-server/test_files/completion.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()]
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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()]
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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()]
Expand All @@ -205,6 +213,7 @@ note:

completions:
- Address (Struct)
- Bytes (Struct)
- Evm (Struct)
- Helper (Struct)
- Option (Enum)
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions crates/uitest/fixtures/ty_check/payable_on_msg_variant.fe
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::abi::sol

msg M {
#[payable]
#[selector = sol("ping()")]
Expand Down
4 changes: 2 additions & 2 deletions crates/uitest/fixtures/ty_check/payable_on_msg_variant.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions crates/uitest/fixtures/ty_check/payable_on_recv_block.fe
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::abi::sol

msg M {
#[selector = sol("ping()")]
Ping,
Expand Down
4 changes: 2 additions & 2 deletions crates/uitest/fixtures/ty_check/payable_on_recv_block.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::abi::sol

msg M {
#[selector = sol("ping()")]
Ping,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions ingots/std/src/prelude.fe
Original file line number Diff line number Diff line change
Expand Up @@ -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}
1 change: 1 addition & 0 deletions newsfragments/1417.feature.md
Original file line number Diff line number Diff line change
@@ -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.
Loading