xrpl_hooks/api/
ledger.rs

1use super::*;
2
3/// Retreive the 20 byte Account ID the Hook is executing on
4#[inline(always)]
5pub fn hook_account(accid: &mut [u8]) -> Result<u64> {
6    buf_write(accid, _c::hook_account)
7}
8
9/// Retreive the 32 byte namespace biased SHA512H of the currently executing Hook
10#[inline(always)]
11pub fn hook_hash(hash: &mut [u8]) -> Result<u64> {
12    buf_write(hash, _c::hook_hash)
13}
14
15/// Fetch the fee base of the current ledger
16#[inline(always)]
17pub fn fee_base() -> i64 {
18    unsafe { _c::fee_base() }
19}
20
21/// Fetch the current ledger sequence number
22#[inline(always)]
23pub fn ledger_seq() -> i64 {
24    unsafe { _c::ledger_seq() }
25}
26
27/// Retreive the 32 byte namespace biased SHA512H of the last closed ledger
28#[inline(always)]
29pub fn ledger_last_hash(hash: &mut [u8]) -> Result<u64> {
30    buf_write(hash, _c::ledger_last_hash)
31}
32
33/// Generate a 32 byte nonce for use in an emitted transaction
34#[inline(always)]
35pub fn nonce(n: &mut [u8]) -> Result<u64> {
36    buf_write(n, _c::nonce)
37}