-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds an `EvmAddress` type, equivalent to the Sway std lib type. Co-authored-by: hal3e <hal3e.git@gmail.com> Co-authored-by: iqdecay <victor@berasconsulting.com> Co-authored-by: Rodrigo Araújo <rod.dearaujo@gmail.com>
- Loading branch information
1 parent
ccd3e16
commit e1a68d4
Showing
8 changed files
with
284 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# EvmAddress | ||
|
||
In the Rust SDK, Ethereum Virtual Machine (EVM) addresses can be represented with the 'EvmAddress' type. Its definition matches with the Sway standard library type with the same name and will be converted accordingly when interacting with contracts: | ||
|
||
```rust,ignore | ||
{{#include ../../../packages/fuels-core/src/types/bits_256.rs:evm_address}} | ||
``` | ||
|
||
Here's an example: | ||
|
||
```rust,ignore | ||
{{#include ../../../packages/fuels/tests/bindings.rs:evm_address_arg}} | ||
``` | ||
|
||
> **Note:** when creating an `EvmAddress` from `Bits256`, the first 12 bytes will be cleared because an evm address is only 20 bytes long. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "evm_address" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
contract; | ||
|
||
use std::vm::evm::evm_address::EvmAddress; | ||
|
||
abi EvmTest { | ||
fn evm_address_as_input(evm_addr: EvmAddress) -> bool; | ||
fn evm_address_from_literal() -> EvmAddress; | ||
fn evm_address_from_argument(raw_address: b256) -> EvmAddress; | ||
} | ||
|
||
impl EvmTest for Contract { | ||
fn evm_address_as_input(evm_addr: EvmAddress) -> bool { | ||
let evm_addr2 = EvmAddress::from(0x1616060606060606060606060606060606060606060606060606060606060606); | ||
|
||
evm_addr == evm_addr2 | ||
} | ||
|
||
fn evm_address_from_literal() -> EvmAddress { | ||
EvmAddress::from(0x0606060606060606060606060606060606060606060606060606060606060606) | ||
} | ||
|
||
fn evm_address_from_argument(raw_address: b256) -> EvmAddress { | ||
EvmAddress::from(raw_address) | ||
} | ||
} |