hooks_rs

Module api

Source
Expand description

XRPL Hooks API that abstracts the usage of external C API

Re-exports§

pub use self::Result::*;

Structs§

XFL
Abstraction of XFL floating point numbers. The struct is overloaded with basic numeric operations, such as addition, subtraction, multiplication, division, and negation. Comparison operators are also implemented.

Enums§

AccountType
Account type
AmountType
Amount type
DataRepr
Data representation
Error
Possible errors returned by Hook APIs.
FieldId
Field type
FieldOrXrpAmount
Field or amount type
KeyletType
Keylet type
Result
Result is a type that represents either success (Ok) or failure (Err). This is simple version of Result type to comply XRPL Hooks Webassembly restrictions
SlotTypeFlags
Flags for slot_type
TxnType
Transaction type

Constants§

ACC_ID_LEN
Account id byte length
AMOUNT_LEN
Amount byte length
CURRENCY_CODE_SIZE
Currency code byte length
EMIT_DETAILS_SIZE
Emit details byte length
HASH_LEN
Hash byte length
KEYLET_LEN
Keylet byte length
LEDGER_HASH_LEN
Ledger hash byte length
NONCE_LEN
Nonce byte length
PREPARE_PAYMENT_SIMPLE_SIZE
Payment simple transaction byte length
STATE_KEY_LEN
State key byte length
TF_CANONICAL
Flags canonical
XFL_LEN
XFL byte length

Functions§

_g
Guard function
accept
Accept the originating transaction and commit any changes the hook made
emit
Emit a new transaction from the hook and return the 32-bytes long txn hash T should almost always be MaybeUninit<u8> or u8 type depending on your use case.
emit_from_ptr
Emit a new transaction from the hook and return the 32-bytes long txn hash. Same as emit but takes a pointer to the transaction buffer instead of a slice. This might be useful for dealing with raw pointers.
etxn_burden
Get the burden of a hypothetically emitted transaction
etxn_details
Produce emit details for for a soon-to-be emitted transaction. Normally, it is appended at the end of the transaction buffer.
etxn_fee_base
Estimate the required fee for a txn to be emitted successfully
etxn_fee_base_from_ptr
Estimate the required fee for a txn to be emitted successfully from a pointer to the transaction buffer. Does the same thing as etxn_fee_base but takes a pointer to the transaction buffer instead of a slice.
etxn_generation
Get the generation of a hypothetically emitted transaction
etxn_nonce
Generate a 32 byte nonce for use in an emitted transaction
etxn_reserve
Estimate the required fee for a txn to be emitted successfully
fee_base
Fetch the fee base of the current ledger
float_sto
Output an XFL as a serialized object
hook_account
Retreive the 20 byte Account ID the Hook is executing on
hook_param
Retrieve the parameter value for a named hook parameter
insert_etxn_details_from_ptr
Produce emit details for for a soon-to-be emitted transaction. Normally, it is appended at the end of the transaction buffer.
ledger_last_hash
Retreive the 32 byte namespace biased SHA512H of the last closed ledger
ledger_seq
Fetch the current ledger sequence number
max_iter
Instead of having to pass the GUARD_ID parameter to every call to _g, you can use this function to generate a unique GUARD_ID for each call automatically.
nonce
Generate a 32 byte nonce for use in an emitted transaction
otxn_burden
Get the burden of the originating transaction
otxn_field
Serialize and output a field from the originating transaction
otxn_field_txt
Output a field from the originating transaction as a human readable string
otxn_generation
Get the generation of the originating transaction
otxn_id
Output the canonical hash of the originating transaction
otxn_param
Retrieve the parameter value for a named Invoke transaction parameter
otxn_slot
Load the originating transaction into a slot
otxn_type
Get the Transaction Type of the originating transaction
rollback
Reject the originating transaction and discard any changes the hook made
slot
Serialize and output a slotted object
slot_clear
Free up a currently occupied slot
slot_count
Count the elements of an array object in a slot
slot_float
Parse the STI_AMOUNT in the specified slot and return it as an XFL enclosed number
slot_id
Slot ID
slot_set
Locate an object based on its keylet and place it into a slot
slot_size
Compute the serialized size of an object in a slot
slot_subarray
Index into a slotted array and assign a sub-object to another slot
slot_subfield
Index into a slotted object and assign a sub-object to another slot
slot_type
Retrieve the field code of an object in a slot and, optionally, some other information
state
Retrieve the data pointed to by a Hook State key and write it to an output buffer The keys are always 32 bytes (unsigned 256 bit integer) and the values are variable length with a maximum size determined by validator voting, at time of writing 128 bytes.
state_foreign
Retrieve the data pointed to, on another account, by a Hook State key and write it to an output buffer
state_set
Set the Hook State for a given key and value
sto_emplace
Emplace a field into an existing STObject at its canonical placement
sto_erase
Remove a field from an STObject
sto_subarray
Index into a xrpld serialized array and return the location and length of an index
sto_subfield
Index into a xrpld serialized object and return the location and length of a subfield
sto_validate
Validate an STObject
trace
Write the contents of a buffer to the XRPLD trace log
trace_float
Write a XFL float to the XRPLD trace log
trace_num
Write an integer to the XRPLD trace log
trace_slot
Write the contents of a slot to the XRPLD trace log
util_accid
Convert an r-address into a 20 byte Account ID
util_raddr
Convert a 20 byte Account ID to an r-address of 25 and 35 characters in length.
util_sha512h
Compute an sha512-half over some data
util_verify
Verify a cryptographic signature

Type Aliases§

AccountId
Account id buffer
Amount
Amount buffer
Buffer
Buffer of the specified size
CurrencyCode
Currency code buffer
EmitDetails
Emit details buffer
Hash
Hash buffer
Keylet
Keylet buffer
Nonce
Nonce buffer
StateKey
State key buffer
TxnPaymentSimple
Simple payment transaction buffer