-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compute calldata offset on
B256
argument (#203)
- Loading branch information
Showing
12 changed files
with
172 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Syntax highlighting of sway files as rust | ||
*.sw linguist-language=Rust |
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
12 changes: 12 additions & 0 deletions
12
packages/fuels-abigen-macro/tests/test_projects/auth_testing_abi/Forc.lock
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,12 @@ | ||
[[package]] | ||
name = 'auth_testing_abi' | ||
dependencies = ['std git+https://github.com/FuelLabs/sway?branch=master#b0ab3f8a67f71f6697266c36394ef56d429637aa'] | ||
|
||
[[package]] | ||
name = 'core' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'git+https://github.com/FuelLabs/sway?branch=master#b0ab3f8a67f71f6697266c36394ef56d429637aa' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
packages/fuels-abigen-macro/tests/test_projects/auth_testing_abi/Forc.toml
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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "auth_testing_abi" | ||
|
||
[dependencies] | ||
std = { git = "https://github.com/FuelLabs/sway", branch = "master" } |
Empty file.
11 changes: 11 additions & 0 deletions
11
packages/fuels-abigen-macro/tests/test_projects/auth_testing_abi/src/main.sw
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,11 @@ | ||
library auth_testing_abi; | ||
|
||
use std::address::Address; | ||
use std::contract_id::ContractId; | ||
use std::chain::auth::*; | ||
use std::result::*; | ||
|
||
abi AuthTesting { | ||
fn is_caller_external() -> bool; | ||
fn check_msg_sender(expected_id: Address) -> bool; | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/fuels-abigen-macro/tests/test_projects/auth_testing_contract/Forc.lock
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,19 @@ | ||
[[package]] | ||
name = 'auth_testing_abi' | ||
dependencies = ['std git+https://github.com/FuelLabs/sway?branch=master#35cac1b6b4a1ca21e2b617d9334dcafa1363f737'] | ||
|
||
[[package]] | ||
name = 'auth_testing_contract' | ||
dependencies = [ | ||
'auth_testing_abi', | ||
'std git+https://github.com/FuelLabs/sway?branch=master#35cac1b6b4a1ca21e2b617d9334dcafa1363f737', | ||
] | ||
|
||
[[package]] | ||
name = 'core' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'git+https://github.com/FuelLabs/sway?branch=master#35cac1b6b4a1ca21e2b617d9334dcafa1363f737' | ||
dependencies = ['core'] |
9 changes: 9 additions & 0 deletions
9
packages/fuels-abigen-macro/tests/test_projects/auth_testing_contract/Forc.toml
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,9 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "auth_testing_contract" | ||
|
||
[dependencies] | ||
std = { git = "https://github.com/FuelLabs/sway", branch = "master" } | ||
auth_testing_abi = { path = "../auth_testing_abi"} |
38 changes: 38 additions & 0 deletions
38
...-macro/tests/test_projects/auth_testing_contract/out/debug/auth_testing_contract-abi.json
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,38 @@ | ||
[ | ||
{ | ||
"type": "function", | ||
"inputs": [], | ||
"name": "is_caller_external", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "bool", | ||
"components": null | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"inputs": [ | ||
{ | ||
"name": "expected_id", | ||
"type": "struct Address", | ||
"components": [ | ||
{ | ||
"name": "value", | ||
"type": "b256", | ||
"components": null | ||
} | ||
] | ||
} | ||
], | ||
"name": "check_msg_sender", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "bool", | ||
"components": null | ||
} | ||
] | ||
} | ||
] |
Binary file added
BIN
+1.23 KB
...bigen-macro/tests/test_projects/auth_testing_contract/out/debug/auth_testing_contract.bin
Binary file not shown.
32 changes: 32 additions & 0 deletions
32
packages/fuels-abigen-macro/tests/test_projects/auth_testing_contract/src/main.sw
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,32 @@ | ||
contract; | ||
|
||
use std::address::Address; | ||
use std::chain::auth::*; | ||
use std::contract_id::ContractId; | ||
use auth_testing_abi::*; | ||
use std::result::*; | ||
use std::assert::assert; | ||
|
||
impl AuthTesting for Contract { | ||
fn is_caller_external() -> bool { | ||
caller_is_external() | ||
} | ||
|
||
fn check_msg_sender(expected_id: Address) -> bool { | ||
let result: Result<Sender, AuthError> = msg_sender(); | ||
let mut ret = false; | ||
if result.is_err() { | ||
ret = false; | ||
} else { | ||
let unwrapped = result.unwrap(); | ||
if let Sender::Address(v) = unwrapped { | ||
assert(v == expected_id); | ||
ret = true; | ||
} else { | ||
ret = false; | ||
} | ||
}; | ||
|
||
ret | ||
} | ||
} |
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