diff --git a/sway-lib-std/src/token.sw b/sway-lib-std/src/token.sw index be1b90c0c7e..3298860cff0 100644 --- a/sway-lib-std/src/token.sw +++ b/sway-lib-std/src/token.sw @@ -87,8 +87,6 @@ pub fn force_transfer_to_contract(amount: u64, asset_id: ContractId, to: Contrac /// Transfer `amount` coins of type `asset_id` and send them to /// the address `to`. pub fn transfer_to_output(amount: u64, asset_id: ContractId, to: Address) { - const OUTPUT_VARIABLE_TYPE: u8 = 4; - // maintain a manual index as we only have `while` loops in sway atm: let mut index = 0; let mut output_index = 0; @@ -99,7 +97,7 @@ pub fn transfer_to_output(amount: u64, asset_id: ContractId, to: Address) { // variable output with a value of zero is by definition unused. let outputs_count = tx_outputs_count(); while index < outputs_count { - if tx_output_type(index) == OUTPUT_VARIABLE_TYPE && tx_output_amount(index) == 0 { + if tx_output_type(index) == OUTPUT_VARIABLE && tx_output_amount(index) == 0 { output_index = index; output_found = true; break; // break early and use the output we found diff --git a/sway-lib-std/src/tx.sw b/sway-lib-std/src/tx.sw index ba2b6e64f4d..de696db9148 100644 --- a/sway-lib-std/src/tx.sw +++ b/sway-lib-std/src/tx.sw @@ -44,6 +44,19 @@ const TX_WITNESSES_COUNT_OFFSET = 10312; const TX_RECEIPTS_ROOT_OFFSET = 10320; const TX_SCRIPT_START_OFFSET = 10352; +// Input types +const INPUT_COIN = 0u8; +const INPUT_CONTRACT = 1u8; +const INPUT_MESSAGE = 2u8; + +// Output types +const OUTPUT_COIN = 0u8; +const OUTPUT_CONTRACT = 1u8; +const OUTPUT_MESSAGE = 2u8; +const OUTPUT_CHANGE = 3u8; +const OUTPUT_VARIABLE = 4u8; +const OUTPUT_CONTRACT_CREATED = 5u8; + /// Get the transaction type. pub fn tx_type() -> u8 { asm(r1, r2: TX_TYPE_OFFSET) {