sway
sway copied to clipboard
Extend support for Input::Message type fields in std::inputs
Also adds tests for untested functions currently in the stdlib.
Can we add support for getting the hash of the script bytecode? I've been using this in the current predicate for the bridge:
use std::constants::ZERO_B256;
const GTF_SCRIPT_SCRIPT_LENGTH = 0x005;
const GTF_SCRIPT_SCRIPT = 0x00B;
/// Get the hash of the script bytecode
pub fn tx_script_bytecode_hash() -> b256 {
// Get the script memory details
let mut result_buffer: b256 = ZERO_B256;
let script_length = __gtf::<u64>(0, GTF_SCRIPT_SCRIPT_LENGTH);
let script_ptr = __gtf::<u64>(0, GTF_SCRIPT_SCRIPT);
// Run the hash opcode for the script in memory
asm(hash: result_buffer, ptr: script_ptr, len: script_length) {
s256 hash ptr len;
hash: b256
}
}
I feel like it belongs in tx.sw since it requires the constant values for certain GTF fields.
Can we add support for getting the hash of the script bytecode?
@pixelcircuits I'm not opposed to this. Would you mind opening a separate issue to track it?
Can we add support for getting the hash of the script bytecode?
@pixelcircuits I'm not opposed to this. Would you mind opening a separate issue to track it?
Sure! #2721
This PR should wait until #2810 is finished since there is a lot of overlap
This PR is looking good. I just wanted to point to the tests on my now defunct branch for testing things like predicate bytecode and data when you get to that.
Can we go ahead and use this issue to make all GTF_ const definitions public (pub) so that they can be referenced for more lower level solutions like the current bridge message-contract-predicate?
Can we go ahead and use this issue to make all GTF_ const definitions public (
pub) so that they can be referenced for more lower level solutions like the current bridge message-contract-predicate?
I think so. So far I've only been exposing them as needed, but no reason to keep any of them private.