Hey all,
Below is a snip of a loop i have in Sway, going over the outputs in the tx, It simply logs the output type, asset_id, an “to” address.
The end goal of this loop (not implemented) is when i find the output type Output::Change
, I want to also discover what the “to” address is and validate the change is going back to a specific address.
However when I log the results of these function calls. For the Change output I get a None
in place where I would expect the change return address, and also, a None
in the asset id place.
I’m assuming these fields are not populated yet in this part of the transactions execution?
let out_count = output_count();
log(out_count);
let mut j = 0;
while j < out_count {
let o_ass_id = output_asset_id(j);
log(o_ass_id);
let o_ass_to = output_asset_to(j);
log(o_ass_to);
let o_type = output_type(j);
log(o_type);
j += 1;
}
Logged output: Ok("None"), Ok("None"), Ok("Change")
Ok("None") --> output asset id (should be the default asset id)
Ok("None") --> output asset to address (where the output has the change to go back to)
Ok("Change") --> Output type (Change)
Is there any way I can investigate the Change to address at this point in the execution? Or is there another technique?
edit:
from outputs.sw this explains the None
for the asset id and “to”
pub fn output_asset_id(index: u64) -> Option<AssetId> {
match output_type(index) {
Output::Coin => Some(AssetId::from(__gtf::<b256>(index, GTF_OUTPUT_COIN_ASSET_ID))),
_ => None,
}
}
pub fn output_asset_to(index: u64) -> Option<b256> {
match output_type(index) {
Output::Coin => Some(__gtf::<b256>(index, GTF_OUTPUT_COIN_TO)),
_ => None,
}
}
So i guess is there any way to investivate the output change to address at all?
In metadata.rs
in the fuel-vm
there doesn’t look like there are any GTFArgs
for “::OutputChange”