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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
use serde::{Deserialize, Serialize};
mod data;
mod fixed_size_data;
mod hex;
mod input_type;
mod output_type;
mod quantity;
mod receipt_type;
mod transaction_status;
mod transaction_type;
mod uint;
mod util;
pub use data::Data;
pub use fixed_size_data::FixedSizeData;
pub use hex::Hex;
pub use input_type::InputType;
pub use output_type::OutputType;
pub use quantity::Quantity;
pub use receipt_type::ReceiptType;
pub use transaction_status::TransactionStatus;
pub use transaction_type::TransactionType;
pub use uint::UInt;
// referencing https://docs.fuel.network/docs/graphql/reference/objects/#header
/// The header contains metadata about a certain block.
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BlockHeader {
/// Hash of the header
pub id: Hash,
/// The block height for the data availability layer up to which (inclusive) input messages are processed.
pub da_height: UInt,
/// The number of transactions in the block.
pub transactions_count: Quantity,
/// version of consensus
pub consensus_parameters_version: UInt,
/// version of the state transition
pub state_transition_bytecode_version: UInt,
/// The number of receipt messages in the block.
pub message_receipt_count: Quantity,
/// The merkle root of the transactions in the block.
pub transactions_root: Hash,
/// The merkle root of the messages in the block.
pub message_outbox_root: Hash,
pub event_inbox_root: Hash,
/// The block height.
pub height: UInt,
/// The merkle root of all previous consensus header hashes (not including this block).
pub prev_root: Hash,
/// The timestamp for the block.
pub time: UInt,
/// The hash of the serialized application header for this block.
pub application_hash: Hash,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Block<Tx> {
#[serde(flatten)]
pub header: BlockHeader,
pub transactions: Vec<Tx>,
}
/// An object containing information about a transaction.
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Transaction {
/// block the transaction is in.
pub block_height: UInt,
/// A unique transaction id.
pub id: Hash,
/// An array of asset ids used for the transaction inputs.
pub input_asset_ids: Option<Vec<Hash>>,
// Contract object -> bincode into schema
/// An array of contracts used for the transaction inputs.
pub input_contracts: Option<Vec<ContractId>>,
/// A contract used for the transaction input.
/// A unique 32 byte identifier for the UTXO for a contract used for the transaction input.
pub input_contract_utxo_id: Option<Hash>,
/// The root of amount of coins owned by contract before transaction execution for a contract used for the transaction input.
pub input_contract_balance_root: Option<Hash>,
/// The state root of contract before transaction execution for a contract used for the transaction input.
pub input_contract_state_root: Option<Hash>,
/// A pointer to the TX whose output is being spent for a contract used for the transaction input.
pub input_contract_tx_pointer_block_height: Option<UInt>,
/// A pointer to the TX whose output is being spent for a contract used for the transaction input.
pub input_contract_tx_pointer_tx_index: Option<UInt>,
/// The contract id for a contract used for the transaction input.
pub input_contract: Option<ContractId>,
pub policies_tip: Option<UInt>,
pub policies_witness_limit: Option<UInt>,
pub policies_maturity: Option<UInt>,
pub policies_max_fee: Option<UInt>,
/// The gas limit for the script.
pub script_gas_limit: Option<UInt>,
/// The minimum block height that the transaction can be included at.
pub maturity: Option<UInt>,
/// The amount minted in the transaction.
pub mint_amount: Option<UInt>,
/// The asset ID for coins minted in the transaction.
pub mint_asset_id: Option<Hash>,
pub mint_gas_price: Option<UInt>,
/// The location of the transaction in the block.
pub tx_pointer_block_height: Option<UInt>,
pub tx_pointer_tx_index: Option<UInt>,
/// Script, creating a new contract, or minting new coins
pub tx_type: TransactionType,
/// The index of the input from a transaction that changed the state of a contract.
pub output_contract_input_index: Option<UInt>,
/// The root of amount of coins owned by contract after transaction execution from a transaction that changed the state of a contract.
pub output_contract_balance_root: Option<Hash>,
/// The state root of contract after transaction execution from a transaction that changed the state of a contract.
pub output_contract_state_root: Option<Hash>,
/// An array of witnesses.
pub witnesses: Option<Data>, // TODO: only first one, but this is a vec
/// The root of the receipts.
pub receipts_root: Option<Hash>,
/// The status type of the transaction.
pub status: TransactionStatus,
/// for SubmittedStatus, SuccessStatus, and FailureStatus, the time a transaction was submitted, successful, or failed
pub time: UInt,
/// for SuccessStatus, the state of the program execution
// pub program_state: Option<ProgramState>
/// for SqueezedOutStatus & FailureStatus, the reason the transaction was squeezed out or failed
pub reason: Option<String>,
/// The script to execute.
pub script: Option<Data>,
/// The script input parameters.
pub script_data: Option<Data>,
/// The witness index of contract bytecode.
pub bytecode_witness_index: Option<UInt>,
pub bytecode_root: Option<Hash>,
pub subsection_index: Option<UInt>,
pub subsections_number: Option<UInt>,
pub proof_set: Option<Data>, // TODO: only first one, but this is a vec
pub consensus_parameters_upgrade_purpose_witness_index: Option<UInt>,
pub consensus_parameters_upgrade_purpose_checksum: Option<Data>,
pub state_transition_upgrade_purpose_root: Option<Hash>,
/// The salt value for the transaction.
pub salt: Option<Data>,
}
/// An object representing all possible types of receipts.
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Receipt {
/// Index of the receipt in the block
pub receipt_index: UInt,
/// Contract that produced the receipt
pub root_contract_id: Option<ContractId>,
/// transaction that this receipt originated from
pub tx_id: Hash,
/// The status type of the transaction this receipt originated from
pub tx_status: TransactionStatus,
/// block that the receipt originated in
pub block_height: UInt,
/// The value of the program counter register $pc, which is the memory address of the current instruction.
pub pc: Option<UInt>,
/// The value of register $is, which is the pointer to the start of the currently-executing code.
pub is: Option<UInt>,
/// The recipient contract
pub to: Option<ContractId>,
/// The recipient address
pub to_address: Option<Address>,
/// The amount of coins transferred.
pub amount: Option<UInt>,
/// The asset id of the coins transferred.
pub asset_id: Option<Hash>,
/// The gas used for the transaction.
pub gas: Option<UInt>,
/// The first parameter for a CALL receipt type, holds the function selector.
pub param1: Option<UInt>,
/// The second parameter for a CALL receipt type, typically used for the user-specified input to the ABI function being selected.
pub param2: Option<UInt>,
/// The value of registers at the end of execution, used for debugging.
pub val: Option<UInt>,
/// The value of the pointer register, used for debugging.
pub ptr: Option<UInt>,
/// A 32-byte hash of MEM[$rC, $rD]. The syntax MEM[x, y] means the memory range starting at byte x, of length y bytes.
pub digest: Option<Hash>,
/// The decimal string representation of an 8-bit unsigned integer for the panic reason. Only returned if the receipt type is PANIC.
pub reason: Option<UInt>,
/// The value of register $rA.
pub ra: Option<UInt>,
/// The value of register $rB.
pub rb: Option<UInt>,
/// The value of register $rC.
pub rc: Option<UInt>,
/// The value of register $rD.
pub rd: Option<UInt>,
/// The length of the receipt.
pub len: Option<UInt>,
/// The type of receipt.
pub receipt_type: ReceiptType,
/// 0 if script exited successfully, any otherwise.
pub result: Option<UInt>,
/// The amount of gas consumed by the script.
pub gas_used: Option<UInt>,
/// The receipt data.
pub data: Option<Data>,
/// The address of the message sender.
pub sender: Option<Address>,
/// The address of the message recipient.
pub recipient: Option<Address>,
/// The nonce value for a message.
pub nonce: Option<Quantity>,
/// Current context if in an internal context. null otherwise
pub contract_id: Option<ContractId>,
/// The sub id.
pub sub_id: Option<Hash>,
}
/// An object representing all possible types of inputs. InputCoin, InputContract, InputMessage
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Input {
/// transaction that this input originated from
pub tx_id: Hash,
/// The status type of the transaction this input originated from
pub tx_status: TransactionStatus,
/// block that the input originated in
pub block_height: UInt,
/// InputCoin, InputContract, or InputMessage
pub input_type: InputType,
/// A unique 32 byte identifier for the UTXO.
pub utxo_id: Option<Hash>,
/// The owning address or predicate root.
pub owner: Option<Address>,
/// for InputCoin type: The amount of coins.
/// for InputMessage type: The amount sent in the message.
pub amount: Option<UInt>,
/// The asset ID of the coins.
pub asset_id: Option<Hash>,
/// A pointer to the transaction whose output is being spent.
pub tx_pointer_block_height: Option<UInt>,
pub tx_pointer_tx_index: Option<UInt>,
/// The index of the witness that authorizes spending the coin.
pub witness_index: Option<UInt>,
/// The amount of gas used in the predicate transaction.
pub predicate_gas_used: Option<UInt>,
/// The predicate bytecode.
pub predicate: Option<Data>,
/// The predicate input parameters.
pub predicate_data: Option<Data>,
/// The root of amount of coins owned by contract before transaction execution.
pub balance_root: Option<Hash>,
/// The state root of contract before transaction execution.
pub state_root: Option<Hash>,
/// The input contract.
pub contract: Option<ContractId>,
/// The sender address of the message.
pub sender: Option<Address>,
/// The recipient address of the message.
pub recipient: Option<Address>,
/// A nonce value for the message input, which is determined by the sending system and is published at the time the message is sent.
pub nonce: Option<Data>,
/// The message data.
pub data: Option<Data>,
}
/// An object representing all possible types of Outputs. CoinOutput, ContractOutput, ChangeOutput, VariableOutput, ContractCreated
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Output {
/// transaction that this out originated from
pub tx_id: Hash,
/// The status type of the transaction this output originated from
pub tx_status: TransactionStatus,
/// block that the output originated in
pub block_height: UInt,
/// CoinOutput, ContractOutput, ChangeOutput, VariableOutput, or ContractCreated
pub output_type: OutputType,
/// The address the coins were sent to.
pub to: Option<Address>,
/// The amount of coins in the output.
pub amount: Option<UInt>,
/// The asset id for the coins sent.
pub asset_id: Option<Hash>,
/// The index of the input.
pub input_index: Option<UInt>,
/// The root of amount of coins owned by contract after transaction execution.
pub balance_root: Option<Hash>,
/// for ContractedCreated type: The initial state root of contract.
/// for ContractOutput type: The state root of contract after transaction execution.
pub state_root: Option<Hash>,
/// for ContractCreated type: The contract that was created.
pub contract: Option<ContractId>,
}
/// hash is 32 bytes of data
pub type Hash = FixedSizeData<32>;
/// An address of an externally owned account identified by a 32 byte string prefixed by 0x.
pub type Address = FixedSizeData<32>;
// contract id is also a 32 byte hash
pub type ContractId = FixedSizeData<32>;