-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
output_asset_to()
and output_asset_id()
to handle `Output:…
…:Variable` (#6781) ## Description Allows for fetching of the `AssetId` and the to `Address` from an `Output::Variable`. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [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: K1-R1 <[email protected]> Co-authored-by: IGI-111 <[email protected]>
- Loading branch information
1 parent
f7e4fb4
commit 192f163
Showing
11 changed files
with
147 additions
and
51 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
13 changes: 0 additions & 13 deletions
13
test/src/sdk-harness/test_artifacts/tx_output_change_contract/src/main.sw
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "tx_output_change_contract" | ||
name = "tx_output_contract" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../sway-lib-std" } |
35 changes: 35 additions & 0 deletions
35
test/src/sdk-harness/test_artifacts/tx_output_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,35 @@ | ||
contract; | ||
|
||
use std::asset::transfer; | ||
use std::outputs::*; | ||
|
||
abi TxOutputContract { | ||
fn send_assets_change(to: Address, asset: AssetId, amount: u64); | ||
fn send_assets_variable(to: Address, asset: AssetId, index: u64) -> (Address, AssetId, u64); | ||
} | ||
|
||
impl TxOutputContract for Contract { | ||
fn send_assets_change(to: Address, asset: AssetId, amount: u64) { | ||
transfer(Identity::Address(to), asset, amount); | ||
} | ||
|
||
fn send_assets_variable(to: Address, asset: AssetId, index: u64) -> (Address, AssetId, u64) { | ||
transfer(Identity::Address(to), asset, 1); | ||
|
||
get_variable_tx_params(index) | ||
} | ||
} | ||
|
||
fn get_variable_tx_params(index: u64) -> (Address, AssetId, u64) { | ||
let tx_asset_id = output_asset_id(index); | ||
let tx_to = output_asset_to(index); | ||
let tx_amount = output_amount(index); | ||
|
||
let tx_output_type = output_type(index); | ||
assert(tx_output_type.is_some() && tx_output_type.unwrap() == Output::Variable); | ||
( | ||
tx_to.unwrap_or(Address::zero()), | ||
tx_asset_id.unwrap_or(AssetId::zero()), | ||
tx_amount.unwrap_or(0), | ||
) | ||
} |
2 changes: 1 addition & 1 deletion
2
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
2 changes: 1 addition & 1 deletion
2
test/src/sdk-harness/test_artifacts/tx_type_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
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