pub fn amm_keylet(issue1: &Issue, issue2: &Issue) -> Result<KeyletBytes>Expand description
Generates an AMM keylet for a given pair of accounts and currency code.
An AMM keylet is used to reference AMM entries in the XRP Ledger.
§Arguments
issue1- The first Issue in the AMM relationshipissue2- The second Issue in the AMM relationship
§Returns
Result<KeyletBytes>- On success, returns a 32-byte AMM keylet. On failure, returns anErrorwith the corresponding error code.
§Safety
This function makes unsafe FFI calls to the host environment through
the host::amm_keylet function.
§Example
use xrpl_wasm_stdlib::core::types::account_id::AccountID;
use xrpl_wasm_stdlib::core::types::issue::{Issue, XrpIssue, IouIssue};
use xrpl_wasm_stdlib::core::types::currency::Currency;
use xrpl_wasm_stdlib::core::keylets::amm_keylet;
use xrpl_wasm_stdlib::host::trace::{DataRepr, trace_data, trace_num};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let issue1: Issue = Issue::XRP(XrpIssue {});
let issuer: AccountID =
AccountID::from(*b"\xd5\xb9\x84VP\x9f \xb5'\x9d\x1eJ.\xe8\xb2\xaa\x82\xaec\xe3");
let currency = b"RLUSD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; // RLUSD currency code
let currency: Currency = Currency::from(*currency);
let issue2 = Issue::IOU(IouIssue::new(issuer, currency));
match amm_keylet(&issue1, &issue2) {
xrpl_wasm_stdlib::host::Result::Ok(keylet) => {
let _ = trace_data("Generated keylet", &keylet, DataRepr::AsHex);
}
xrpl_wasm_stdlib::host::Result::Err(e) => {
let _ = trace_num("Error assembling keylet", e.code() as i64);
}
}
Ok(())
}