1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use fuel_tx::{field::Script, ConsensusParameters, InputRepr};
use fuel_types::bytes::padded_len_usize;
use fuel_vm::prelude::Instruction;
pub fn base_offset(consensus_parameters: &ConsensusParameters) -> usize {
consensus_parameters.tx_offset() + fuel_tx::Script::script_offset_static()
}
pub fn call_script_data_offset(
consensus_parameters: &ConsensusParameters,
calls_instructions_len: usize,
) -> usize {
let opcode_len = Instruction::SIZE;
base_offset(consensus_parameters) + padded_len_usize(calls_instructions_len + opcode_len)
}
pub fn coin_predicate_data_offset(code_len: usize) -> usize {
InputRepr::Coin
.coin_predicate_offset()
.expect("should have predicate offset")
+ padded_len_usize(code_len)
}
pub fn message_predicate_data_offset(message_data_len: usize, code_len: usize) -> usize {
InputRepr::Message
.data_offset()
.expect("should have data offset")
+ padded_len_usize(message_data_len)
+ padded_len_usize(code_len)
}