forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
GTF_OUTPUT_COIN_ASSET_ID
and GTF_OUTPUT_COIN_TO
opcode getters (
FuelLabs#4694) ## Description Added getters for the `GTF_OUTPUT_COIN_ASSET_ID` and `GTF_OUTPUT_COIN_TO` opcodes. These have been highly requested by external teams for use in predicates. Note: The `output_asset_to()` getter currently returns a `b256` rather than an `Identity`. This should be updated when FuelLabs#4569 is resolved. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: bitzoic <[email protected]> Co-authored-by: K1-R1 <[email protected]>
- Loading branch information
1 parent
00982e4
commit 7245883
Showing
9 changed files
with
175 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
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
13 changes: 13 additions & 0 deletions
13
test/src/sdk-harness/test_artifacts/tx_output_predicate/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,13 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-3E8AFAF9D04B1844' | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-3E8AFAF9D04B1844' | ||
dependencies = ['core'] | ||
|
||
[[package]] | ||
name = 'tx_output_predicate' | ||
source = 'member' | ||
dependencies = ['std'] |
8 changes: 8 additions & 0 deletions
8
test/src/sdk-harness/test_artifacts/tx_output_predicate/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 = "tx_output_predicate" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../sway-lib-std" } |
14 changes: 14 additions & 0 deletions
14
test/src/sdk-harness/test_artifacts/tx_output_predicate/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,14 @@ | ||
predicate; | ||
|
||
use std::outputs::{output_asset_id, output_asset_to}; | ||
|
||
fn main(index: u64, asset_id: ContractId, to: b256) -> bool { | ||
|
||
let tx_asset_id = output_asset_id(index); | ||
let tx_to = output_asset_to(index); | ||
|
||
assert(tx_asset_id.is_some() && tx_asset_id.unwrap() == asset_id); | ||
assert(tx_to.is_some() && tx_to.unwrap() == to); | ||
|
||
true | ||
} |
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