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§
- Account
Type - Account type
- Amount
Type - Amount type
- Data
Repr - Data representation
- Error
- Possible errors returned by Hook APIs.
- FieldId
- Field type
- Field
OrXrp Amount - Field or amount type
- Keylet
Type - 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- Slot
Type Flags - 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>
oru8
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 uniqueGUARD_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§
- Account
Id - Account id buffer
- Amount
- Amount buffer
- Buffer
- Buffer of the specified size
- Currency
Code - Currency code buffer
- Emit
Details - Emit details buffer
- Hash
- Hash buffer
- Keylet
- Keylet buffer
- Nonce
- Nonce buffer
- State
Key - State key buffer
- TxnPayment
Simple - Simple payment transaction buffer