Skip to content

Commit

Permalink
Return type of output_asset_to changed to Address
Browse files Browse the repository at this point in the history
  • Loading branch information
dmihal committed May 14, 2024
1 parent 675135f commit 1d488c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions sway-lib-std/src/outputs.sw
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! This includes `Output::Coins`, `Input::Messages` and `Input::Contracts`.
library;

use ::address::Address;
use ::asset_id::AssetId;
use ::contract_id::ContractId;
use ::revert::revert;
Expand Down Expand Up @@ -226,16 +227,15 @@ pub fn output_asset_id(index: u64) -> Option<AssetId> {
}
}

// TODO: Update to `Identity` when https://github.com/FuelLabs/sway/issues/4569 is resolved
/// Returns the receiver of the output if it is a `Output::Coin`. Represents the receiver as a `b256`.
/// Returns the receiver of the output if it is a `Output::Coin`.
///
/// # Arguments
///
/// * `index`: [u64] - The index of the output to get the receiver of.
///
/// # Returns
///
/// * [Option<b256>] - The receiver of the output if it is a `Output::Coin`. None otherwise.
/// * [Option<Address>] - The receiver of the output if it is a `Output::Coin`. None otherwise.
///
/// # Reverts
///
Expand All @@ -251,9 +251,9 @@ pub fn output_asset_id(index: u64) -> Option<AssetId> {
/// log(output_receiver);
/// }
/// ```
pub fn output_asset_to(index: u64) -> Option<b256> {
pub fn output_asset_to(index: u64) -> Option<Address> {
match output_type(index) {
Output::Coin => Some(__gtf::<b256>(index, GTF_OUTPUT_COIN_TO)),
Output::Coin => Some(__gtf::<Address>(index, GTF_OUTPUT_COIN_TO)),
_ => None,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main(index: u64, asset_id: b256, to: b256) -> bool {
let tx_to = output_asset_to(index);

assert(tx_asset_id.is_some() && tx_asset_id.unwrap().bits() == asset_id);
assert(tx_to.is_some() && tx_to.unwrap() == to);
assert(tx_to.is_some() && tx_to.unwrap().bits() == to);

true
}

0 comments on commit 1d488c0

Please sign in to comment.