Compare commits

..

17 Commits

Author SHA1 Message Date
Pratik Mankawde
363870eb34 Fix join() race in CoroTaskRunner by replacing bool with counter
When post() is called from within the coroutine body (via JobQueueAwaiter),
two resume operations can overlap: R1 is still running while R2 is queued.
With a boolean running_ flag, R1's cleanup (running_=false) clobbers R2's
pending state, causing join() to return prematurely on ARM64.

Replace bool running_ with int runCount_: post() increments before enqueue,
resume() decrements after completion. join() waits for runCount_==0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:47:04 +00:00
Pratik Mankawde
926d8128af Re-trigger CI (GCC-12 ARM64 was cancelled due to runner timeout) 2026-02-28 12:49:46 +00:00
Pratik Mankawde
a0a72a6934 Fix CoroTaskRunner destructor assertion race on GCC-12
Add join() before the finished_ assertion in the destructor. With async
dispatch, the coroutine runs on a worker thread. A gate signal inside
the coroutine body can wake the test thread before resume() sets
finished_. The test thread then triggers Env destruction, and the
runner's destructor fires while finished_ is still false.

join() establishes a happens-before edge via mutex_run_:
  finished_ = true → unlock(mutex_run_) in resume()
  → lock(mutex_run_) in join() → read finished_

This guarantees finished_ is visible when the assertion checks it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 11:38:32 +00:00
Pratik Mankawde
3ed8a51d48 Fix LocalValues contamination in postCoroTask by using async dispatch
Revert the initial coroutine dispatch from synchronous resume() to async
post(). The synchronous approach ran the coroutine body on the caller's
thread, swapping in the coroutine's LocalValues. When coroutines mutated
LocalValues (e.g. thread_specific_storage), those mutations bled back
into the caller's thread-local state after the swap-out, corrupting
unrelated tests (Book, Subscribe) sharing the same thread pool.

Async post() dispatches the coroutine to a JobQueue worker thread whose
LocalValues are managed by the thread pool, not by the caller. The
original assertion issue that motivated sync resume was a symptom of the
shared_ptr cycle and double-free bugs that have since been fixed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 10:46:51 +00:00
Pratik Mankawde
81eb10885b Re-trigger CI (non-deterministic GCC-12 ARM64) 2026-02-27 23:19:00 +00:00
Pratik Mankawde
8f517e41f6 Fix non-deterministic assertion in CoroTaskRunner destructor
Change postCoroTask from async post() to synchronous resume() for the
initial coroutine dispatch. The async approach created a timing-dependent
race during Env destruction where the coroutine frame's shared_ptr
reference cycle could be broken in an indeterminate order, causing the
debug-only finished_ assertion to fire non-deterministically on GCC-12
and GCC-15 debug builds.

The synchronous resume runs the coroutine body to its first suspension
point (co_await) or completion (co_return) on the caller's thread,
ensuring the coroutine state is determinate before postCoroTask returns.
Subsequent resumes still happen on worker threads via post().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 20:13:44 +00:00
Pratik Mankawde
4613377a41 Fix double-free on GCC-12 in CoroTaskRunner frame destruction
Replace `task_ = {}` with `std::move(task_)` in resume() and
expectEarlyExit(). The move assignment operator calls
handle_.destroy() while task_.handle_ still holds the old (now
dangling) handle value. If frame destruction triggers re-entrant
runner cleanup on GCC-12, the destructor sees a non-null handle_
and destroys the same frame again — a double-free.

std::move(task_) immediately nulls task_.handle_ via the move
constructor, then the frame is destroyed when the local goes out
of scope. This eliminates the re-entrancy window.

Also remove storedFunc_.reset() from resume() — the callable does
not participate in the shared_ptr cycle and will be cleaned up by
the runner's destructor.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 18:38:30 +00:00
Pratik Mankawde
51ae47cdc6 Fix shared_ptr reference cycle causing ASAN leaks in CoroTaskRunner
After a coroutine completes, the frame remains alive holding a captured
shared_ptr<CoroTaskRunner> back to its owner. This creates an unreachable
cycle: runner -> task_ -> frame -> shared_ptr<runner>.

Break the cycle in resume() by destroying the coroutine frame (task_ = {})
and the stored callable when the coroutine is done. Also fix runnable() to
handle the null-handle state after cleanup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 17:20:53 +00:00
Pratik Mankawde
185921ea94 comments and document update
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-02-27 16:44:58 +00:00
Pratik Mankawde
403abe6408 Merge branch 'develop' into pratik/std-coro/add-coroutine-primitives 2026-02-27 15:31:40 +00:00
Pratik Mankawde
eb83e111af Fix coroutine lambda lifetime and add value-returning tests
Store the coroutine callable on the heap in CoroTaskRunner::init()
via a type-erased FuncStore wrapper. Coroutine frames store a
reference to the callable's implicit object parameter (the lambda);
if the callable is a temporary, that reference dangles after the
caller returns. This caused stack-use-after-scope (ASAN), assertion
failures, and hangs across multiple compilers.

Also fix expectEarlyExit() to destroy the coroutine frame when
postCoroTask() fails, breaking a potential shared_ptr cycle.

Switch all coroutine test lambda captures from [&] to explicit
pointer-by-value as defense-in-depth against GCC 14 coroutine
frame corruption. Add value-returning CoroTask<T> tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 14:09:26 +00:00
Pratik Mankawde
464c09efc7 Apply pre-commit formatting fixes
clang-format: collapse single-line initializer lists and function
arguments. prettier: add blank lines in markdown lists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 13:17:33 +00:00
Pratik Mankawde
897c75bc6b Add cspell dictionary words for coroutine migration plan doc
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 12:37:34 +00:00
Pratik Mankawde
ca15c0efd7 Add C++20 coroutine primitives: CoroTask, CoroTaskRunner, JobQueueAwaiter
Introduce the core building blocks for migrating from Boost.Coroutine to
C++20 stackless coroutines (Milestone 1):

- CoroTask<T>: RAII coroutine return type with promise_type, symmetric
  transfer via FinalAwaiter, and lazy start (suspend_always)
- CoroTaskRunner: Lifecycle manager (nested in JobQueue) mirroring the
  existing Coro class — handles LocalValues swap, nSuspend_ accounting,
  mutex-guarded resume, and join/post semantics
- JobQueueAwaiter: Convenience awaiter combining suspend + auto-repost,
  with graceful fallback when JobQueue is stopping
- postCoroTask(): JobQueue entry point for launching C++20 coroutines
- CoroTask_test.cpp: 8 unit tests covering completion, suspend/resume
  ordering, LocalValue isolation, exception propagation, and shutdown

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 17:38:28 +00:00
Pratik Mankawde
bb4bc1d167 doc updated with branch names
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-02-25 17:38:08 +00:00
Pratik Mankawde
b9d14fb9e1 document update
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-02-25 17:03:00 +00:00
Pratik Mankawde
af30b71043 Plan doc added
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-02-25 16:36:45 +00:00
234 changed files with 8830 additions and 33226 deletions

View File

@@ -10,7 +10,6 @@ Checks: "-*,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
bugprone-empty-catch,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-inaccurate-erase,
@@ -24,7 +23,6 @@ Checks: "-*,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-pointer-arithmetic-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multi-level-implicit-pointer-conversion,
bugprone-multiple-new-in-one-expression,
bugprone-multiple-statement-macro,
@@ -33,12 +31,10 @@ Checks: "-*,
bugprone-parent-virtual-call,
bugprone-posix-return,
bugprone-redundant-branch-condition,
bugprone-return-const-ref-from-parameter,
bugprone-shared-ptr-array-mismatch,
bugprone-signal-handler,
bugprone-signed-char-misuse,
bugprone-sizeof-container,
bugprone-sizeof-expression,
bugprone-spuriously-wake-up-functions,
bugprone-standalone-empty,
bugprone-string-constructor,
@@ -85,14 +81,17 @@ Checks: "-*,
performance-trivially-destructible
"
# ---
# more checks that have some issues that need to be resolved:
# checks that have some issues that need to be resolved:
#
# bugprone-empty-catch,
# bugprone-crtp-constructor-accessibility,
# bugprone-inc-dec-in-conditions,
# bugprone-reserved-identifier,
# bugprone-move-forwarding-reference,
# bugprone-unused-local-non-trivial-variable,
# bugprone-return-const-ref-from-parameter,
# bugprone-switch-missing-default-case,
# bugprone-sizeof-expression,
# bugprone-suspicious-stringview-data-usage,
# bugprone-suspicious-missing-comma,
# bugprone-pointer-arithmetic-on-polymorphic-object,

View File

@@ -19,7 +19,6 @@ libxrpl.nodestore > xrpl.protocol
libxrpl.protocol > xrpl.basics
libxrpl.protocol > xrpl.json
libxrpl.protocol > xrpl.protocol
libxrpl.protocol_autogen > xrpl.protocol_autogen
libxrpl.rdb > xrpl.basics
libxrpl.rdb > xrpl.rdb
libxrpl.resource > xrpl.basics
@@ -191,8 +190,6 @@ xrpl.nodestore > xrpl.basics
xrpl.nodestore > xrpl.protocol
xrpl.protocol > xrpl.basics
xrpl.protocol > xrpl.json
xrpl.protocol_autogen > xrpl.json
xrpl.protocol_autogen > xrpl.protocol
xrpl.rdb > xrpl.basics
xrpl.rdb > xrpl.core
xrpl.rdb > xrpl.protocol

View File

@@ -11,7 +11,7 @@ on:
jobs:
# Call the workflow in the XRPLF/actions repo that runs the pre-commit hooks.
run-hooks:
uses: XRPLF/actions/.github/workflows/pre-commit.yml@56de1bdf19639e009639a50b8d17c28ca954f267
uses: XRPLF/actions/.github/workflows/pre-commit.yml@320be44621ca2a080f05aeb15817c44b84518108
with:
runs_on: ubuntu-latest
container: '{ "image": "ghcr.io/xrplf/ci/tools-rippled-pre-commit:sha-41ec7c1" }'

View File

@@ -40,18 +40,15 @@ env:
NPROC_SUBTRACT: ${{ github.event.repository.private && '1' || '2' }}
jobs:
build:
publish:
runs-on: ubuntu-latest
container: ghcr.io/xrplf/ci/tools-rippled-documentation:sha-a8c7be1
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Prepare runner
uses: XRPLF/actions/prepare-runner@2cbf481018d930656e9276fcc20dc0e3a0be5b6d
with:
enable_ccache: false
- name: Get number of processors
uses: XRPLF/actions/get-nproc@cf0433aa74563aead044a1e395610c96d65a37cf
id: nproc
@@ -81,23 +78,9 @@ jobs:
cmake -Donly_docs=ON ..
cmake --build . --target docs --parallel ${BUILD_NPROC}
- name: Create documentation artifact
- name: Publish documentation
if: ${{ github.event_name == 'push' }}
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
path: ${{ env.BUILD_DIR }}/docs/html
deploy:
if: ${{ github.event_name == 'push' }}
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.BUILD_DIR }}/docs/html

View File

@@ -177,7 +177,7 @@ jobs:
- name: Upload the binary (Linux)
if: ${{ github.repository_owner == 'XRPLF' && runner.os == 'Linux' }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: xrpld-${{ inputs.config_name }}
path: ${{ env.BUILD_DIR }}/xrpld

View File

@@ -84,7 +84,7 @@ jobs:
- name: Upload clang-tidy output
if: steps.run_clang_tidy.outcome != 'success'
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: clang-tidy-results
path: clang-tidy-output.txt

3
.gitignore vendored
View File

@@ -80,6 +80,3 @@ DerivedData
# clangd cache
/.cache
# python cache
__pycache__

View File

@@ -14,21 +14,17 @@ repos:
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
hooks:
- id: trailing-whitespace
exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_objects)/
- id: end-of-file-fixer
exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_objects)/
- id: mixed-line-ending
exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_objects)/
- id: check-merge-conflict
args: [--assume-in-merge]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: cd481d7b0bfb5c7b3090c21846317f9a8262e891 # frozen: v22.1.0
rev: 75ca4ad908dc4a99f57921f29b7e6c1521e10b26 # frozen: v21.1.8
hooks:
- id: clang-format
args: [--style=file]
"types_or": [c++, c, proto]
exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_objects)/
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: e2c2116d86a80e72e7146a06e68b7c228afc6319 # frozen: v0.6.13
@@ -37,20 +33,20 @@ repos:
additional_dependencies: [PyYAML]
- repo: https://github.com/rbubley/mirrors-prettier
rev: c2bc67fe8f8f549cc489e00ba8b45aa18ee713b1 # frozen: v3.8.1
rev: 5ba47274f9b181bce26a5150a725577f3c336011 # frozen: v3.6.2
hooks:
- id: prettier
- repo: https://github.com/psf/black-pre-commit-mirror
rev: ea488cebbfd88a5f50b8bd95d5c829d0bb76feb8 # frozen: 26.1.0
rev: 831207fd435b47aeffdf6af853097e64322b4d44 # frozen: v25.12.0
hooks:
- id: black
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: a42085ade523f591dca134379a595e7859986445 # frozen: v9.7.0
rev: 1cfa010f078c354f3ffb8413616280cc28f5ba21 # frozen: v9.4.0
hooks:
- id: cspell # Spell check changed files
exclude: (.config/cspell.config.yaml|^include/xrpl/protocol_autogen/(transactions|ledger_objects)/)
exclude: .config/cspell.config.yaml
- id: cspell # Spell check the commit message
name: check commit message spelling
args:
@@ -65,15 +61,7 @@ repos:
hooks:
- id: nix-fmt
name: Format Nix files
entry: |
bash -c '
if command -v nix &> /dev/null || [ "$GITHUB_ACTIONS" = "true" ]; then
nix --extra-experimental-features "nix-command flakes" fmt "$@"
else
echo "Skipping nix-fmt: nix not installed and not in GitHub Actions"
exit 0
fi
' --
entry: nix --extra-experimental-features 'nix-command flakes' fmt
language: system
types:
- nix

View File

@@ -22,19 +22,6 @@ API version 2 is available in `rippled` version 2.0.0 and later. See [API-VERSIO
This version is supported by all `rippled` versions. For WebSocket and HTTP JSON-RPC requests, it is currently the default API version used when no `api_version` is specified.
## Unreleased
This section contains changes targeting a future version.
### Additions
- `server_definitions`: Added the following new sections to the response ([#6321](https://github.com/XRPLF/rippled/pull/6321)):
- `TRANSACTION_FORMATS`: Describes the fields and their optionality for each transaction type, including common fields shared across all transactions.
- `LEDGER_ENTRY_FORMATS`: Describes the fields and their optionality for each ledger entry type, including common fields shared across all ledger entries.
- `TRANSACTION_FLAGS`: Maps transaction type names to their supported flags and flag values.
- `LEDGER_ENTRY_FLAGS`: Maps ledger entry type names to their flags and flag values.
- `ACCOUNT_SET_FLAGS`: Maps AccountSet flag names (asf flags) to their numeric values.
## XRP Ledger server version 3.1.0
[Version 3.1.0](https://github.com/XRPLF/rippled/releases/tag/3.1.0) was released on Jan 27, 2026.

File diff suppressed because it is too large Load Diff

View File

@@ -36,6 +36,26 @@ endif ()
# Enable ccache to speed up builds.
include(Ccache)
# make GIT_COMMIT_HASH define available to all sources
find_package(Git)
if (Git_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git rev-parse
HEAD OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE gch)
if (gch)
set(GIT_COMMIT_HASH "${gch}")
message(STATUS gch: ${GIT_COMMIT_HASH})
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
endif ()
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git rev-parse
--abbrev-ref HEAD OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE gb)
if (gb)
set(GIT_BRANCH "${gb}")
message(STATUS gb: ${GIT_BRANCH})
add_definitions(-DGIT_BRANCH="${GIT_BRANCH}")
endif ()
endif () # git
if (thread_safety_analysis)
add_compile_options(-Wthread-safety -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
-DXRPL_ENABLE_THREAD_SAFETY_ANNOTATIONS)

View File

@@ -1,21 +0,0 @@
include_guard()
set(GIT_BUILD_BRANCH "")
set(GIT_COMMIT_HASH "")
find_package(Git)
if (NOT Git_FOUND)
message(WARNING "Git not found. Git branch and commit hash will be empty.")
return()
endif ()
set(GIT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.git)
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${GIT_DIRECTORY} rev-parse --abbrev-ref HEAD
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GIT_BUILD_BRANCH)
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${GIT_DIRECTORY} rev-parse HEAD
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GIT_COMMIT_HASH)
message(STATUS "Git branch: ${GIT_BUILD_BRANCH}")
message(STATUS "Git commit hash: ${GIT_COMMIT_HASH}")

View File

@@ -58,12 +58,6 @@ include(target_link_modules)
add_module(xrpl beast)
target_link_libraries(xrpl.libxrpl.beast PUBLIC xrpl.imports.main)
include(GitInfo)
add_module(xrpl git)
target_compile_definitions(xrpl.libxrpl.git PRIVATE GIT_COMMIT_HASH="${GIT_COMMIT_HASH}"
GIT_BUILD_BRANCH="${GIT_BUILD_BRANCH}")
target_link_libraries(xrpl.libxrpl.git PUBLIC xrpl.imports.main)
# Level 02
add_module(xrpl basics)
target_link_libraries(xrpl.libxrpl.basics PUBLIC xrpl.libxrpl.beast)
@@ -77,27 +71,18 @@ target_link_libraries(xrpl.libxrpl.crypto PUBLIC xrpl.libxrpl.basics)
# Level 04
add_module(xrpl protocol)
target_link_libraries(xrpl.libxrpl.protocol PUBLIC xrpl.libxrpl.crypto xrpl.libxrpl.git
xrpl.libxrpl.json)
target_link_libraries(xrpl.libxrpl.protocol PUBLIC xrpl.libxrpl.crypto xrpl.libxrpl.json)
# Level 05
## Set up code generation for protocol_autogen module
include(XrplProtocolAutogen)
setup_protocol_autogen()
add_module(xrpl protocol_autogen)
target_link_libraries(xrpl.libxrpl.protocol_autogen PUBLIC xrpl.libxrpl.protocol)
# Level 06
add_module(xrpl core)
target_link_libraries(xrpl.libxrpl.core PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json
xrpl.libxrpl.protocol xrpl.libxrpl.protocol_autogen)
xrpl.libxrpl.protocol)
# Level 07
# Level 06
add_module(xrpl resource)
target_link_libraries(xrpl.libxrpl.resource PUBLIC xrpl.libxrpl.protocol)
# Level 08
# Level 07
add_module(xrpl net)
target_link_libraries(xrpl.libxrpl.net PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json
xrpl.libxrpl.protocol xrpl.libxrpl.resource)
@@ -126,7 +111,6 @@ target_link_libraries(
PUBLIC xrpl.libxrpl.basics
xrpl.libxrpl.json
xrpl.libxrpl.protocol
xrpl.libxrpl.protocol_autogen
xrpl.libxrpl.rdb
xrpl.libxrpl.server
xrpl.libxrpl.shamap
@@ -151,13 +135,11 @@ target_link_modules(
conditions
core
crypto
git
json
ledger
net
nodestore
protocol
protocol_autogen
rdb
resource
server

View File

@@ -23,14 +23,12 @@ install(TARGETS common
xrpl.libxrpl.conditions
xrpl.libxrpl.core
xrpl.libxrpl.crypto
xrpl.libxrpl.git
xrpl.libxrpl.json
xrpl.libxrpl.rdb
xrpl.libxrpl.ledger
xrpl.libxrpl.net
xrpl.libxrpl.nodestore
xrpl.libxrpl.protocol
xrpl.libxrpl.protocol_autogen
xrpl.libxrpl.resource
xrpl.libxrpl.server
xrpl.libxrpl.shamap

View File

@@ -1,155 +0,0 @@
#[===================================================================[
Protocol Autogen - Code generation for protocol wrapper classes
#]===================================================================]
# Options for code generation
set(CODEGEN_VENV_DIR
""
CACHE PATH
"Path to Python virtual environment for code generation. If provided, automatic venv setup is skipped."
)
# Function to set up code generation for protocol_autogen module
# This runs at configure time to generate C++ wrapper classes from macro files
function (setup_protocol_autogen)
# Directory paths
set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/xrpl/protocol/detail")
set(AUTOGEN_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/xrpl/protocol_autogen")
set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
# Input macro files
set(TRANSACTIONS_MACRO "${MACRO_DIR}/transactions.macro")
set(LEDGER_ENTRIES_MACRO "${MACRO_DIR}/ledger_entries.macro")
set(SFIELDS_MACRO "${MACRO_DIR}/sfields.macro")
# Python scripts
set(GENERATE_TX_SCRIPT "${SCRIPTS_DIR}/generate_tx_classes.py")
set(GENERATE_LEDGER_SCRIPT "${SCRIPTS_DIR}/generate_ledger_classes.py")
set(REQUIREMENTS_FILE "${SCRIPTS_DIR}/requirements.txt")
# Create output directories
file(MAKE_DIRECTORY "${AUTOGEN_HEADER_DIR}/transactions")
file(MAKE_DIRECTORY "${AUTOGEN_HEADER_DIR}/ledger_objects")
# Find Python3 - check if already found by Conan or find it ourselves
if (NOT Python3_EXECUTABLE)
find_package(Python3 COMPONENTS Interpreter QUIET)
endif ()
if (NOT Python3_EXECUTABLE)
# Try finding python3 executable directly
find_program(Python3_EXECUTABLE NAMES python3 python)
endif ()
if (NOT Python3_EXECUTABLE)
message(FATAL_ERROR "Python3 not found. Code generation cannot proceed.")
return()
endif ()
message(STATUS "Using Python3 for code generation: ${Python3_EXECUTABLE}")
# Set up Python virtual environment for code generation
if (CODEGEN_VENV_DIR)
# User-provided venv - skip automatic setup
set(VENV_DIR "${CODEGEN_VENV_DIR}")
message(STATUS "Using user-provided Python venv: ${VENV_DIR}")
else ()
# Use default venv in build directory
set(VENV_DIR "${CMAKE_CURRENT_BINARY_DIR}/codegen_venv")
endif ()
# Determine the Python executable path in the venv
if (WIN32)
set(VENV_PYTHON "${VENV_DIR}/Scripts/python.exe")
set(VENV_PIP "${VENV_DIR}/Scripts/pip.exe")
else ()
set(VENV_PYTHON "${VENV_DIR}/bin/python")
set(VENV_PIP "${VENV_DIR}/bin/pip")
endif ()
# Only auto-setup venv if not user-provided
if (NOT CODEGEN_VENV_DIR)
# Check if venv needs to be created or updated
set(VENV_NEEDS_UPDATE FALSE)
if (NOT EXISTS "${VENV_PYTHON}")
set(VENV_NEEDS_UPDATE TRUE)
message(STATUS "Creating Python virtual environment for code generation...")
elseif ("${REQUIREMENTS_FILE}" IS_NEWER_THAN "${VENV_DIR}/.requirements_installed")
set(VENV_NEEDS_UPDATE TRUE)
message(STATUS "Updating Python virtual environment (requirements changed)...")
endif ()
# Create/update virtual environment if needed
if (VENV_NEEDS_UPDATE)
message(STATUS "Setting up Python virtual environment at ${VENV_DIR}")
execute_process(COMMAND ${Python3_EXECUTABLE} -m venv "${VENV_DIR}"
RESULT_VARIABLE VENV_RESULT ERROR_VARIABLE VENV_ERROR)
if (NOT VENV_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to create virtual environment: ${VENV_ERROR}")
endif ()
message(STATUS "Installing Python dependencies...")
execute_process(COMMAND ${VENV_PIP} install --upgrade pip
RESULT_VARIABLE PIP_UPGRADE_RESULT OUTPUT_QUIET
ERROR_VARIABLE PIP_UPGRADE_ERROR)
if (NOT PIP_UPGRADE_RESULT EQUAL 0)
message(WARNING "Failed to upgrade pip: ${PIP_UPGRADE_ERROR}")
endif ()
execute_process(COMMAND ${VENV_PIP} install -r "${REQUIREMENTS_FILE}"
RESULT_VARIABLE PIP_INSTALL_RESULT ERROR_VARIABLE PIP_INSTALL_ERROR)
if (NOT PIP_INSTALL_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to install Python dependencies: ${PIP_INSTALL_ERROR}")
endif ()
# Mark requirements as installed
file(TOUCH "${VENV_DIR}/.requirements_installed")
message(STATUS "Python virtual environment ready")
endif ()
endif ()
# Generate transaction classes at configure time
message(STATUS "Generating transaction classes from transactions.macro...")
execute_process(COMMAND ${VENV_PYTHON} "${GENERATE_TX_SCRIPT}" "${TRANSACTIONS_MACRO}"
--header-dir "${AUTOGEN_HEADER_DIR}/transactions" --sfields-macro
"${SFIELDS_MACRO}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE TX_GEN_RESULT
OUTPUT_VARIABLE TX_GEN_OUTPUT
ERROR_VARIABLE TX_GEN_ERROR)
if (NOT TX_GEN_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to generate transaction classes:\n${TX_GEN_ERROR}")
else ()
message(STATUS "Transaction classes generated successfully")
endif ()
# Generate ledger entry classes at configure time
message(STATUS "Generating ledger entry classes from ledger_entries.macro...")
execute_process(COMMAND ${VENV_PYTHON} "${GENERATE_LEDGER_SCRIPT}" "${LEDGER_ENTRIES_MACRO}"
--header-dir "${AUTOGEN_HEADER_DIR}/ledger_objects" --sfields-macro
"${SFIELDS_MACRO}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE LEDGER_GEN_RESULT
OUTPUT_VARIABLE LEDGER_GEN_OUTPUT
ERROR_VARIABLE LEDGER_GEN_ERROR)
if (NOT LEDGER_GEN_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to generate ledger entry classes:\n${LEDGER_GEN_ERROR}")
else ()
message(STATUS "Ledger entry classes generated successfully")
endif ()
# Register dependencies so CMake reconfigures when these files change
set_property(DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS
"${TRANSACTIONS_MACRO}"
"${LEDGER_ENTRIES_MACRO}"
"${SFIELDS_MACRO}"
"${GENERATE_TX_SCRIPT}"
"${GENERATE_LEDGER_SCRIPT}"
"${SCRIPTS_DIR}/macro_parser_common.py"
"${SCRIPTS_DIR}/templates/Transaction.h.mako"
"${SCRIPTS_DIR}/templates/LedgerEntry.h.mako"
"${REQUIREMENTS_FILE}")
endfunction ()

View File

@@ -71,6 +71,7 @@ words:
- coldwallet
- compr
- conanfile
- cppcoro
- conanrun
- confs
- connectability
@@ -101,9 +102,11 @@ words:
- Falco
- finalizers
- firewalled
- fcontext
- fmtdur
- fsanitize
- funclets
- gantt
- gcov
- gcovr
- ghead
@@ -176,8 +179,6 @@ words:
- nixfmt
- nixos
- nixpkgs
- NOLINT
- NOLINTNEXTLINE
- nonxrp
- noripple
- nudb
@@ -187,6 +188,7 @@ words:
- ostr
- pargs
- partitioner
- pratik
- paychan
- paychans
- permdex
@@ -208,6 +210,7 @@ words:
- queuable
- Raphson
- replayer
- repost
- rerere
- retriable
- RIPD
@@ -238,6 +241,7 @@ words:
- soci
- socidb
- sslws
- stackful
- statsd
- STATSDCOLLECTOR
- stissue

View File

@@ -1,7 +1,6 @@
#pragma once
#include <string>
#include <string_view>
#include <vector>
namespace beast {
@@ -27,14 +26,14 @@ public:
SemanticVersion();
SemanticVersion(std::string_view version);
SemanticVersion(std::string const& version);
/** Parse a semantic version string.
The parsing is as strict as possible.
@return `true` if the string was parsed.
*/
bool
parse(std::string_view input);
parse(std::string const& input);
/** Produce a string from semantic version components. */
std::string

View File

@@ -0,0 +1,687 @@
#pragma once
#include <coroutine>
#include <exception>
#include <utility>
#include <variant>
namespace xrpl {
template <typename T = void>
class CoroTask;
/**
* CoroTask<void> -- coroutine return type for void-returning coroutines.
*
* Class / Dependency Diagram
* ==========================
*
* CoroTask<void>
* +-----------------------------------------------+
* | - handle_ : Handle (coroutine_handle<promise>) |
* +-----------------------------------------------+
* | + handle(), done() |
* | + await_ready/suspend/resume (Awaiter iface) |
* +-----------------------------------------------+
* | owns
* v
* promise_type
* +-----------------------------------------------+
* | - exception_ : std::exception_ptr |
* | - continuation_ : std::coroutine_handle<> |
* +-----------------------------------------------+
* | + get_return_object() -> CoroTask |
* | + initial_suspend() -> suspend_always (lazy) |
* | + final_suspend() -> FinalAwaiter |
* | + return_void() |
* | + unhandled_exception() |
* +-----------------------------------------------+
* | returns at final_suspend
* v
* FinalAwaiter
* +-----------------------------------------------+
* | await_suspend(h): |
* | if continuation_ set -> symmetric transfer |
* | else -> noop_coroutine |
* +-----------------------------------------------+
*
* Design Notes
* ------------
* - Lazy start: initial_suspend returns suspend_always, so the coroutine
* body does not execute until the handle is explicitly resumed.
* - Symmetric transfer: await_suspend returns a coroutine_handle instead
* of void/bool, allowing the scheduler to jump directly to the next
* coroutine without growing the call stack.
* - Continuation chaining: when one CoroTask is co_await-ed inside
* another, the caller's handle is stored as continuation_ so
* FinalAwaiter can resume it when this task finishes.
* - Move-only: the handle is exclusively owned; copy is deleted.
*
* Usage Examples
* ==============
*
* 1. Basic void coroutine (the most common case in rippled):
*
* CoroTask<void> doWork(std::shared_ptr<CoroTaskRunner> runner) {
* // do something
* co_await runner->suspend(); // yield control
* // resumed later via runner->post() or runner->resume()
* co_return;
* }
*
* 2. co_await-ing one CoroTask<void> from another (chaining):
*
* CoroTask<void> inner() {
* // ...
* co_return;
* }
* CoroTask<void> outer() {
* co_await inner(); // continuation_ links outer -> inner
* co_return; // FinalAwaiter resumes outer
* }
*
* 3. Exceptions propagate through co_await:
*
* CoroTask<void> failing() {
* throw std::runtime_error("oops");
* co_return;
* }
* CoroTask<void> caller() {
* try { co_await failing(); }
* catch (std::runtime_error const&) { // caught here }
* }
*
* Caveats / Pitfalls
* ==================
*
* BUG-RISK: Dangling references in coroutine parameters.
* Coroutine parameters are copied into the frame, but references
* are NOT -- they are stored as-is. If the referent goes out of scope
* before the coroutine finishes, you get use-after-free.
*
* // BROKEN -- local dies before coroutine runs:
* CoroTask<void> bad(int& ref) { co_return; }
* void launch() {
* int local = 42;
* auto task = bad(local); // frame stores &local
* } // local destroyed; frame holds dangling ref
*
* // FIX -- pass by value, or ensure lifetime via shared_ptr.
*
* BUG-RISK: GCC 14 corrupts reference captures in coroutine lambdas.
* When a lambda that returns CoroTask captures by reference ([&]),
* GCC 14 may generate a corrupted coroutine frame. Always capture
* by explicit pointer-to-value instead:
*
* // BROKEN on GCC 14:
* jq.postCoroTask(t, n, [&](auto) -> CoroTask<void> { ... });
*
* // FIX -- capture pointers explicitly:
* jq.postCoroTask(t, n, [ptr = &val](auto) -> CoroTask<void> { ... });
*
* BUG-RISK: Resuming a destroyed or completed CoroTask.
* Calling handle().resume() after the coroutine has already run to
* completion (done() == true) is undefined behavior. The CoroTaskRunner
* guards against this with an XRPL_ASSERT, but standalone usage of
* CoroTask must check done() before resuming.
*
* BUG-RISK: Moving a CoroTask that is being awaited.
* If task A is co_await-ed by task B (so A.continuation_ == B), moving
* or destroying A will invalidate the continuation link. Never move
* or reassign a CoroTask while it is mid-execution or being awaited.
*
* LIMITATION: CoroTask is fire-and-forget for the top-level owner.
* There is no built-in notification when the coroutine finishes.
* The caller must use external synchronization (e.g. CoroTaskRunner::join
* or a gate/condition_variable) to know when it is done.
*
* LIMITATION: No cancellation token.
* There is no way to cancel a suspended CoroTask from outside. The
* coroutine body must cooperatively check a flag (e.g. jq_.isStopping())
* after each co_await and co_return early if needed.
*
* LIMITATION: Stackless -- cannot suspend from nested non-coroutine calls.
* If a coroutine calls a regular function that wants to "yield", it
* cannot. Only the immediate coroutine body can use co_await.
* This is acceptable for rippled because all yield() sites are shallow.
*/
template <>
class CoroTask<void>
{
public:
struct promise_type;
using Handle = std::coroutine_handle<promise_type>;
/**
* Coroutine promise. Compiler uses this to manage coroutine state.
* Stores the exception (if any) and the continuation handle for
* symmetric transfer back to the awaiting coroutine.
*/
struct promise_type
{
// Captured exception from the coroutine body, rethrown in
// await_resume() when this task is co_await-ed by a caller.
std::exception_ptr exception_;
// Handle to the coroutine that is co_await-ing this task.
// Set by await_suspend(). FinalAwaiter uses it for symmetric
// transfer back to the caller. Null if this is a top-level task.
std::coroutine_handle<> continuation_;
/**
* Create the CoroTask return object.
* Called by the compiler at coroutine creation.
*/
CoroTask
get_return_object()
{
return CoroTask{Handle::from_promise(*this)};
}
/**
* Lazy start. The coroutine body does not execute until the
* handle is explicitly resumed (e.g. by CoroTaskRunner::resume).
*/
std::suspend_always
initial_suspend() noexcept
{
return {};
}
/**
* Awaiter returned by final_suspend(). Uses symmetric transfer:
* if a continuation exists, transfers control directly to it
* (tail-call, no stack growth). Otherwise returns noop_coroutine
* so the coroutine frame stays alive for the owner to destroy.
*/
struct FinalAwaiter
{
/**
* Always false. We need await_suspend to run for
* symmetric transfer.
*/
bool
await_ready() noexcept
{
return false;
}
/**
* Symmetric transfer: returns the continuation handle so
* the compiler emits a tail-call instead of a nested resume.
* If no continuation is set, returns noop_coroutine to
* suspend at final_suspend without destroying the frame.
*
* @param h Handle to this completing coroutine
*
* @return Continuation handle, or noop_coroutine
*/
std::coroutine_handle<>
await_suspend(Handle h) noexcept
{
if (auto cont = h.promise().continuation_)
return cont;
return std::noop_coroutine();
}
void
await_resume() noexcept
{
}
};
/**
* Returns FinalAwaiter for symmetric transfer at coroutine end.
*/
FinalAwaiter
final_suspend() noexcept
{
return {};
}
/**
* Called by the compiler for `co_return;` (void coroutine).
*/
void
return_void()
{
}
/**
* Called by the compiler when an exception escapes the coroutine
* body. Captures it for later rethrowing in await_resume().
*/
void
unhandled_exception()
{
exception_ = std::current_exception();
}
};
/**
* Default constructor. Creates an empty (null handle) task.
*/
CoroTask() = default;
/**
* Takes ownership of a compiler-generated coroutine handle.
*
* @param h Coroutine handle to own
*/
explicit CoroTask(Handle h) : handle_(h)
{
}
/**
* Destroys the coroutine frame if this task owns one.
*/
~CoroTask()
{
if (handle_)
handle_.destroy();
}
/**
* Move constructor. Transfers handle ownership, leaves other empty.
*/
CoroTask(CoroTask&& other) noexcept : handle_(std::exchange(other.handle_, {}))
{
}
/**
* Move assignment. Destroys current frame (if any), takes other's.
*/
CoroTask&
operator=(CoroTask&& other) noexcept
{
if (this != &other)
{
if (handle_)
handle_.destroy();
handle_ = std::exchange(other.handle_, {});
}
return *this;
}
CoroTask(CoroTask const&) = delete;
CoroTask&
operator=(CoroTask const&) = delete;
/**
* @return The underlying coroutine_handle
*/
Handle
handle() const
{
return handle_;
}
/**
* @return true if the coroutine has run to completion (or thrown)
*/
bool
done() const
{
return handle_ && handle_.done();
}
// -- Awaiter interface: allows `co_await someCoroTask;` --
/**
* Always false. This task is lazy, so co_await always suspends
* the caller to set up the continuation link.
*/
bool
await_ready() const noexcept
{
return false;
}
/**
* Stores the caller's handle as our continuation, then returns
* our handle for symmetric transfer (caller suspends, we resume).
*
* @param caller Handle of the coroutine doing co_await on us
*
* @return Our handle for symmetric transfer
*/
std::coroutine_handle<>
await_suspend(std::coroutine_handle<> caller) noexcept
{
handle_.promise().continuation_ = caller;
return handle_; // Symmetric transfer
}
/**
* Called when the caller resumes after co_await. Rethrows any
* exception captured by unhandled_exception().
*/
void
await_resume()
{
if (auto& ep = handle_.promise().exception_)
std::rethrow_exception(ep);
}
private:
// Exclusively-owned coroutine handle. Null after move or default
// construction. Destroyed in the destructor.
Handle handle_;
};
/**
* CoroTask<T> -- coroutine return type for value-returning coroutines.
*
* Class / Dependency Diagram
* ==========================
*
* CoroTask<T>
* +-----------------------------------------------+
* | - handle_ : Handle (coroutine_handle<promise>) |
* +-----------------------------------------------+
* | + handle(), done() |
* | + await_ready/suspend/resume (Awaiter iface) |
* +-----------------------------------------------+
* | owns
* v
* promise_type
* +-----------------------------------------------+
* | - result_ : variant<monostate, T, |
* | exception_ptr> |
* | - continuation_ : std::coroutine_handle<> |
* +-----------------------------------------------+
* | + get_return_object() -> CoroTask |
* | + initial_suspend() -> suspend_always (lazy) |
* | + final_suspend() -> FinalAwaiter |
* | + return_value(T) -> stores in result_[1] |
* | + unhandled_exception -> stores in result_[2] |
* +-----------------------------------------------+
* | returns at final_suspend
* v
* FinalAwaiter (same symmetric-transfer pattern as CoroTask<void>)
*
* Value Extraction
* ----------------
* await_resume() inspects the variant:
* - index 2 (exception_ptr) -> rethrow
* - index 1 (T) -> return value via move
*
* Usage Examples
* ==============
*
* 1. Simple value return:
*
* CoroTask<int> computeAnswer() { co_return 42; }
*
* CoroTask<void> caller() {
* int v = co_await computeAnswer(); // v == 42
* }
*
* 2. Chaining value-returning coroutines:
*
* CoroTask<int> add(int a, int b) { co_return a + b; }
* CoroTask<int> doubleSum(int a, int b) {
* int s = co_await add(a, b);
* co_return s * 2;
* }
*
* 3. Exception propagation from inner to outer:
*
* CoroTask<int> failing() {
* throw std::runtime_error("bad");
* co_return 0; // never reached
* }
* CoroTask<void> caller() {
* try {
* int v = co_await failing(); // throws here
* } catch (std::runtime_error const& e) {
* // e.what() == "bad"
* }
* }
*
* Caveats / Pitfalls (in addition to CoroTask<void> caveats above)
* ================================================================
*
* BUG-RISK: await_resume() moves the value out of the variant.
* Calling co_await on the same CoroTask<T> instance twice is undefined
* behavior -- the second call will see a moved-from T. CoroTask is
* single-shot: one co_return, one co_await.
*
* BUG-RISK: T must be move-constructible.
* return_value(T) takes by value and moves into the variant.
* Types that are not movable cannot be used as T.
*
* LIMITATION: No co_yield support.
* CoroTask<T> only supports a single co_return. It does not implement
* yield_value(), so using co_yield inside a CoroTask<T> coroutine is a
* compile error. For streaming values, a different return type
* (e.g. Generator<T>) would be needed.
*
* LIMITATION: Result is only accessible via co_await.
* There is no .get() or .result() method. The value can only be
* extracted by co_await-ing the CoroTask<T> from inside another
* coroutine. For extracting results in non-coroutine code, pass a
* pointer to the caller and write through it (as the tests do).
*/
template <typename T>
class CoroTask
{
public:
struct promise_type;
using Handle = std::coroutine_handle<promise_type>;
/**
* Coroutine promise for value-returning coroutines.
* Stores the result as a variant: monostate (not yet set),
* T (co_return value), or exception_ptr (unhandled exception).
*/
struct promise_type
{
// Tri-state result:
// index 0 (monostate) -- coroutine has not yet completed
// index 1 (T) -- co_return value stored here
// index 2 (exception) -- unhandled exception captured here
std::variant<std::monostate, T, std::exception_ptr> result_;
// Handle to the coroutine co_await-ing this task. Used by
// FinalAwaiter for symmetric transfer. Null for top-level tasks.
std::coroutine_handle<> continuation_;
/**
* Create the CoroTask return object.
* Called by the compiler at coroutine creation.
*/
CoroTask
get_return_object()
{
return CoroTask{Handle::from_promise(*this)};
}
/**
* Lazy start. Coroutine body does not run until explicitly resumed.
*/
std::suspend_always
initial_suspend() noexcept
{
return {};
}
/**
* Symmetric-transfer awaiter at coroutine completion.
* Same pattern as CoroTask<void>::FinalAwaiter.
*/
struct FinalAwaiter
{
bool
await_ready() noexcept
{
return false;
}
/**
* Returns continuation for symmetric transfer, or
* noop_coroutine if this is a top-level task.
*
* @param h Handle to this completing coroutine
*
* @return Continuation handle, or noop_coroutine
*/
std::coroutine_handle<>
await_suspend(Handle h) noexcept
{
if (auto cont = h.promise().continuation_)
return cont;
return std::noop_coroutine();
}
void
await_resume() noexcept
{
}
};
FinalAwaiter
final_suspend() noexcept
{
return {};
}
/**
* Called by the compiler for `co_return value;`.
* Moves the value into result_ at index 1.
*
* @param value The value to store
*/
void
return_value(T value)
{
result_.template emplace<1>(std::move(value));
}
/**
* Captures unhandled exceptions at index 2 of result_.
* Rethrown later in await_resume().
*/
void
unhandled_exception()
{
result_.template emplace<2>(std::current_exception());
}
};
/**
* Default constructor. Creates an empty (null handle) task.
*/
CoroTask() = default;
/**
* Takes ownership of a compiler-generated coroutine handle.
*
* @param h Coroutine handle to own
*/
explicit CoroTask(Handle h) : handle_(h)
{
}
/**
* Destroys the coroutine frame if this task owns one.
*/
~CoroTask()
{
if (handle_)
handle_.destroy();
}
/**
* Move constructor. Transfers handle ownership, leaves other empty.
*/
CoroTask(CoroTask&& other) noexcept : handle_(std::exchange(other.handle_, {}))
{
}
/**
* Move assignment. Destroys current frame (if any), takes other's.
*/
CoroTask&
operator=(CoroTask&& other) noexcept
{
if (this != &other)
{
if (handle_)
handle_.destroy();
handle_ = std::exchange(other.handle_, {});
}
return *this;
}
CoroTask(CoroTask const&) = delete;
CoroTask&
operator=(CoroTask const&) = delete;
/**
* @return The underlying coroutine_handle
*/
Handle
handle() const
{
return handle_;
}
/**
* @return true if the coroutine has run to completion (or thrown)
*/
bool
done() const
{
return handle_ && handle_.done();
}
// -- Awaiter interface: allows `T val = co_await someCoroTask;` --
/**
* Always false. co_await always suspends to set up continuation.
*/
bool
await_ready() const noexcept
{
return false;
}
/**
* Stores caller as continuation, returns our handle for
* symmetric transfer.
*
* @param caller Handle of the coroutine doing co_await on us
*
* @return Our handle for symmetric transfer
*/
std::coroutine_handle<>
await_suspend(std::coroutine_handle<> caller) noexcept
{
handle_.promise().continuation_ = caller;
return handle_;
}
/**
* Extracts the result: rethrows if exception, otherwise moves
* the T value out of the variant. Single-shot: calling twice
* on the same task is undefined (moved-from T).
*
* @return The co_return-ed value
*/
T
await_resume()
{
auto& result = handle_.promise().result_;
if (auto* ep = std::get_if<2>(&result))
std::rethrow_exception(*ep);
return std::get<1>(std::move(result));
}
private:
// Exclusively-owned coroutine handle. Null after move or default
// construction. Destroyed in the destructor.
Handle handle_;
};
} // namespace xrpl

View File

@@ -0,0 +1,329 @@
#pragma once
/**
* @file CoroTaskRunner.ipp
*
* CoroTaskRunner inline implementation.
*
* This file contains the business logic for managing C++20 coroutines
* on the JobQueue. It is included at the bottom of JobQueue.h.
*
* Data Flow: suspend / post / resume cycle
* =========================================
*
* coroutine body CoroTaskRunner JobQueue
* -------------- -------------- --------
* |
* co_await runner->suspend()
* |
* +--- await_suspend ------> onSuspend()
* | ++nSuspend_ ------------> nSuspend_
* | [coroutine is now suspended]
* |
* . (externally or by JobQueueAwaiter)
* .
* +--- (caller calls) -----> post()
* | ++runCount_
* | addJob(resume) ----------> job enqueued
* | |
* | [worker picks up]
* | |
* +--- <----- resume() <-----------------------------------+
* | --nSuspend_ ------> nSuspend_
* | swap in LocalValues (lvs_)
* | task_.handle().resume()
* | |
* | [coroutine body continues here]
* | |
* | swap out LocalValues
* | --runCount_
* | cv_.notify_all()
* v
*
* Thread Safety
* =============
* - mutex_ : guards task_.handle().resume() so that post()-before-suspend
* races cannot resume the coroutine while it is still running.
* (See the race condition discussion in JobQueue.h)
* - mutex_run_ : guards runCount_ counter; used by join() to wait until
* all in-flight resume operations complete.
* - jq_.m_mutex: guards nSuspend_ increments/decrements.
*
* Common Mistakes When Modifying This File
* =========================================
*
* 1. Changing lock ordering.
* resume() acquires locks in this order: jq_.m_mutex -> mutex_ -> mutex_run_.
* post() acquires only mutex_run_. Any new code path that touches these
* mutexes must follow the same order to avoid deadlocks.
*
* 2. Removing the shared_from_this() capture in post().
* The lambda passed to addJob captures [this, sp = shared_from_this()].
* If you remove sp, 'this' can be destroyed before the job runs,
* causing use-after-free. The sp capture is load-bearing.
*
* 3. Forgetting to decrement nSuspend_ on a new code path.
* Every ++nSuspend_ must have a matching --nSuspend_. If you add a new
* suspension path (e.g. a new awaiter) and forget to decrement on resume
* or on failure, JobQueue::stop() will hang.
*
* 4. Calling task_.handle().resume() without holding mutex_.
* This allows a race where the coroutine runs on two threads
* simultaneously. Always hold mutex_ around resume().
*
* 5. Swapping LocalValues outside of the mutex_ critical section.
* The swap-in and swap-out of LocalValues must bracket the resume()
* call. If you move the swap-out before the lock_guard(mutex_) is
* released, you break LocalValue isolation for any code that runs
* after the coroutine suspends but before the lock is dropped.
*/
//
namespace xrpl {
/**
* Construct a CoroTaskRunner. Sets runCount_ to 0; does not
* create the coroutine. Call init() afterwards.
*
* @param jq The JobQueue this coroutine will run on
* @param type Job type for scheduling priority
* @param name Human-readable name for logging
*/
inline JobQueue::CoroTaskRunner::CoroTaskRunner(
create_t,
JobQueue& jq,
JobType type,
std::string const& name)
: jq_(jq), type_(type), name_(name), runCount_(0)
{
}
/**
* Initialize with a coroutine-returning callable.
* Stores the callable on the heap (FuncStore) so it outlives the
* coroutine frame. Coroutine frames store a reference to the
* callable's implicit object parameter (the lambda). If the callable
* is a temporary, that reference dangles after the caller returns.
* Keeping the callable alive here ensures the coroutine's captures
* remain valid.
*
* @param f Callable: CoroTask<void>(shared_ptr<CoroTaskRunner>)
*/
template <class F>
void
JobQueue::CoroTaskRunner::init(F&& f)
{
using Fn = std::decay_t<F>;
auto store = std::make_unique<FuncStore<Fn>>(std::forward<F>(f));
task_ = store->func(shared_from_this());
storedFunc_ = std::move(store);
}
/**
* Destructor. Waits for any in-flight resume() to complete, then
* asserts (debug) that the coroutine has finished or
* expectEarlyExit() was called.
*
* The join() call is necessary because with async dispatch the
* coroutine runs on a worker thread. The gate signal (which wakes
* the test thread) can arrive before resume() has set finished_.
* join() synchronizes via mutex_run_, establishing a happens-before
* edge: finished_ = true → unlock(mutex_run_) in resume() →
* lock(mutex_run_) in join() → read finished_.
*/
inline JobQueue::CoroTaskRunner::~CoroTaskRunner()
{
#ifndef NDEBUG
join();
XRPL_ASSERT(finished_, "xrpl::JobQueue::CoroTaskRunner::~CoroTaskRunner : is finished");
#endif
}
/**
* Increment the JobQueue's suspended-coroutine count (nSuspend_).
*/
inline void
JobQueue::CoroTaskRunner::onSuspend()
{
std::lock_guard lock(jq_.m_mutex);
++jq_.nSuspend_;
}
/**
* Decrement nSuspend_ without resuming.
*/
inline void
JobQueue::CoroTaskRunner::onUndoSuspend()
{
std::lock_guard lock(jq_.m_mutex);
--jq_.nSuspend_;
}
/**
* Return a SuspendAwaiter whose await_suspend() increments nSuspend_
* before the coroutine actually suspends. The caller must later call
* post() or resume() to continue execution.
*
* @return Awaiter for use with `co_await runner->suspend()`
*/
inline auto
JobQueue::CoroTaskRunner::suspend()
{
/**
* Custom awaiter for suspend(). Always suspends (await_ready
* returns false) and increments nSuspend_ in await_suspend().
*/
struct SuspendAwaiter
{
CoroTaskRunner& runner_; // The runner that owns this coroutine.
/**
* Always returns false so the coroutine suspends.
*/
bool
await_ready() const noexcept
{
return false;
}
/**
* Called when the coroutine suspends. Increments nSuspend_
* so the JobQueue knows a coroutine is waiting.
*/
void
await_suspend(std::coroutine_handle<>) const
{
runner_.onSuspend();
}
void
await_resume() const noexcept
{
}
};
return SuspendAwaiter{*this};
}
/**
* Schedule coroutine resumption as a job on the JobQueue.
* A shared_ptr capture (sp) prevents this CoroTaskRunner from being
* destroyed while the job is queued but not yet executed.
*
* @return false if the JobQueue rejected the job (shutting down)
*/
inline bool
JobQueue::CoroTaskRunner::post()
{
{
std::lock_guard lk(mutex_run_);
++runCount_;
}
// sp prevents 'this' from being destroyed while the job is pending
if (jq_.addJob(type_, name_, [this, sp = shared_from_this()]() { resume(); }))
{
return true;
}
// The coroutine will not run. Undo the runCount_ increment.
std::lock_guard lk(mutex_run_);
--runCount_;
cv_.notify_all();
return false;
}
/**
* Resume the coroutine on the current thread.
*
* Steps:
* 1. Decrement nSuspend_ (under jq_.m_mutex)
* 2. Swap in this coroutine's LocalValues for thread-local isolation
* 3. Resume the coroutine handle (under mutex_)
* 4. Swap out LocalValues, restoring the thread's previous state
* 5. Decrement runCount_ and notify join() waiters
*
* Note: runCount_ is NOT incremented here — post() already did that.
* This ensures join() stays blocked for the entire post→resume lifetime.
*/
inline void
JobQueue::CoroTaskRunner::resume()
{
{
std::lock_guard lock(jq_.m_mutex);
--jq_.nSuspend_;
}
auto saved = detail::getLocalValues().release();
detail::getLocalValues().reset(&lvs_);
std::lock_guard lock(mutex_);
XRPL_ASSERT(!task_.done(), "xrpl::JobQueue::CoroTaskRunner::resume : task is not done");
task_.handle().resume();
detail::getLocalValues().release();
detail::getLocalValues().reset(saved);
if (task_.done())
{
#ifndef NDEBUG
finished_ = true;
#endif
// Break the shared_ptr cycle: frame -> shared_ptr<runner> -> this.
// Use std::move (not task_ = {}) so task_.handle_ is null BEFORE the
// frame is destroyed. operator= would destroy the frame while handle_
// still holds the old value -- a re-entrancy hazard on GCC-12 if
// frame destruction triggers runner cleanup.
[[maybe_unused]] auto completed = std::move(task_);
}
std::lock_guard lk(mutex_run_);
--runCount_;
cv_.notify_all();
}
/**
* @return true if the coroutine has not yet run to completion
*/
inline bool
JobQueue::CoroTaskRunner::runnable() const
{
// After normal completion, task_ is reset to break the shared_ptr cycle
// (handle_ becomes null). A null handle means the coroutine is done.
return task_.handle() && !task_.done();
}
/**
* Handle early termination when the coroutine never ran (e.g. JobQueue
* is stopping). Decrements nSuspend_ and destroys the coroutine frame
* to break the shared_ptr cycle: frame -> lambda -> runner -> frame.
*/
inline void
JobQueue::CoroTaskRunner::expectEarlyExit()
{
#ifndef NDEBUG
if (!finished_)
#endif
{
std::lock_guard lock(jq_.m_mutex);
--jq_.nSuspend_;
#ifndef NDEBUG
finished_ = true;
#endif
}
// Break the shared_ptr cycle: frame -> shared_ptr<runner> -> this.
// The coroutine is at initial_suspend and never ran user code, so
// destroying it is safe. Use std::move (not task_ = {}) so
// task_.handle_ is null before the frame is destroyed.
{
[[maybe_unused]] auto completed = std::move(task_);
}
storedFunc_.reset();
}
/**
* Block until all pending/active resume operations complete.
* Uses cv_ + mutex_run_ to wait until runCount_ reaches 0.
*/
inline void
JobQueue::CoroTaskRunner::join()
{
std::unique_lock<std::mutex> lk(mutex_run_);
cv_.wait(lk, [this]() { return runCount_ == 0; });
}
} // namespace xrpl

View File

@@ -2,6 +2,7 @@
#include <xrpl/basics/LocalValue.h>
#include <xrpl/core/ClosureCounter.h>
#include <xrpl/core/CoroTask.h>
#include <xrpl/core/JobTypeData.h>
#include <xrpl/core/JobTypes.h>
#include <xrpl/core/detail/Workers.h>
@@ -9,6 +10,7 @@
#include <boost/coroutine/all.hpp>
#include <coroutine>
#include <set>
namespace xrpl {
@@ -119,6 +121,395 @@ public:
join();
};
/** C++20 coroutine lifecycle manager. Replaces Coro for new code.
*
* Class / Inheritance / Dependency Diagram
* =========================================
*
* std::enable_shared_from_this<CoroTaskRunner>
* ^
* | (public inheritance)
* |
* CoroTaskRunner
* +---------------------------------------------------+
* | - lvs_ : detail::LocalValues |
* | - jq_ : JobQueue& |
* | - type_ : JobType |
* | - name_ : std::string |
* | - runCount_ : int (in-flight resumes) |
* | - mutex_ : std::mutex (coroutine guard) |
* | - mutex_run_ : std::mutex (join guard) |
* | - cv_ : condition_variable |
* | - task_ : CoroTask<void> |
* | - storedFunc_ : unique_ptr<FuncBase> (type-erased)|
* +---------------------------------------------------+
* | + init(F&&) : set up coroutine callable |
* | + onSuspend() : ++jq_.nSuspend_ |
* | + onUndoSuspend() : --jq_.nSuspend_ |
* | + suspend() : returns SuspendAwaiter |
* | + post() : schedule resume on JobQueue |
* | + resume() : resume coroutine on caller |
* | + runnable() : !task_.done() |
* | + expectEarlyExit() : teardown for failed post |
* | + join() : block until not running |
* +---------------------------------------------------+
* | |
* | owns | references
* v v
* CoroTask<void> JobQueue
* (coroutine frame) (thread pool + nSuspend_)
*
* FuncBase / FuncStore<F> (type-erased heap storage
* for the coroutine lambda)
*
* Coroutine Lifecycle (Control Flow)
* ===================================
*
* Caller thread JobQueue worker thread
* ------------- ----------------------
* postCoroTask(f)
* |
* +-- check stopping_ (reject if JQ shutting down)
* +-- ++nSuspend_ (lazy start counts as suspended)
* +-- make_shared<CoroTaskRunner>
* +-- init(f)
* | +-- store lambda on heap (FuncStore)
* | +-- task_ = f(shared_from_this())
* | [coroutine created, suspended at initial_suspend]
* +-- post()
* | +-- ++runCount_
* | +-- addJob(type_, [resume]{})
* | resume()
* | |
* | +-- --nSuspend_
* | +-- swap in LocalValues
* | +-- task_.handle().resume()
* | | [coroutine body runs]
* | | ...
* | | co_await suspend()
* | | +-- ++nSuspend_
* | | [coroutine suspends]
* | +-- swap out LocalValues
* | +-- --runCount_
* | +-- cv_.notify_all()
* |
* post() <-- called externally or by JobQueueAwaiter
* +-- ++runCount_
* +-- addJob(type_, [resume]{})
* resume()
* |
* +-- [coroutine body continues]
* +-- co_return
* +-- --runCount_
* +-- cv_.notify_all()
* join()
* +-- cv_.wait([]{runCount_ == 0})
* +-- [done]
*
* Usage Examples
* ==============
*
* 1. Fire-and-forget coroutine (most common pattern):
*
* jq.postCoroTask(jtCLIENT, "MyWork",
* [](auto runner) -> CoroTask<void> {
* doSomeWork();
* co_await runner->suspend(); // yield to other jobs
* doMoreWork();
* co_return;
* });
*
* 2. Manually controlling suspend / resume (external trigger):
*
* auto runner = jq.postCoroTask(jtCLIENT, "ExtTrigger",
* [&result](auto runner) -> CoroTask<void> {
* startAsyncOperation(callback);
* co_await runner->suspend();
* // callback called runner->post() to get here
* result = collectResult();
* co_return;
* });
* // ... later, from the callback:
* runner->post(); // reschedule the coroutine on the JobQueue
*
* 3. Using JobQueueAwaiter for automatic suspend + repost:
*
* jq.postCoroTask(jtCLIENT, "AutoRepost",
* [](auto runner) -> CoroTask<void> {
* step1();
* co_await JobQueueAwaiter{runner}; // yield + auto-repost
* step2();
* co_await JobQueueAwaiter{runner};
* step3();
* co_return;
* });
*
* 4. Checking shutdown after co_await (cooperative cancellation):
*
* jq.postCoroTask(jtCLIENT, "Cancellable",
* [&jq](auto runner) -> CoroTask<void> {
* while (moreWork()) {
* co_await JobQueueAwaiter{runner};
* if (jq.isStopping())
* co_return; // bail out cleanly
* processNextItem();
* }
* co_return;
* });
*
* Caveats / Pitfalls
* ==================
*
* BUG-RISK: Calling suspend() without a matching post()/resume().
* After co_await runner->suspend(), the coroutine is parked and
* nSuspend_ is incremented. If nothing ever calls post() or
* resume(), the coroutine is leaked and JobQueue::stop() will
* hang forever waiting for nSuspend_ to reach zero.
*
* BUG-RISK: Calling post() on an already-running coroutine.
* post() schedules a resume() job. If the coroutine has not
* actually suspended yet (no co_await executed), the resume job
* will try to call handle().resume() while the coroutine is still
* running on another thread. This is UB. The mutex_ prevents
* data corruption but the logic is wrong — always co_await
* suspend() before calling post(). (The test testIncorrectOrder
* shows this works only because mutex_ serializes the calls.)
*
* BUG-RISK: Dropping the shared_ptr<CoroTaskRunner> before join().
* The CoroTaskRunner destructor asserts (!finished_ is false).
* If you let the last shared_ptr die while the coroutine is still
* running or suspended, you get an assertion failure in debug and
* UB in release. Always call join() or expectEarlyExit() first.
*
* BUG-RISK: Lambda captures outliving the coroutine frame.
* The lambda passed to postCoroTask is heap-allocated (FuncStore)
* to prevent dangling. But objects captured by pointer still need
* their own lifetime management. If you capture a raw pointer to
* a stack variable, and the stack frame exits before the coroutine
* finishes, the pointer dangles. Use shared_ptr or ensure the
* pointed-to object outlives the coroutine.
*
* BUG-RISK: Forgetting co_return in a void coroutine.
* If the coroutine body falls off the end without co_return,
* the compiler may silently treat it as co_return (per standard),
* but some compilers warn. Always write explicit co_return.
*
* LIMITATION: CoroTaskRunner only supports CoroTask<void>.
* The task_ member is CoroTask<void>. To return values from
* the top-level coroutine, write through a captured pointer
* (as the tests demonstrate), or co_await inner CoroTask<T>
* coroutines that return values.
*
* LIMITATION: One coroutine per CoroTaskRunner.
* init() must be called exactly once. You cannot reuse a
* CoroTaskRunner to run a second coroutine. Create a new one
* via postCoroTask() instead.
*
* LIMITATION: No timeout on join().
* join() blocks indefinitely. If the coroutine is suspended
* and never posted, join() will deadlock. Use timed waits
* on the gate pattern (condition_variable + wait_for) in tests.
*/
class CoroTaskRunner : public std::enable_shared_from_this<CoroTaskRunner>
{
private:
// Per-coroutine thread-local storage. Swapped in before resume()
// and swapped out after, so each coroutine sees its own LocalValue
// state regardless of which worker thread executes it.
detail::LocalValues lvs_;
// Back-reference to the owning JobQueue. Used to post jobs,
// increment/decrement nSuspend_, and acquire jq_.m_mutex.
JobQueue& jq_;
// Job type passed to addJob() when posting this coroutine.
JobType type_;
// Human-readable name for this coroutine job (for logging).
std::string name_;
// Number of in-flight resume operations (pending + active).
// Incremented by post(), decremented when resume() finishes.
// Guarded by mutex_run_. join() blocks until this reaches 0.
//
// A counter (not a bool) is needed because post() can be called
// from within the coroutine body (e.g. via JobQueueAwaiter),
// enqueuing a second resume while the first is still running.
// A bool would be clobbered: R2.post() sets true, then R1's
// cleanup sets false — losing the fact that R2 is still pending.
int runCount_;
// Guards task_.handle().resume() to prevent the coroutine from
// running on two threads simultaneously. Handles the race where
// post() enqueues a resume before the coroutine has actually
// suspended (post-before-suspend pattern).
std::mutex mutex_;
// Guards runCount_. Used with cv_ for join() to wait
// until all pending/active resume operations complete.
std::mutex mutex_run_;
// Notified when runCount_ reaches zero, allowing
// join() waiters to wake up.
std::condition_variable cv_;
// The coroutine handle wrapper. Owns the coroutine frame.
// Set by init(), reset to empty by expectEarlyExit() on
// early termination.
CoroTask<void> task_;
/**
* Type-erased base for heap-stored callables.
* Prevents the coroutine lambda from being destroyed before
* the coroutine frame is done with it.
*
* @see FuncStore
*/
struct FuncBase
{
virtual ~FuncBase() = default;
};
/**
* Concrete type-erased storage for a callable of type F.
* The coroutine frame stores a reference to the lambda's implicit
* object parameter. If the lambda is a temporary, that reference
* dangles after the call returns. FuncStore keeps it alive on
* the heap for the lifetime of the CoroTaskRunner.
*/
template <class F>
struct FuncStore : FuncBase
{
F func; // The stored callable (coroutine lambda).
explicit FuncStore(F&& f) : func(std::move(f))
{
}
};
// Heap-allocated callable storage. Set by init(), ensures the
// lambda outlives the coroutine frame that references it.
std::unique_ptr<FuncBase> storedFunc_;
#ifndef NDEBUG
// Debug-only flag. True once the coroutine has completed or
// expectEarlyExit() was called. Asserted in the destructor
// to catch leaked runners.
bool finished_ = false;
#endif
public:
/**
* Tag type for private construction. Prevents external code
* from constructing CoroTaskRunner directly. Use postCoroTask().
*/
struct create_t
{
explicit create_t() = default;
};
/**
* Construct a CoroTaskRunner. Private by convention (create_t tag).
*
* @param jq The JobQueue this coroutine will run on
* @param type Job type for scheduling priority
* @param name Human-readable name for logging
*/
CoroTaskRunner(create_t, JobQueue&, JobType, std::string const&);
CoroTaskRunner(CoroTaskRunner const&) = delete;
CoroTaskRunner&
operator=(CoroTaskRunner const&) = delete;
/**
* Destructor. Asserts (debug) that the coroutine has finished
* or expectEarlyExit() was called.
*/
~CoroTaskRunner();
/**
* Initialize with a coroutine-returning callable.
* Must be called exactly once, after the object is managed by
* shared_ptr (because init uses shared_from_this internally).
* This is handled automatically by postCoroTask().
*
* @param f Callable: CoroTask<void>(shared_ptr<CoroTaskRunner>)
*/
template <class F>
void
init(F&& f);
/**
* Increment the JobQueue's suspended-coroutine count (nSuspend_).
* Called when the coroutine is about to suspend. Every call
* must be balanced by a corresponding decrement (via resume()
* or onUndoSuspend()), or JobQueue::stop() will hang.
*/
void
onSuspend();
/**
* Decrement nSuspend_ without resuming.
* Used to undo onSuspend() when a scheduled post() fails
* (e.g. JobQueue is stopping).
*/
void
onUndoSuspend();
/**
* Suspend the coroutine.
* The awaiter's await_suspend() increments nSuspend_ before the
* coroutine actually suspends. The caller must later call post()
* or resume() to continue execution.
*
* @return An awaiter for use with `co_await runner->suspend()`
*/
auto
suspend();
/**
* Schedule coroutine resumption as a job on the JobQueue.
* Captures shared_from_this() to prevent this runner from being
* destroyed while the job is queued.
*
* @return true if the job was accepted; false if the JobQueue
* is stopping (caller must handle cleanup)
*/
bool
post();
/**
* Resume the coroutine on the current thread.
* Decrements nSuspend_, swaps in LocalValues, resumes the
* coroutine handle, swaps out LocalValues, and notifies join()
* waiters. Lock ordering: mutex_run_ -> jq_.m_mutex -> mutex_.
*/
void
resume();
/**
* @return true if the coroutine has not yet run to completion
*/
bool
runnable() const;
/**
* Handle early termination when the coroutine never ran.
* Decrements nSuspend_ and destroys the coroutine frame to
* break the shared_ptr cycle (frame -> lambda -> runner -> frame).
* Called by postCoroTask() when post() fails.
*/
void
expectEarlyExit();
/**
* Block until all pending/active resume operations complete.
* Uses cv_ + mutex_run_ to wait until runCount_ reaches 0.
* Warning: deadlocks if the coroutine is suspended and never posted.
*/
void
join();
};
using JobFunction = std::function<void()>;
JobQueue(
@@ -165,6 +556,19 @@ public:
std::shared_ptr<Coro>
postCoro(JobType t, std::string const& name, F&& f);
/** Creates a C++20 coroutine and adds a job to the queue to run it.
@param t The type of job.
@param name Name of the job.
@param f Callable with signature
CoroTask<void>(std::shared_ptr<CoroTaskRunner>).
@return shared_ptr to posted CoroTaskRunner. nullptr if not successful.
*/
template <class F>
std::shared_ptr<CoroTaskRunner>
postCoroTask(JobType t, std::string const& name, F&& f);
/** Jobs waiting at this priority.
*/
int
@@ -379,6 +783,7 @@ private:
} // namespace xrpl
#include <xrpl/core/Coro.ipp>
#include <xrpl/core/CoroTaskRunner.ipp>
namespace xrpl {
@@ -401,4 +806,69 @@ JobQueue::postCoro(JobType t, std::string const& name, F&& f)
return coro;
}
// postCoroTask — entry point for launching a C++20 coroutine on the JobQueue.
//
// Control Flow
// ============
//
// postCoroTask(t, name, f)
// |
// +-- 1. Check stopping_ — reject if JQ shutting down
// |
// +-- 2. ++nSuspend_ (mirrors Boost Coro ctor's implicit yield)
// | The coroutine is "suspended" from the JobQueue's perspective
// | even though it hasn't run yet — this keeps the JQ shutdown
// | logic correct (it waits for nSuspend_ to reach 0).
// |
// +-- 3. Create CoroTaskRunner (shared_ptr, ref-counted)
// |
// +-- 4. runner->init(f)
// | +-- Heap-allocate the lambda (FuncStore) to prevent
// | | dangling captures in the coroutine frame
// | +-- task_ = f(shared_from_this())
// | [coroutine created but NOT started — lazy initial_suspend]
// |
// +-- 5. runner->post()
// | +-- addJob(type_, [resume]{}) → resume on worker thread
// | +-- failure (JQ stopping):
// | +-- runner->expectEarlyExit()
// | | --nSuspend_, destroy coroutine frame
// | +-- return nullptr
//
// Why async post() instead of synchronous resume()?
// ==================================================
// The initial dispatch MUST use async post() so the coroutine body runs on
// a JobQueue worker thread, not the caller's thread. resume() swaps the
// caller's thread-local LocalValues with the coroutine's private copy.
// If the coroutine mutates LocalValues (e.g. thread_specific_storage test),
// those mutations bleed back into the caller's thread-local state after the
// swap-out, corrupting subsequent tests that share the same thread pool.
// Async post() avoids this by running the coroutine on a worker thread whose
// LocalValues are managed by the thread pool, not by the caller.
//
template <class F>
std::shared_ptr<JobQueue::CoroTaskRunner>
JobQueue::postCoroTask(JobType t, std::string const& name, F&& f)
{
// Reject if the JQ is shutting down — matches addJob()'s stopping_ check.
// Must check before incrementing nSuspend_ to avoid leaving an orphan
// count that would cause stop() to hang.
if (stopping_)
return nullptr;
{
std::lock_guard lock(m_mutex);
++nSuspend_;
}
auto runner = std::make_shared<CoroTaskRunner>(CoroTaskRunner::create_t{}, *this, t, name);
runner->init(std::forward<F>(f));
if (!runner->post())
{
runner->expectEarlyExit();
runner.reset();
}
return runner;
}
} // namespace xrpl

View File

@@ -0,0 +1,174 @@
#pragma once
#include <xrpl/core/JobQueue.h>
#include <coroutine>
#include <memory>
namespace xrpl {
/**
* Awaiter that suspends and immediately reschedules on the JobQueue.
* Equivalent to calling yield() followed by post() in the old Coro API.
*
* Usage:
* co_await JobQueueAwaiter{runner};
*
* What it waits for: The coroutine is re-queued as a job and resumes
* when a worker thread picks it up.
*
* Which thread resumes: A JobQueue worker thread.
*
* What await_resume() returns: void.
*
* Dependency Diagram
* ==================
*
* JobQueueAwaiter
* +----------------------------------------------+
* | + runner : shared_ptr<CoroTaskRunner> |
* +----------------------------------------------+
* | + await_ready() -> false (always suspend) |
* | + await_suspend() -> bool (suspend or cancel) |
* | + await_resume() -> void |
* +----------------------------------------------+
* | |
* | uses | uses
* v v
* CoroTaskRunner JobQueue
* .onSuspend() (via runner->post() -> addJob)
* .onUndoSuspend()
* .post()
*
* Control Flow (await_suspend)
* ============================
*
* co_await JobQueueAwaiter{runner}
* |
* +-- await_ready() -> false
* +-- await_suspend(handle)
* |
* +-- runner->onSuspend() // ++nSuspend_
* +-- runner->post() // addJob to JobQueue
* | |
* | +-- success? return true // coroutine stays suspended
* | | // worker thread will call resume()
* | +-- failure? (JQ stopping)
* | +-- runner->onUndoSuspend() // --nSuspend_
* | +-- return false // coroutine continues immediately
* | // so it can clean up and co_return
*
* Usage Examples
* ==============
*
* 1. Yield and auto-repost (most common -- replaces yield() + post()):
*
* CoroTask<void> handler(auto runner) {
* doPartA();
* co_await JobQueueAwaiter{runner}; // yield + repost
* doPartB(); // runs on a worker thread
* co_return;
* }
*
* 2. Multiple yield points in a loop:
*
* CoroTask<void> batchProcessor(auto runner) {
* for (auto& item : items) {
* process(item);
* co_await JobQueueAwaiter{runner}; // let other jobs run
* }
* co_return;
* }
*
* 3. Graceful shutdown -- checking after resume:
*
* CoroTask<void> longTask(auto runner, JobQueue& jq) {
* while (hasWork()) {
* co_await JobQueueAwaiter{runner};
* // If JQ is stopping, await_suspend returns false and
* // the coroutine continues immediately without re-queuing.
* // Always check isStopping() to decide whether to proceed:
* if (jq.isStopping())
* co_return;
* doNextChunk();
* }
* co_return;
* }
*
* Caveats / Pitfalls
* ==================
*
* BUG-RISK: Using a stale or null runner.
* The runner shared_ptr must be valid and point to the CoroTaskRunner
* that owns the coroutine currently executing. Passing a runner from
* a different coroutine, or a default-constructed shared_ptr, is UB.
*
* BUG-RISK: Assuming resume happens on the same thread.
* After co_await JobQueueAwaiter, the coroutine resumes on whatever
* worker thread picks up the job. Do not rely on thread-local state
* unless it is managed through LocalValue (which CoroTaskRunner
* automatically swaps in/out).
*
* BUG-RISK: Ignoring the shutdown path.
* When the JobQueue is stopping, post() fails and await_suspend()
* returns false (coroutine does NOT actually suspend). The coroutine
* body continues immediately on the same thread. If your code after
* co_await assumes it was re-queued and is running on a worker thread,
* that assumption breaks during shutdown. Always handle the "JQ is
* stopping" case, either by checking jq.isStopping() or by letting
* the coroutine fall through to co_return naturally.
*
* DIFFERENCE from runner->suspend() + runner->post():
* JobQueueAwaiter combines both in one atomic operation. With the
* manual suspend()/post() pattern, there is a window between the
* two calls where an external event could race. JobQueueAwaiter
* removes that window -- onSuspend() and post() happen within the
* same await_suspend() call while the coroutine is guaranteed to
* be suspended. Prefer JobQueueAwaiter unless you need an external
* party to decide *when* to call post().
*/
struct JobQueueAwaiter
{
// The CoroTaskRunner that owns the currently executing coroutine.
std::shared_ptr<JobQueue::CoroTaskRunner> runner;
/**
* Always returns false so the coroutine suspends.
*/
bool
await_ready() const noexcept
{
return false;
}
/**
* Increment nSuspend (equivalent to yield()) and schedule resume
* on the JobQueue (equivalent to post()). If the JobQueue is
* stopping, undoes the suspend count and returns false so the
* coroutine continues immediately and can clean up.
*
* @return true if coroutine should stay suspended (job posted);
* false if coroutine should continue (JQ stopping)
*/
bool
await_suspend(std::coroutine_handle<>)
{
runner->onSuspend();
if (!runner->post())
{
// JobQueue is stopping. Undo the suspend count and
// don't actually suspend — the coroutine continues
// immediately so it can clean up and co_return.
runner->onUndoSuspend();
return false;
}
return true;
}
void
await_resume() const noexcept
{
}
};
} // namespace xrpl

View File

@@ -1,13 +0,0 @@
#pragma once
#include <string>
namespace xrpl::git {
std::string const&
getCommitHash();
std::string const&
getBuildBranch();
} // namespace xrpl::git

View File

@@ -23,13 +23,13 @@ public:
static constexpr size_t initialBufferSize = kilobytes(256);
RawStateTable()
: monotonic_resource_{
std::make_unique<boost::container::pmr::monotonic_buffer_resource>(initialBufferSize)}
: monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
initialBufferSize)}
, items_{monotonic_resource_.get()} {};
RawStateTable(RawStateTable const& rhs)
: monotonic_resource_{
std::make_unique<boost::container::pmr::monotonic_buffer_resource>(initialBufferSize)}
: monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
initialBufferSize)}
, items_{rhs.items_, monotonic_resource_.get()}
, dropsDestroyed_{rhs.dropsDestroyed_} {};

View File

@@ -49,7 +49,7 @@ getFullVersionString();
@return the encoded version in a 64-bit integer
*/
std::uint64_t
encodeSoftwareVersion(std::string_view versionStr);
encodeSoftwareVersion(char const* const versionStr);
/** Returns this server's version packed in a 64-bit integer. */
std::uint64_t

View File

@@ -30,11 +30,9 @@ public:
Item(
char const* name,
KeyType type,
std::vector<SOElement> uniqueFields,
std::vector<SOElement> commonFields)
: soTemplate_(std::move(uniqueFields), std::move(commonFields))
, name_(name)
, type_(type)
std::initializer_list<SOElement> uniqueFields,
std::initializer_list<SOElement> commonFields)
: soTemplate_(uniqueFields, commonFields), name_(name), type_(type)
{
// Verify that KeyType is appropriate.
static_assert(
@@ -144,16 +142,16 @@ protected:
@param name The name of this format.
@param type The type of this format.
@param uniqueFields A std::vector of unique fields
@param commonFields A std::vector of common fields
@param uniqueFields An std::initializer_list of unique fields
@param commonFields An std::initializer_list of common fields
@return The created format.
*/
Item const&
add(char const* name,
KeyType type,
std::vector<SOElement> uniqueFields,
std::vector<SOElement> commonFields = {})
std::initializer_list<SOElement> uniqueFields,
std::initializer_list<SOElement> commonFields = {})
{
if (auto const item = findByType(type))
{
@@ -162,7 +160,7 @@ protected:
item->getName());
}
formats_.emplace_front(name, type, std::move(uniqueFields), std::move(commonFields));
formats_.emplace_front(name, type, uniqueFields, commonFields);
Item const& item{formats_.front()};
names_[name] = &item;

View File

@@ -2,34 +2,36 @@
#include <xrpl/protocol/KnownFormats.h>
#include <map>
#include <string>
#include <vector>
namespace xrpl {
/** Identifiers for on-ledger objects.
Each ledger object requires a unique type identifier, which is stored within the object itself;
this makes it possible to iterate the entire ledger and determine each object's type and verify
that the object you retrieved from a given hash matches the expected type.
Each ledger object requires a unique type identifier, which is stored
within the object itself; this makes it possible to iterate the entire
ledger and determine each object's type and verify that the object you
retrieved from a given hash matches the expected type.
@warning Since these values are stored inside objects stored on the ledger they are part of the
protocol.
**Changing them should be avoided because without special handling, this will result in a hard
@warning Since these values are stored inside objects stored on the ledger
they are part of the protocol. **Changing them should be avoided
because without special handling, this will result in a hard
fork.**
@note Values outside this range may be used internally by the code for various purposes, but
attempting to use such values to identify on-ledger objects will result in an invariant failure.
@note Values outside this range may be used internally by the code for
various purposes, but attempting to use such values to identify
on-ledger objects will results in an invariant failure.
@note When retiring types, the specific values should not be removed but should be marked as
[[deprecated]]. This is to avoid accidental reuse of identifiers.
@note When retiring types, the specific values should not be removed but
should be marked as [[deprecated]]. This is to avoid accidental
reuse of identifiers.
@todo The C++ language does not enable checking for duplicate values here.
If it becomes possible then we should do this.
@todo The C++ language does not enable checking for duplicate values
here. If it becomes possible then we should do this.
@ingroup protocol
*/
enum LedgerEntryType : std::uint16_t {
// clang-format off
enum LedgerEntryType : std::uint16_t
{
#pragma push_macro("LEDGER_ENTRY")
#undef LEDGER_ENTRY
@@ -44,10 +46,12 @@ enum LedgerEntryType : std::uint16_t {
//---------------------------------------------------------------------------
/** A special type, matching any ledger entry type.
The value does not represent a concrete type, but rather is used in contexts where the
specific type of a ledger object is unimportant, unknown or unavailable.
The value does not represent a concrete type, but rather is used in
contexts where the specific type of a ledger object is unimportant,
unknown or unavailable.
Objects with this special type cannot be created or stored on the ledger.
Objects with this special type cannot be created or stored on the
ledger.
\sa keylet::unchecked
*/
@@ -55,11 +59,12 @@ enum LedgerEntryType : std::uint16_t {
/** A special type, matching any ledger type except directory nodes.
The value does not represent a concrete type, but rather is used in contexts where the
ledger object must not be a directory node but its specific type is otherwise unimportant,
unknown or unavailable.
The value does not represent a concrete type, but rather is used in
contexts where the ledger object must not be a directory node but
its specific type is otherwise unimportant, unknown or unavailable.
Objects with this special type cannot be created or stored on the ledger.
Objects with this special type cannot be created or stored on the
ledger.
\sa keylet::child
*/
@@ -88,188 +93,104 @@ enum LedgerEntryType : std::uint16_t {
Support for this type of object was never implemented.
No objects of this type were ever created.
*/
ltGENERATOR_MAP [[deprecated("This object type is not supported and should not be used.")]] =
0x0067,
ltGENERATOR_MAP [[deprecated("This object type is not supported and should not be used.")]] = 0x0067,
};
/** Ledger object flags.
These flags are specified in ledger objects and modify their behavior.
@warning Ledger object flags form part of the protocol.
**Changing them should be avoided because without special handling, this will result in a hard
fork.**
@ingroup protocol
*/
#pragma push_macro("XMACRO")
#pragma push_macro("TO_VALUE")
#pragma push_macro("VALUE_TO_MAP")
#pragma push_macro("NULL_NAME")
#pragma push_macro("TO_MAP")
#pragma push_macro("ALL_LEDGER_FLAGS")
#undef XMACRO
#undef TO_VALUE
#undef VALUE_TO_MAP
#undef NULL_NAME
#undef TO_MAP
#undef ALL_LEDGER_FLAGS
// clang-format off
#define XMACRO(LEDGER_OBJECT, LSF_FLAG, LSF_FLAG2) \
LEDGER_OBJECT(AccountRoot, \
LSF_FLAG(lsfPasswordSpent, 0x00010000) /* True, if password set fee is spent. */ \
LSF_FLAG(lsfRequireDestTag, 0x00020000) /* True, to require a DestinationTag for payments. */ \
LSF_FLAG(lsfRequireAuth, 0x00040000) /* True, to require a authorization to hold IOUs. */ \
LSF_FLAG(lsfDisallowXRP, 0x00080000) /* True, to disallow sending XRP. */ \
LSF_FLAG(lsfDisableMaster, 0x00100000) /* True, force regular key */ \
LSF_FLAG(lsfNoFreeze, 0x00200000) /* True, cannot freeze ripple states */ \
LSF_FLAG(lsfGlobalFreeze, 0x00400000) /* True, all assets frozen */ \
LSF_FLAG(lsfDefaultRipple, 0x00800000) /* True, incoming trust lines allow rippling by default */ \
LSF_FLAG(lsfDepositAuth, 0x01000000) /* True, all deposits require authorization */ \
LSF_FLAG(lsfDisallowIncomingNFTokenOffer, 0x04000000) /* True, reject new incoming NFT offers */ \
LSF_FLAG(lsfDisallowIncomingCheck, 0x08000000) /* True, reject new checks */ \
LSF_FLAG(lsfDisallowIncomingPayChan, 0x10000000) /* True, reject new paychans */ \
LSF_FLAG(lsfDisallowIncomingTrustline, 0x20000000) /* True, reject new trustlines (only if no issued assets) */ \
LSF_FLAG(lsfAllowTrustLineLocking, 0x40000000) /* True, enable trustline locking */ \
LSF_FLAG(lsfAllowTrustLineClawback, 0x80000000)) /* True, enable clawback */ \
\
LEDGER_OBJECT(Offer, \
LSF_FLAG(lsfPassive, 0x00010000) \
LSF_FLAG(lsfSell, 0x00020000) /* True, offer was placed as a sell. */ \
LSF_FLAG(lsfHybrid, 0x00040000)) /* True, offer is hybrid. */ \
\
LEDGER_OBJECT(RippleState, \
LSF_FLAG(lsfLowReserve, 0x00010000) /* True, if entry counts toward reserve. */ \
LSF_FLAG(lsfHighReserve, 0x00020000) \
LSF_FLAG(lsfLowAuth, 0x00040000) \
LSF_FLAG(lsfHighAuth, 0x00080000) \
LSF_FLAG(lsfLowNoRipple, 0x00100000) \
LSF_FLAG(lsfHighNoRipple, 0x00200000) \
LSF_FLAG(lsfLowFreeze, 0x00400000) /* True, low side has set freeze flag */ \
LSF_FLAG(lsfHighFreeze, 0x00800000) /* True, high side has set freeze flag */ \
LSF_FLAG(lsfAMMNode, 0x01000000) /* True, trust line to AMM. */ \
/* Used by client apps to identify payments via AMM. */ \
LSF_FLAG(lsfLowDeepFreeze, 0x02000000) /* True, low side has set deep freeze flag */ \
LSF_FLAG(lsfHighDeepFreeze, 0x04000000)) /* True, high side has set deep freeze flag */ \
\
LEDGER_OBJECT(SignerList, \
LSF_FLAG(lsfOneOwnerCount, 0x00010000)) /* True, uses only one OwnerCount */ \
\
LEDGER_OBJECT(DirNode, \
LSF_FLAG(lsfNFTokenBuyOffers, 0x00000001) \
LSF_FLAG(lsfNFTokenSellOffers, 0x00000002)) \
\
LEDGER_OBJECT(NFTokenOffer, \
LSF_FLAG(lsfSellNFToken, 0x00000001)) \
\
LEDGER_OBJECT(MPTokenIssuance, \
LSF_FLAG(lsfMPTLocked, 0x00000001) /* Also used in ltMPTOKEN */ \
LSF_FLAG(lsfMPTCanLock, 0x00000002) \
LSF_FLAG(lsfMPTRequireAuth, 0x00000004) \
LSF_FLAG(lsfMPTCanEscrow, 0x00000008) \
LSF_FLAG(lsfMPTCanTrade, 0x00000010) \
LSF_FLAG(lsfMPTCanTransfer, 0x00000020) \
LSF_FLAG(lsfMPTCanClawback, 0x00000040)) \
\
LEDGER_OBJECT(MPTokenIssuanceMutable, \
LSF_FLAG(lsmfMPTCanMutateCanLock, 0x00000002) \
LSF_FLAG(lsmfMPTCanMutateRequireAuth, 0x00000004) \
LSF_FLAG(lsmfMPTCanMutateCanEscrow, 0x00000008) \
LSF_FLAG(lsmfMPTCanMutateCanTrade, 0x00000010) \
LSF_FLAG(lsmfMPTCanMutateCanTransfer, 0x00000020) \
LSF_FLAG(lsmfMPTCanMutateCanClawback, 0x00000040) \
LSF_FLAG(lsmfMPTCanMutateMetadata, 0x00010000) \
LSF_FLAG(lsmfMPTCanMutateTransferFee, 0x00020000)) \
\
LEDGER_OBJECT(MPToken, \
LSF_FLAG2(lsfMPTLocked, 0x00000001) \
LSF_FLAG(lsfMPTAuthorized, 0x00000002)) \
\
LEDGER_OBJECT(Credential, \
LSF_FLAG(lsfAccepted, 0x00010000)) \
\
LEDGER_OBJECT(Vault, \
LSF_FLAG(lsfVaultPrivate, 0x00010000)) \
\
LEDGER_OBJECT(Loan, \
LSF_FLAG(lsfLoanDefault, 0x00010000) \
LSF_FLAG(lsfLoanImpaired, 0x00020000) \
LSF_FLAG(lsfLoanOverpayment, 0x00040000)) /* True, loan allows overpayments */
/**
@ingroup protocol
*/
enum LedgerSpecificFlags {
// ltACCOUNT_ROOT
lsfPasswordSpent = 0x00010000, // True, if password set fee is spent.
lsfRequireDestTag =
0x00020000, // True, to require a DestinationTag for payments.
lsfRequireAuth =
0x00040000, // True, to require a authorization to hold IOUs.
lsfDisallowXRP = 0x00080000, // True, to disallow sending XRP.
lsfDisableMaster = 0x00100000, // True, force regular key
lsfNoFreeze = 0x00200000, // True, cannot freeze ripple states
lsfGlobalFreeze = 0x00400000, // True, all assets frozen
lsfDefaultRipple =
0x00800000, // True, incoming trust lines allow rippling by default
lsfDepositAuth = 0x01000000, // True, all deposits require authorization
/* // reserved for Hooks amendment
lsfTshCollect = 0x02000000, // True, allow TSH collect-calls to acc hooks
*/
lsfDisallowIncomingNFTokenOffer =
0x04000000, // True, reject new incoming NFT offers
lsfDisallowIncomingCheck =
0x08000000, // True, reject new checks
lsfDisallowIncomingPayChan =
0x10000000, // True, reject new paychans
lsfDisallowIncomingTrustline =
0x20000000, // True, reject new trustlines (only if no issued assets)
lsfAllowTrustLineLocking =
0x40000000, // True, enable trustline locking
lsfAllowTrustLineClawback =
0x80000000, // True, enable clawback
// clang-format on
// ltOFFER
lsfPassive = 0x00010000,
lsfSell = 0x00020000, // True, offer was placed as a sell.
lsfHybrid = 0x00040000, // True, offer is hybrid.
// Create all the flag values as an enum.
//
// example:
// enum LedgerSpecificFlags {
// lsfPasswordSpent = 0x00010000,
// lsfRequireDestTag = 0x00020000,
// ...
// };
#define TO_VALUE(name, value) name = value,
#define NULL_NAME(name, values) values
#define NULL_OUTPUT(name, value)
enum LedgerSpecificFlags : std::uint32_t { XMACRO(NULL_NAME, TO_VALUE, NULL_OUTPUT) };
// ltRIPPLE_STATE
lsfLowReserve = 0x00010000, // True, if entry counts toward reserve.
lsfHighReserve = 0x00020000,
lsfLowAuth = 0x00040000,
lsfHighAuth = 0x00080000,
lsfLowNoRipple = 0x00100000,
lsfHighNoRipple = 0x00200000,
lsfLowFreeze = 0x00400000, // True, low side has set freeze flag
lsfHighFreeze = 0x00800000, // True, high side has set freeze flag
lsfLowDeepFreeze = 0x02000000, // True, low side has set deep freeze flag
lsfHighDeepFreeze = 0x04000000, // True, high side has set deep freeze flag
lsfAMMNode = 0x01000000, // True, trust line to AMM. Used by client
// apps to identify payments via AMM.
// Create getter functions for each set of flags using Meyer's singleton pattern.
// This avoids static initialization order fiasco while still providing efficient access.
// This is used below in `getAllLedgerFlags()` to generate the server_definitions RPC output.
//
// example:
// inline LedgerFlagMap const& getAccountRootFlags() {
// static LedgerFlagMap const flags = {
// {"lsfPasswordSpent", 0x00010000},
// {"lsfRequireDestTag", 0x00020000},
// ...};
// return flags;
// }
using LedgerFlagMap = std::map<std::string, std::uint32_t>;
#define VALUE_TO_MAP(name, value) {#name, value},
#define TO_MAP(name, values) \
inline LedgerFlagMap const& get##name##Flags() \
{ \
static LedgerFlagMap const flags = {values}; \
return flags; \
}
XMACRO(TO_MAP, VALUE_TO_MAP, VALUE_TO_MAP)
// ltSIGNER_LIST
lsfOneOwnerCount = 0x00010000, // True, uses only one OwnerCount
// Create a getter function for all ledger flag maps using Meyer's singleton pattern.
// This is used to generate the server_definitions RPC output.
//
// example:
// inline std::vector<std::pair<std::string, LedgerFlagMap>> const& getAllLedgerFlags() {
// static std::vector<std::pair<std::string, LedgerFlagMap>> const flags = {
// {"AccountRoot", getAccountRootFlags()},
// ...};
// return flags;
// }
#define ALL_LEDGER_FLAGS(name, values) {#name, get##name##Flags()},
inline std::vector<std::pair<std::string, LedgerFlagMap>> const&
getAllLedgerFlags()
{
static std::vector<std::pair<std::string, LedgerFlagMap>> const flags = {
XMACRO(ALL_LEDGER_FLAGS, NULL_OUTPUT, NULL_OUTPUT)};
return flags;
}
// ltDIR_NODE
lsfNFTokenBuyOffers = 0x00000001,
lsfNFTokenSellOffers = 0x00000002,
#undef XMACRO
#undef TO_VALUE
#undef VALUE_TO_MAP
#undef NULL_NAME
#undef NULL_OUTPUT
#undef TO_MAP
#undef ALL_LEDGER_FLAGS
// ltNFTOKEN_OFFER
lsfSellNFToken = 0x00000001,
#pragma pop_macro("XMACRO")
#pragma pop_macro("TO_VALUE")
#pragma pop_macro("VALUE_TO_MAP")
#pragma pop_macro("NULL_NAME")
#pragma pop_macro("TO_MAP")
#pragma pop_macro("ALL_LEDGER_FLAGS")
// ltMPTOKEN_ISSUANCE
lsfMPTLocked = 0x00000001, // Also used in ltMPTOKEN
lsfMPTCanLock = 0x00000002,
lsfMPTRequireAuth = 0x00000004,
lsfMPTCanEscrow = 0x00000008,
lsfMPTCanTrade = 0x00000010,
lsfMPTCanTransfer = 0x00000020,
lsfMPTCanClawback = 0x00000040,
lsmfMPTCanMutateCanLock = 0x00000002,
lsmfMPTCanMutateRequireAuth = 0x00000004,
lsmfMPTCanMutateCanEscrow = 0x00000008,
lsmfMPTCanMutateCanTrade = 0x00000010,
lsmfMPTCanMutateCanTransfer = 0x00000020,
lsmfMPTCanMutateCanClawback = 0x00000040,
lsmfMPTCanMutateMetadata = 0x00010000,
lsmfMPTCanMutateTransferFee = 0x00020000,
// ltMPTOKEN
lsfMPTAuthorized = 0x00000002,
// ltCREDENTIAL
lsfAccepted = 0x00010000,
// ltVAULT
lsfVaultPrivate = 0x00010000,
// ltLOAN
lsfLoanDefault = 0x00010000,
lsfLoanImpaired = 0x00020000,
lsfLoanOverpayment = 0x00040000, // True, loan allows overpayments
};
//------------------------------------------------------------------------------
@@ -286,10 +207,6 @@ private:
public:
static LedgerFormats const&
getInstance();
// Fields shared by all ledger entry formats:
static std::vector<SOElement> const&
getCommonFields();
};
} // namespace xrpl

View File

@@ -6,7 +6,6 @@
#include <functional>
#include <initializer_list>
#include <stdexcept>
#include <vector>
namespace xrpl {
@@ -98,12 +97,8 @@ public:
operator=(SOTemplate&& other) = default;
/** Create a template populated with all fields.
After creating the template fields cannot be added, modified, or removed.
*/
SOTemplate(std::vector<SOElement> uniqueFields, std::vector<SOElement> commonFields = {});
/** Create a template populated with all fields.
Note: Defers to the vector constructor above.
After creating the template fields cannot be
added, modified, or removed.
*/
SOTemplate(
std::initializer_list<SOElement> uniqueFields,

View File

@@ -3,444 +3,294 @@
#include <xrpl/protocol/LedgerFormats.h>
#include <cstdint>
#include <map>
#include <string>
#include <utility>
#include <vector>
namespace xrpl {
/** Transaction flags.
These flags are specified in a transaction's 'Flags' field and modify
the behavior of that transaction.
These flags are specified in a transaction's 'Flags' field and modify the
behavior of that transaction.
There are two types of flags:
(1) Universal flags: these are flags which apply to, and are interpreted the same way by,
all transactions, except, perhaps, to special pseudo-transactions.
(1) Universal flags: these are flags which apply to, and are interpreted
the same way by, all transactions, except, perhaps,
to special pseudo-transactions.
(2) Tx-Specific flags: these are flags which are interpreted according to the type of the
transaction being executed. That is, the same numerical flag value may have different
effects, depending on the transaction being executed.
(2) Tx-Specific flags: these are flags which are interpreted according
to the type of the transaction being executed.
That is, the same numerical flag value may have
different effects, depending on the transaction
being executed.
@note The universal transaction flags occupy the high-order 8 bits.
The tx-specific flags occupy the remaining 24 bits.
@note The universal transaction flags occupy the high-order 8 bits. The
tx-specific flags occupy the remaining 24 bits.
@warning Transaction flags form part of the protocol.
**Changing them should be avoided because without special handling, this will result in
a hard fork.**
@warning Transaction flags form part of the protocol. **Changing them
should be avoided because without special handling, this will
result in a hard fork.**
@ingroup protocol
*/
using FlagValue = std::uint32_t;
// Universal Transaction flags:
inline constexpr FlagValue tfFullyCanonicalSig = 0x80000000;
inline constexpr FlagValue tfInnerBatchTxn = 0x40000000;
inline constexpr FlagValue tfUniversal = tfFullyCanonicalSig | tfInnerBatchTxn;
inline constexpr FlagValue tfUniversalMask = ~tfUniversal;
#pragma push_macro("XMACRO")
#pragma push_macro("TO_VALUE")
#pragma push_macro("VALUE_TO_MAP")
#pragma push_macro("NULL_NAME")
#pragma push_macro("NULL_OUTPUT")
#pragma push_macro("TO_MAP")
#pragma push_macro("TO_MASK")
#pragma push_macro("VALUE_TO_MASK")
#pragma push_macro("ALL_TX_FLAGS")
#pragma push_macro("NULL_MASK_ADJ")
#pragma push_macro("MASK_ADJ_TO_MASK")
#undef XMACRO
#undef TO_VALUE
#undef VALUE_TO_MAP
#undef NULL_NAME
#undef NULL_OUTPUT
#undef TO_MAP
#undef TO_MASK
#undef VALUE_TO_MASK
#undef NULL_MASK_ADJ
#undef MASK_ADJ_TO_MASK
// Formatting equals sign aligned 4 spaces after longest prefix, except for
// wrapped lines
// clang-format off
#undef ALL_TX_FLAGS
// Universal Transaction flags:
constexpr std::uint32_t tfFullyCanonicalSig = 0x80000000;
constexpr std::uint32_t tfInnerBatchTxn = 0x40000000;
constexpr std::uint32_t tfUniversal = tfFullyCanonicalSig | tfInnerBatchTxn;
constexpr std::uint32_t tfUniversalMask = ~tfUniversal;
// XMACRO parameters:
// - TRANSACTION: handles the transaction name, its flags, and mask adjustment
// - TF_FLAG: defines a new flag constant
// - TF_FLAG2: references an existing flag constant (no new definition)
// - MASK_ADJ: specifies flags to add back to the mask (making them invalid for this tx type)
//
// Note: MASK_ADJ is used when a universal flag should be invalid for a specific transaction.
// For example, Batch uses MASK_ADJ(tfInnerBatchTxn) because the outer Batch transaction
// must not have tfInnerBatchTxn set (only inner transactions should have it).
//
// TODO: Consider rewriting this using reflection in C++26 or later. Alternatively this could be a DSL processed by a script at build time.
#define XMACRO(TRANSACTION, TF_FLAG, TF_FLAG2, MASK_ADJ) \
TRANSACTION(AccountSet, \
TF_FLAG(tfRequireDestTag, 0x00010000) \
TF_FLAG(tfOptionalDestTag, 0x00020000) \
TF_FLAG(tfRequireAuth, 0x00040000) \
TF_FLAG(tfOptionalAuth, 0x00080000) \
TF_FLAG(tfDisallowXRP, 0x00100000) \
TF_FLAG(tfAllowXRP, 0x00200000), \
MASK_ADJ(0)) \
\
TRANSACTION(OfferCreate, \
TF_FLAG(tfPassive, 0x00010000) \
TF_FLAG(tfImmediateOrCancel, 0x00020000) \
TF_FLAG(tfFillOrKill, 0x00040000) \
TF_FLAG(tfSell, 0x00080000) \
TF_FLAG(tfHybrid, 0x00100000), \
MASK_ADJ(0)) \
\
TRANSACTION(Payment, \
TF_FLAG(tfNoRippleDirect, 0x00010000) \
TF_FLAG(tfPartialPayment, 0x00020000) \
TF_FLAG(tfLimitQuality, 0x00040000), \
MASK_ADJ(0)) \
\
TRANSACTION(TrustSet, \
TF_FLAG(tfSetfAuth, 0x00010000) \
TF_FLAG(tfSetNoRipple, 0x00020000) \
TF_FLAG(tfClearNoRipple, 0x00040000) \
TF_FLAG(tfSetFreeze, 0x00100000) \
TF_FLAG(tfClearFreeze, 0x00200000) \
TF_FLAG(tfSetDeepFreeze, 0x00400000) \
TF_FLAG(tfClearDeepFreeze, 0x00800000), \
MASK_ADJ(0)) \
\
TRANSACTION(EnableAmendment, \
TF_FLAG(tfGotMajority, 0x00010000) \
TF_FLAG(tfLostMajority, 0x00020000), \
MASK_ADJ(0)) \
\
TRANSACTION(PaymentChannelClaim, \
TF_FLAG(tfRenew, 0x00010000) \
TF_FLAG(tfClose, 0x00020000), \
MASK_ADJ(0)) \
\
TRANSACTION(NFTokenMint, \
TF_FLAG(tfBurnable, 0x00000001) \
TF_FLAG(tfOnlyXRP, 0x00000002) \
/* deprecated TF_FLAG(tfTrustLine, 0x00000004) */ \
TF_FLAG(tfTransferable, 0x00000008) \
TF_FLAG(tfMutable, 0x00000010), \
MASK_ADJ(0)) \
\
TRANSACTION(MPTokenIssuanceCreate, \
/* Note: tf/lsfMPTLocked is intentionally omitted since this transaction is not allowed to modify it. */ \
TF_FLAG(tfMPTCanLock, lsfMPTCanLock) \
TF_FLAG(tfMPTRequireAuth, lsfMPTRequireAuth) \
TF_FLAG(tfMPTCanEscrow, lsfMPTCanEscrow) \
TF_FLAG(tfMPTCanTrade, lsfMPTCanTrade) \
TF_FLAG(tfMPTCanTransfer, lsfMPTCanTransfer) \
TF_FLAG(tfMPTCanClawback, lsfMPTCanClawback), \
MASK_ADJ(0)) \
\
TRANSACTION(MPTokenAuthorize, \
TF_FLAG(tfMPTUnauthorize, 0x00000001), \
MASK_ADJ(0)) \
\
TRANSACTION(MPTokenIssuanceSet, \
TF_FLAG(tfMPTLock, 0x00000001) \
TF_FLAG(tfMPTUnlock, 0x00000002), \
MASK_ADJ(0)) \
\
TRANSACTION(NFTokenCreateOffer, \
TF_FLAG(tfSellNFToken, 0x00000001), \
MASK_ADJ(0)) \
\
TRANSACTION(AMMDeposit, \
TF_FLAG(tfLPToken, 0x00010000) \
TF_FLAG(tfSingleAsset, 0x00080000) \
TF_FLAG(tfTwoAsset, 0x00100000) \
TF_FLAG(tfOneAssetLPToken, 0x00200000) \
TF_FLAG(tfLimitLPToken, 0x00400000) \
TF_FLAG(tfTwoAssetIfEmpty, 0x00800000), \
MASK_ADJ(0)) \
\
TRANSACTION(AMMWithdraw, \
TF_FLAG2(tfLPToken, 0x00010000) \
TF_FLAG(tfWithdrawAll, 0x00020000) \
TF_FLAG(tfOneAssetWithdrawAll, 0x00040000) \
TF_FLAG2(tfSingleAsset, 0x00080000) \
TF_FLAG2(tfTwoAsset, 0x00100000) \
TF_FLAG2(tfOneAssetLPToken, 0x00200000) \
TF_FLAG2(tfLimitLPToken, 0x00400000), \
MASK_ADJ(0)) \
\
TRANSACTION(AMMClawback, \
TF_FLAG(tfClawTwoAssets, 0x00000001), \
MASK_ADJ(0)) \
\
TRANSACTION(XChainModifyBridge, \
TF_FLAG(tfClearAccountCreateAmount, 0x00010000), \
MASK_ADJ(0)) \
\
TRANSACTION(VaultCreate, \
TF_FLAG(tfVaultPrivate, lsfVaultPrivate) \
TF_FLAG(tfVaultShareNonTransferable, 0x00020000), \
MASK_ADJ(0)) \
\
TRANSACTION(Batch, \
TF_FLAG(tfAllOrNothing, 0x00010000) \
TF_FLAG(tfOnlyOne, 0x00020000) \
TF_FLAG(tfUntilFailure, 0x00040000) \
TF_FLAG(tfIndependent, 0x00080000), \
MASK_ADJ(tfInnerBatchTxn)) /* Batch must reject tfInnerBatchTxn - only inner transactions should have this flag */ \
\
TRANSACTION(LoanSet, /* True indicates the loan supports overpayments */ \
TF_FLAG(tfLoanOverpayment, 0x00010000), \
MASK_ADJ(0)) \
\
TRANSACTION(LoanPay, /* True indicates any excess in this payment can be used as an overpayment. */ \
/* False: no overpayments will be taken. */ \
TF_FLAG2(tfLoanOverpayment, 0x00010000) \
TF_FLAG(tfLoanFullPayment, 0x00020000) /* True indicates that the payment is an early full payment. */ \
/* It must pay the entire loan including close interest and fees, or it will fail. */ \
/* False: Not a full payment. */ \
TF_FLAG(tfLoanLatePayment, 0x00040000), /* True indicates that the payment is late, and includes late interest and fees. */ \
/* If the loan is not late, it will fail. */ \
/* False: not a late payment. If the current payment is overdue, the transaction will fail.*/ \
MASK_ADJ(0)) \
\
TRANSACTION(LoanManage, \
TF_FLAG(tfLoanDefault, 0x00010000) \
TF_FLAG(tfLoanImpair, 0x00020000) \
TF_FLAG(tfLoanUnimpair, 0x00040000), \
MASK_ADJ(0))
// AccountSet flags:
constexpr std::uint32_t tfRequireDestTag = 0x00010000;
constexpr std::uint32_t tfOptionalDestTag = 0x00020000;
constexpr std::uint32_t tfRequireAuth = 0x00040000;
constexpr std::uint32_t tfOptionalAuth = 0x00080000;
constexpr std::uint32_t tfDisallowXRP = 0x00100000;
constexpr std::uint32_t tfAllowXRP = 0x00200000;
constexpr std::uint32_t tfAccountSetMask =
~(tfUniversal | tfRequireDestTag | tfOptionalDestTag | tfRequireAuth |
tfOptionalAuth | tfDisallowXRP | tfAllowXRP);
// clang-format on
// AccountSet SetFlag/ClearFlag values
constexpr std::uint32_t asfRequireDest = 1;
constexpr std::uint32_t asfRequireAuth = 2;
constexpr std::uint32_t asfDisallowXRP = 3;
constexpr std::uint32_t asfDisableMaster = 4;
constexpr std::uint32_t asfAccountTxnID = 5;
constexpr std::uint32_t asfNoFreeze = 6;
constexpr std::uint32_t asfGlobalFreeze = 7;
constexpr std::uint32_t asfDefaultRipple = 8;
constexpr std::uint32_t asfDepositAuth = 9;
constexpr std::uint32_t asfAuthorizedNFTokenMinter = 10;
/* // reserved for Hooks amendment
constexpr std::uint32_t asfTshCollect = 11;
*/
constexpr std::uint32_t asfDisallowIncomingNFTokenOffer = 12;
constexpr std::uint32_t asfDisallowIncomingCheck = 13;
constexpr std::uint32_t asfDisallowIncomingPayChan = 14;
constexpr std::uint32_t asfDisallowIncomingTrustline = 15;
constexpr std::uint32_t asfAllowTrustLineClawback = 16;
constexpr std::uint32_t asfAllowTrustLineLocking = 17;
// Create all the flag values.
//
// example:
// inline constexpr FlagValue tfAccountSetRequireDestTag = 0x00010000;
#define TO_VALUE(name, value) inline constexpr FlagValue name = value;
#define NULL_NAME(name, values, maskAdj) values
#define NULL_OUTPUT(name, value)
#define NULL_MASK_ADJ(value)
XMACRO(NULL_NAME, TO_VALUE, NULL_OUTPUT, NULL_MASK_ADJ)
// OfferCreate flags:
constexpr std::uint32_t tfPassive = 0x00010000;
constexpr std::uint32_t tfImmediateOrCancel = 0x00020000;
constexpr std::uint32_t tfFillOrKill = 0x00040000;
constexpr std::uint32_t tfSell = 0x00080000;
constexpr std::uint32_t tfHybrid = 0x00100000;
constexpr std::uint32_t tfOfferCreateMask =
~(tfUniversal | tfPassive | tfImmediateOrCancel | tfFillOrKill | tfSell | tfHybrid);
// Create masks for each transaction type that has flags.
//
// example:
// inline constexpr FlagValue tfAccountSetMask = ~(tfUniversal | tfRequireDestTag |
// tfOptionalDestTag | tfRequireAuth | tfOptionalAuth | tfDisallowXRP | tfAllowXRP);
//
// The mask adjustment (maskAdj) allows adding flags back to the mask, making them invalid.
// For example, Batch uses MASK_ADJ(tfInnerBatchTxn) to reject tfInnerBatchTxn on outer Batch.
#define TO_MASK(name, values, maskAdj) \
inline constexpr FlagValue tf##name##Mask = ~(tfUniversal values) | maskAdj;
#define VALUE_TO_MASK(name, value) | name
#define MASK_ADJ_TO_MASK(value) value
XMACRO(TO_MASK, VALUE_TO_MASK, VALUE_TO_MASK, MASK_ADJ_TO_MASK)
// Payment flags:
constexpr std::uint32_t tfNoRippleDirect = 0x00010000;
constexpr std::uint32_t tfPartialPayment = 0x00020000;
constexpr std::uint32_t tfLimitQuality = 0x00040000;
constexpr std::uint32_t tfPaymentMask =
~(tfUniversal | tfPartialPayment | tfLimitQuality | tfNoRippleDirect);
constexpr std::uint32_t tfMPTPaymentMask = ~(tfUniversal | tfPartialPayment);
// Verify that tfBatchMask correctly rejects tfInnerBatchTxn.
// The outer Batch transaction must NOT have tfInnerBatchTxn set; only inner transactions should
// have it.
static_assert(
(tfBatchMask & tfInnerBatchTxn) == tfInnerBatchTxn,
"tfBatchMask must include tfInnerBatchTxn to reject it on outer Batch");
// TrustSet flags:
constexpr std::uint32_t tfSetfAuth = 0x00010000;
constexpr std::uint32_t tfSetNoRipple = 0x00020000;
constexpr std::uint32_t tfClearNoRipple = 0x00040000;
constexpr std::uint32_t tfSetFreeze = 0x00100000;
constexpr std::uint32_t tfClearFreeze = 0x00200000;
constexpr std::uint32_t tfSetDeepFreeze = 0x00400000;
constexpr std::uint32_t tfClearDeepFreeze = 0x00800000;
constexpr std::uint32_t tfTrustSetMask =
~(tfUniversal | tfSetfAuth | tfSetNoRipple | tfClearNoRipple | tfSetFreeze |
tfClearFreeze | tfSetDeepFreeze | tfClearDeepFreeze);
constexpr std::uint32_t tfTrustSetPermissionMask = ~(tfUniversal | tfSetfAuth | tfSetFreeze | tfClearFreeze);
// Verify that other transaction masks correctly allow tfInnerBatchTxn.
// Inner transactions need tfInnerBatchTxn to be valid, so these masks must not reject it.
static_assert(
(tfPaymentMask & tfInnerBatchTxn) == 0,
"tfPaymentMask must not reject tfInnerBatchTxn");
static_assert(
(tfAccountSetMask & tfInnerBatchTxn) == 0,
"tfAccountSetMask must not reject tfInnerBatchTxn");
// EnableAmendment flags:
constexpr std::uint32_t tfGotMajority = 0x00010000;
constexpr std::uint32_t tfLostMajority = 0x00020000;
constexpr std::uint32_t tfChangeMask =
~( tfUniversal | tfGotMajority | tfLostMajority);
// Create getter functions for each set of flags using Meyer's singleton pattern.
// This avoids static initialization order fiasco while still providing efficient access.
// This is used below in `getAllTxFlags()` to generate the server_definitions RPC
// output.
//
// example:
// inline FlagMap const& getAccountSetFlags() {
// static FlagMap const flags = {
// {"tfRequireDestTag", 0x00010000},
// {"tfOptionalDestTag", 0x00020000},
// ...};
// return flags;
// }
using FlagMap = std::map<std::string, FlagValue>;
#define VALUE_TO_MAP(name, value) {#name, value},
#define TO_MAP(name, values, maskAdj) \
inline FlagMap const& get##name##Flags() \
{ \
static FlagMap const flags = {values}; \
return flags; \
}
XMACRO(TO_MAP, VALUE_TO_MAP, VALUE_TO_MAP, NULL_MASK_ADJ)
// PaymentChannelClaim flags:
constexpr std::uint32_t tfRenew = 0x00010000;
constexpr std::uint32_t tfClose = 0x00020000;
constexpr std::uint32_t tfPayChanClaimMask = ~(tfUniversal | tfRenew | tfClose);
inline FlagMap const&
getUniversalFlags()
{
static FlagMap const flags = {
{"tfFullyCanonicalSig", tfFullyCanonicalSig}, {"tfInnerBatchTxn", tfInnerBatchTxn}};
return flags;
}
// NFTokenMint flags:
constexpr std::uint32_t const tfBurnable = 0x00000001;
constexpr std::uint32_t const tfOnlyXRP = 0x00000002;
constexpr std::uint32_t const tfTrustLine = 0x00000004;
constexpr std::uint32_t const tfTransferable = 0x00000008;
constexpr std::uint32_t const tfMutable = 0x00000010;
// Create a getter function for all transaction flag maps using Meyer's singleton pattern.
// This is used to generate the server_definitions RPC output.
//
// example:
// inline FlagMapPairList const& getAllTxFlags() {
// static FlagMapPairList const flags = {
// {"AccountSet", getAccountSetFlags()},
// ...};
// return flags;
// }
using FlagMapPairList = std::vector<std::pair<std::string, FlagMap>>;
#define ALL_TX_FLAGS(name, values, maskAdj) {#name, get##name##Flags()},
inline FlagMapPairList const&
getAllTxFlags()
{
static FlagMapPairList const flags = {
{"universal", getUniversalFlags()},
XMACRO(ALL_TX_FLAGS, NULL_OUTPUT, NULL_OUTPUT, NULL_MASK_ADJ)};
return flags;
}
#undef XMACRO
#undef TO_VALUE
#undef VALUE_TO_MAP
#undef NULL_NAME
#undef NULL_OUTPUT
#undef TO_MAP
#undef TO_MASK
#undef VALUE_TO_MASK
#undef ALL_TX_FLAGS
#undef NULL_MASK_ADJ
#undef MASK_ADJ_TO_MASK
#pragma pop_macro("XMACRO")
#pragma pop_macro("TO_VALUE")
#pragma pop_macro("VALUE_TO_MAP")
#pragma pop_macro("NULL_NAME")
#pragma pop_macro("NULL_OUTPUT")
#pragma pop_macro("TO_MAP")
#pragma pop_macro("TO_MASK")
#pragma pop_macro("VALUE_TO_MASK")
#pragma pop_macro("ALL_TX_FLAGS")
#pragma pop_macro("NULL_MASK_ADJ")
#pragma pop_macro("MASK_ADJ_TO_MASK")
// Additional transaction masks and combos
inline constexpr FlagValue tfMPTPaymentMask = ~(tfUniversal | tfPartialPayment);
inline constexpr FlagValue tfTrustSetPermissionMask =
~(tfUniversal | tfSetfAuth | tfSetFreeze | tfClearFreeze);
// MPTokenIssuanceCreate flags:
// Note: tf/lsfMPTLocked is intentionally omitted, since this transaction
// is not allowed to modify it.
constexpr std::uint32_t const tfMPTCanLock = lsfMPTCanLock;
constexpr std::uint32_t const tfMPTRequireAuth = lsfMPTRequireAuth;
constexpr std::uint32_t const tfMPTCanEscrow = lsfMPTCanEscrow;
constexpr std::uint32_t const tfMPTCanTrade = lsfMPTCanTrade;
constexpr std::uint32_t const tfMPTCanTransfer = lsfMPTCanTransfer;
constexpr std::uint32_t const tfMPTCanClawback = lsfMPTCanClawback;
constexpr std::uint32_t const tfMPTokenIssuanceCreateMask =
~(tfUniversal | tfMPTCanLock | tfMPTRequireAuth | tfMPTCanEscrow | tfMPTCanTrade | tfMPTCanTransfer | tfMPTCanClawback);
// MPTokenIssuanceCreate MutableFlags:
// Indicating specific fields or flags may be changed after issuance.
inline constexpr FlagValue tmfMPTCanMutateCanLock = lsmfMPTCanMutateCanLock;
inline constexpr FlagValue tmfMPTCanMutateRequireAuth = lsmfMPTCanMutateRequireAuth;
inline constexpr FlagValue tmfMPTCanMutateCanEscrow = lsmfMPTCanMutateCanEscrow;
inline constexpr FlagValue tmfMPTCanMutateCanTrade = lsmfMPTCanMutateCanTrade;
inline constexpr FlagValue tmfMPTCanMutateCanTransfer = lsmfMPTCanMutateCanTransfer;
inline constexpr FlagValue tmfMPTCanMutateCanClawback = lsmfMPTCanMutateCanClawback;
inline constexpr FlagValue tmfMPTCanMutateMetadata = lsmfMPTCanMutateMetadata;
inline constexpr FlagValue tmfMPTCanMutateTransferFee = lsmfMPTCanMutateTransferFee;
inline constexpr FlagValue tmfMPTokenIssuanceCreateMutableMask =
~(tmfMPTCanMutateCanLock | tmfMPTCanMutateRequireAuth | tmfMPTCanMutateCanEscrow |
tmfMPTCanMutateCanTrade | tmfMPTCanMutateCanTransfer | tmfMPTCanMutateCanClawback |
tmfMPTCanMutateMetadata | tmfMPTCanMutateTransferFee);
constexpr std::uint32_t const tmfMPTCanMutateCanLock = lsmfMPTCanMutateCanLock;
constexpr std::uint32_t const tmfMPTCanMutateRequireAuth = lsmfMPTCanMutateRequireAuth;
constexpr std::uint32_t const tmfMPTCanMutateCanEscrow = lsmfMPTCanMutateCanEscrow;
constexpr std::uint32_t const tmfMPTCanMutateCanTrade = lsmfMPTCanMutateCanTrade;
constexpr std::uint32_t const tmfMPTCanMutateCanTransfer = lsmfMPTCanMutateCanTransfer;
constexpr std::uint32_t const tmfMPTCanMutateCanClawback = lsmfMPTCanMutateCanClawback;
constexpr std::uint32_t const tmfMPTCanMutateMetadata = lsmfMPTCanMutateMetadata;
constexpr std::uint32_t const tmfMPTCanMutateTransferFee = lsmfMPTCanMutateTransferFee;
constexpr std::uint32_t const tmfMPTokenIssuanceCreateMutableMask =
~(tmfMPTCanMutateCanLock | tmfMPTCanMutateRequireAuth | tmfMPTCanMutateCanEscrow | tmfMPTCanMutateCanTrade
| tmfMPTCanMutateCanTransfer | tmfMPTCanMutateCanClawback | tmfMPTCanMutateMetadata | tmfMPTCanMutateTransferFee);
// MPTokenAuthorize flags:
constexpr std::uint32_t const tfMPTUnauthorize = 0x00000001;
constexpr std::uint32_t const tfMPTokenAuthorizeMask = ~(tfUniversal | tfMPTUnauthorize);
// MPTokenIssuanceSet flags:
constexpr std::uint32_t const tfMPTLock = 0x00000001;
constexpr std::uint32_t const tfMPTUnlock = 0x00000002;
constexpr std::uint32_t const tfMPTokenIssuanceSetMask = ~(tfUniversal | tfMPTLock | tfMPTUnlock);
constexpr std::uint32_t const tfMPTokenIssuanceSetPermissionMask = ~(tfUniversal | tfMPTLock | tfMPTUnlock);
// MPTokenIssuanceSet MutableFlags:
// Set or Clear flags.
constexpr std::uint32_t const tmfMPTSetCanLock = 0x00000001;
constexpr std::uint32_t const tmfMPTClearCanLock = 0x00000002;
constexpr std::uint32_t const tmfMPTSetRequireAuth = 0x00000004;
constexpr std::uint32_t const tmfMPTClearRequireAuth = 0x00000008;
constexpr std::uint32_t const tmfMPTSetCanEscrow = 0x00000010;
constexpr std::uint32_t const tmfMPTClearCanEscrow = 0x00000020;
constexpr std::uint32_t const tmfMPTSetCanTrade = 0x00000040;
constexpr std::uint32_t const tmfMPTClearCanTrade = 0x00000080;
constexpr std::uint32_t const tmfMPTSetCanTransfer = 0x00000100;
constexpr std::uint32_t const tmfMPTClearCanTransfer = 0x00000200;
constexpr std::uint32_t const tmfMPTSetCanClawback = 0x00000400;
constexpr std::uint32_t const tmfMPTClearCanClawback = 0x00000800;
constexpr std::uint32_t const tmfMPTokenIssuanceSetMutableMask = ~(tmfMPTSetCanLock | tmfMPTClearCanLock |
tmfMPTSetRequireAuth | tmfMPTClearRequireAuth | tmfMPTSetCanEscrow | tmfMPTClearCanEscrow |
tmfMPTSetCanTrade | tmfMPTClearCanTrade | tmfMPTSetCanTransfer | tmfMPTClearCanTransfer |
tmfMPTSetCanClawback | tmfMPTClearCanClawback);
inline constexpr FlagValue tmfMPTSetCanLock = 0x00000001;
inline constexpr FlagValue tmfMPTClearCanLock = 0x00000002;
inline constexpr FlagValue tmfMPTSetRequireAuth = 0x00000004;
inline constexpr FlagValue tmfMPTClearRequireAuth = 0x00000008;
inline constexpr FlagValue tmfMPTSetCanEscrow = 0x00000010;
inline constexpr FlagValue tmfMPTClearCanEscrow = 0x00000020;
inline constexpr FlagValue tmfMPTSetCanTrade = 0x00000040;
inline constexpr FlagValue tmfMPTClearCanTrade = 0x00000080;
inline constexpr FlagValue tmfMPTSetCanTransfer = 0x00000100;
inline constexpr FlagValue tmfMPTClearCanTransfer = 0x00000200;
inline constexpr FlagValue tmfMPTSetCanClawback = 0x00000400;
inline constexpr FlagValue tmfMPTClearCanClawback = 0x00000800;
inline constexpr FlagValue tmfMPTokenIssuanceSetMutableMask = ~(
tmfMPTSetCanLock | tmfMPTClearCanLock | tmfMPTSetRequireAuth | tmfMPTClearRequireAuth |
tmfMPTSetCanEscrow | tmfMPTClearCanEscrow | tmfMPTSetCanTrade | tmfMPTClearCanTrade |
tmfMPTSetCanTransfer | tmfMPTClearCanTransfer | tmfMPTSetCanClawback | tmfMPTClearCanClawback);
// MPTokenIssuanceDestroy flags:
constexpr std::uint32_t const tfMPTokenIssuanceDestroyMask = ~tfUniversal;
// Prior to fixRemoveNFTokenAutoTrustLine, transfer of an NFToken between accounts allowed a
// TrustLine to be added to the issuer of that token without explicit permission from that issuer.
// This was enabled by minting the NFToken with the tfTrustLine flag set.
// Prior to fixRemoveNFTokenAutoTrustLine, transfer of an NFToken between
// accounts allowed a TrustLine to be added to the issuer of that token
// without explicit permission from that issuer. This was enabled by
// minting the NFToken with the tfTrustLine flag set.
//
// That capability could be used to attack the NFToken issuer.
// It would be possible for two accounts to trade the NFToken back and forth building up any number
// of TrustLines on the issuer, increasing the issuer's reserve without bound.
// That capability could be used to attack the NFToken issuer. It
// would be possible for two accounts to trade the NFToken back and forth
// building up any number of TrustLines on the issuer, increasing the
// issuer's reserve without bound.
//
// The fixRemoveNFTokenAutoTrustLine amendment disables minting with the tfTrustLine flag as a way
// to prevent the attack. But until the amendment passes we still need to keep the old behavior
// available.
inline constexpr FlagValue tfTrustLine = 0x00000004; // needed for backwards compatibility
inline constexpr FlagValue tfNFTokenMintMaskWithoutMutable =
// The fixRemoveNFTokenAutoTrustLine amendment disables minting with the
// tfTrustLine flag as a way to prevent the attack. But until the
// amendment passes we still need to keep the old behavior available.
constexpr std::uint32_t const tfNFTokenMintMask =
~(tfUniversal | tfBurnable | tfOnlyXRP | tfTransferable);
inline constexpr FlagValue tfNFTokenMintOldMask = ~(~tfNFTokenMintMaskWithoutMutable | tfTrustLine);
constexpr std::uint32_t const tfNFTokenMintOldMask =
~( ~tfNFTokenMintMask | tfTrustLine);
// if featureDynamicNFT enabled then new flag allowing mutable URI available.
inline constexpr FlagValue tfNFTokenMintOldMaskWithMutable = ~(~tfNFTokenMintOldMask | tfMutable);
constexpr std::uint32_t const tfNFTokenMintOldMaskWithMutable =
~( ~tfNFTokenMintOldMask | tfMutable);
inline constexpr FlagValue tfWithdrawSubTx = tfLPToken | tfSingleAsset | tfTwoAsset |
tfOneAssetLPToken | tfLimitLPToken | tfWithdrawAll | tfOneAssetWithdrawAll;
inline constexpr FlagValue tfDepositSubTx =
tfLPToken | tfSingleAsset | tfTwoAsset | tfOneAssetLPToken | tfLimitLPToken | tfTwoAssetIfEmpty;
constexpr std::uint32_t const tfNFTokenMintMaskWithMutable =
~( ~tfNFTokenMintMask | tfMutable);
#pragma push_macro("ACCOUNTSET_FLAGS")
#pragma push_macro("ACCOUNTSET_FLAG_TO_VALUE")
#pragma push_macro("ACCOUNTSET_FLAG_TO_MAP")
// NFTokenCreateOffer flags:
constexpr std::uint32_t const tfSellNFToken = 0x00000001;
constexpr std::uint32_t const tfNFTokenCreateOfferMask =
~(tfUniversal | tfSellNFToken);
// AccountSet SetFlag/ClearFlag values
#define ACCOUNTSET_FLAGS(ASF_FLAG) \
ASF_FLAG(asfRequireDest, 1) \
ASF_FLAG(asfRequireAuth, 2) \
ASF_FLAG(asfDisallowXRP, 3) \
ASF_FLAG(asfDisableMaster, 4) \
ASF_FLAG(asfAccountTxnID, 5) \
ASF_FLAG(asfNoFreeze, 6) \
ASF_FLAG(asfGlobalFreeze, 7) \
ASF_FLAG(asfDefaultRipple, 8) \
ASF_FLAG(asfDepositAuth, 9) \
ASF_FLAG(asfAuthorizedNFTokenMinter, 10) \
/* 11 is reserved for Hooks amendment */ \
/* ASF_FLAG(asfTshCollect, 11) */ \
ASF_FLAG(asfDisallowIncomingNFTokenOffer, 12) \
ASF_FLAG(asfDisallowIncomingCheck, 13) \
ASF_FLAG(asfDisallowIncomingPayChan, 14) \
ASF_FLAG(asfDisallowIncomingTrustline, 15) \
ASF_FLAG(asfAllowTrustLineClawback, 16) \
ASF_FLAG(asfAllowTrustLineLocking, 17)
// NFTokenCancelOffer flags:
constexpr std::uint32_t const tfNFTokenCancelOfferMask = ~tfUniversal;
#define ACCOUNTSET_FLAG_TO_VALUE(name, value) inline constexpr FlagValue name = value;
#define ACCOUNTSET_FLAG_TO_MAP(name, value) {#name, value},
// NFTokenAcceptOffer flags:
constexpr std::uint32_t const tfNFTokenAcceptOfferMask = ~tfUniversal;
ACCOUNTSET_FLAGS(ACCOUNTSET_FLAG_TO_VALUE)
// Clawback flags:
constexpr std::uint32_t const tfClawbackMask = ~tfUniversal;
inline std::map<std::string, FlagValue> const&
getAsfFlagMap()
{
static std::map<std::string, FlagValue> const flags = {
ACCOUNTSET_FLAGS(ACCOUNTSET_FLAG_TO_MAP)};
return flags;
}
// AMM Flags:
constexpr std::uint32_t tfLPToken = 0x00010000;
constexpr std::uint32_t tfWithdrawAll = 0x00020000;
constexpr std::uint32_t tfOneAssetWithdrawAll = 0x00040000;
constexpr std::uint32_t tfSingleAsset = 0x00080000;
constexpr std::uint32_t tfTwoAsset = 0x00100000;
constexpr std::uint32_t tfOneAssetLPToken = 0x00200000;
constexpr std::uint32_t tfLimitLPToken = 0x00400000;
constexpr std::uint32_t tfTwoAssetIfEmpty = 0x00800000;
constexpr std::uint32_t tfWithdrawSubTx =
tfLPToken | tfSingleAsset | tfTwoAsset | tfOneAssetLPToken |
tfLimitLPToken | tfWithdrawAll | tfOneAssetWithdrawAll;
constexpr std::uint32_t tfDepositSubTx =
tfLPToken | tfSingleAsset | tfTwoAsset | tfOneAssetLPToken |
tfLimitLPToken | tfTwoAssetIfEmpty;
constexpr std::uint32_t tfWithdrawMask = ~(tfUniversal | tfWithdrawSubTx);
constexpr std::uint32_t tfDepositMask = ~(tfUniversal | tfDepositSubTx);
#undef ACCOUNTSET_FLAG_TO_VALUE
#undef ACCOUNTSET_FLAG_TO_MAP
#undef ACCOUNTSET_FLAGS
// AMMClawback flags:
constexpr std::uint32_t tfClawTwoAssets = 0x00000001;
constexpr std::uint32_t tfAMMClawbackMask = ~(tfUniversal | tfClawTwoAssets);
#pragma pop_macro("ACCOUNTSET_FLAG_TO_VALUE")
#pragma pop_macro("ACCOUNTSET_FLAG_TO_MAP")
#pragma pop_macro("ACCOUNTSET_FLAGS")
// BridgeModify flags:
constexpr std::uint32_t tfClearAccountCreateAmount = 0x00010000;
constexpr std::uint32_t tfBridgeModifyMask = ~(tfUniversal | tfClearAccountCreateAmount);
// VaultCreate flags:
constexpr std::uint32_t const tfVaultPrivate = 0x00010000;
static_assert(tfVaultPrivate == lsfVaultPrivate);
constexpr std::uint32_t const tfVaultShareNonTransferable = 0x00020000;
constexpr std::uint32_t const tfVaultCreateMask = ~(tfUniversal | tfVaultPrivate | tfVaultShareNonTransferable);
// Batch Flags:
constexpr std::uint32_t tfAllOrNothing = 0x00010000;
constexpr std::uint32_t tfOnlyOne = 0x00020000;
constexpr std::uint32_t tfUntilFailure = 0x00040000;
constexpr std::uint32_t tfIndependent = 0x00080000;
/**
* @note If nested Batch transactions are supported in the future, the tfInnerBatchTxn flag
* will need to be removed from this mask to allow Batch transaction to be inside
* the sfRawTransactions array.
*/
constexpr std::uint32_t const tfBatchMask =
~(tfUniversal | tfAllOrNothing | tfOnlyOne | tfUntilFailure | tfIndependent) | tfInnerBatchTxn;
// LoanSet and LoanPay flags:
// LoanSet: True, indicates the loan supports overpayments
// LoanPay: True, indicates any excess in this payment can be used
// as an overpayment. False, no overpayments will be taken.
constexpr std::uint32_t const tfLoanOverpayment = 0x00010000;
// LoanPay exclusive flags:
// tfLoanFullPayment: True, indicates that the payment is an early
// full payment. It must pay the entire loan including close
// interest and fees, or it will fail. False: Not a full payment.
constexpr std::uint32_t const tfLoanFullPayment = 0x00020000;
// tfLoanLatePayment: True, indicates that the payment is late,
// and includes late interest and fees. If the loan is not late,
// it will fail. False: not a late payment. If the current payment
// is overdue, the transaction will fail.
constexpr std::uint32_t const tfLoanLatePayment = 0x00040000;
constexpr std::uint32_t const tfLoanSetMask = ~(tfUniversal |
tfLoanOverpayment);
constexpr std::uint32_t const tfLoanPayMask = ~(tfUniversal |
tfLoanOverpayment | tfLoanFullPayment | tfLoanLatePayment);
// LoanManage flags:
constexpr std::uint32_t const tfLoanDefault = 0x00010000;
constexpr std::uint32_t const tfLoanImpair = 0x00020000;
constexpr std::uint32_t const tfLoanUnimpair = 0x00040000;
constexpr std::uint32_t const tfLoanManageMask = ~(tfUniversal | tfLoanDefault | tfLoanImpair | tfLoanUnimpair);
// clang-format on
} // namespace xrpl

View File

@@ -2,8 +2,6 @@
#include <xrpl/protocol/KnownFormats.h>
#include <vector>
namespace xrpl {
/** Transaction type identifiers.
@@ -75,9 +73,6 @@ private:
public:
static TxFormats const&
getInstance();
static std::vector<SOElement> const&
getCommonFields();
};
} // namespace xrpl

View File

@@ -25,7 +25,6 @@ namespace jss {
JSS(AL_size); // out: GetCounts
JSS(AL_hit_rate); // out: GetCounts
JSS(AcceptedCredentials); // out: AccountObjects
JSS(ACCOUNT_SET_FLAGS); // out: RPC server_definitions
JSS(Account); // in: TransactionSign; field.
JSS(AMMID); // field
JSS(Amount); // in: TransactionSign; field.
@@ -188,7 +187,6 @@ JSS(closed_ledger); // out: NetworkOPs
JSS(cluster); // out: PeerImp
JSS(code); // out: errors
JSS(command); // in: RPCHandler
JSS(common); // out: RPC server_definitions
JSS(complete); // out: NetworkOPs, InboundLedger
JSS(complete_ledgers); // out: NetworkOPs, PeerImp
JSS(consensus); // out: NetworkOPs, LedgerConsensus
@@ -358,8 +356,6 @@ JSS(ledger_min); // in, out: AccountTx*
JSS(ledger_time); // out: NetworkOPs
JSS(LEDGER_ENTRY_TYPES); // out: RPC server_definitions
// matches definitions.json format
JSS(LEDGER_ENTRY_FLAGS); // out: RPC server_definitions
JSS(LEDGER_ENTRY_FORMATS); // out: RPC server_definitions
JSS(levels); // LogLevels
JSS(limit); // in/out: AccountTx*, AccountOffers,
// AccountLines, AccountObjects
@@ -461,7 +457,6 @@ JSS(open); // out: handlers/Ledger
JSS(open_ledger_cost); // out: SubmitTransaction
JSS(open_ledger_fee); // out: TxQ
JSS(open_ledger_level); // out: TxQ
JSS(optionality); // out: server_definitions
JSS(oracles); // in: get_aggregate_price
JSS(oracle_document_id); // in: get_aggregate_price
JSS(owner); // in: LedgerEntry, out: NetworkOPs
@@ -621,8 +616,6 @@ JSS(TRANSACTION_RESULTS); // out: RPC server_definitions
// matches definitions.json format
JSS(TRANSACTION_TYPES); // out: RPC server_definitions
// matches definitions.json format
JSS(TRANSACTION_FLAGS); // out: RPC server_definitions
JSS(TRANSACTION_FORMATS); // out: RPC server_definitions
JSS(TYPES); // out: RPC server_definitions
// matches definitions.json format
JSS(transfer_rate); // out: nft_info (clio)

View File

@@ -1,152 +0,0 @@
#pragma once
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/protocol/SField.h>
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol_autogen/STObjectValidation.h>
#include <xrpl/protocol_autogen/Utils.h>
#include <optional>
#include <string>
namespace xrpl::ledger_entries {
/**
* @brief Base class for type-safe ledger entry wrappers.
*
* This class provides common functionality for all ledger entry types,
* including access to common fields (sfLedgerIndex, sfLedgerEntryType, sfFlags).
*
* This is an immutable wrapper around SLE (Serialized Ledger Entry).
* Use the corresponding Builder classes to construct new ledger entries.
*/
class LedgerEntryBase
{
public:
/**
* @brief Construct a ledger entry wrapper from an existing SLE object.
* @param sle The underlying serialized ledger entry to wrap
*/
explicit LedgerEntryBase(SLE const& sle) : sle_(sle)
{
}
/**
* @brief Validate the ledger entry
* @return true if validation passes, false otherwise
*/
[[nodiscard]]
bool
validate()
{
if (!sle_.isFieldPresent(sfLedgerEntryType))
{
return false;
}
auto ledgerEntryType = static_cast<LedgerEntryType>(sle_.getFieldU16(sfLedgerEntryType));
return protocol_autogen::validateSTObject(
sle_, LedgerFormats::getInstance().findByType(ledgerEntryType)->getSOTemplate());
}
/**
* @brief Get the ledger entry type.
* @return The type of this ledger entry
*/
[[nodiscard]]
LedgerEntryType
getType() const
{
return sle_.getType();
}
/**
* @brief Get the key (index) of this ledger entry.
*
* The key uniquely identifies this ledger entry in the ledger state.
* @return A constant reference to the 256-bit key
*/
[[nodiscard]]
uint256 const&
getKey() const
{
return sle_.key();
}
// Common field getters (from LedgerFormats.cpp commonFields)
/**
* @brief Get the ledger index (sfLedgerIndex).
*
* This field is OPTIONAL and represents the index of the ledger entry.
* @return The ledger index if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<uint256>
getLedgerIndex() const
{
if (sle_.isFieldPresent(sfLedgerIndex))
{
return sle_.at(sfLedgerIndex);
}
return std::nullopt;
}
/**
* @brief Check if the ledger entry has a ledger index.
* @return true if sfLedgerIndex is present, false otherwise
*/
[[nodiscard]]
bool
hasLedgerIndex() const
{
return sle_.isFieldPresent(sfLedgerIndex);
}
/**
* @brief Get the ledger entry type field (sfLedgerEntryType).
*
* This field is REQUIRED for all ledger entries and indicates the type
* of the ledger entry (e.g., AccountRoot, RippleState, Offer, etc.).
* @return The ledger entry type as a 16-bit unsigned integer
*/
[[nodiscard]]
uint16_t
getLedgerEntryType() const
{
return sle_.at(sfLedgerEntryType);
}
/**
* @brief Get the flags field (sfFlags).
*
* This field is REQUIRED for all ledger entries and contains
* type-specific flags that modify the behavior of the ledger entry.
* @return The flags value as a 32-bit unsigned integer
*/
[[nodiscard]]
std::uint32_t
getFlags() const
{
return sle_.at(sfFlags);
}
/**
* @brief Get the underlying SLE object.
*
* Provides direct access to the wrapped serialized ledger entry object
* for cases where the type-safe accessors are insufficient.
* @return A constant reference to the underlying SLE object
*/
[[nodiscard]]
SLE const&
getSle() const
{
return sle_;
}
protected:
/** @brief The underlying serialized ledger entry being wrapped. */
SLE const& sle_;
};
} // namespace xrpl::ledger_entries

View File

@@ -1,78 +0,0 @@
#pragma once
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/protocol/SField.h>
#include <xrpl/protocol/STAccount.h>
#include <xrpl/protocol/STAmount.h>
#include <xrpl/protocol/STBlob.h>
#include <xrpl/protocol/STInteger.h>
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STObject.h>
#include <xrpl/protocol_autogen/STObjectValidation.h>
namespace xrpl::ledger_entries {
/**
* Base class for all ledger entry builders.
* Provides common field setters that are available for all ledger entry types.
*/
template <typename Derived>
class LedgerEntryBuilderBase
{
public:
LedgerEntryBuilderBase() = default;
LedgerEntryBuilderBase(
SF_UINT16::type::value_type ledgerEntryType,
SF_UINT32::type::value_type flags = 0)
{
object_[sfLedgerEntryType] = ledgerEntryType;
object_[sfFlags] = flags;
}
/**
* @brief Validate the ledger entry
* @return true if validation passes, false otherwise
*/
[[nodiscard]]
bool
validate()
{
if (!object_.isFieldPresent(sfLedgerEntryType))
{
return false;
}
auto ledgerEntryType = static_cast<LedgerEntryType>(object_.getFieldU16(sfLedgerEntryType));
return protocol_autogen::validateSTObject(
object_, LedgerFormats::getInstance().findByType(ledgerEntryType)->getSOTemplate());
}
/**
* Set the ledger index.
* @param value Ledger index
* @return Reference to the derived builder for method chaining.
*/
Derived&
setLedgerIndex(uint256 const& value)
{
object_[sfLedgerIndex] = value;
return static_cast<Derived&>(*this);
}
/**
* Set the flags.
* @param value Flags value
* @return Reference to the derived builder for method chaining.
*/
Derived&
setFlags(uint32_t value)
{
object_.setFieldU32(sfFlags, value);
return static_cast<Derived&>(*this);
}
protected:
STObject object_{sfLedgerEntry};
};
} // namespace xrpl::ledger_entries

View File

@@ -1,81 +0,0 @@
<!-- cspell:words pyparsing -->
# Protocol Autogen
This directory contains auto-generated C++ wrapper classes for XRP Ledger protocol types.
## Generated Files
The files in this directory are automatically generated at **CMake configure time** from macro definition files:
- **Transaction classes** (in `transactions/`): Generated from `include/xrpl/protocol/detail/transactions.macro` by `scripts/generate_tx_classes.py`
- **Ledger entry classes** (in `ledger_objects/`): Generated from `include/xrpl/protocol/detail/ledger_entries.macro` by `scripts/generate_ledger_classes.py`
## Generation Process
The generation happens automatically when you **configure** the project (not during build). When you run CMake, the system:
1. Creates a Python virtual environment in the build directory (`codegen_venv`)
2. Installs Python dependencies from `scripts/requirements.txt` into the venv (only if needed)
3. Runs the Python generation scripts using the venv Python interpreter
4. Parses the macro files to extract type definitions
5. Generates type-safe C++ wrapper classes using Mako templates
6. Places the generated headers in this directory
### When Regeneration Happens
The code is regenerated when:
- You run CMake configure for the first time
- The Python virtual environment doesn't exist
- `scripts/requirements.txt` has been modified
To force regeneration, delete the build directory and reconfigure.
### Python Dependencies
The code generation requires the following Python packages (automatically installed):
- `pcpp` - C preprocessor for Python
- `pyparsing` - Parser combinator library
- `Mako` - Template engine
These are isolated in a virtual environment and won't affect your system Python installation.
## Version Control
The generated `.h` files **are checked into version control**. This means:
- Developers without Python 3 can still build the project using the committed files
- CI/CD systems don't need to run code generation if files are up to date
- Changes to generated files are visible in code review
## Modifying Generated Code
**Do not manually edit generated files.** Any changes will be overwritten the next time CMake configure runs.
To modify the generated classes:
- Edit the macro files in `include/xrpl/protocol/detail/`
- Edit the Mako templates in `scripts/templates/`
- Edit the generation scripts in `scripts/`
- Update Python dependencies in `scripts/requirements.txt`
- Run CMake configure to regenerate
## Adding Common Fields
If you add a new common field to `TxFormats.cpp` or `LedgerFormats.cpp`, you should also update the corresponding base classes and templates manually:
Base classes:
- `TransactionBase.h` - Add getters for new common transaction fields
- `TransactionBuilderBase.h` - Add setters, and if the field is required, add it to the constructor parameters
- `LedgerEntryBase.h` - Add getters for new common ledger entry fields
- `LedgerEntryBuilderBase.h` - Add setters, and if the field is required, add it to the constructor parameters
Templates (update to pass required common fields to base class constructors):
- `scripts/templates/Transaction.h.mako`
- `scripts/templates/LedgerEntry.h.mako`
These files are **not auto-generated** and must be updated by hand.

View File

@@ -1,32 +0,0 @@
#pragma once
#include <xrpl/protocol/SOTemplate.h>
#include <xrpl/protocol/STObject.h>
namespace xrpl::protocol_autogen {
[[nodiscard]]
bool
validateSTObject(STObject const& obj, SOTemplate const& format)
{
for (auto const& field : format)
{
if (obj.isFieldPresent(field.sField()) && field.style() == soeREQUIRED)
{
return false;
}
if (!field.supportMPT() && obj.isFieldPresent(field.sField()) &&
field.sField().fieldType == STI_ISSUE)
{
auto const& amount = obj.getFieldAmount(field.sField());
if (amount.asset().holds<MPTIssue>())
return false;
}
}
return true;
}
} // namespace xrpl::protocol_autogen

View File

@@ -1,444 +0,0 @@
#pragma once
#include <xrpl/protocol/SField.h>
#include <xrpl/protocol/STAccount.h>
#include <xrpl/protocol/STArray.h>
#include <xrpl/protocol/STObject.h>
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/TxFormats.h>
#include <xrpl/protocol_autogen/STObjectValidation.h>
#include <xrpl/protocol_autogen/Utils.h>
#include <optional>
#include <string>
namespace xrpl::transactions {
/**
* @brief Base class for all transaction wrapper types.
*
* Provides type-safe read-only accessors for common transaction fields.
* This is an immutable wrapper around STTx. Use the corresponding Builder classes
* to construct new transactions.
*/
class TransactionBase
{
public:
/**
* @brief Construct a transaction wrapper from an existing STTx object.
* @param tx The underlying transaction object to wrap
*/
explicit TransactionBase(STTx const& tx) : tx_(tx)
{
}
/**
* @brief Validate the transaction
* @return true if validation passes, false otherwise
*/
[[nodiscard]]
bool
validate() const
{
return protocol_autogen::validateSTObject(
tx_, TxFormats::getInstance().findByType(tx_.getTxnType())->getSOTemplate());
}
/**
* @brief Get the transaction type.
* @return The type of this transaction
*/
[[nodiscard]]
xrpl::TxType
getTransactionType() const
{
return tx_.getTxnType();
}
/**
* @brief Get the account initiating the transaction (sfAccount).
*
* This field is REQUIRED for all transactions.
* @return The account ID of the transaction sender
*/
[[nodiscard]]
AccountID
getAccount() const
{
return tx_.at(sfAccount);
}
/**
* @brief Get the sequence number of the transaction (sfSequence).
*
* This field is REQUIRED for all transactions.
* @return The sequence number
*/
[[nodiscard]]
std::uint32_t
getSequence() const
{
return tx_.at(sfSequence);
}
/**
* @brief Get the transaction fee (sfFee).
*
* This field is REQUIRED for all transactions.
* @return The fee amount
*/
[[nodiscard]]
STAmount
getFee() const
{
return tx_.at(sfFee);
}
/**
* @brief Get the signing public key (sfSigningPubKey).
*
* This field is REQUIRED for all transactions.
* @return The public key used for signing as a blob
*/
[[nodiscard]]
Blob
getSigningPubKey() const
{
return tx_.getFieldVL(sfSigningPubKey);
}
/**
* @brief Get the transaction flags (sfFlags).
*
* This field is OPTIONAL.
* @return The flags value if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<uint32_t>
getFlags() const
{
if (tx_.isFieldPresent(sfFlags))
return tx_.at(sfFlags);
return std::nullopt;
}
/**
* @brief Check if the transaction has flags set.
* @return true if sfFlags is present, false otherwise
*/
[[nodiscard]]
bool
hasFlags() const
{
return tx_.isFieldPresent(sfFlags);
}
/**
* @brief Get the source tag (sfSourceTag).
*
* This field is OPTIONAL and used to identify the source of a payment.
* @return The source tag value if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<uint32_t>
getSourceTag() const
{
if (tx_.isFieldPresent(sfSourceTag))
return tx_.at(sfSourceTag);
return std::nullopt;
}
/**
* @brief Check if the transaction has a source tag.
* @return true if sfSourceTag is present, false otherwise
*/
[[nodiscard]]
bool
hasSourceTag() const
{
return tx_.isFieldPresent(sfSourceTag);
}
/**
* @brief Get the previous transaction ID (sfPreviousTxnID).
*
* This field is OPTIONAL and used for transaction chaining.
* @return The previous transaction ID if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<uint256>
getPreviousTxnID() const
{
if (tx_.isFieldPresent(sfPreviousTxnID))
return tx_.at(sfPreviousTxnID);
return std::nullopt;
}
/**
* @brief Check if the transaction has a previous transaction ID.
* @return true if sfPreviousTxnID is present, false otherwise
*/
[[nodiscard]]
bool
hasPreviousTxnID() const
{
return tx_.isFieldPresent(sfPreviousTxnID);
}
/**
* @brief Get the last ledger sequence (sfLastLedgerSequence).
*
* This field is OPTIONAL and specifies the latest ledger sequence
* in which this transaction can be included.
* @return The last ledger sequence if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<uint32_t>
getLastLedgerSequence() const
{
if (tx_.isFieldPresent(sfLastLedgerSequence))
return tx_.at(sfLastLedgerSequence);
return std::nullopt;
}
/**
* @brief Check if the transaction has a last ledger sequence.
* @return true if sfLastLedgerSequence is present, false otherwise
*/
[[nodiscard]]
bool
hasLastLedgerSequence() const
{
return tx_.isFieldPresent(sfLastLedgerSequence);
}
/**
* @brief Get the account transaction ID (sfAccountTxnID).
*
* This field is OPTIONAL and used to track transaction sequences.
* @return The account transaction ID if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<uint256>
getAccountTxnID() const
{
if (tx_.isFieldPresent(sfAccountTxnID))
return tx_.at(sfAccountTxnID);
return std::nullopt;
}
/**
* @brief Check if the transaction has an account transaction ID.
* @return true if sfAccountTxnID is present, false otherwise
*/
[[nodiscard]]
bool
hasAccountTxnID() const
{
return tx_.isFieldPresent(sfAccountTxnID);
}
/**
* @brief Get the operation limit (sfOperationLimit).
*
* This field is OPTIONAL and limits the number of operations in a transaction.
* @return The operation limit if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<uint32_t>
getOperationLimit() const
{
if (tx_.isFieldPresent(sfOperationLimit))
return tx_.at(sfOperationLimit);
return std::nullopt;
}
/**
* @brief Check if the transaction has an operation limit.
* @return true if sfOperationLimit is present, false otherwise
*/
[[nodiscard]]
bool
hasOperationLimit() const
{
return tx_.isFieldPresent(sfOperationLimit);
}
/**
* @brief Get the memos array (sfMemos).
*
* This field is OPTIONAL and contains arbitrary data attached to the transaction.
* @note This is an untyped field (STArray).
* @return A reference wrapper to the memos array if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getMemos() const
{
if (tx_.isFieldPresent(sfMemos))
return tx_.getFieldArray(sfMemos);
return std::nullopt;
}
/**
* @brief Check if the transaction has memos.
* @return true if sfMemos is present, false otherwise
*/
[[nodiscard]]
bool
hasMemos() const
{
return tx_.isFieldPresent(sfMemos);
}
/**
* @brief Get the ticket sequence (sfTicketSequence).
*
* This field is OPTIONAL and used when consuming a ticket instead of a sequence number.
* @return The ticket sequence if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<uint32_t>
getTicketSequence() const
{
if (tx_.isFieldPresent(sfTicketSequence))
return tx_.at(sfTicketSequence);
return std::nullopt;
}
/**
* @brief Check if the transaction has a ticket sequence.
* @return true if sfTicketSequence is present, false otherwise
*/
[[nodiscard]]
bool
hasTicketSequence() const
{
return tx_.isFieldPresent(sfTicketSequence);
}
/**
* @brief Get the transaction signature (sfTxnSignature).
*
* This field is OPTIONAL and contains the signature for single-signed transactions.
* @return The transaction signature as a blob if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<Blob>
getTxnSignature() const
{
if (tx_.isFieldPresent(sfTxnSignature))
return tx_.getFieldVL(sfTxnSignature);
return std::nullopt;
}
/**
* @brief Check if the transaction has a transaction signature.
* @return true if sfTxnSignature is present, false otherwise
*/
[[nodiscard]]
bool
hasTxnSignature() const
{
return tx_.isFieldPresent(sfTxnSignature);
}
/**
* @brief Get the signers array (sfSigners).
*
* This field is OPTIONAL and contains the list of signers for multi-signed transactions.
* @note This is an untyped field (STArray).
* @return A reference wrapper to the signers array if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getSigners() const
{
if (tx_.isFieldPresent(sfSigners))
return tx_.getFieldArray(sfSigners);
return std::nullopt;
}
/**
* @brief Check if the transaction has signers.
* @return true if sfSigners is present, false otherwise
*/
[[nodiscard]]
bool
hasSigners() const
{
return tx_.isFieldPresent(sfSigners);
}
/**
* @brief Get the network ID (sfNetworkID).
*
* This field is OPTIONAL and identifies the network this transaction is intended for.
* @return The network ID if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<uint32_t>
getNetworkID() const
{
if (tx_.isFieldPresent(sfNetworkID))
return tx_.at(sfNetworkID);
return std::nullopt;
}
/**
* @brief Check if the transaction has a network ID.
* @return true if sfNetworkID is present, false otherwise
*/
[[nodiscard]]
bool
hasNetworkID() const
{
return tx_.isFieldPresent(sfNetworkID);
}
/**
* @brief Get the delegate account (sfDelegate).
*
* This field is OPTIONAL and specifies a delegate account for the transaction.
* @return The delegate account ID if present, std::nullopt otherwise
*/
[[nodiscard]]
std::optional<AccountID>
getDelegate() const
{
if (tx_.isFieldPresent(sfDelegate))
return tx_.at(sfDelegate);
return std::nullopt;
}
/**
* @brief Check if the transaction has a delegate account.
* @return true if sfDelegate is present, false otherwise
*/
[[nodiscard]]
bool
hasDelegate() const
{
return tx_.isFieldPresent(sfDelegate);
}
/**
* @brief Get the underlying STTx object.
*
* Provides direct access to the wrapped transaction object for cases
* where the type-safe accessors are insufficient.
* @return A constant reference to the underlying STTx object
*/
[[nodiscard]]
STTx const&
getSTTx() const
{
return tx_;
}
protected:
/** @brief The underlying transaction object being wrapped. */
STTx const& tx_;
};
} // namespace xrpl::transactions

View File

@@ -1,182 +0,0 @@
#pragma once
#include <xrpl/protocol/HashPrefix.h>
#include <xrpl/protocol/PublicKey.h>
#include <xrpl/protocol/SField.h>
#include <xrpl/protocol/STAccount.h>
#include <xrpl/protocol/STAmount.h>
#include <xrpl/protocol/STBlob.h>
#include <xrpl/protocol/STInteger.h>
#include <xrpl/protocol/STObject.h>
#include <xrpl/protocol/STXChainBridge.h>
#include <xrpl/protocol/SecretKey.h>
#include <xrpl/protocol/Serializer.h>
#include <xrpl/protocol/TxFormats.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/STObjectValidation.h>
namespace xrpl::transactions {
/**
* Base class for all transaction builders.
* Provides common field setters that are available for all transaction types.
*/
template <typename Derived>
class TransactionBuilderBase
{
public:
TransactionBuilderBase() = default;
TransactionBuilderBase(
SF_UINT16::type::value_type transactionType,
SF_ACCOUNT::type::value_type account,
std::optional<SF_UINT32::type::value_type> sequence,
std::optional<SF_AMOUNT::type::value_type> fee)
{
object_[sfTransactionType] = transactionType;
setAccount(account);
if (sequence)
{
setSequence(*sequence);
}
if (fee)
{
setFee(*fee);
}
}
/**
* @brief Validate the transaction
* @return true if validation passes, false otherwise
*/
[[nodiscard]]
bool
validate()
{
if (!object_.isFieldPresent(sfTransactionType))
{
return false;
}
auto transactionType = static_cast<TxType>(object_.getFieldU16(sfTransactionType));
return protocol_autogen::validateSTObject(
object_, TxFormats::getInstance().findByType(transactionType)->getSOTemplate());
}
/**
* Set the account that is sending the transaction.
* @param value Account address (typically as a string)
* @return Reference to the derived builder for method chaining.
*/
Derived&
setAccount(AccountID const& value)
{
object_[sfAccount] = value;
return static_cast<Derived&>(*this);
}
/**
* Set the transaction fee.
* @param value Fee in drops (typically as a string or number)
* @return Reference to the derived builder for method chaining.
*/
Derived&
setFee(STAmount const& value)
{
object_[sfFee] = value;
return static_cast<Derived&>(*this);
}
/**
* Set the sequence number.
* @param value Sequence number
* @return Reference to the derived builder for method chaining.
*/
Derived&
setSequence(std::uint32_t const& value)
{
object_[sfSequence] = value;
return static_cast<Derived&>(*this);
}
/**
* Set transaction flags.
* @param value Flags value
* @return Reference to the derived builder for method chaining.
*/
Derived&
setFlags(std::uint32_t const& value)
{
object_[sfFlags] = value;
return static_cast<Derived&>(*this);
}
/**
* Set the source tag.
* @param value Source tag
* @return Reference to the derived builder for method chaining.
*/
Derived&
setSourceTag(std::uint32_t const& value)
{
object_[sfSourceTag] = value;
return static_cast<Derived&>(*this);
}
/**
* Set the last ledger sequence.
* @param value Last ledger sequence number
* @return Reference to the derived builder for method chaining.
*/
Derived&
setLastLedgerSequence(std::uint32_t const& value)
{
object_[sfLastLedgerSequence] = value;
return static_cast<Derived&>(*this);
}
/**
* Set the account transaction ID.
* @param value Account transaction ID (typically as a hex string)
* @return Reference to the derived builder for method chaining.
*/
Derived&
setAccountTxnID(uint256 const& value)
{
object_[sfAccountTxnID] = value;
return static_cast<Derived&>(*this);
}
/**
* Sign the transaction with the given keys.
*
* This sets the SigningPubKey field and computes the TxnSignature.
*
* @param publicKey The public key for signing
* @param secretKey The secret key for signing
* @return Reference to the derived builder for method chaining.
*/
Derived&
sign(PublicKey const& publicKey, SecretKey const& secretKey)
{
// Set the signing public key
object_.setFieldVL(sfSigningPubKey, publicKey.slice());
// Build the signing data: HashPrefix::txSign + serialized object
// (without signing fields)
Serializer s;
s.add32(HashPrefix::txSign);
object_.addWithoutSigningFields(s);
// Sign and set the signature
auto const sig = xrpl::sign(publicKey, secretKey, s.slice());
object_.setFieldVL(sfTxnSignature, sig);
return static_cast<Derived&>(*this);
}
protected:
STObject object_{sfTransaction};
};
} // namespace xrpl::transactions

View File

@@ -1,14 +0,0 @@
#pragma once
#include <optional>
#include <type_traits>
namespace xrpl::protocol_autogen {
template <typename ValueType>
using Optional = std::conditional_t<
std::is_reference_v<ValueType>,
std::optional<std::reference_wrapper<std::remove_reference_t<ValueType>>>,
std::optional<ValueType>>;
}

View File

@@ -1,347 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class AMMBuilder;
/**
* Ledger Entry: AMM
* Type: ltAMM (0x0079)
* RPC Name: amm
*
* Immutable wrapper around SLE providing type-safe field access.
* Use AMMBuilder to construct new ledger entries.
*/
class AMM : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltAMM;
/**
* Construct a AMM ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit AMM(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for AMM");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfTradingFee (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT16::type::value_type>
getTradingFee() const
{
if (hasTradingFee())
return this->sle_.at(sfTradingFee);
return std::nullopt;
}
[[nodiscard]]
bool
hasTradingFee() const
{
return this->sle_.isFieldPresent(sfTradingFee);
}
/**
* Get sfVoteSlots (soeOPTIONAL)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getVoteSlots() const
{
if (this->sle_.isFieldPresent(sfVoteSlots))
return this->sle_.getFieldArray(sfVoteSlots);
return std::nullopt;
}
[[nodiscard]]
bool
hasVoteSlots() const
{
return this->sle_.isFieldPresent(sfVoteSlots);
}
/**
* Get sfAuctionSlot (soeOPTIONAL)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
std::optional<STObject>
getAuctionSlot() const
{
if (this->sle_.isFieldPresent(sfAuctionSlot))
return this->sle_.getFieldObject(sfAuctionSlot);
return std::nullopt;
}
[[nodiscard]]
bool
hasAuctionSlot() const
{
return this->sle_.isFieldPresent(sfAuctionSlot);
}
/**
* Get sfLPTokenBalance (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getLPTokenBalance() const
{
return this->sle_.at(sfLPTokenBalance);
}
/**
* Get sfAsset (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset() const
{
return this->sle_.at(sfAsset);
}
/**
* Get sfAsset2 (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset2() const
{
return this->sle_.at(sfAsset2);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getPreviousTxnID() const
{
if (hasPreviousTxnID())
return this->sle_.at(sfPreviousTxnID);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnID() const
{
return this->sle_.isFieldPresent(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getPreviousTxnLgrSeq() const
{
if (hasPreviousTxnLgrSeq())
return this->sle_.at(sfPreviousTxnLgrSeq);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnLgrSeq() const
{
return this->sle_.isFieldPresent(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for AMM ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class AMMBuilder : public LedgerEntryBuilderBase<AMMBuilder>
{
public:
AMMBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_AMOUNT::type::value_type> const& lPTokenBalance,std::decay_t<typename SF_ISSUE::type::value_type> const& asset,std::decay_t<typename SF_ISSUE::type::value_type> const& asset2,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode)
: LedgerEntryBuilderBase<AMMBuilder>(ltAMM)
{
setAccount(account);
setLPTokenBalance(lPTokenBalance);
setAsset(asset);
setAsset2(asset2);
setOwnerNode(ownerNode);
}
AMMBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltAMM)
{
throw std::runtime_error("Invalid ledger entry type for AMM");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfTradingFee (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setTradingFee(std::decay_t<typename SF_UINT16::type::value_type> const& value)
{
object_[sfTradingFee] = value;
return *this;
}
/**
* Set sfVoteSlots (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setVoteSlots(STArray const& value)
{
object_.setFieldArray(sfVoteSlots, value);
return *this;
}
/**
* Set sfAuctionSlot (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setAuctionSlot(STObject const& value)
{
object_.setFieldObject(sfAuctionSlot, value);
return *this;
}
/**
* Set sfLPTokenBalance (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setLPTokenBalance(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfLPTokenBalance] = value;
return *this;
}
/**
* Set sfAsset (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setAsset(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset] = STIssue(sfAsset, value);
return *this;
}
/**
* Set sfAsset2 (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setAsset2(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset2] = STIssue(sfAsset2, value);
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed AMM wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
AMM
build(uint256 const& index)
{
return AMM{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,727 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class AccountRootBuilder;
/**
* Ledger Entry: AccountRoot
* Type: ltACCOUNT_ROOT (0x0061)
* RPC Name: account
*
* Immutable wrapper around SLE providing type-safe field access.
* Use AccountRootBuilder to construct new ledger entries.
*/
class AccountRoot : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltACCOUNT_ROOT;
/**
* Construct a AccountRoot ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit AccountRoot(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for AccountRoot");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSequence() const
{
return this->sle_.at(sfSequence);
}
/**
* Get sfBalance (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getBalance() const
{
return this->sle_.at(sfBalance);
}
/**
* Get sfOwnerCount (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getOwnerCount() const
{
return this->sle_.at(sfOwnerCount);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfAccountTxnID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getAccountTxnID() const
{
if (hasAccountTxnID())
return this->sle_.at(sfAccountTxnID);
return std::nullopt;
}
[[nodiscard]]
bool
hasAccountTxnID() const
{
return this->sle_.isFieldPresent(sfAccountTxnID);
}
/**
* Get sfRegularKey (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getRegularKey() const
{
if (hasRegularKey())
return this->sle_.at(sfRegularKey);
return std::nullopt;
}
[[nodiscard]]
bool
hasRegularKey() const
{
return this->sle_.isFieldPresent(sfRegularKey);
}
/**
* Get sfEmailHash (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT128::type::value_type>
getEmailHash() const
{
if (hasEmailHash())
return this->sle_.at(sfEmailHash);
return std::nullopt;
}
[[nodiscard]]
bool
hasEmailHash() const
{
return this->sle_.isFieldPresent(sfEmailHash);
}
/**
* Get sfWalletLocator (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getWalletLocator() const
{
if (hasWalletLocator())
return this->sle_.at(sfWalletLocator);
return std::nullopt;
}
[[nodiscard]]
bool
hasWalletLocator() const
{
return this->sle_.isFieldPresent(sfWalletLocator);
}
/**
* Get sfWalletSize (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getWalletSize() const
{
if (hasWalletSize())
return this->sle_.at(sfWalletSize);
return std::nullopt;
}
[[nodiscard]]
bool
hasWalletSize() const
{
return this->sle_.isFieldPresent(sfWalletSize);
}
/**
* Get sfMessageKey (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getMessageKey() const
{
if (hasMessageKey())
return this->sle_.at(sfMessageKey);
return std::nullopt;
}
[[nodiscard]]
bool
hasMessageKey() const
{
return this->sle_.isFieldPresent(sfMessageKey);
}
/**
* Get sfTransferRate (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getTransferRate() const
{
if (hasTransferRate())
return this->sle_.at(sfTransferRate);
return std::nullopt;
}
[[nodiscard]]
bool
hasTransferRate() const
{
return this->sle_.isFieldPresent(sfTransferRate);
}
/**
* Get sfDomain (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getDomain() const
{
if (hasDomain())
return this->sle_.at(sfDomain);
return std::nullopt;
}
[[nodiscard]]
bool
hasDomain() const
{
return this->sle_.isFieldPresent(sfDomain);
}
/**
* Get sfTickSize (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT8::type::value_type>
getTickSize() const
{
if (hasTickSize())
return this->sle_.at(sfTickSize);
return std::nullopt;
}
[[nodiscard]]
bool
hasTickSize() const
{
return this->sle_.isFieldPresent(sfTickSize);
}
/**
* Get sfTicketCount (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getTicketCount() const
{
if (hasTicketCount())
return this->sle_.at(sfTicketCount);
return std::nullopt;
}
[[nodiscard]]
bool
hasTicketCount() const
{
return this->sle_.isFieldPresent(sfTicketCount);
}
/**
* Get sfNFTokenMinter (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getNFTokenMinter() const
{
if (hasNFTokenMinter())
return this->sle_.at(sfNFTokenMinter);
return std::nullopt;
}
[[nodiscard]]
bool
hasNFTokenMinter() const
{
return this->sle_.isFieldPresent(sfNFTokenMinter);
}
/**
* Get sfMintedNFTokens (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getMintedNFTokens() const
{
if (hasMintedNFTokens())
return this->sle_.at(sfMintedNFTokens);
return std::nullopt;
}
[[nodiscard]]
bool
hasMintedNFTokens() const
{
return this->sle_.isFieldPresent(sfMintedNFTokens);
}
/**
* Get sfBurnedNFTokens (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getBurnedNFTokens() const
{
if (hasBurnedNFTokens())
return this->sle_.at(sfBurnedNFTokens);
return std::nullopt;
}
[[nodiscard]]
bool
hasBurnedNFTokens() const
{
return this->sle_.isFieldPresent(sfBurnedNFTokens);
}
/**
* Get sfFirstNFTokenSequence (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getFirstNFTokenSequence() const
{
if (hasFirstNFTokenSequence())
return this->sle_.at(sfFirstNFTokenSequence);
return std::nullopt;
}
[[nodiscard]]
bool
hasFirstNFTokenSequence() const
{
return this->sle_.isFieldPresent(sfFirstNFTokenSequence);
}
/**
* Get sfAMMID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getAMMID() const
{
if (hasAMMID())
return this->sle_.at(sfAMMID);
return std::nullopt;
}
[[nodiscard]]
bool
hasAMMID() const
{
return this->sle_.isFieldPresent(sfAMMID);
}
/**
* Get sfVaultID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getVaultID() const
{
if (hasVaultID())
return this->sle_.at(sfVaultID);
return std::nullopt;
}
[[nodiscard]]
bool
hasVaultID() const
{
return this->sle_.isFieldPresent(sfVaultID);
}
/**
* Get sfLoanBrokerID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getLoanBrokerID() const
{
if (hasLoanBrokerID())
return this->sle_.at(sfLoanBrokerID);
return std::nullopt;
}
[[nodiscard]]
bool
hasLoanBrokerID() const
{
return this->sle_.isFieldPresent(sfLoanBrokerID);
}
};
/**
* Builder for AccountRoot ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class AccountRootBuilder : public LedgerEntryBuilderBase<AccountRootBuilder>
{
public:
AccountRootBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_UINT32::type::value_type> const& sequence,std::decay_t<typename SF_AMOUNT::type::value_type> const& balance,std::decay_t<typename SF_UINT32::type::value_type> const& ownerCount,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<AccountRootBuilder>(ltACCOUNT_ROOT)
{
setAccount(account);
setSequence(sequence);
setBalance(balance);
setOwnerCount(ownerCount);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
AccountRootBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltACCOUNT_ROOT)
{
throw std::runtime_error("Invalid ledger entry type for AccountRoot");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSequence] = value;
return *this;
}
/**
* Set sfBalance (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setBalance(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfBalance] = value;
return *this;
}
/**
* Set sfOwnerCount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfOwnerCount] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfAccountTxnID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setAccountTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfAccountTxnID] = value;
return *this;
}
/**
* Set sfRegularKey (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setRegularKey(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfRegularKey] = value;
return *this;
}
/**
* Set sfEmailHash (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setEmailHash(std::decay_t<typename SF_UINT128::type::value_type> const& value)
{
object_[sfEmailHash] = value;
return *this;
}
/**
* Set sfWalletLocator (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setWalletLocator(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfWalletLocator] = value;
return *this;
}
/**
* Set sfWalletSize (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setWalletSize(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfWalletSize] = value;
return *this;
}
/**
* Set sfMessageKey (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setMessageKey(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfMessageKey] = value;
return *this;
}
/**
* Set sfTransferRate (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setTransferRate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfTransferRate] = value;
return *this;
}
/**
* Set sfDomain (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setDomain(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfDomain] = value;
return *this;
}
/**
* Set sfTickSize (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setTickSize(std::decay_t<typename SF_UINT8::type::value_type> const& value)
{
object_[sfTickSize] = value;
return *this;
}
/**
* Set sfTicketCount (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setTicketCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfTicketCount] = value;
return *this;
}
/**
* Set sfNFTokenMinter (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setNFTokenMinter(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfNFTokenMinter] = value;
return *this;
}
/**
* Set sfMintedNFTokens (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setMintedNFTokens(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfMintedNFTokens] = value;
return *this;
}
/**
* Set sfBurnedNFTokens (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setBurnedNFTokens(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfBurnedNFTokens] = value;
return *this;
}
/**
* Set sfFirstNFTokenSequence (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setFirstNFTokenSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfFirstNFTokenSequence] = value;
return *this;
}
/**
* Set sfAMMID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setAMMID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfAMMID] = value;
return *this;
}
/**
* Set sfVaultID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setVaultID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfVaultID] = value;
return *this;
}
/**
* Set sfLoanBrokerID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setLoanBrokerID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfLoanBrokerID] = value;
return *this;
}
/**
* Build and return the completed AccountRoot wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
AccountRoot
build(uint256 const& index)
{
return AccountRoot{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,206 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class AmendmentsBuilder;
/**
* Ledger Entry: Amendments
* Type: ltAMENDMENTS (0x0066)
* RPC Name: amendments
*
* Immutable wrapper around SLE providing type-safe field access.
* Use AmendmentsBuilder to construct new ledger entries.
*/
class Amendments : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltAMENDMENTS;
/**
* Construct a Amendments ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Amendments(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Amendments");
}
}
// Ledger entry-specific field getters
/**
* Get sfAmendments (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VECTOR256::type::value_type>
getAmendments() const
{
if (hasAmendments())
return this->sle_.at(sfAmendments);
return std::nullopt;
}
[[nodiscard]]
bool
hasAmendments() const
{
return this->sle_.isFieldPresent(sfAmendments);
}
/**
* Get sfMajorities (soeOPTIONAL)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getMajorities() const
{
if (this->sle_.isFieldPresent(sfMajorities))
return this->sle_.getFieldArray(sfMajorities);
return std::nullopt;
}
[[nodiscard]]
bool
hasMajorities() const
{
return this->sle_.isFieldPresent(sfMajorities);
}
/**
* Get sfPreviousTxnID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getPreviousTxnID() const
{
if (hasPreviousTxnID())
return this->sle_.at(sfPreviousTxnID);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnID() const
{
return this->sle_.isFieldPresent(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getPreviousTxnLgrSeq() const
{
if (hasPreviousTxnLgrSeq())
return this->sle_.at(sfPreviousTxnLgrSeq);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnLgrSeq() const
{
return this->sle_.isFieldPresent(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for Amendments ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class AmendmentsBuilder : public LedgerEntryBuilderBase<AmendmentsBuilder>
{
public:
AmendmentsBuilder()
: LedgerEntryBuilderBase<AmendmentsBuilder>(ltAMENDMENTS)
{
}
AmendmentsBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltAMENDMENTS)
{
throw std::runtime_error("Invalid ledger entry type for Amendments");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAmendments (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AmendmentsBuilder&
setAmendments(std::decay_t<typename SF_VECTOR256::type::value_type> const& value)
{
object_[sfAmendments] = value;
return *this;
}
/**
* Set sfMajorities (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AmendmentsBuilder&
setMajorities(STArray const& value)
{
object_.setFieldArray(sfMajorities, value);
return *this;
}
/**
* Set sfPreviousTxnID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AmendmentsBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AmendmentsBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed Amendments wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Amendments
build(uint256 const& index)
{
return Amendments{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,313 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class BridgeBuilder;
/**
* Ledger Entry: Bridge
* Type: ltBRIDGE (0x0069)
* RPC Name: bridge
*
* Immutable wrapper around SLE providing type-safe field access.
* Use BridgeBuilder to construct new ledger entries.
*/
class Bridge : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltBRIDGE;
/**
* Construct a Bridge ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Bridge(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Bridge");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfSignatureReward (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getSignatureReward() const
{
return this->sle_.at(sfSignatureReward);
}
/**
* Get sfMinAccountCreateAmount (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getMinAccountCreateAmount() const
{
if (hasMinAccountCreateAmount())
return this->sle_.at(sfMinAccountCreateAmount);
return std::nullopt;
}
[[nodiscard]]
bool
hasMinAccountCreateAmount() const
{
return this->sle_.isFieldPresent(sfMinAccountCreateAmount);
}
/**
* Get sfXChainBridge (soeREQUIRED)
*/
[[nodiscard]]
SF_XCHAIN_BRIDGE::type::value_type
getXChainBridge() const
{
return this->sle_.at(sfXChainBridge);
}
/**
* Get sfXChainClaimID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getXChainClaimID() const
{
return this->sle_.at(sfXChainClaimID);
}
/**
* Get sfXChainAccountCreateCount (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getXChainAccountCreateCount() const
{
return this->sle_.at(sfXChainAccountCreateCount);
}
/**
* Get sfXChainAccountClaimCount (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getXChainAccountClaimCount() const
{
return this->sle_.at(sfXChainAccountClaimCount);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for Bridge ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class BridgeBuilder : public LedgerEntryBuilderBase<BridgeBuilder>
{
public:
BridgeBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_AMOUNT::type::value_type> const& signatureReward,std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& xChainBridge,std::decay_t<typename SF_UINT64::type::value_type> const& xChainClaimID,std::decay_t<typename SF_UINT64::type::value_type> const& xChainAccountCreateCount,std::decay_t<typename SF_UINT64::type::value_type> const& xChainAccountClaimCount,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<BridgeBuilder>(ltBRIDGE)
{
setAccount(account);
setSignatureReward(signatureReward);
setXChainBridge(xChainBridge);
setXChainClaimID(xChainClaimID);
setXChainAccountCreateCount(xChainAccountCreateCount);
setXChainAccountClaimCount(xChainAccountClaimCount);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
BridgeBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltBRIDGE)
{
throw std::runtime_error("Invalid ledger entry type for Bridge");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfSignatureReward (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setSignatureReward(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfSignatureReward] = value;
return *this;
}
/**
* Set sfMinAccountCreateAmount (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setMinAccountCreateAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfMinAccountCreateAmount] = value;
return *this;
}
/**
* Set sfXChainBridge (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setXChainBridge(std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& value)
{
object_[sfXChainBridge] = value;
return *this;
}
/**
* Set sfXChainClaimID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setXChainClaimID(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfXChainClaimID] = value;
return *this;
}
/**
* Set sfXChainAccountCreateCount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setXChainAccountCreateCount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfXChainAccountCreateCount] = value;
return *this;
}
/**
* Set sfXChainAccountClaimCount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setXChainAccountClaimCount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfXChainAccountClaimCount] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BridgeBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed Bridge wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Bridge
build(uint256 const& index)
{
return Bridge{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,381 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class CheckBuilder;
/**
* Ledger Entry: Check
* Type: ltCHECK (0x0043)
* RPC Name: check
*
* Immutable wrapper around SLE providing type-safe field access.
* Use CheckBuilder to construct new ledger entries.
*/
class Check : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltCHECK;
/**
* Construct a Check ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Check(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Check");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfDestination (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getDestination() const
{
return this->sle_.at(sfDestination);
}
/**
* Get sfSendMax (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getSendMax() const
{
return this->sle_.at(sfSendMax);
}
/**
* Get sfSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSequence() const
{
return this->sle_.at(sfSequence);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfDestinationNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getDestinationNode() const
{
return this->sle_.at(sfDestinationNode);
}
/**
* Get sfExpiration (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getExpiration() const
{
if (hasExpiration())
return this->sle_.at(sfExpiration);
return std::nullopt;
}
[[nodiscard]]
bool
hasExpiration() const
{
return this->sle_.isFieldPresent(sfExpiration);
}
/**
* Get sfInvoiceID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getInvoiceID() const
{
if (hasInvoiceID())
return this->sle_.at(sfInvoiceID);
return std::nullopt;
}
[[nodiscard]]
bool
hasInvoiceID() const
{
return this->sle_.isFieldPresent(sfInvoiceID);
}
/**
* Get sfSourceTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getSourceTag() const
{
if (hasSourceTag())
return this->sle_.at(sfSourceTag);
return std::nullopt;
}
[[nodiscard]]
bool
hasSourceTag() const
{
return this->sle_.isFieldPresent(sfSourceTag);
}
/**
* Get sfDestinationTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getDestinationTag() const
{
if (hasDestinationTag())
return this->sle_.at(sfDestinationTag);
return std::nullopt;
}
[[nodiscard]]
bool
hasDestinationTag() const
{
return this->sle_.isFieldPresent(sfDestinationTag);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for Check ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class CheckBuilder : public LedgerEntryBuilderBase<CheckBuilder>
{
public:
CheckBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_ACCOUNT::type::value_type> const& destination,std::decay_t<typename SF_AMOUNT::type::value_type> const& sendMax,std::decay_t<typename SF_UINT32::type::value_type> const& sequence,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT64::type::value_type> const& destinationNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<CheckBuilder>(ltCHECK)
{
setAccount(account);
setDestination(destination);
setSendMax(sendMax);
setSequence(sequence);
setOwnerNode(ownerNode);
setDestinationNode(destinationNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
CheckBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltCHECK)
{
throw std::runtime_error("Invalid ledger entry type for Check");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfDestination (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfDestination] = value;
return *this;
}
/**
* Set sfSendMax (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setSendMax(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfSendMax] = value;
return *this;
}
/**
* Set sfSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSequence] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfDestinationNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setDestinationNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfDestinationNode] = value;
return *this;
}
/**
* Set sfExpiration (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setExpiration(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfExpiration] = value;
return *this;
}
/**
* Set sfInvoiceID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setInvoiceID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfInvoiceID] = value;
return *this;
}
/**
* Set sfSourceTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setSourceTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSourceTag] = value;
return *this;
}
/**
* Set sfDestinationTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setDestinationTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfDestinationTag] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed Check wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Check
build(uint256 const& index)
{
return Check{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,307 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class CredentialBuilder;
/**
* Ledger Entry: Credential
* Type: ltCREDENTIAL (0x0081)
* RPC Name: credential
*
* Immutable wrapper around SLE providing type-safe field access.
* Use CredentialBuilder to construct new ledger entries.
*/
class Credential : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltCREDENTIAL;
/**
* Construct a Credential ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Credential(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Credential");
}
}
// Ledger entry-specific field getters
/**
* Get sfSubject (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getSubject() const
{
return this->sle_.at(sfSubject);
}
/**
* Get sfIssuer (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getIssuer() const
{
return this->sle_.at(sfIssuer);
}
/**
* Get sfCredentialType (soeREQUIRED)
*/
[[nodiscard]]
SF_VL::type::value_type
getCredentialType() const
{
return this->sle_.at(sfCredentialType);
}
/**
* Get sfExpiration (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getExpiration() const
{
if (hasExpiration())
return this->sle_.at(sfExpiration);
return std::nullopt;
}
[[nodiscard]]
bool
hasExpiration() const
{
return this->sle_.isFieldPresent(sfExpiration);
}
/**
* Get sfURI (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getURI() const
{
if (hasURI())
return this->sle_.at(sfURI);
return std::nullopt;
}
[[nodiscard]]
bool
hasURI() const
{
return this->sle_.isFieldPresent(sfURI);
}
/**
* Get sfIssuerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getIssuerNode() const
{
return this->sle_.at(sfIssuerNode);
}
/**
* Get sfSubjectNode (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getSubjectNode() const
{
if (hasSubjectNode())
return this->sle_.at(sfSubjectNode);
return std::nullopt;
}
[[nodiscard]]
bool
hasSubjectNode() const
{
return this->sle_.isFieldPresent(sfSubjectNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for Credential ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class CredentialBuilder : public LedgerEntryBuilderBase<CredentialBuilder>
{
public:
CredentialBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& subject,std::decay_t<typename SF_ACCOUNT::type::value_type> const& issuer,std::decay_t<typename SF_VL::type::value_type> const& credentialType,std::decay_t<typename SF_UINT64::type::value_type> const& issuerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<CredentialBuilder>(ltCREDENTIAL)
{
setSubject(subject);
setIssuer(issuer);
setCredentialType(credentialType);
setIssuerNode(issuerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
CredentialBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltCREDENTIAL)
{
throw std::runtime_error("Invalid ledger entry type for Credential");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfSubject (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialBuilder&
setSubject(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfSubject] = value;
return *this;
}
/**
* Set sfIssuer (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialBuilder&
setIssuer(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfIssuer] = value;
return *this;
}
/**
* Set sfCredentialType (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialBuilder&
setCredentialType(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfCredentialType] = value;
return *this;
}
/**
* Set sfExpiration (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CredentialBuilder&
setExpiration(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfExpiration] = value;
return *this;
}
/**
* Set sfURI (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CredentialBuilder&
setURI(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfURI] = value;
return *this;
}
/**
* Set sfIssuerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialBuilder&
setIssuerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfIssuerNode] = value;
return *this;
}
/**
* Set sfSubjectNode (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CredentialBuilder&
setSubjectNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfSubjectNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed Credential wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Credential
build(uint256 const& index)
{
return Credential{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,263 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class DIDBuilder;
/**
* Ledger Entry: DID
* Type: ltDID (0x0049)
* RPC Name: did
*
* Immutable wrapper around SLE providing type-safe field access.
* Use DIDBuilder to construct new ledger entries.
*/
class DID : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltDID;
/**
* Construct a DID ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit DID(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for DID");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfDIDDocument (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getDIDDocument() const
{
if (hasDIDDocument())
return this->sle_.at(sfDIDDocument);
return std::nullopt;
}
[[nodiscard]]
bool
hasDIDDocument() const
{
return this->sle_.isFieldPresent(sfDIDDocument);
}
/**
* Get sfURI (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getURI() const
{
if (hasURI())
return this->sle_.at(sfURI);
return std::nullopt;
}
[[nodiscard]]
bool
hasURI() const
{
return this->sle_.isFieldPresent(sfURI);
}
/**
* Get sfData (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getData() const
{
if (hasData())
return this->sle_.at(sfData);
return std::nullopt;
}
[[nodiscard]]
bool
hasData() const
{
return this->sle_.isFieldPresent(sfData);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for DID ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class DIDBuilder : public LedgerEntryBuilderBase<DIDBuilder>
{
public:
DIDBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<DIDBuilder>(ltDID)
{
setAccount(account);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
DIDBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltDID)
{
throw std::runtime_error("Invalid ledger entry type for DID");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DIDBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfDIDDocument (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DIDBuilder&
setDIDDocument(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfDIDDocument] = value;
return *this;
}
/**
* Set sfURI (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DIDBuilder&
setURI(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfURI] = value;
return *this;
}
/**
* Set sfData (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DIDBuilder&
setData(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfData] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DIDBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DIDBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DIDBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed DID wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
DID
build(uint256 const& index)
{
return DID{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,218 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class DelegateBuilder;
/**
* Ledger Entry: Delegate
* Type: ltDELEGATE (0x0083)
* RPC Name: delegate
*
* Immutable wrapper around SLE providing type-safe field access.
* Use DelegateBuilder to construct new ledger entries.
*/
class Delegate : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltDELEGATE;
/**
* Construct a Delegate ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Delegate(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Delegate");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfAuthorize (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAuthorize() const
{
return this->sle_.at(sfAuthorize);
}
/**
* Get sfPermissions (soeREQUIRED)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
STArray const&
getPermissions() const
{
return this->sle_.getFieldArray(sfPermissions);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for Delegate ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class DelegateBuilder : public LedgerEntryBuilderBase<DelegateBuilder>
{
public:
DelegateBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_ACCOUNT::type::value_type> const& authorize,STArray const& permissions,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<DelegateBuilder>(ltDELEGATE)
{
setAccount(account);
setAuthorize(authorize);
setPermissions(permissions);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
DelegateBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltDELEGATE)
{
throw std::runtime_error("Invalid ledger entry type for Delegate");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DelegateBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfAuthorize (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DelegateBuilder&
setAuthorize(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAuthorize] = value;
return *this;
}
/**
* Set sfPermissions (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DelegateBuilder&
setPermissions(STArray const& value)
{
object_.setFieldArray(sfPermissions, value);
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DelegateBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DelegateBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DelegateBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed Delegate wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Delegate
build(uint256 const& index)
{
return Delegate{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,234 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class DepositPreauthBuilder;
/**
* Ledger Entry: DepositPreauth
* Type: ltDEPOSIT_PREAUTH (0x0070)
* RPC Name: deposit_preauth
*
* Immutable wrapper around SLE providing type-safe field access.
* Use DepositPreauthBuilder to construct new ledger entries.
*/
class DepositPreauth : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltDEPOSIT_PREAUTH;
/**
* Construct a DepositPreauth ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit DepositPreauth(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for DepositPreauth");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfAuthorize (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getAuthorize() const
{
if (hasAuthorize())
return this->sle_.at(sfAuthorize);
return std::nullopt;
}
[[nodiscard]]
bool
hasAuthorize() const
{
return this->sle_.isFieldPresent(sfAuthorize);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfAuthorizeCredentials (soeOPTIONAL)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getAuthorizeCredentials() const
{
if (this->sle_.isFieldPresent(sfAuthorizeCredentials))
return this->sle_.getFieldArray(sfAuthorizeCredentials);
return std::nullopt;
}
[[nodiscard]]
bool
hasAuthorizeCredentials() const
{
return this->sle_.isFieldPresent(sfAuthorizeCredentials);
}
};
/**
* Builder for DepositPreauth ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class DepositPreauthBuilder : public LedgerEntryBuilderBase<DepositPreauthBuilder>
{
public:
DepositPreauthBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<DepositPreauthBuilder>(ltDEPOSIT_PREAUTH)
{
setAccount(account);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
DepositPreauthBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltDEPOSIT_PREAUTH)
{
throw std::runtime_error("Invalid ledger entry type for DepositPreauth");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfAuthorize (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setAuthorize(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAuthorize] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfAuthorizeCredentials (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setAuthorizeCredentials(STArray const& value)
{
object_.setFieldArray(sfAuthorizeCredentials, value);
return *this;
}
/**
* Build and return the completed DepositPreauth wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
DepositPreauth
build(uint256 const& index)
{
return DepositPreauth{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,489 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class DirectoryNodeBuilder;
/**
* Ledger Entry: DirectoryNode
* Type: ltDIR_NODE (0x0064)
* RPC Name: directory
*
* Immutable wrapper around SLE providing type-safe field access.
* Use DirectoryNodeBuilder to construct new ledger entries.
*/
class DirectoryNode : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltDIR_NODE;
/**
* Construct a DirectoryNode ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit DirectoryNode(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for DirectoryNode");
}
}
// Ledger entry-specific field getters
/**
* Get sfOwner (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getOwner() const
{
if (hasOwner())
return this->sle_.at(sfOwner);
return std::nullopt;
}
[[nodiscard]]
bool
hasOwner() const
{
return this->sle_.isFieldPresent(sfOwner);
}
/**
* Get sfTakerPaysCurrency (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT160::type::value_type>
getTakerPaysCurrency() const
{
if (hasTakerPaysCurrency())
return this->sle_.at(sfTakerPaysCurrency);
return std::nullopt;
}
[[nodiscard]]
bool
hasTakerPaysCurrency() const
{
return this->sle_.isFieldPresent(sfTakerPaysCurrency);
}
/**
* Get sfTakerPaysIssuer (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT160::type::value_type>
getTakerPaysIssuer() const
{
if (hasTakerPaysIssuer())
return this->sle_.at(sfTakerPaysIssuer);
return std::nullopt;
}
[[nodiscard]]
bool
hasTakerPaysIssuer() const
{
return this->sle_.isFieldPresent(sfTakerPaysIssuer);
}
/**
* Get sfTakerGetsCurrency (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT160::type::value_type>
getTakerGetsCurrency() const
{
if (hasTakerGetsCurrency())
return this->sle_.at(sfTakerGetsCurrency);
return std::nullopt;
}
[[nodiscard]]
bool
hasTakerGetsCurrency() const
{
return this->sle_.isFieldPresent(sfTakerGetsCurrency);
}
/**
* Get sfTakerGetsIssuer (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT160::type::value_type>
getTakerGetsIssuer() const
{
if (hasTakerGetsIssuer())
return this->sle_.at(sfTakerGetsIssuer);
return std::nullopt;
}
[[nodiscard]]
bool
hasTakerGetsIssuer() const
{
return this->sle_.isFieldPresent(sfTakerGetsIssuer);
}
/**
* Get sfExchangeRate (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getExchangeRate() const
{
if (hasExchangeRate())
return this->sle_.at(sfExchangeRate);
return std::nullopt;
}
[[nodiscard]]
bool
hasExchangeRate() const
{
return this->sle_.isFieldPresent(sfExchangeRate);
}
/**
* Get sfIndexes (soeREQUIRED)
*/
[[nodiscard]]
SF_VECTOR256::type::value_type
getIndexes() const
{
return this->sle_.at(sfIndexes);
}
/**
* Get sfRootIndex (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getRootIndex() const
{
return this->sle_.at(sfRootIndex);
}
/**
* Get sfIndexNext (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getIndexNext() const
{
if (hasIndexNext())
return this->sle_.at(sfIndexNext);
return std::nullopt;
}
[[nodiscard]]
bool
hasIndexNext() const
{
return this->sle_.isFieldPresent(sfIndexNext);
}
/**
* Get sfIndexPrevious (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getIndexPrevious() const
{
if (hasIndexPrevious())
return this->sle_.at(sfIndexPrevious);
return std::nullopt;
}
[[nodiscard]]
bool
hasIndexPrevious() const
{
return this->sle_.isFieldPresent(sfIndexPrevious);
}
/**
* Get sfNFTokenID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getNFTokenID() const
{
if (hasNFTokenID())
return this->sle_.at(sfNFTokenID);
return std::nullopt;
}
[[nodiscard]]
bool
hasNFTokenID() const
{
return this->sle_.isFieldPresent(sfNFTokenID);
}
/**
* Get sfPreviousTxnID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getPreviousTxnID() const
{
if (hasPreviousTxnID())
return this->sle_.at(sfPreviousTxnID);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnID() const
{
return this->sle_.isFieldPresent(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getPreviousTxnLgrSeq() const
{
if (hasPreviousTxnLgrSeq())
return this->sle_.at(sfPreviousTxnLgrSeq);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnLgrSeq() const
{
return this->sle_.isFieldPresent(sfPreviousTxnLgrSeq);
}
/**
* Get sfDomainID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getDomainID() const
{
if (hasDomainID())
return this->sle_.at(sfDomainID);
return std::nullopt;
}
[[nodiscard]]
bool
hasDomainID() const
{
return this->sle_.isFieldPresent(sfDomainID);
}
};
/**
* Builder for DirectoryNode ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class DirectoryNodeBuilder : public LedgerEntryBuilderBase<DirectoryNodeBuilder>
{
public:
DirectoryNodeBuilder(std::decay_t<typename SF_VECTOR256::type::value_type> const& indexes,std::decay_t<typename SF_UINT256::type::value_type> const& rootIndex)
: LedgerEntryBuilderBase<DirectoryNodeBuilder>(ltDIR_NODE)
{
setIndexes(indexes);
setRootIndex(rootIndex);
}
DirectoryNodeBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltDIR_NODE)
{
throw std::runtime_error("Invalid ledger entry type for DirectoryNode");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfOwner (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Set sfTakerPaysCurrency (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setTakerPaysCurrency(std::decay_t<typename SF_UINT160::type::value_type> const& value)
{
object_[sfTakerPaysCurrency] = value;
return *this;
}
/**
* Set sfTakerPaysIssuer (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setTakerPaysIssuer(std::decay_t<typename SF_UINT160::type::value_type> const& value)
{
object_[sfTakerPaysIssuer] = value;
return *this;
}
/**
* Set sfTakerGetsCurrency (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setTakerGetsCurrency(std::decay_t<typename SF_UINT160::type::value_type> const& value)
{
object_[sfTakerGetsCurrency] = value;
return *this;
}
/**
* Set sfTakerGetsIssuer (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setTakerGetsIssuer(std::decay_t<typename SF_UINT160::type::value_type> const& value)
{
object_[sfTakerGetsIssuer] = value;
return *this;
}
/**
* Set sfExchangeRate (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setExchangeRate(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfExchangeRate] = value;
return *this;
}
/**
* Set sfIndexes (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setIndexes(std::decay_t<typename SF_VECTOR256::type::value_type> const& value)
{
object_[sfIndexes] = value;
return *this;
}
/**
* Set sfRootIndex (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setRootIndex(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfRootIndex] = value;
return *this;
}
/**
* Set sfIndexNext (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setIndexNext(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfIndexNext] = value;
return *this;
}
/**
* Set sfIndexPrevious (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setIndexPrevious(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfIndexPrevious] = value;
return *this;
}
/**
* Set sfNFTokenID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setNFTokenID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfNFTokenID] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfDomainID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DirectoryNodeBuilder&
setDomainID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfDomainID] = value;
return *this;
}
/**
* Build and return the completed DirectoryNode wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
DirectoryNode
build(uint256 const& index)
{
return DirectoryNode{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,487 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class EscrowBuilder;
/**
* Ledger Entry: Escrow
* Type: ltESCROW (0x0075)
* RPC Name: escrow
*
* Immutable wrapper around SLE providing type-safe field access.
* Use EscrowBuilder to construct new ledger entries.
*/
class Escrow : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltESCROW;
/**
* Construct a Escrow ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Escrow(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Escrow");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfSequence (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getSequence() const
{
if (hasSequence())
return this->sle_.at(sfSequence);
return std::nullopt;
}
[[nodiscard]]
bool
hasSequence() const
{
return this->sle_.isFieldPresent(sfSequence);
}
/**
* Get sfDestination (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getDestination() const
{
return this->sle_.at(sfDestination);
}
/**
* Get sfAmount (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getAmount() const
{
return this->sle_.at(sfAmount);
}
/**
* Get sfCondition (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getCondition() const
{
if (hasCondition())
return this->sle_.at(sfCondition);
return std::nullopt;
}
[[nodiscard]]
bool
hasCondition() const
{
return this->sle_.isFieldPresent(sfCondition);
}
/**
* Get sfCancelAfter (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getCancelAfter() const
{
if (hasCancelAfter())
return this->sle_.at(sfCancelAfter);
return std::nullopt;
}
[[nodiscard]]
bool
hasCancelAfter() const
{
return this->sle_.isFieldPresent(sfCancelAfter);
}
/**
* Get sfFinishAfter (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getFinishAfter() const
{
if (hasFinishAfter())
return this->sle_.at(sfFinishAfter);
return std::nullopt;
}
[[nodiscard]]
bool
hasFinishAfter() const
{
return this->sle_.isFieldPresent(sfFinishAfter);
}
/**
* Get sfSourceTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getSourceTag() const
{
if (hasSourceTag())
return this->sle_.at(sfSourceTag);
return std::nullopt;
}
[[nodiscard]]
bool
hasSourceTag() const
{
return this->sle_.isFieldPresent(sfSourceTag);
}
/**
* Get sfDestinationTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getDestinationTag() const
{
if (hasDestinationTag())
return this->sle_.at(sfDestinationTag);
return std::nullopt;
}
[[nodiscard]]
bool
hasDestinationTag() const
{
return this->sle_.isFieldPresent(sfDestinationTag);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfDestinationNode (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getDestinationNode() const
{
if (hasDestinationNode())
return this->sle_.at(sfDestinationNode);
return std::nullopt;
}
[[nodiscard]]
bool
hasDestinationNode() const
{
return this->sle_.isFieldPresent(sfDestinationNode);
}
/**
* Get sfTransferRate (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getTransferRate() const
{
if (hasTransferRate())
return this->sle_.at(sfTransferRate);
return std::nullopt;
}
[[nodiscard]]
bool
hasTransferRate() const
{
return this->sle_.isFieldPresent(sfTransferRate);
}
/**
* Get sfIssuerNode (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getIssuerNode() const
{
if (hasIssuerNode())
return this->sle_.at(sfIssuerNode);
return std::nullopt;
}
[[nodiscard]]
bool
hasIssuerNode() const
{
return this->sle_.isFieldPresent(sfIssuerNode);
}
};
/**
* Builder for Escrow ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class EscrowBuilder : public LedgerEntryBuilderBase<EscrowBuilder>
{
public:
EscrowBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_ACCOUNT::type::value_type> const& destination,std::decay_t<typename SF_AMOUNT::type::value_type> const& amount,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<EscrowBuilder>(ltESCROW)
{
setAccount(account);
setDestination(destination);
setAmount(amount);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
EscrowBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltESCROW)
{
throw std::runtime_error("Invalid ledger entry type for Escrow");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfSequence (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSequence] = value;
return *this;
}
/**
* Set sfDestination (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfDestination] = value;
return *this;
}
/**
* Set sfAmount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfCondition (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setCondition(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfCondition] = value;
return *this;
}
/**
* Set sfCancelAfter (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setCancelAfter(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfCancelAfter] = value;
return *this;
}
/**
* Set sfFinishAfter (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setFinishAfter(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfFinishAfter] = value;
return *this;
}
/**
* Set sfSourceTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setSourceTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSourceTag] = value;
return *this;
}
/**
* Set sfDestinationTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setDestinationTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfDestinationTag] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfDestinationNode (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setDestinationNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfDestinationNode] = value;
return *this;
}
/**
* Set sfTransferRate (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setTransferRate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfTransferRate] = value;
return *this;
}
/**
* Set sfIssuerNode (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setIssuerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfIssuerNode] = value;
return *this;
}
/**
* Build and return the completed Escrow wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Escrow
build(uint256 const& index)
{
return Escrow{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,355 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class FeeSettingsBuilder;
/**
* Ledger Entry: FeeSettings
* Type: ltFEE_SETTINGS (0x0073)
* RPC Name: fee
*
* Immutable wrapper around SLE providing type-safe field access.
* Use FeeSettingsBuilder to construct new ledger entries.
*/
class FeeSettings : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltFEE_SETTINGS;
/**
* Construct a FeeSettings ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit FeeSettings(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for FeeSettings");
}
}
// Ledger entry-specific field getters
/**
* Get sfBaseFee (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getBaseFee() const
{
if (hasBaseFee())
return this->sle_.at(sfBaseFee);
return std::nullopt;
}
[[nodiscard]]
bool
hasBaseFee() const
{
return this->sle_.isFieldPresent(sfBaseFee);
}
/**
* Get sfReferenceFeeUnits (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getReferenceFeeUnits() const
{
if (hasReferenceFeeUnits())
return this->sle_.at(sfReferenceFeeUnits);
return std::nullopt;
}
[[nodiscard]]
bool
hasReferenceFeeUnits() const
{
return this->sle_.isFieldPresent(sfReferenceFeeUnits);
}
/**
* Get sfReserveBase (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getReserveBase() const
{
if (hasReserveBase())
return this->sle_.at(sfReserveBase);
return std::nullopt;
}
[[nodiscard]]
bool
hasReserveBase() const
{
return this->sle_.isFieldPresent(sfReserveBase);
}
/**
* Get sfReserveIncrement (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getReserveIncrement() const
{
if (hasReserveIncrement())
return this->sle_.at(sfReserveIncrement);
return std::nullopt;
}
[[nodiscard]]
bool
hasReserveIncrement() const
{
return this->sle_.isFieldPresent(sfReserveIncrement);
}
/**
* Get sfBaseFeeDrops (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getBaseFeeDrops() const
{
if (hasBaseFeeDrops())
return this->sle_.at(sfBaseFeeDrops);
return std::nullopt;
}
[[nodiscard]]
bool
hasBaseFeeDrops() const
{
return this->sle_.isFieldPresent(sfBaseFeeDrops);
}
/**
* Get sfReserveBaseDrops (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getReserveBaseDrops() const
{
if (hasReserveBaseDrops())
return this->sle_.at(sfReserveBaseDrops);
return std::nullopt;
}
[[nodiscard]]
bool
hasReserveBaseDrops() const
{
return this->sle_.isFieldPresent(sfReserveBaseDrops);
}
/**
* Get sfReserveIncrementDrops (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getReserveIncrementDrops() const
{
if (hasReserveIncrementDrops())
return this->sle_.at(sfReserveIncrementDrops);
return std::nullopt;
}
[[nodiscard]]
bool
hasReserveIncrementDrops() const
{
return this->sle_.isFieldPresent(sfReserveIncrementDrops);
}
/**
* Get sfPreviousTxnID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getPreviousTxnID() const
{
if (hasPreviousTxnID())
return this->sle_.at(sfPreviousTxnID);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnID() const
{
return this->sle_.isFieldPresent(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getPreviousTxnLgrSeq() const
{
if (hasPreviousTxnLgrSeq())
return this->sle_.at(sfPreviousTxnLgrSeq);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnLgrSeq() const
{
return this->sle_.isFieldPresent(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for FeeSettings ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class FeeSettingsBuilder : public LedgerEntryBuilderBase<FeeSettingsBuilder>
{
public:
FeeSettingsBuilder()
: LedgerEntryBuilderBase<FeeSettingsBuilder>(ltFEE_SETTINGS)
{
}
FeeSettingsBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltFEE_SETTINGS)
{
throw std::runtime_error("Invalid ledger entry type for FeeSettings");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfBaseFee (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
FeeSettingsBuilder&
setBaseFee(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfBaseFee] = value;
return *this;
}
/**
* Set sfReferenceFeeUnits (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
FeeSettingsBuilder&
setReferenceFeeUnits(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfReferenceFeeUnits] = value;
return *this;
}
/**
* Set sfReserveBase (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
FeeSettingsBuilder&
setReserveBase(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfReserveBase] = value;
return *this;
}
/**
* Set sfReserveIncrement (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
FeeSettingsBuilder&
setReserveIncrement(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfReserveIncrement] = value;
return *this;
}
/**
* Set sfBaseFeeDrops (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
FeeSettingsBuilder&
setBaseFeeDrops(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfBaseFeeDrops] = value;
return *this;
}
/**
* Set sfReserveBaseDrops (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
FeeSettingsBuilder&
setReserveBaseDrops(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfReserveBaseDrops] = value;
return *this;
}
/**
* Set sfReserveIncrementDrops (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
FeeSettingsBuilder&
setReserveIncrementDrops(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfReserveIncrementDrops] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
FeeSettingsBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
FeeSettingsBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed FeeSettings wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
FeeSettings
build(uint256 const& index)
{
return FeeSettings{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,167 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class LedgerHashesBuilder;
/**
* Ledger Entry: LedgerHashes
* Type: ltLEDGER_HASHES (0x0068)
* RPC Name: hashes
*
* Immutable wrapper around SLE providing type-safe field access.
* Use LedgerHashesBuilder to construct new ledger entries.
*/
class LedgerHashes : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltLEDGER_HASHES;
/**
* Construct a LedgerHashes ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit LedgerHashes(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for LedgerHashes");
}
}
// Ledger entry-specific field getters
/**
* Get sfFirstLedgerSequence (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getFirstLedgerSequence() const
{
if (hasFirstLedgerSequence())
return this->sle_.at(sfFirstLedgerSequence);
return std::nullopt;
}
[[nodiscard]]
bool
hasFirstLedgerSequence() const
{
return this->sle_.isFieldPresent(sfFirstLedgerSequence);
}
/**
* Get sfLastLedgerSequence (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getLastLedgerSequence() const
{
if (hasLastLedgerSequence())
return this->sle_.at(sfLastLedgerSequence);
return std::nullopt;
}
[[nodiscard]]
bool
hasLastLedgerSequence() const
{
return this->sle_.isFieldPresent(sfLastLedgerSequence);
}
/**
* Get sfHashes (soeREQUIRED)
*/
[[nodiscard]]
SF_VECTOR256::type::value_type
getHashes() const
{
return this->sle_.at(sfHashes);
}
};
/**
* Builder for LedgerHashes ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class LedgerHashesBuilder : public LedgerEntryBuilderBase<LedgerHashesBuilder>
{
public:
LedgerHashesBuilder(std::decay_t<typename SF_VECTOR256::type::value_type> const& hashes)
: LedgerEntryBuilderBase<LedgerHashesBuilder>(ltLEDGER_HASHES)
{
setHashes(hashes);
}
LedgerHashesBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltLEDGER_HASHES)
{
throw std::runtime_error("Invalid ledger entry type for LedgerHashes");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfFirstLedgerSequence (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LedgerHashesBuilder&
setFirstLedgerSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfFirstLedgerSequence] = value;
return *this;
}
/**
* Set sfLastLedgerSequence (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LedgerHashesBuilder&
setLastLedgerSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfLastLedgerSequence] = value;
return *this;
}
/**
* Set sfHashes (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LedgerHashesBuilder&
setHashes(std::decay_t<typename SF_VECTOR256::type::value_type> const& value)
{
object_[sfHashes] = value;
return *this;
}
/**
* Build and return the completed LedgerHashes wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
LedgerHashes
build(uint256 const& index)
{
return LedgerHashes{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,815 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class LoanBuilder;
/**
* Ledger Entry: Loan
* Type: ltLOAN (0x0089)
* RPC Name: loan
*
* Immutable wrapper around SLE providing type-safe field access.
* Use LoanBuilder to construct new ledger entries.
*/
class Loan : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltLOAN;
/**
* Construct a Loan ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Loan(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Loan");
}
}
// Ledger entry-specific field getters
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfLoanBrokerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getLoanBrokerNode() const
{
return this->sle_.at(sfLoanBrokerNode);
}
/**
* Get sfLoanBrokerID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getLoanBrokerID() const
{
return this->sle_.at(sfLoanBrokerID);
}
/**
* Get sfLoanSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getLoanSequence() const
{
return this->sle_.at(sfLoanSequence);
}
/**
* Get sfBorrower (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getBorrower() const
{
return this->sle_.at(sfBorrower);
}
/**
* Get sfLoanOriginationFee (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getLoanOriginationFee() const
{
if (hasLoanOriginationFee())
return this->sle_.at(sfLoanOriginationFee);
return std::nullopt;
}
[[nodiscard]]
bool
hasLoanOriginationFee() const
{
return this->sle_.isFieldPresent(sfLoanOriginationFee);
}
/**
* Get sfLoanServiceFee (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getLoanServiceFee() const
{
if (hasLoanServiceFee())
return this->sle_.at(sfLoanServiceFee);
return std::nullopt;
}
[[nodiscard]]
bool
hasLoanServiceFee() const
{
return this->sle_.isFieldPresent(sfLoanServiceFee);
}
/**
* Get sfLatePaymentFee (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getLatePaymentFee() const
{
if (hasLatePaymentFee())
return this->sle_.at(sfLatePaymentFee);
return std::nullopt;
}
[[nodiscard]]
bool
hasLatePaymentFee() const
{
return this->sle_.isFieldPresent(sfLatePaymentFee);
}
/**
* Get sfClosePaymentFee (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getClosePaymentFee() const
{
if (hasClosePaymentFee())
return this->sle_.at(sfClosePaymentFee);
return std::nullopt;
}
[[nodiscard]]
bool
hasClosePaymentFee() const
{
return this->sle_.isFieldPresent(sfClosePaymentFee);
}
/**
* Get sfOverpaymentFee (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getOverpaymentFee() const
{
if (hasOverpaymentFee())
return this->sle_.at(sfOverpaymentFee);
return std::nullopt;
}
[[nodiscard]]
bool
hasOverpaymentFee() const
{
return this->sle_.isFieldPresent(sfOverpaymentFee);
}
/**
* Get sfInterestRate (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getInterestRate() const
{
if (hasInterestRate())
return this->sle_.at(sfInterestRate);
return std::nullopt;
}
[[nodiscard]]
bool
hasInterestRate() const
{
return this->sle_.isFieldPresent(sfInterestRate);
}
/**
* Get sfLateInterestRate (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getLateInterestRate() const
{
if (hasLateInterestRate())
return this->sle_.at(sfLateInterestRate);
return std::nullopt;
}
[[nodiscard]]
bool
hasLateInterestRate() const
{
return this->sle_.isFieldPresent(sfLateInterestRate);
}
/**
* Get sfCloseInterestRate (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getCloseInterestRate() const
{
if (hasCloseInterestRate())
return this->sle_.at(sfCloseInterestRate);
return std::nullopt;
}
[[nodiscard]]
bool
hasCloseInterestRate() const
{
return this->sle_.isFieldPresent(sfCloseInterestRate);
}
/**
* Get sfOverpaymentInterestRate (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getOverpaymentInterestRate() const
{
if (hasOverpaymentInterestRate())
return this->sle_.at(sfOverpaymentInterestRate);
return std::nullopt;
}
[[nodiscard]]
bool
hasOverpaymentInterestRate() const
{
return this->sle_.isFieldPresent(sfOverpaymentInterestRate);
}
/**
* Get sfStartDate (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getStartDate() const
{
return this->sle_.at(sfStartDate);
}
/**
* Get sfPaymentInterval (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPaymentInterval() const
{
return this->sle_.at(sfPaymentInterval);
}
/**
* Get sfGracePeriod (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getGracePeriod() const
{
if (hasGracePeriod())
return this->sle_.at(sfGracePeriod);
return std::nullopt;
}
[[nodiscard]]
bool
hasGracePeriod() const
{
return this->sle_.isFieldPresent(sfGracePeriod);
}
/**
* Get sfPreviousPaymentDueDate (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getPreviousPaymentDueDate() const
{
if (hasPreviousPaymentDueDate())
return this->sle_.at(sfPreviousPaymentDueDate);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousPaymentDueDate() const
{
return this->sle_.isFieldPresent(sfPreviousPaymentDueDate);
}
/**
* Get sfNextPaymentDueDate (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getNextPaymentDueDate() const
{
if (hasNextPaymentDueDate())
return this->sle_.at(sfNextPaymentDueDate);
return std::nullopt;
}
[[nodiscard]]
bool
hasNextPaymentDueDate() const
{
return this->sle_.isFieldPresent(sfNextPaymentDueDate);
}
/**
* Get sfPaymentRemaining (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getPaymentRemaining() const
{
if (hasPaymentRemaining())
return this->sle_.at(sfPaymentRemaining);
return std::nullopt;
}
[[nodiscard]]
bool
hasPaymentRemaining() const
{
return this->sle_.isFieldPresent(sfPaymentRemaining);
}
/**
* Get sfPeriodicPayment (soeREQUIRED)
*/
[[nodiscard]]
SF_NUMBER::type::value_type
getPeriodicPayment() const
{
return this->sle_.at(sfPeriodicPayment);
}
/**
* Get sfPrincipalOutstanding (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getPrincipalOutstanding() const
{
if (hasPrincipalOutstanding())
return this->sle_.at(sfPrincipalOutstanding);
return std::nullopt;
}
[[nodiscard]]
bool
hasPrincipalOutstanding() const
{
return this->sle_.isFieldPresent(sfPrincipalOutstanding);
}
/**
* Get sfTotalValueOutstanding (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getTotalValueOutstanding() const
{
if (hasTotalValueOutstanding())
return this->sle_.at(sfTotalValueOutstanding);
return std::nullopt;
}
[[nodiscard]]
bool
hasTotalValueOutstanding() const
{
return this->sle_.isFieldPresent(sfTotalValueOutstanding);
}
/**
* Get sfManagementFeeOutstanding (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getManagementFeeOutstanding() const
{
if (hasManagementFeeOutstanding())
return this->sle_.at(sfManagementFeeOutstanding);
return std::nullopt;
}
[[nodiscard]]
bool
hasManagementFeeOutstanding() const
{
return this->sle_.isFieldPresent(sfManagementFeeOutstanding);
}
/**
* Get sfLoanScale (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_INT32::type::value_type>
getLoanScale() const
{
if (hasLoanScale())
return this->sle_.at(sfLoanScale);
return std::nullopt;
}
[[nodiscard]]
bool
hasLoanScale() const
{
return this->sle_.isFieldPresent(sfLoanScale);
}
};
/**
* Builder for Loan ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class LoanBuilder : public LedgerEntryBuilderBase<LoanBuilder>
{
public:
LoanBuilder(std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT64::type::value_type> const& loanBrokerNode,std::decay_t<typename SF_UINT256::type::value_type> const& loanBrokerID,std::decay_t<typename SF_UINT32::type::value_type> const& loanSequence,std::decay_t<typename SF_ACCOUNT::type::value_type> const& borrower,std::decay_t<typename SF_UINT32::type::value_type> const& startDate,std::decay_t<typename SF_UINT32::type::value_type> const& paymentInterval,std::decay_t<typename SF_NUMBER::type::value_type> const& periodicPayment)
: LedgerEntryBuilderBase<LoanBuilder>(ltLOAN)
{
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
setOwnerNode(ownerNode);
setLoanBrokerNode(loanBrokerNode);
setLoanBrokerID(loanBrokerID);
setLoanSequence(loanSequence);
setBorrower(borrower);
setStartDate(startDate);
setPaymentInterval(paymentInterval);
setPeriodicPayment(periodicPayment);
}
LoanBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltLOAN)
{
throw std::runtime_error("Invalid ledger entry type for Loan");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfLoanBrokerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setLoanBrokerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfLoanBrokerNode] = value;
return *this;
}
/**
* Set sfLoanBrokerID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setLoanBrokerID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfLoanBrokerID] = value;
return *this;
}
/**
* Set sfLoanSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setLoanSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfLoanSequence] = value;
return *this;
}
/**
* Set sfBorrower (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setBorrower(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfBorrower] = value;
return *this;
}
/**
* Set sfLoanOriginationFee (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setLoanOriginationFee(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfLoanOriginationFee] = value;
return *this;
}
/**
* Set sfLoanServiceFee (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setLoanServiceFee(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfLoanServiceFee] = value;
return *this;
}
/**
* Set sfLatePaymentFee (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setLatePaymentFee(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfLatePaymentFee] = value;
return *this;
}
/**
* Set sfClosePaymentFee (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setClosePaymentFee(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfClosePaymentFee] = value;
return *this;
}
/**
* Set sfOverpaymentFee (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setOverpaymentFee(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfOverpaymentFee] = value;
return *this;
}
/**
* Set sfInterestRate (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setInterestRate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfInterestRate] = value;
return *this;
}
/**
* Set sfLateInterestRate (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setLateInterestRate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfLateInterestRate] = value;
return *this;
}
/**
* Set sfCloseInterestRate (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setCloseInterestRate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfCloseInterestRate] = value;
return *this;
}
/**
* Set sfOverpaymentInterestRate (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setOverpaymentInterestRate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfOverpaymentInterestRate] = value;
return *this;
}
/**
* Set sfStartDate (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setStartDate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfStartDate] = value;
return *this;
}
/**
* Set sfPaymentInterval (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setPaymentInterval(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPaymentInterval] = value;
return *this;
}
/**
* Set sfGracePeriod (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setGracePeriod(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfGracePeriod] = value;
return *this;
}
/**
* Set sfPreviousPaymentDueDate (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setPreviousPaymentDueDate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousPaymentDueDate] = value;
return *this;
}
/**
* Set sfNextPaymentDueDate (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setNextPaymentDueDate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfNextPaymentDueDate] = value;
return *this;
}
/**
* Set sfPaymentRemaining (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setPaymentRemaining(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPaymentRemaining] = value;
return *this;
}
/**
* Set sfPeriodicPayment (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setPeriodicPayment(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfPeriodicPayment] = value;
return *this;
}
/**
* Set sfPrincipalOutstanding (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setPrincipalOutstanding(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfPrincipalOutstanding] = value;
return *this;
}
/**
* Set sfTotalValueOutstanding (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setTotalValueOutstanding(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfTotalValueOutstanding] = value;
return *this;
}
/**
* Set sfManagementFeeOutstanding (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setManagementFeeOutstanding(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfManagementFeeOutstanding] = value;
return *this;
}
/**
* Set sfLoanScale (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBuilder&
setLoanScale(std::decay_t<typename SF_INT32::type::value_type> const& value)
{
object_[sfLoanScale] = value;
return *this;
}
/**
* Build and return the completed Loan wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Loan
build(uint256 const& index)
{
return Loan{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,523 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class LoanBrokerBuilder;
/**
* Ledger Entry: LoanBroker
* Type: ltLOAN_BROKER (0x0088)
* RPC Name: loan_broker
*
* Immutable wrapper around SLE providing type-safe field access.
* Use LoanBrokerBuilder to construct new ledger entries.
*/
class LoanBroker : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltLOAN_BROKER;
/**
* Construct a LoanBroker ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit LoanBroker(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for LoanBroker");
}
}
// Ledger entry-specific field getters
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSequence() const
{
return this->sle_.at(sfSequence);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfVaultNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getVaultNode() const
{
return this->sle_.at(sfVaultNode);
}
/**
* Get sfVaultID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getVaultID() const
{
return this->sle_.at(sfVaultID);
}
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfOwner (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getOwner() const
{
return this->sle_.at(sfOwner);
}
/**
* Get sfLoanSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getLoanSequence() const
{
return this->sle_.at(sfLoanSequence);
}
/**
* Get sfData (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getData() const
{
if (hasData())
return this->sle_.at(sfData);
return std::nullopt;
}
[[nodiscard]]
bool
hasData() const
{
return this->sle_.isFieldPresent(sfData);
}
/**
* Get sfManagementFeeRate (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT16::type::value_type>
getManagementFeeRate() const
{
if (hasManagementFeeRate())
return this->sle_.at(sfManagementFeeRate);
return std::nullopt;
}
[[nodiscard]]
bool
hasManagementFeeRate() const
{
return this->sle_.isFieldPresent(sfManagementFeeRate);
}
/**
* Get sfOwnerCount (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getOwnerCount() const
{
if (hasOwnerCount())
return this->sle_.at(sfOwnerCount);
return std::nullopt;
}
[[nodiscard]]
bool
hasOwnerCount() const
{
return this->sle_.isFieldPresent(sfOwnerCount);
}
/**
* Get sfDebtTotal (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getDebtTotal() const
{
if (hasDebtTotal())
return this->sle_.at(sfDebtTotal);
return std::nullopt;
}
[[nodiscard]]
bool
hasDebtTotal() const
{
return this->sle_.isFieldPresent(sfDebtTotal);
}
/**
* Get sfDebtMaximum (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getDebtMaximum() const
{
if (hasDebtMaximum())
return this->sle_.at(sfDebtMaximum);
return std::nullopt;
}
[[nodiscard]]
bool
hasDebtMaximum() const
{
return this->sle_.isFieldPresent(sfDebtMaximum);
}
/**
* Get sfCoverAvailable (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getCoverAvailable() const
{
if (hasCoverAvailable())
return this->sle_.at(sfCoverAvailable);
return std::nullopt;
}
[[nodiscard]]
bool
hasCoverAvailable() const
{
return this->sle_.isFieldPresent(sfCoverAvailable);
}
/**
* Get sfCoverRateMinimum (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getCoverRateMinimum() const
{
if (hasCoverRateMinimum())
return this->sle_.at(sfCoverRateMinimum);
return std::nullopt;
}
[[nodiscard]]
bool
hasCoverRateMinimum() const
{
return this->sle_.isFieldPresent(sfCoverRateMinimum);
}
/**
* Get sfCoverRateLiquidation (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getCoverRateLiquidation() const
{
if (hasCoverRateLiquidation())
return this->sle_.at(sfCoverRateLiquidation);
return std::nullopt;
}
[[nodiscard]]
bool
hasCoverRateLiquidation() const
{
return this->sle_.isFieldPresent(sfCoverRateLiquidation);
}
};
/**
* Builder for LoanBroker ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class LoanBrokerBuilder : public LedgerEntryBuilderBase<LoanBrokerBuilder>
{
public:
LoanBrokerBuilder(std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq,std::decay_t<typename SF_UINT32::type::value_type> const& sequence,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT64::type::value_type> const& vaultNode,std::decay_t<typename SF_UINT256::type::value_type> const& vaultID,std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_ACCOUNT::type::value_type> const& owner,std::decay_t<typename SF_UINT32::type::value_type> const& loanSequence)
: LedgerEntryBuilderBase<LoanBrokerBuilder>(ltLOAN_BROKER)
{
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
setSequence(sequence);
setOwnerNode(ownerNode);
setVaultNode(vaultNode);
setVaultID(vaultID);
setAccount(account);
setOwner(owner);
setLoanSequence(loanSequence);
}
LoanBrokerBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltLOAN_BROKER)
{
throw std::runtime_error("Invalid ledger entry type for LoanBroker");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSequence] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfVaultNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setVaultNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfVaultNode] = value;
return *this;
}
/**
* Set sfVaultID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setVaultID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfVaultID] = value;
return *this;
}
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfOwner (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Set sfLoanSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setLoanSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfLoanSequence] = value;
return *this;
}
/**
* Set sfData (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setData(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfData] = value;
return *this;
}
/**
* Set sfManagementFeeRate (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setManagementFeeRate(std::decay_t<typename SF_UINT16::type::value_type> const& value)
{
object_[sfManagementFeeRate] = value;
return *this;
}
/**
* Set sfOwnerCount (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfOwnerCount] = value;
return *this;
}
/**
* Set sfDebtTotal (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setDebtTotal(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfDebtTotal] = value;
return *this;
}
/**
* Set sfDebtMaximum (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setDebtMaximum(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfDebtMaximum] = value;
return *this;
}
/**
* Set sfCoverAvailable (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setCoverAvailable(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfCoverAvailable] = value;
return *this;
}
/**
* Set sfCoverRateMinimum (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setCoverRateMinimum(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfCoverRateMinimum] = value;
return *this;
}
/**
* Set sfCoverRateLiquidation (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
LoanBrokerBuilder&
setCoverRateLiquidation(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfCoverRateLiquidation] = value;
return *this;
}
/**
* Build and return the completed LoanBroker wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
LoanBroker
build(uint256 const& index)
{
return LoanBroker{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,255 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class MPTokenBuilder;
/**
* Ledger Entry: MPToken
* Type: ltMPTOKEN (0x007f)
* RPC Name: mptoken
*
* Immutable wrapper around SLE providing type-safe field access.
* Use MPTokenBuilder to construct new ledger entries.
*/
class MPToken : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltMPTOKEN;
/**
* Construct a MPToken ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit MPToken(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for MPToken");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfMPTokenIssuanceID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT192::type::value_type
getMPTokenIssuanceID() const
{
return this->sle_.at(sfMPTokenIssuanceID);
}
/**
* Get sfMPTAmount (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getMPTAmount() const
{
if (hasMPTAmount())
return this->sle_.at(sfMPTAmount);
return std::nullopt;
}
[[nodiscard]]
bool
hasMPTAmount() const
{
return this->sle_.isFieldPresent(sfMPTAmount);
}
/**
* Get sfLockedAmount (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getLockedAmount() const
{
if (hasLockedAmount())
return this->sle_.at(sfLockedAmount);
return std::nullopt;
}
[[nodiscard]]
bool
hasLockedAmount() const
{
return this->sle_.isFieldPresent(sfLockedAmount);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for MPToken ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class MPTokenBuilder : public LedgerEntryBuilderBase<MPTokenBuilder>
{
public:
MPTokenBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_UINT192::type::value_type> const& mPTokenIssuanceID,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<MPTokenBuilder>(ltMPTOKEN)
{
setAccount(account);
setMPTokenIssuanceID(mPTokenIssuanceID);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
MPTokenBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltMPTOKEN)
{
throw std::runtime_error("Invalid ledger entry type for MPToken");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfMPTokenIssuanceID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenBuilder&
setMPTokenIssuanceID(std::decay_t<typename SF_UINT192::type::value_type> const& value)
{
object_[sfMPTokenIssuanceID] = value;
return *this;
}
/**
* Set sfMPTAmount (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
MPTokenBuilder&
setMPTAmount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfMPTAmount] = value;
return *this;
}
/**
* Set sfLockedAmount (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
MPTokenBuilder&
setLockedAmount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfLockedAmount] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed MPToken wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
MPToken
build(uint256 const& index)
{
return MPToken{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,427 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class MPTokenIssuanceBuilder;
/**
* Ledger Entry: MPTokenIssuance
* Type: ltMPTOKEN_ISSUANCE (0x007e)
* RPC Name: mpt_issuance
*
* Immutable wrapper around SLE providing type-safe field access.
* Use MPTokenIssuanceBuilder to construct new ledger entries.
*/
class MPTokenIssuance : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltMPTOKEN_ISSUANCE;
/**
* Construct a MPTokenIssuance ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit MPTokenIssuance(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for MPTokenIssuance");
}
}
// Ledger entry-specific field getters
/**
* Get sfIssuer (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getIssuer() const
{
return this->sle_.at(sfIssuer);
}
/**
* Get sfSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSequence() const
{
return this->sle_.at(sfSequence);
}
/**
* Get sfTransferFee (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT16::type::value_type>
getTransferFee() const
{
if (hasTransferFee())
return this->sle_.at(sfTransferFee);
return std::nullopt;
}
[[nodiscard]]
bool
hasTransferFee() const
{
return this->sle_.isFieldPresent(sfTransferFee);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfAssetScale (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT8::type::value_type>
getAssetScale() const
{
if (hasAssetScale())
return this->sle_.at(sfAssetScale);
return std::nullopt;
}
[[nodiscard]]
bool
hasAssetScale() const
{
return this->sle_.isFieldPresent(sfAssetScale);
}
/**
* Get sfMaximumAmount (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getMaximumAmount() const
{
if (hasMaximumAmount())
return this->sle_.at(sfMaximumAmount);
return std::nullopt;
}
[[nodiscard]]
bool
hasMaximumAmount() const
{
return this->sle_.isFieldPresent(sfMaximumAmount);
}
/**
* Get sfOutstandingAmount (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOutstandingAmount() const
{
return this->sle_.at(sfOutstandingAmount);
}
/**
* Get sfLockedAmount (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getLockedAmount() const
{
if (hasLockedAmount())
return this->sle_.at(sfLockedAmount);
return std::nullopt;
}
[[nodiscard]]
bool
hasLockedAmount() const
{
return this->sle_.isFieldPresent(sfLockedAmount);
}
/**
* Get sfMPTokenMetadata (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getMPTokenMetadata() const
{
if (hasMPTokenMetadata())
return this->sle_.at(sfMPTokenMetadata);
return std::nullopt;
}
[[nodiscard]]
bool
hasMPTokenMetadata() const
{
return this->sle_.isFieldPresent(sfMPTokenMetadata);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfDomainID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getDomainID() const
{
if (hasDomainID())
return this->sle_.at(sfDomainID);
return std::nullopt;
}
[[nodiscard]]
bool
hasDomainID() const
{
return this->sle_.isFieldPresent(sfDomainID);
}
/**
* Get sfMutableFlags (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getMutableFlags() const
{
if (hasMutableFlags())
return this->sle_.at(sfMutableFlags);
return std::nullopt;
}
[[nodiscard]]
bool
hasMutableFlags() const
{
return this->sle_.isFieldPresent(sfMutableFlags);
}
};
/**
* Builder for MPTokenIssuance ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class MPTokenIssuanceBuilder : public LedgerEntryBuilderBase<MPTokenIssuanceBuilder>
{
public:
MPTokenIssuanceBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& issuer,std::decay_t<typename SF_UINT32::type::value_type> const& sequence,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT64::type::value_type> const& outstandingAmount,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<MPTokenIssuanceBuilder>(ltMPTOKEN_ISSUANCE)
{
setIssuer(issuer);
setSequence(sequence);
setOwnerNode(ownerNode);
setOutstandingAmount(outstandingAmount);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
MPTokenIssuanceBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltMPTOKEN_ISSUANCE)
{
throw std::runtime_error("Invalid ledger entry type for MPTokenIssuance");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfIssuer (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setIssuer(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfIssuer] = value;
return *this;
}
/**
* Set sfSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSequence] = value;
return *this;
}
/**
* Set sfTransferFee (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setTransferFee(std::decay_t<typename SF_UINT16::type::value_type> const& value)
{
object_[sfTransferFee] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfAssetScale (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setAssetScale(std::decay_t<typename SF_UINT8::type::value_type> const& value)
{
object_[sfAssetScale] = value;
return *this;
}
/**
* Set sfMaximumAmount (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setMaximumAmount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfMaximumAmount] = value;
return *this;
}
/**
* Set sfOutstandingAmount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setOutstandingAmount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOutstandingAmount] = value;
return *this;
}
/**
* Set sfLockedAmount (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setLockedAmount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfLockedAmount] = value;
return *this;
}
/**
* Set sfMPTokenMetadata (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setMPTokenMetadata(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfMPTokenMetadata] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfDomainID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setDomainID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfDomainID] = value;
return *this;
}
/**
* Set sfMutableFlags (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceBuilder&
setMutableFlags(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfMutableFlags] = value;
return *this;
}
/**
* Build and return the completed MPTokenIssuance wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
MPTokenIssuance
build(uint256 const& index)
{
return MPTokenIssuance{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,299 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class NFTokenOfferBuilder;
/**
* Ledger Entry: NFTokenOffer
* Type: ltNFTOKEN_OFFER (0x0037)
* RPC Name: nft_offer
*
* Immutable wrapper around SLE providing type-safe field access.
* Use NFTokenOfferBuilder to construct new ledger entries.
*/
class NFTokenOffer : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltNFTOKEN_OFFER;
/**
* Construct a NFTokenOffer ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit NFTokenOffer(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for NFTokenOffer");
}
}
// Ledger entry-specific field getters
/**
* Get sfOwner (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getOwner() const
{
return this->sle_.at(sfOwner);
}
/**
* Get sfNFTokenID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getNFTokenID() const
{
return this->sle_.at(sfNFTokenID);
}
/**
* Get sfAmount (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getAmount() const
{
return this->sle_.at(sfAmount);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfNFTokenOfferNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getNFTokenOfferNode() const
{
return this->sle_.at(sfNFTokenOfferNode);
}
/**
* Get sfDestination (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getDestination() const
{
if (hasDestination())
return this->sle_.at(sfDestination);
return std::nullopt;
}
[[nodiscard]]
bool
hasDestination() const
{
return this->sle_.isFieldPresent(sfDestination);
}
/**
* Get sfExpiration (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getExpiration() const
{
if (hasExpiration())
return this->sle_.at(sfExpiration);
return std::nullopt;
}
[[nodiscard]]
bool
hasExpiration() const
{
return this->sle_.isFieldPresent(sfExpiration);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for NFTokenOffer ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class NFTokenOfferBuilder : public LedgerEntryBuilderBase<NFTokenOfferBuilder>
{
public:
NFTokenOfferBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& owner,std::decay_t<typename SF_UINT256::type::value_type> const& nFTokenID,std::decay_t<typename SF_AMOUNT::type::value_type> const& amount,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT64::type::value_type> const& nFTokenOfferNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<NFTokenOfferBuilder>(ltNFTOKEN_OFFER)
{
setOwner(owner);
setNFTokenID(nFTokenID);
setAmount(amount);
setOwnerNode(ownerNode);
setNFTokenOfferNode(nFTokenOfferNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
NFTokenOfferBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltNFTOKEN_OFFER)
{
throw std::runtime_error("Invalid ledger entry type for NFTokenOffer");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfOwner (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenOfferBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Set sfNFTokenID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenOfferBuilder&
setNFTokenID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfNFTokenID] = value;
return *this;
}
/**
* Set sfAmount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenOfferBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenOfferBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfNFTokenOfferNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenOfferBuilder&
setNFTokenOfferNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfNFTokenOfferNode] = value;
return *this;
}
/**
* Set sfDestination (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
NFTokenOfferBuilder&
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfDestination] = value;
return *this;
}
/**
* Set sfExpiration (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
NFTokenOfferBuilder&
setExpiration(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfExpiration] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenOfferBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenOfferBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed NFTokenOffer wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
NFTokenOffer
build(uint256 const& index)
{
return NFTokenOffer{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,212 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class NFTokenPageBuilder;
/**
* Ledger Entry: NFTokenPage
* Type: ltNFTOKEN_PAGE (0x0050)
* RPC Name: nft_page
*
* Immutable wrapper around SLE providing type-safe field access.
* Use NFTokenPageBuilder to construct new ledger entries.
*/
class NFTokenPage : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltNFTOKEN_PAGE;
/**
* Construct a NFTokenPage ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit NFTokenPage(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for NFTokenPage");
}
}
// Ledger entry-specific field getters
/**
* Get sfPreviousPageMin (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getPreviousPageMin() const
{
if (hasPreviousPageMin())
return this->sle_.at(sfPreviousPageMin);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousPageMin() const
{
return this->sle_.isFieldPresent(sfPreviousPageMin);
}
/**
* Get sfNextPageMin (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getNextPageMin() const
{
if (hasNextPageMin())
return this->sle_.at(sfNextPageMin);
return std::nullopt;
}
[[nodiscard]]
bool
hasNextPageMin() const
{
return this->sle_.isFieldPresent(sfNextPageMin);
}
/**
* Get sfNFTokens (soeREQUIRED)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
STArray const&
getNFTokens() const
{
return this->sle_.getFieldArray(sfNFTokens);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for NFTokenPage ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class NFTokenPageBuilder : public LedgerEntryBuilderBase<NFTokenPageBuilder>
{
public:
NFTokenPageBuilder(STArray const& nFTokens,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<NFTokenPageBuilder>(ltNFTOKEN_PAGE)
{
setNFTokens(nFTokens);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
NFTokenPageBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltNFTOKEN_PAGE)
{
throw std::runtime_error("Invalid ledger entry type for NFTokenPage");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfPreviousPageMin (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
NFTokenPageBuilder&
setPreviousPageMin(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousPageMin] = value;
return *this;
}
/**
* Set sfNextPageMin (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
NFTokenPageBuilder&
setNextPageMin(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfNextPageMin] = value;
return *this;
}
/**
* Set sfNFTokens (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenPageBuilder&
setNFTokens(STArray const& value)
{
object_.setFieldArray(sfNFTokens, value);
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenPageBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
NFTokenPageBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed NFTokenPage wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
NFTokenPage
build(uint256 const& index)
{
return NFTokenPage{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,236 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class NegativeUNLBuilder;
/**
* Ledger Entry: NegativeUNL
* Type: ltNEGATIVE_UNL (0x004e)
* RPC Name: nunl
*
* Immutable wrapper around SLE providing type-safe field access.
* Use NegativeUNLBuilder to construct new ledger entries.
*/
class NegativeUNL : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltNEGATIVE_UNL;
/**
* Construct a NegativeUNL ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit NegativeUNL(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for NegativeUNL");
}
}
// Ledger entry-specific field getters
/**
* Get sfDisabledValidators (soeOPTIONAL)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getDisabledValidators() const
{
if (this->sle_.isFieldPresent(sfDisabledValidators))
return this->sle_.getFieldArray(sfDisabledValidators);
return std::nullopt;
}
[[nodiscard]]
bool
hasDisabledValidators() const
{
return this->sle_.isFieldPresent(sfDisabledValidators);
}
/**
* Get sfValidatorToDisable (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getValidatorToDisable() const
{
if (hasValidatorToDisable())
return this->sle_.at(sfValidatorToDisable);
return std::nullopt;
}
[[nodiscard]]
bool
hasValidatorToDisable() const
{
return this->sle_.isFieldPresent(sfValidatorToDisable);
}
/**
* Get sfValidatorToReEnable (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getValidatorToReEnable() const
{
if (hasValidatorToReEnable())
return this->sle_.at(sfValidatorToReEnable);
return std::nullopt;
}
[[nodiscard]]
bool
hasValidatorToReEnable() const
{
return this->sle_.isFieldPresent(sfValidatorToReEnable);
}
/**
* Get sfPreviousTxnID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getPreviousTxnID() const
{
if (hasPreviousTxnID())
return this->sle_.at(sfPreviousTxnID);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnID() const
{
return this->sle_.isFieldPresent(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getPreviousTxnLgrSeq() const
{
if (hasPreviousTxnLgrSeq())
return this->sle_.at(sfPreviousTxnLgrSeq);
return std::nullopt;
}
[[nodiscard]]
bool
hasPreviousTxnLgrSeq() const
{
return this->sle_.isFieldPresent(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for NegativeUNL ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class NegativeUNLBuilder : public LedgerEntryBuilderBase<NegativeUNLBuilder>
{
public:
NegativeUNLBuilder()
: LedgerEntryBuilderBase<NegativeUNLBuilder>(ltNEGATIVE_UNL)
{
}
NegativeUNLBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltNEGATIVE_UNL)
{
throw std::runtime_error("Invalid ledger entry type for NegativeUNL");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfDisabledValidators (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
NegativeUNLBuilder&
setDisabledValidators(STArray const& value)
{
object_.setFieldArray(sfDisabledValidators, value);
return *this;
}
/**
* Set sfValidatorToDisable (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
NegativeUNLBuilder&
setValidatorToDisable(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfValidatorToDisable] = value;
return *this;
}
/**
* Set sfValidatorToReEnable (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
NegativeUNLBuilder&
setValidatorToReEnable(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfValidatorToReEnable] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
NegativeUNLBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
NegativeUNLBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed NegativeUNL wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
NegativeUNL
build(uint256 const& index)
{
return NegativeUNL{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,374 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class OfferBuilder;
/**
* Ledger Entry: Offer
* Type: ltOFFER (0x006f)
* RPC Name: offer
*
* Immutable wrapper around SLE providing type-safe field access.
* Use OfferBuilder to construct new ledger entries.
*/
class Offer : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltOFFER;
/**
* Construct a Offer ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Offer(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Offer");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSequence() const
{
return this->sle_.at(sfSequence);
}
/**
* Get sfTakerPays (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getTakerPays() const
{
return this->sle_.at(sfTakerPays);
}
/**
* Get sfTakerGets (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getTakerGets() const
{
return this->sle_.at(sfTakerGets);
}
/**
* Get sfBookDirectory (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getBookDirectory() const
{
return this->sle_.at(sfBookDirectory);
}
/**
* Get sfBookNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getBookNode() const
{
return this->sle_.at(sfBookNode);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfExpiration (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getExpiration() const
{
if (hasExpiration())
return this->sle_.at(sfExpiration);
return std::nullopt;
}
[[nodiscard]]
bool
hasExpiration() const
{
return this->sle_.isFieldPresent(sfExpiration);
}
/**
* Get sfDomainID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getDomainID() const
{
if (hasDomainID())
return this->sle_.at(sfDomainID);
return std::nullopt;
}
[[nodiscard]]
bool
hasDomainID() const
{
return this->sle_.isFieldPresent(sfDomainID);
}
/**
* Get sfAdditionalBooks (soeOPTIONAL)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getAdditionalBooks() const
{
if (this->sle_.isFieldPresent(sfAdditionalBooks))
return this->sle_.getFieldArray(sfAdditionalBooks);
return std::nullopt;
}
[[nodiscard]]
bool
hasAdditionalBooks() const
{
return this->sle_.isFieldPresent(sfAdditionalBooks);
}
};
/**
* Builder for Offer ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class OfferBuilder : public LedgerEntryBuilderBase<OfferBuilder>
{
public:
OfferBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_UINT32::type::value_type> const& sequence,std::decay_t<typename SF_AMOUNT::type::value_type> const& takerPays,std::decay_t<typename SF_AMOUNT::type::value_type> const& takerGets,std::decay_t<typename SF_UINT256::type::value_type> const& bookDirectory,std::decay_t<typename SF_UINT64::type::value_type> const& bookNode,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<OfferBuilder>(ltOFFER)
{
setAccount(account);
setSequence(sequence);
setTakerPays(takerPays);
setTakerGets(takerGets);
setBookDirectory(bookDirectory);
setBookNode(bookNode);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
OfferBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltOFFER)
{
throw std::runtime_error("Invalid ledger entry type for Offer");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSequence] = value;
return *this;
}
/**
* Set sfTakerPays (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setTakerPays(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfTakerPays] = value;
return *this;
}
/**
* Set sfTakerGets (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setTakerGets(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfTakerGets] = value;
return *this;
}
/**
* Set sfBookDirectory (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setBookDirectory(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfBookDirectory] = value;
return *this;
}
/**
* Set sfBookNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setBookNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfBookNode] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfExpiration (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setExpiration(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfExpiration] = value;
return *this;
}
/**
* Set sfDomainID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setDomainID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfDomainID] = value;
return *this;
}
/**
* Set sfAdditionalBooks (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
OfferBuilder&
setAdditionalBooks(STArray const& value)
{
object_.setFieldArray(sfAdditionalBooks, value);
return *this;
}
/**
* Build and return the completed Offer wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Offer
build(uint256 const& index)
{
return Offer{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,322 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class OracleBuilder;
/**
* Ledger Entry: Oracle
* Type: ltORACLE (0x0080)
* RPC Name: oracle
*
* Immutable wrapper around SLE providing type-safe field access.
* Use OracleBuilder to construct new ledger entries.
*/
class Oracle : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltORACLE;
/**
* Construct a Oracle ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Oracle(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Oracle");
}
}
// Ledger entry-specific field getters
/**
* Get sfOwner (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getOwner() const
{
return this->sle_.at(sfOwner);
}
/**
* Get sfOracleDocumentID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getOracleDocumentID() const
{
if (hasOracleDocumentID())
return this->sle_.at(sfOracleDocumentID);
return std::nullopt;
}
[[nodiscard]]
bool
hasOracleDocumentID() const
{
return this->sle_.isFieldPresent(sfOracleDocumentID);
}
/**
* Get sfProvider (soeREQUIRED)
*/
[[nodiscard]]
SF_VL::type::value_type
getProvider() const
{
return this->sle_.at(sfProvider);
}
/**
* Get sfPriceDataSeries (soeREQUIRED)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
STArray const&
getPriceDataSeries() const
{
return this->sle_.getFieldArray(sfPriceDataSeries);
}
/**
* Get sfAssetClass (soeREQUIRED)
*/
[[nodiscard]]
SF_VL::type::value_type
getAssetClass() const
{
return this->sle_.at(sfAssetClass);
}
/**
* Get sfLastUpdateTime (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getLastUpdateTime() const
{
return this->sle_.at(sfLastUpdateTime);
}
/**
* Get sfURI (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getURI() const
{
if (hasURI())
return this->sle_.at(sfURI);
return std::nullopt;
}
[[nodiscard]]
bool
hasURI() const
{
return this->sle_.isFieldPresent(sfURI);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for Oracle ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class OracleBuilder : public LedgerEntryBuilderBase<OracleBuilder>
{
public:
OracleBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& owner,std::decay_t<typename SF_VL::type::value_type> const& provider,STArray const& priceDataSeries,std::decay_t<typename SF_VL::type::value_type> const& assetClass,std::decay_t<typename SF_UINT32::type::value_type> const& lastUpdateTime,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<OracleBuilder>(ltORACLE)
{
setOwner(owner);
setProvider(provider);
setPriceDataSeries(priceDataSeries);
setAssetClass(assetClass);
setLastUpdateTime(lastUpdateTime);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
OracleBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltORACLE)
{
throw std::runtime_error("Invalid ledger entry type for Oracle");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfOwner (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Set sfOracleDocumentID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setOracleDocumentID(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfOracleDocumentID] = value;
return *this;
}
/**
* Set sfProvider (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setProvider(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfProvider] = value;
return *this;
}
/**
* Set sfPriceDataSeries (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setPriceDataSeries(STArray const& value)
{
object_.setFieldArray(sfPriceDataSeries, value);
return *this;
}
/**
* Set sfAssetClass (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setAssetClass(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfAssetClass] = value;
return *this;
}
/**
* Set sfLastUpdateTime (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setLastUpdateTime(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfLastUpdateTime] = value;
return *this;
}
/**
* Set sfURI (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setURI(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfURI] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
OracleBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed Oracle wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Oracle
build(uint256 const& index)
{
return Oracle{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,463 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class PayChannelBuilder;
/**
* Ledger Entry: PayChannel
* Type: ltPAYCHAN (0x0078)
* RPC Name: payment_channel
*
* Immutable wrapper around SLE providing type-safe field access.
* Use PayChannelBuilder to construct new ledger entries.
*/
class PayChannel : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltPAYCHAN;
/**
* Construct a PayChannel ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit PayChannel(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for PayChannel");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfDestination (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getDestination() const
{
return this->sle_.at(sfDestination);
}
/**
* Get sfSequence (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getSequence() const
{
if (hasSequence())
return this->sle_.at(sfSequence);
return std::nullopt;
}
[[nodiscard]]
bool
hasSequence() const
{
return this->sle_.isFieldPresent(sfSequence);
}
/**
* Get sfAmount (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getAmount() const
{
return this->sle_.at(sfAmount);
}
/**
* Get sfBalance (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getBalance() const
{
return this->sle_.at(sfBalance);
}
/**
* Get sfPublicKey (soeREQUIRED)
*/
[[nodiscard]]
SF_VL::type::value_type
getPublicKey() const
{
return this->sle_.at(sfPublicKey);
}
/**
* Get sfSettleDelay (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSettleDelay() const
{
return this->sle_.at(sfSettleDelay);
}
/**
* Get sfExpiration (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getExpiration() const
{
if (hasExpiration())
return this->sle_.at(sfExpiration);
return std::nullopt;
}
[[nodiscard]]
bool
hasExpiration() const
{
return this->sle_.isFieldPresent(sfExpiration);
}
/**
* Get sfCancelAfter (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getCancelAfter() const
{
if (hasCancelAfter())
return this->sle_.at(sfCancelAfter);
return std::nullopt;
}
[[nodiscard]]
bool
hasCancelAfter() const
{
return this->sle_.isFieldPresent(sfCancelAfter);
}
/**
* Get sfSourceTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getSourceTag() const
{
if (hasSourceTag())
return this->sle_.at(sfSourceTag);
return std::nullopt;
}
[[nodiscard]]
bool
hasSourceTag() const
{
return this->sle_.isFieldPresent(sfSourceTag);
}
/**
* Get sfDestinationTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getDestinationTag() const
{
if (hasDestinationTag())
return this->sle_.at(sfDestinationTag);
return std::nullopt;
}
[[nodiscard]]
bool
hasDestinationTag() const
{
return this->sle_.isFieldPresent(sfDestinationTag);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfDestinationNode (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getDestinationNode() const
{
if (hasDestinationNode())
return this->sle_.at(sfDestinationNode);
return std::nullopt;
}
[[nodiscard]]
bool
hasDestinationNode() const
{
return this->sle_.isFieldPresent(sfDestinationNode);
}
};
/**
* Builder for PayChannel ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class PayChannelBuilder : public LedgerEntryBuilderBase<PayChannelBuilder>
{
public:
PayChannelBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_ACCOUNT::type::value_type> const& destination,std::decay_t<typename SF_AMOUNT::type::value_type> const& amount,std::decay_t<typename SF_AMOUNT::type::value_type> const& balance,std::decay_t<typename SF_VL::type::value_type> const& publicKey,std::decay_t<typename SF_UINT32::type::value_type> const& settleDelay,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<PayChannelBuilder>(ltPAYCHAN)
{
setAccount(account);
setDestination(destination);
setAmount(amount);
setBalance(balance);
setPublicKey(publicKey);
setSettleDelay(settleDelay);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
PayChannelBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltPAYCHAN)
{
throw std::runtime_error("Invalid ledger entry type for PayChannel");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfDestination (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfDestination] = value;
return *this;
}
/**
* Set sfSequence (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSequence] = value;
return *this;
}
/**
* Set sfAmount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfBalance (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setBalance(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfBalance] = value;
return *this;
}
/**
* Set sfPublicKey (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setPublicKey(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfPublicKey] = value;
return *this;
}
/**
* Set sfSettleDelay (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setSettleDelay(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSettleDelay] = value;
return *this;
}
/**
* Set sfExpiration (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setExpiration(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfExpiration] = value;
return *this;
}
/**
* Set sfCancelAfter (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setCancelAfter(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfCancelAfter] = value;
return *this;
}
/**
* Set sfSourceTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setSourceTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSourceTag] = value;
return *this;
}
/**
* Set sfDestinationTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setDestinationTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfDestinationTag] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfDestinationNode (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
PayChannelBuilder&
setDestinationNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfDestinationNode] = value;
return *this;
}
/**
* Build and return the completed PayChannel wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
PayChannel
build(uint256 const& index)
{
return PayChannel{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,218 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class PermissionedDomainBuilder;
/**
* Ledger Entry: PermissionedDomain
* Type: ltPERMISSIONED_DOMAIN (0x0082)
* RPC Name: permissioned_domain
*
* Immutable wrapper around SLE providing type-safe field access.
* Use PermissionedDomainBuilder to construct new ledger entries.
*/
class PermissionedDomain : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltPERMISSIONED_DOMAIN;
/**
* Construct a PermissionedDomain ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit PermissionedDomain(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for PermissionedDomain");
}
}
// Ledger entry-specific field getters
/**
* Get sfOwner (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getOwner() const
{
return this->sle_.at(sfOwner);
}
/**
* Get sfSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSequence() const
{
return this->sle_.at(sfSequence);
}
/**
* Get sfAcceptedCredentials (soeREQUIRED)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
STArray const&
getAcceptedCredentials() const
{
return this->sle_.getFieldArray(sfAcceptedCredentials);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for PermissionedDomain ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class PermissionedDomainBuilder : public LedgerEntryBuilderBase<PermissionedDomainBuilder>
{
public:
PermissionedDomainBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& owner,std::decay_t<typename SF_UINT32::type::value_type> const& sequence,STArray const& acceptedCredentials,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<PermissionedDomainBuilder>(ltPERMISSIONED_DOMAIN)
{
setOwner(owner);
setSequence(sequence);
setAcceptedCredentials(acceptedCredentials);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
PermissionedDomainBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltPERMISSIONED_DOMAIN)
{
throw std::runtime_error("Invalid ledger entry type for PermissionedDomain");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfOwner (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PermissionedDomainBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Set sfSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PermissionedDomainBuilder&
setSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSequence] = value;
return *this;
}
/**
* Set sfAcceptedCredentials (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PermissionedDomainBuilder&
setAcceptedCredentials(STArray const& value)
{
object_.setFieldArray(sfAcceptedCredentials, value);
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PermissionedDomainBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PermissionedDomainBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
PermissionedDomainBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed PermissionedDomain wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
PermissionedDomain
build(uint256 const& index)
{
return PermissionedDomain{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,375 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class RippleStateBuilder;
/**
* Ledger Entry: RippleState
* Type: ltRIPPLE_STATE (0x0072)
* RPC Name: state
*
* Immutable wrapper around SLE providing type-safe field access.
* Use RippleStateBuilder to construct new ledger entries.
*/
class RippleState : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltRIPPLE_STATE;
/**
* Construct a RippleState ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit RippleState(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for RippleState");
}
}
// Ledger entry-specific field getters
/**
* Get sfBalance (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getBalance() const
{
return this->sle_.at(sfBalance);
}
/**
* Get sfLowLimit (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getLowLimit() const
{
return this->sle_.at(sfLowLimit);
}
/**
* Get sfHighLimit (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getHighLimit() const
{
return this->sle_.at(sfHighLimit);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfLowNode (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getLowNode() const
{
if (hasLowNode())
return this->sle_.at(sfLowNode);
return std::nullopt;
}
[[nodiscard]]
bool
hasLowNode() const
{
return this->sle_.isFieldPresent(sfLowNode);
}
/**
* Get sfLowQualityIn (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getLowQualityIn() const
{
if (hasLowQualityIn())
return this->sle_.at(sfLowQualityIn);
return std::nullopt;
}
[[nodiscard]]
bool
hasLowQualityIn() const
{
return this->sle_.isFieldPresent(sfLowQualityIn);
}
/**
* Get sfLowQualityOut (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getLowQualityOut() const
{
if (hasLowQualityOut())
return this->sle_.at(sfLowQualityOut);
return std::nullopt;
}
[[nodiscard]]
bool
hasLowQualityOut() const
{
return this->sle_.isFieldPresent(sfLowQualityOut);
}
/**
* Get sfHighNode (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getHighNode() const
{
if (hasHighNode())
return this->sle_.at(sfHighNode);
return std::nullopt;
}
[[nodiscard]]
bool
hasHighNode() const
{
return this->sle_.isFieldPresent(sfHighNode);
}
/**
* Get sfHighQualityIn (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getHighQualityIn() const
{
if (hasHighQualityIn())
return this->sle_.at(sfHighQualityIn);
return std::nullopt;
}
[[nodiscard]]
bool
hasHighQualityIn() const
{
return this->sle_.isFieldPresent(sfHighQualityIn);
}
/**
* Get sfHighQualityOut (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getHighQualityOut() const
{
if (hasHighQualityOut())
return this->sle_.at(sfHighQualityOut);
return std::nullopt;
}
[[nodiscard]]
bool
hasHighQualityOut() const
{
return this->sle_.isFieldPresent(sfHighQualityOut);
}
};
/**
* Builder for RippleState ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class RippleStateBuilder : public LedgerEntryBuilderBase<RippleStateBuilder>
{
public:
RippleStateBuilder(std::decay_t<typename SF_AMOUNT::type::value_type> const& balance,std::decay_t<typename SF_AMOUNT::type::value_type> const& lowLimit,std::decay_t<typename SF_AMOUNT::type::value_type> const& highLimit,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<RippleStateBuilder>(ltRIPPLE_STATE)
{
setBalance(balance);
setLowLimit(lowLimit);
setHighLimit(highLimit);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
RippleStateBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltRIPPLE_STATE)
{
throw std::runtime_error("Invalid ledger entry type for RippleState");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfBalance (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setBalance(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfBalance] = value;
return *this;
}
/**
* Set sfLowLimit (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setLowLimit(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfLowLimit] = value;
return *this;
}
/**
* Set sfHighLimit (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setHighLimit(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfHighLimit] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfLowNode (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setLowNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfLowNode] = value;
return *this;
}
/**
* Set sfLowQualityIn (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setLowQualityIn(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfLowQualityIn] = value;
return *this;
}
/**
* Set sfLowQualityOut (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setLowQualityOut(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfLowQualityOut] = value;
return *this;
}
/**
* Set sfHighNode (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setHighNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfHighNode] = value;
return *this;
}
/**
* Set sfHighQualityIn (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setHighQualityIn(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfHighQualityIn] = value;
return *this;
}
/**
* Set sfHighQualityOut (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setHighQualityOut(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfHighQualityOut] = value;
return *this;
}
/**
* Build and return the completed RippleState wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
RippleState
build(uint256 const& index)
{
return RippleState{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,248 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class SignerListBuilder;
/**
* Ledger Entry: SignerList
* Type: ltSIGNER_LIST (0x0053)
* RPC Name: signer_list
*
* Immutable wrapper around SLE providing type-safe field access.
* Use SignerListBuilder to construct new ledger entries.
*/
class SignerList : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltSIGNER_LIST;
/**
* Construct a SignerList ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit SignerList(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for SignerList");
}
}
// Ledger entry-specific field getters
/**
* Get sfOwner (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getOwner() const
{
if (hasOwner())
return this->sle_.at(sfOwner);
return std::nullopt;
}
[[nodiscard]]
bool
hasOwner() const
{
return this->sle_.isFieldPresent(sfOwner);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfSignerQuorum (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSignerQuorum() const
{
return this->sle_.at(sfSignerQuorum);
}
/**
* Get sfSignerEntries (soeREQUIRED)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
STArray const&
getSignerEntries() const
{
return this->sle_.getFieldArray(sfSignerEntries);
}
/**
* Get sfSignerListID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSignerListID() const
{
return this->sle_.at(sfSignerListID);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for SignerList ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class SignerListBuilder : public LedgerEntryBuilderBase<SignerListBuilder>
{
public:
SignerListBuilder(std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT32::type::value_type> const& signerQuorum,STArray const& signerEntries,std::decay_t<typename SF_UINT32::type::value_type> const& signerListID,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<SignerListBuilder>(ltSIGNER_LIST)
{
setOwnerNode(ownerNode);
setSignerQuorum(signerQuorum);
setSignerEntries(signerEntries);
setSignerListID(signerListID);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
SignerListBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltSIGNER_LIST)
{
throw std::runtime_error("Invalid ledger entry type for SignerList");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfOwner (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
SignerListBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
SignerListBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfSignerQuorum (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
SignerListBuilder&
setSignerQuorum(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSignerQuorum] = value;
return *this;
}
/**
* Set sfSignerEntries (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
SignerListBuilder&
setSignerEntries(STArray const& value)
{
object_.setFieldArray(sfSignerEntries, value);
return *this;
}
/**
* Set sfSignerListID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
SignerListBuilder&
setSignerListID(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSignerListID] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
SignerListBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
SignerListBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed SignerList wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
SignerList
build(uint256 const& index)
{
return SignerList{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,195 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class TicketBuilder;
/**
* Ledger Entry: Ticket
* Type: ltTICKET (0x0054)
* RPC Name: ticket
*
* Immutable wrapper around SLE providing type-safe field access.
* Use TicketBuilder to construct new ledger entries.
*/
class Ticket : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltTICKET;
/**
* Construct a Ticket ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Ticket(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Ticket");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfTicketSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getTicketSequence() const
{
return this->sle_.at(sfTicketSequence);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for Ticket ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class TicketBuilder : public LedgerEntryBuilderBase<TicketBuilder>
{
public:
TicketBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT32::type::value_type> const& ticketSequence,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<TicketBuilder>(ltTICKET)
{
setAccount(account);
setOwnerNode(ownerNode);
setTicketSequence(ticketSequence);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
TicketBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltTICKET)
{
throw std::runtime_error("Invalid ledger entry type for Ticket");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
TicketBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
TicketBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfTicketSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
TicketBuilder&
setTicketSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfTicketSequence] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
TicketBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
TicketBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed Ticket wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Ticket
build(uint256 const& index)
{
return Ticket{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,463 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class VaultBuilder;
/**
* Ledger Entry: Vault
* Type: ltVAULT (0x0084)
* RPC Name: vault
*
* Immutable wrapper around SLE providing type-safe field access.
* Use VaultBuilder to construct new ledger entries.
*/
class Vault : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltVAULT;
/**
* Construct a Vault ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Vault(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Vault");
}
}
// Ledger entry-specific field getters
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
/**
* Get sfSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getSequence() const
{
return this->sle_.at(sfSequence);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfOwner (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getOwner() const
{
return this->sle_.at(sfOwner);
}
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfData (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getData() const
{
if (hasData())
return this->sle_.at(sfData);
return std::nullopt;
}
[[nodiscard]]
bool
hasData() const
{
return this->sle_.isFieldPresent(sfData);
}
/**
* Get sfAsset (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset() const
{
return this->sle_.at(sfAsset);
}
/**
* Get sfAssetsTotal (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getAssetsTotal() const
{
if (hasAssetsTotal())
return this->sle_.at(sfAssetsTotal);
return std::nullopt;
}
[[nodiscard]]
bool
hasAssetsTotal() const
{
return this->sle_.isFieldPresent(sfAssetsTotal);
}
/**
* Get sfAssetsAvailable (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getAssetsAvailable() const
{
if (hasAssetsAvailable())
return this->sle_.at(sfAssetsAvailable);
return std::nullopt;
}
[[nodiscard]]
bool
hasAssetsAvailable() const
{
return this->sle_.isFieldPresent(sfAssetsAvailable);
}
/**
* Get sfAssetsMaximum (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getAssetsMaximum() const
{
if (hasAssetsMaximum())
return this->sle_.at(sfAssetsMaximum);
return std::nullopt;
}
[[nodiscard]]
bool
hasAssetsMaximum() const
{
return this->sle_.isFieldPresent(sfAssetsMaximum);
}
/**
* Get sfLossUnrealized (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getLossUnrealized() const
{
if (hasLossUnrealized())
return this->sle_.at(sfLossUnrealized);
return std::nullopt;
}
[[nodiscard]]
bool
hasLossUnrealized() const
{
return this->sle_.isFieldPresent(sfLossUnrealized);
}
/**
* Get sfShareMPTID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT192::type::value_type
getShareMPTID() const
{
return this->sle_.at(sfShareMPTID);
}
/**
* Get sfWithdrawalPolicy (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT8::type::value_type
getWithdrawalPolicy() const
{
return this->sle_.at(sfWithdrawalPolicy);
}
/**
* Get sfScale (soeDEFAULT)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT8::type::value_type>
getScale() const
{
if (hasScale())
return this->sle_.at(sfScale);
return std::nullopt;
}
[[nodiscard]]
bool
hasScale() const
{
return this->sle_.isFieldPresent(sfScale);
}
};
/**
* Builder for Vault ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class VaultBuilder : public LedgerEntryBuilderBase<VaultBuilder>
{
public:
VaultBuilder(std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq,std::decay_t<typename SF_UINT32::type::value_type> const& sequence,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_ACCOUNT::type::value_type> const& owner,std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_ISSUE::type::value_type> const& asset,std::decay_t<typename SF_UINT192::type::value_type> const& shareMPTID,std::decay_t<typename SF_UINT8::type::value_type> const& withdrawalPolicy)
: LedgerEntryBuilderBase<VaultBuilder>(ltVAULT)
{
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
setSequence(sequence);
setOwnerNode(ownerNode);
setOwner(owner);
setAccount(account);
setAsset(asset);
setShareMPTID(shareMPTID);
setWithdrawalPolicy(withdrawalPolicy);
}
VaultBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltVAULT)
{
throw std::runtime_error("Invalid ledger entry type for Vault");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Set sfSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSequence] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfOwner (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfData (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setData(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfData] = value;
return *this;
}
/**
* Set sfAsset (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setAsset(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset] = STIssue(sfAsset, value);
return *this;
}
/**
* Set sfAssetsTotal (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setAssetsTotal(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfAssetsTotal] = value;
return *this;
}
/**
* Set sfAssetsAvailable (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setAssetsAvailable(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfAssetsAvailable] = value;
return *this;
}
/**
* Set sfAssetsMaximum (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setAssetsMaximum(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfAssetsMaximum] = value;
return *this;
}
/**
* Set sfLossUnrealized (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setLossUnrealized(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfLossUnrealized] = value;
return *this;
}
/**
* Set sfShareMPTID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setShareMPTID(std::decay_t<typename SF_UINT192::type::value_type> const& value)
{
object_[sfShareMPTID] = value;
return *this;
}
/**
* Set sfWithdrawalPolicy (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setWithdrawalPolicy(std::decay_t<typename SF_UINT8::type::value_type> const& value)
{
object_[sfWithdrawalPolicy] = value;
return *this;
}
/**
* Set sfScale (soeDEFAULT)
* @return Reference to this builder for method chaining.
*/
VaultBuilder&
setScale(std::decay_t<typename SF_UINT8::type::value_type> const& value)
{
object_[sfScale] = value;
return *this;
}
/**
* Build and return the completed Vault wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
Vault
build(uint256 const& index)
{
return Vault{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,284 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class XChainOwnedClaimIDBuilder;
/**
* Ledger Entry: XChainOwnedClaimID
* Type: ltXCHAIN_OWNED_CLAIM_ID (0x0071)
* RPC Name: xchain_owned_claim_id
*
* Immutable wrapper around SLE providing type-safe field access.
* Use XChainOwnedClaimIDBuilder to construct new ledger entries.
*/
class XChainOwnedClaimID : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltXCHAIN_OWNED_CLAIM_ID;
/**
* Construct a XChainOwnedClaimID ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit XChainOwnedClaimID(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for XChainOwnedClaimID");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfXChainBridge (soeREQUIRED)
*/
[[nodiscard]]
SF_XCHAIN_BRIDGE::type::value_type
getXChainBridge() const
{
return this->sle_.at(sfXChainBridge);
}
/**
* Get sfXChainClaimID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getXChainClaimID() const
{
return this->sle_.at(sfXChainClaimID);
}
/**
* Get sfOtherChainSource (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getOtherChainSource() const
{
return this->sle_.at(sfOtherChainSource);
}
/**
* Get sfXChainClaimAttestations (soeREQUIRED)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
STArray const&
getXChainClaimAttestations() const
{
return this->sle_.getFieldArray(sfXChainClaimAttestations);
}
/**
* Get sfSignatureReward (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getSignatureReward() const
{
return this->sle_.at(sfSignatureReward);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for XChainOwnedClaimID ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class XChainOwnedClaimIDBuilder : public LedgerEntryBuilderBase<XChainOwnedClaimIDBuilder>
{
public:
XChainOwnedClaimIDBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& xChainBridge,std::decay_t<typename SF_UINT64::type::value_type> const& xChainClaimID,std::decay_t<typename SF_ACCOUNT::type::value_type> const& otherChainSource,STArray const& xChainClaimAttestations,std::decay_t<typename SF_AMOUNT::type::value_type> const& signatureReward,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<XChainOwnedClaimIDBuilder>(ltXCHAIN_OWNED_CLAIM_ID)
{
setAccount(account);
setXChainBridge(xChainBridge);
setXChainClaimID(xChainClaimID);
setOtherChainSource(otherChainSource);
setXChainClaimAttestations(xChainClaimAttestations);
setSignatureReward(signatureReward);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
XChainOwnedClaimIDBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltXCHAIN_OWNED_CLAIM_ID)
{
throw std::runtime_error("Invalid ledger entry type for XChainOwnedClaimID");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedClaimIDBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfXChainBridge (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedClaimIDBuilder&
setXChainBridge(std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& value)
{
object_[sfXChainBridge] = value;
return *this;
}
/**
* Set sfXChainClaimID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedClaimIDBuilder&
setXChainClaimID(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfXChainClaimID] = value;
return *this;
}
/**
* Set sfOtherChainSource (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedClaimIDBuilder&
setOtherChainSource(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOtherChainSource] = value;
return *this;
}
/**
* Set sfXChainClaimAttestations (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedClaimIDBuilder&
setXChainClaimAttestations(STArray const& value)
{
object_.setFieldArray(sfXChainClaimAttestations, value);
return *this;
}
/**
* Set sfSignatureReward (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedClaimIDBuilder&
setSignatureReward(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfSignatureReward] = value;
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedClaimIDBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedClaimIDBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedClaimIDBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed XChainOwnedClaimID wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
XChainOwnedClaimID
build(uint256 const& index)
{
return XChainOwnedClaimID{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,240 +0,0 @@
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
// Forward declaration
class XChainOwnedCreateAccountClaimIDBuilder;
/**
* Ledger Entry: XChainOwnedCreateAccountClaimID
* Type: ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID (0x0074)
* RPC Name: xchain_owned_create_account_claim_id
*
* Immutable wrapper around SLE providing type-safe field access.
* Use XChainOwnedCreateAccountClaimIDBuilder to construct new ledger entries.
*/
class XChainOwnedCreateAccountClaimID : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID;
/**
* Construct a XChainOwnedCreateAccountClaimID ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit XChainOwnedCreateAccountClaimID(SLE const& sle)
: LedgerEntryBase(sle)
{
// Verify ledger entry type
if (sle.getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for XChainOwnedCreateAccountClaimID");
}
}
// Ledger entry-specific field getters
/**
* Get sfAccount (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAccount() const
{
return this->sle_.at(sfAccount);
}
/**
* Get sfXChainBridge (soeREQUIRED)
*/
[[nodiscard]]
SF_XCHAIN_BRIDGE::type::value_type
getXChainBridge() const
{
return this->sle_.at(sfXChainBridge);
}
/**
* Get sfXChainAccountCreateCount (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getXChainAccountCreateCount() const
{
return this->sle_.at(sfXChainAccountCreateCount);
}
/**
* Get sfXChainCreateAccountAttestations (soeREQUIRED)
* Note: This is an untyped field (unknown).
*/
[[nodiscard]]
STArray const&
getXChainCreateAccountAttestations() const
{
return this->sle_.getFieldArray(sfXChainCreateAccountAttestations);
}
/**
* Get sfOwnerNode (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_.at(sfOwnerNode);
}
/**
* Get sfPreviousTxnID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_.at(sfPreviousTxnID);
}
/**
* Get sfPreviousTxnLgrSeq (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_.at(sfPreviousTxnLgrSeq);
}
};
/**
* Builder for XChainOwnedCreateAccountClaimID ledger entries.
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class XChainOwnedCreateAccountClaimIDBuilder : public LedgerEntryBuilderBase<XChainOwnedCreateAccountClaimIDBuilder>
{
public:
XChainOwnedCreateAccountClaimIDBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& xChainBridge,std::decay_t<typename SF_UINT64::type::value_type> const& xChainAccountCreateCount,STArray const& xChainCreateAccountAttestations,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
: LedgerEntryBuilderBase<XChainOwnedCreateAccountClaimIDBuilder>(ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID)
{
setAccount(account);
setXChainBridge(xChainBridge);
setXChainAccountCreateCount(xChainAccountCreateCount);
setXChainCreateAccountAttestations(xChainCreateAccountAttestations);
setOwnerNode(ownerNode);
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
}
XChainOwnedCreateAccountClaimIDBuilder(SLE const& sle)
{
if (sle[sfLedgerEntryType] != ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID)
{
throw std::runtime_error("Invalid ledger entry type for XChainOwnedCreateAccountClaimID");
}
object_ = sle;
}
// Ledger entry-specific field setters
/**
* Set sfAccount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedCreateAccountClaimIDBuilder&
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAccount] = value;
return *this;
}
/**
* Set sfXChainBridge (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedCreateAccountClaimIDBuilder&
setXChainBridge(std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& value)
{
object_[sfXChainBridge] = value;
return *this;
}
/**
* Set sfXChainAccountCreateCount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedCreateAccountClaimIDBuilder&
setXChainAccountCreateCount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfXChainAccountCreateCount] = value;
return *this;
}
/**
* Set sfXChainCreateAccountAttestations (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedCreateAccountClaimIDBuilder&
setXChainCreateAccountAttestations(STArray const& value)
{
object_.setFieldArray(sfXChainCreateAccountAttestations, value);
return *this;
}
/**
* Set sfOwnerNode (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedCreateAccountClaimIDBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedCreateAccountClaimIDBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* Set sfPreviousTxnLgrSeq (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
XChainOwnedCreateAccountClaimIDBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* Build and return the completed XChainOwnedCreateAccountClaimID wrapper.
* @return The constructed ledger entry wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid ledger entry.
*/
XChainOwnedCreateAccountClaimID
build(uint256 const& index)
{
return XChainOwnedCreateAccountClaimID{SLE(object_, index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -1,228 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class AMMBidBuilder;
/**
* Transaction: AMMBid
* Type: ttAMM_BID (39)
* Delegable: Delegation::delegable
* Amendment: featureAMM
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use AMMBidBuilder to construct new transactions.
*/
class AMMBid : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttAMM_BID;
/**
* Construct a AMMBid transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit AMMBid(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for AMMBid");
}
}
// Transaction-specific field getters
/**
* Get sfAsset (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset() const
{
return this->tx_.at(sfAsset);
}
/**
* Get sfAsset2 (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset2() const
{
return this->tx_.at(sfAsset2);
}
/**
* Get sfBidMin (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getBidMin() const
{
if (hasBidMin())
{
return this->tx_.at(sfBidMin);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasBidMin() const
{
return this->tx_.isFieldPresent(sfBidMin);
}
/**
* Get sfBidMax (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getBidMax() const
{
if (hasBidMax())
{
return this->tx_.at(sfBidMax);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasBidMax() const
{
return this->tx_.isFieldPresent(sfBidMax);
}
/**
* Get sfAuthAccounts (soeOPTIONAL)
* Note: This is an untyped field
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getAuthAccounts() const
{
if (this->tx_.isFieldPresent(sfAuthAccounts))
return this->tx_.getFieldArray(sfAuthAccounts);
return std::nullopt;
}
[[nodiscard]]
bool
hasAuthAccounts() const
{
return this->tx_.isFieldPresent(sfAuthAccounts);
}
};
/**
* Builder for AMMBid transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class AMMBidBuilder : public TransactionBuilderBase<AMMBidBuilder>
{
public:
AMMBidBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ISSUE::type::value_type> const& asset, std::decay_t<typename SF_ISSUE::type::value_type> const& asset2, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<AMMBidBuilder>(ttAMM_BID, account, sequence, fee)
{
setAsset(asset);
setAsset2(asset2);
}
AMMBidBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttAMM_BID)
{
throw std::runtime_error("Invalid transaction type for AMMBidBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfAsset (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMBidBuilder&
setAsset(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset] = STIssue(sfAsset, value);
return *this;
}
/**
* Set sfAsset2 (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMBidBuilder&
setAsset2(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset2] = STIssue(sfAsset2, value);
return *this;
}
/**
* Set sfBidMin (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMBidBuilder&
setBidMin(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfBidMin] = value;
return *this;
}
/**
* Set sfBidMax (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMBidBuilder&
setBidMax(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfBidMax] = value;
return *this;
}
/**
* Set sfAuthAccounts (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMBidBuilder&
setAuthAccounts(STArray const& value)
{
object_.setFieldArray(sfAuthAccounts, value);
return *this;
}
/**
* Build and return the completed AMMBid wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
AMMBid
build()
{
return AMMBid(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,188 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class AMMClawbackBuilder;
/**
* Transaction: AMMClawback
* Type: ttAMM_CLAWBACK (31)
* Delegable: Delegation::delegable
* Amendment: featureAMMClawback
* Privileges: mayDeleteAcct | overrideFreeze
*
* Immutable wrapper around STTx providing type-safe field access.
* Use AMMClawbackBuilder to construct new transactions.
*/
class AMMClawback : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttAMM_CLAWBACK;
/**
* Construct a AMMClawback transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit AMMClawback(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for AMMClawback");
}
}
// Transaction-specific field getters
/**
* Get sfHolder (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getHolder() const
{
return this->tx_.at(sfHolder);
}
/**
* Get sfAsset (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset() const
{
return this->tx_.at(sfAsset);
}
/**
* Get sfAsset2 (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset2() const
{
return this->tx_.at(sfAsset2);
}
/**
* Get sfAmount (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getAmount() const
{
if (hasAmount())
{
return this->tx_.at(sfAmount);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasAmount() const
{
return this->tx_.isFieldPresent(sfAmount);
}
};
/**
* Builder for AMMClawback transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class AMMClawbackBuilder : public TransactionBuilderBase<AMMClawbackBuilder>
{
public:
AMMClawbackBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ACCOUNT::type::value_type> const& holder, std::decay_t<typename SF_ISSUE::type::value_type> const& asset, std::decay_t<typename SF_ISSUE::type::value_type> const& asset2, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<AMMClawbackBuilder>(ttAMM_CLAWBACK, account, sequence, fee)
{
setHolder(holder);
setAsset(asset);
setAsset2(asset2);
}
AMMClawbackBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttAMM_CLAWBACK)
{
throw std::runtime_error("Invalid transaction type for AMMClawbackBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfHolder (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMClawbackBuilder&
setHolder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfHolder] = value;
return *this;
}
/**
* Set sfAsset (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMClawbackBuilder&
setAsset(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset] = STIssue(sfAsset, value);
return *this;
}
/**
* Set sfAsset2 (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMClawbackBuilder&
setAsset2(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset2] = STIssue(sfAsset2, value);
return *this;
}
/**
* Set sfAmount (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMClawbackBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Build and return the completed AMMClawback wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
AMMClawback
build()
{
return AMMClawback(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,156 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class AMMCreateBuilder;
/**
* Transaction: AMMCreate
* Type: ttAMM_CREATE (35)
* Delegable: Delegation::delegable
* Amendment: featureAMM
* Privileges: createPseudoAcct
*
* Immutable wrapper around STTx providing type-safe field access.
* Use AMMCreateBuilder to construct new transactions.
*/
class AMMCreate : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttAMM_CREATE;
/**
* Construct a AMMCreate transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit AMMCreate(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for AMMCreate");
}
}
// Transaction-specific field getters
/**
* Get sfAmount (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getAmount() const
{
return this->tx_.at(sfAmount);
}
/**
* Get sfAmount2 (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getAmount2() const
{
return this->tx_.at(sfAmount2);
}
/**
* Get sfTradingFee (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT16::type::value_type
getTradingFee() const
{
return this->tx_.at(sfTradingFee);
}
};
/**
* Builder for AMMCreate transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class AMMCreateBuilder : public TransactionBuilderBase<AMMCreateBuilder>
{
public:
AMMCreateBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_AMOUNT::type::value_type> const& amount, std::decay_t<typename SF_AMOUNT::type::value_type> const& amount2, std::decay_t<typename SF_UINT16::type::value_type> const& tradingFee, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<AMMCreateBuilder>(ttAMM_CREATE, account, sequence, fee)
{
setAmount(amount);
setAmount2(amount2);
setTradingFee(tradingFee);
}
AMMCreateBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttAMM_CREATE)
{
throw std::runtime_error("Invalid transaction type for AMMCreateBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfAmount (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMCreateBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfAmount2 (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMCreateBuilder&
setAmount2(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount2] = value;
return *this;
}
/**
* Set sfTradingFee (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMCreateBuilder&
setTradingFee(std::decay_t<typename SF_UINT16::type::value_type> const& value)
{
object_[sfTradingFee] = value;
return *this;
}
/**
* Build and return the completed AMMCreate wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
AMMCreate
build()
{
return AMMCreate(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,134 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class AMMDeleteBuilder;
/**
* Transaction: AMMDelete
* Type: ttAMM_DELETE (40)
* Delegable: Delegation::delegable
* Amendment: featureAMM
* Privileges: mustDeleteAcct
*
* Immutable wrapper around STTx providing type-safe field access.
* Use AMMDeleteBuilder to construct new transactions.
*/
class AMMDelete : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttAMM_DELETE;
/**
* Construct a AMMDelete transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit AMMDelete(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for AMMDelete");
}
}
// Transaction-specific field getters
/**
* Get sfAsset (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset() const
{
return this->tx_.at(sfAsset);
}
/**
* Get sfAsset2 (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset2() const
{
return this->tx_.at(sfAsset2);
}
};
/**
* Builder for AMMDelete transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class AMMDeleteBuilder : public TransactionBuilderBase<AMMDeleteBuilder>
{
public:
AMMDeleteBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ISSUE::type::value_type> const& asset, std::decay_t<typename SF_ISSUE::type::value_type> const& asset2, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<AMMDeleteBuilder>(ttAMM_DELETE, account, sequence, fee)
{
setAsset(asset);
setAsset2(asset2);
}
AMMDeleteBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttAMM_DELETE)
{
throw std::runtime_error("Invalid transaction type for AMMDeleteBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfAsset (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMDeleteBuilder&
setAsset(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset] = STIssue(sfAsset, value);
return *this;
}
/**
* Set sfAsset2 (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMDeleteBuilder&
setAsset2(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset2] = STIssue(sfAsset2, value);
return *this;
}
/**
* Build and return the completed AMMDelete wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
AMMDelete
build()
{
return AMMDelete(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,294 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class AMMDepositBuilder;
/**
* Transaction: AMMDeposit
* Type: ttAMM_DEPOSIT (36)
* Delegable: Delegation::delegable
* Amendment: featureAMM
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use AMMDepositBuilder to construct new transactions.
*/
class AMMDeposit : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttAMM_DEPOSIT;
/**
* Construct a AMMDeposit transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit AMMDeposit(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for AMMDeposit");
}
}
// Transaction-specific field getters
/**
* Get sfAsset (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset() const
{
return this->tx_.at(sfAsset);
}
/**
* Get sfAsset2 (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset2() const
{
return this->tx_.at(sfAsset2);
}
/**
* Get sfAmount (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getAmount() const
{
if (hasAmount())
{
return this->tx_.at(sfAmount);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasAmount() const
{
return this->tx_.isFieldPresent(sfAmount);
}
/**
* Get sfAmount2 (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getAmount2() const
{
if (hasAmount2())
{
return this->tx_.at(sfAmount2);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasAmount2() const
{
return this->tx_.isFieldPresent(sfAmount2);
}
/**
* Get sfEPrice (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getEPrice() const
{
if (hasEPrice())
{
return this->tx_.at(sfEPrice);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasEPrice() const
{
return this->tx_.isFieldPresent(sfEPrice);
}
/**
* Get sfLPTokenOut (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getLPTokenOut() const
{
if (hasLPTokenOut())
{
return this->tx_.at(sfLPTokenOut);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasLPTokenOut() const
{
return this->tx_.isFieldPresent(sfLPTokenOut);
}
/**
* Get sfTradingFee (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT16::type::value_type>
getTradingFee() const
{
if (hasTradingFee())
{
return this->tx_.at(sfTradingFee);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasTradingFee() const
{
return this->tx_.isFieldPresent(sfTradingFee);
}
};
/**
* Builder for AMMDeposit transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class AMMDepositBuilder : public TransactionBuilderBase<AMMDepositBuilder>
{
public:
AMMDepositBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ISSUE::type::value_type> const& asset, std::decay_t<typename SF_ISSUE::type::value_type> const& asset2, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<AMMDepositBuilder>(ttAMM_DEPOSIT, account, sequence, fee)
{
setAsset(asset);
setAsset2(asset2);
}
AMMDepositBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttAMM_DEPOSIT)
{
throw std::runtime_error("Invalid transaction type for AMMDepositBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfAsset (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMDepositBuilder&
setAsset(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset] = STIssue(sfAsset, value);
return *this;
}
/**
* Set sfAsset2 (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMDepositBuilder&
setAsset2(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset2] = STIssue(sfAsset2, value);
return *this;
}
/**
* Set sfAmount (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMDepositBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfAmount2 (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMDepositBuilder&
setAmount2(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount2] = value;
return *this;
}
/**
* Set sfEPrice (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMDepositBuilder&
setEPrice(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfEPrice] = value;
return *this;
}
/**
* Set sfLPTokenOut (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMDepositBuilder&
setLPTokenOut(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfLPTokenOut] = value;
return *this;
}
/**
* Set sfTradingFee (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMDepositBuilder&
setTradingFee(std::decay_t<typename SF_UINT16::type::value_type> const& value)
{
object_[sfTradingFee] = value;
return *this;
}
/**
* Build and return the completed AMMDeposit wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
AMMDeposit
build()
{
return AMMDeposit(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,156 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class AMMVoteBuilder;
/**
* Transaction: AMMVote
* Type: ttAMM_VOTE (38)
* Delegable: Delegation::delegable
* Amendment: featureAMM
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use AMMVoteBuilder to construct new transactions.
*/
class AMMVote : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttAMM_VOTE;
/**
* Construct a AMMVote transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit AMMVote(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for AMMVote");
}
}
// Transaction-specific field getters
/**
* Get sfAsset (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset() const
{
return this->tx_.at(sfAsset);
}
/**
* Get sfAsset2 (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset2() const
{
return this->tx_.at(sfAsset2);
}
/**
* Get sfTradingFee (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT16::type::value_type
getTradingFee() const
{
return this->tx_.at(sfTradingFee);
}
};
/**
* Builder for AMMVote transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class AMMVoteBuilder : public TransactionBuilderBase<AMMVoteBuilder>
{
public:
AMMVoteBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ISSUE::type::value_type> const& asset, std::decay_t<typename SF_ISSUE::type::value_type> const& asset2, std::decay_t<typename SF_UINT16::type::value_type> const& tradingFee, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<AMMVoteBuilder>(ttAMM_VOTE, account, sequence, fee)
{
setAsset(asset);
setAsset2(asset2);
setTradingFee(tradingFee);
}
AMMVoteBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttAMM_VOTE)
{
throw std::runtime_error("Invalid transaction type for AMMVoteBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfAsset (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMVoteBuilder&
setAsset(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset] = STIssue(sfAsset, value);
return *this;
}
/**
* Set sfAsset2 (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMVoteBuilder&
setAsset2(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset2] = STIssue(sfAsset2, value);
return *this;
}
/**
* Set sfTradingFee (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMVoteBuilder&
setTradingFee(std::decay_t<typename SF_UINT16::type::value_type> const& value)
{
object_[sfTradingFee] = value;
return *this;
}
/**
* Build and return the completed AMMVote wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
AMMVote
build()
{
return AMMVote(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,262 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class AMMWithdrawBuilder;
/**
* Transaction: AMMWithdraw
* Type: ttAMM_WITHDRAW (37)
* Delegable: Delegation::delegable
* Amendment: featureAMM
* Privileges: mayDeleteAcct
*
* Immutable wrapper around STTx providing type-safe field access.
* Use AMMWithdrawBuilder to construct new transactions.
*/
class AMMWithdraw : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttAMM_WITHDRAW;
/**
* Construct a AMMWithdraw transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit AMMWithdraw(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for AMMWithdraw");
}
}
// Transaction-specific field getters
/**
* Get sfAsset (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset() const
{
return this->tx_.at(sfAsset);
}
/**
* Get sfAsset2 (soeREQUIRED)
*/
[[nodiscard]]
SF_ISSUE::type::value_type
getAsset2() const
{
return this->tx_.at(sfAsset2);
}
/**
* Get sfAmount (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getAmount() const
{
if (hasAmount())
{
return this->tx_.at(sfAmount);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasAmount() const
{
return this->tx_.isFieldPresent(sfAmount);
}
/**
* Get sfAmount2 (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getAmount2() const
{
if (hasAmount2())
{
return this->tx_.at(sfAmount2);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasAmount2() const
{
return this->tx_.isFieldPresent(sfAmount2);
}
/**
* Get sfEPrice (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getEPrice() const
{
if (hasEPrice())
{
return this->tx_.at(sfEPrice);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasEPrice() const
{
return this->tx_.isFieldPresent(sfEPrice);
}
/**
* Get sfLPTokenIn (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getLPTokenIn() const
{
if (hasLPTokenIn())
{
return this->tx_.at(sfLPTokenIn);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasLPTokenIn() const
{
return this->tx_.isFieldPresent(sfLPTokenIn);
}
};
/**
* Builder for AMMWithdraw transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class AMMWithdrawBuilder : public TransactionBuilderBase<AMMWithdrawBuilder>
{
public:
AMMWithdrawBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ISSUE::type::value_type> const& asset, std::decay_t<typename SF_ISSUE::type::value_type> const& asset2, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<AMMWithdrawBuilder>(ttAMM_WITHDRAW, account, sequence, fee)
{
setAsset(asset);
setAsset2(asset2);
}
AMMWithdrawBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttAMM_WITHDRAW)
{
throw std::runtime_error("Invalid transaction type for AMMWithdrawBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfAsset (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMWithdrawBuilder&
setAsset(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset] = STIssue(sfAsset, value);
return *this;
}
/**
* Set sfAsset2 (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AMMWithdrawBuilder&
setAsset2(std::decay_t<typename SF_ISSUE::type::value_type> const& value)
{
object_[sfAsset2] = STIssue(sfAsset2, value);
return *this;
}
/**
* Set sfAmount (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMWithdrawBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfAmount2 (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMWithdrawBuilder&
setAmount2(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount2] = value;
return *this;
}
/**
* Set sfEPrice (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMWithdrawBuilder&
setEPrice(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfEPrice] = value;
return *this;
}
/**
* Set sfLPTokenIn (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AMMWithdrawBuilder&
setLPTokenIn(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfLPTokenIn] = value;
return *this;
}
/**
* Build and return the completed AMMWithdraw wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
AMMWithdraw
build()
{
return AMMWithdraw(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,176 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class AccountDeleteBuilder;
/**
* Transaction: AccountDelete
* Type: ttACCOUNT_DELETE (21)
* Delegable: Delegation::notDelegable
* Amendment: uint256{}
* Privileges: mustDeleteAcct
*
* Immutable wrapper around STTx providing type-safe field access.
* Use AccountDeleteBuilder to construct new transactions.
*/
class AccountDelete : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttACCOUNT_DELETE;
/**
* Construct a AccountDelete transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit AccountDelete(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for AccountDelete");
}
}
// Transaction-specific field getters
/**
* Get sfDestination (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getDestination() const
{
return this->tx_.at(sfDestination);
}
/**
* Get sfDestinationTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getDestinationTag() const
{
if (hasDestinationTag())
{
return this->tx_.at(sfDestinationTag);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasDestinationTag() const
{
return this->tx_.isFieldPresent(sfDestinationTag);
}
/**
* Get sfCredentialIDs (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VECTOR256::type::value_type>
getCredentialIDs() const
{
if (hasCredentialIDs())
{
return this->tx_.at(sfCredentialIDs);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasCredentialIDs() const
{
return this->tx_.isFieldPresent(sfCredentialIDs);
}
};
/**
* Builder for AccountDelete transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class AccountDeleteBuilder : public TransactionBuilderBase<AccountDeleteBuilder>
{
public:
AccountDeleteBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ACCOUNT::type::value_type> const& destination, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<AccountDeleteBuilder>(ttACCOUNT_DELETE, account, sequence, fee)
{
setDestination(destination);
}
AccountDeleteBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttACCOUNT_DELETE)
{
throw std::runtime_error("Invalid transaction type for AccountDeleteBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfDestination (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
AccountDeleteBuilder&
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfDestination] = value;
return *this;
}
/**
* Set sfDestinationTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountDeleteBuilder&
setDestinationTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfDestinationTag] = value;
return *this;
}
/**
* Set sfCredentialIDs (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountDeleteBuilder&
setCredentialIDs(std::decay_t<typename SF_VECTOR256::type::value_type> const& value)
{
object_[sfCredentialIDs] = value;
return *this;
}
/**
* Build and return the completed AccountDelete wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
AccountDelete
build()
{
return AccountDelete(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,410 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class AccountSetBuilder;
/**
* Transaction: AccountSet
* Type: ttACCOUNT_SET (3)
* Delegable: Delegation::notDelegable
* Amendment: uint256{}
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use AccountSetBuilder to construct new transactions.
*/
class AccountSet : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttACCOUNT_SET;
/**
* Construct a AccountSet transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit AccountSet(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for AccountSet");
}
}
// Transaction-specific field getters
/**
* Get sfEmailHash (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT128::type::value_type>
getEmailHash() const
{
if (hasEmailHash())
{
return this->tx_.at(sfEmailHash);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasEmailHash() const
{
return this->tx_.isFieldPresent(sfEmailHash);
}
/**
* Get sfWalletLocator (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getWalletLocator() const
{
if (hasWalletLocator())
{
return this->tx_.at(sfWalletLocator);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasWalletLocator() const
{
return this->tx_.isFieldPresent(sfWalletLocator);
}
/**
* Get sfWalletSize (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getWalletSize() const
{
if (hasWalletSize())
{
return this->tx_.at(sfWalletSize);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasWalletSize() const
{
return this->tx_.isFieldPresent(sfWalletSize);
}
/**
* Get sfMessageKey (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getMessageKey() const
{
if (hasMessageKey())
{
return this->tx_.at(sfMessageKey);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasMessageKey() const
{
return this->tx_.isFieldPresent(sfMessageKey);
}
/**
* Get sfDomain (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getDomain() const
{
if (hasDomain())
{
return this->tx_.at(sfDomain);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasDomain() const
{
return this->tx_.isFieldPresent(sfDomain);
}
/**
* Get sfTransferRate (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getTransferRate() const
{
if (hasTransferRate())
{
return this->tx_.at(sfTransferRate);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasTransferRate() const
{
return this->tx_.isFieldPresent(sfTransferRate);
}
/**
* Get sfSetFlag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getSetFlag() const
{
if (hasSetFlag())
{
return this->tx_.at(sfSetFlag);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasSetFlag() const
{
return this->tx_.isFieldPresent(sfSetFlag);
}
/**
* Get sfClearFlag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getClearFlag() const
{
if (hasClearFlag())
{
return this->tx_.at(sfClearFlag);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasClearFlag() const
{
return this->tx_.isFieldPresent(sfClearFlag);
}
/**
* Get sfTickSize (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT8::type::value_type>
getTickSize() const
{
if (hasTickSize())
{
return this->tx_.at(sfTickSize);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasTickSize() const
{
return this->tx_.isFieldPresent(sfTickSize);
}
/**
* Get sfNFTokenMinter (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getNFTokenMinter() const
{
if (hasNFTokenMinter())
{
return this->tx_.at(sfNFTokenMinter);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasNFTokenMinter() const
{
return this->tx_.isFieldPresent(sfNFTokenMinter);
}
};
/**
* Builder for AccountSet transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class AccountSetBuilder : public TransactionBuilderBase<AccountSetBuilder>
{
public:
AccountSetBuilder(SF_ACCOUNT::type::value_type account,
std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<AccountSetBuilder>(ttACCOUNT_SET, account, sequence, fee)
{
}
AccountSetBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttACCOUNT_SET)
{
throw std::runtime_error("Invalid transaction type for AccountSetBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfEmailHash (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setEmailHash(std::decay_t<typename SF_UINT128::type::value_type> const& value)
{
object_[sfEmailHash] = value;
return *this;
}
/**
* Set sfWalletLocator (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setWalletLocator(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfWalletLocator] = value;
return *this;
}
/**
* Set sfWalletSize (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setWalletSize(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfWalletSize] = value;
return *this;
}
/**
* Set sfMessageKey (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setMessageKey(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfMessageKey] = value;
return *this;
}
/**
* Set sfDomain (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setDomain(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfDomain] = value;
return *this;
}
/**
* Set sfTransferRate (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setTransferRate(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfTransferRate] = value;
return *this;
}
/**
* Set sfSetFlag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setSetFlag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSetFlag] = value;
return *this;
}
/**
* Set sfClearFlag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setClearFlag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfClearFlag] = value;
return *this;
}
/**
* Set sfTickSize (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setTickSize(std::decay_t<typename SF_UINT8::type::value_type> const& value)
{
object_[sfTickSize] = value;
return *this;
}
/**
* Set sfNFTokenMinter (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
AccountSetBuilder&
setNFTokenMinter(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfNFTokenMinter] = value;
return *this;
}
/**
* Build and return the completed AccountSet wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
AccountSet
build()
{
return AccountSet(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,142 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class BatchBuilder;
/**
* Transaction: Batch
* Type: ttBATCH (71)
* Delegable: Delegation::notDelegable
* Amendment: featureBatch
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use BatchBuilder to construct new transactions.
*/
class Batch : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttBATCH;
/**
* Construct a Batch transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit Batch(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for Batch");
}
}
// Transaction-specific field getters
/**
* Get sfRawTransactions (soeREQUIRED)
* Note: This is an untyped field
*/
[[nodiscard]]
STArray const&
getRawTransactions() const
{
return this->tx_.getFieldArray(sfRawTransactions);
}
/**
* Get sfBatchSigners (soeOPTIONAL)
* Note: This is an untyped field
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getBatchSigners() const
{
if (this->tx_.isFieldPresent(sfBatchSigners))
return this->tx_.getFieldArray(sfBatchSigners);
return std::nullopt;
}
[[nodiscard]]
bool
hasBatchSigners() const
{
return this->tx_.isFieldPresent(sfBatchSigners);
}
};
/**
* Builder for Batch transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class BatchBuilder : public TransactionBuilderBase<BatchBuilder>
{
public:
BatchBuilder(SF_ACCOUNT::type::value_type account,
STArray const& rawTransactions, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<BatchBuilder>(ttBATCH, account, sequence, fee)
{
setRawTransactions(rawTransactions);
}
BatchBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttBATCH)
{
throw std::runtime_error("Invalid transaction type for BatchBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfRawTransactions (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
BatchBuilder&
setRawTransactions(STArray const& value)
{
object_.setFieldArray(sfRawTransactions, value);
return *this;
}
/**
* Set sfBatchSigners (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
BatchBuilder&
setBatchSigners(STArray const& value)
{
object_.setFieldArray(sfBatchSigners, value);
return *this;
}
/**
* Build and return the completed Batch wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
Batch
build()
{
return Batch(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,112 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class CheckCancelBuilder;
/**
* Transaction: CheckCancel
* Type: ttCHECK_CANCEL (18)
* Delegable: Delegation::delegable
* Amendment: uint256{}
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use CheckCancelBuilder to construct new transactions.
*/
class CheckCancel : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttCHECK_CANCEL;
/**
* Construct a CheckCancel transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit CheckCancel(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for CheckCancel");
}
}
// Transaction-specific field getters
/**
* Get sfCheckID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getCheckID() const
{
return this->tx_.at(sfCheckID);
}
};
/**
* Builder for CheckCancel transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class CheckCancelBuilder : public TransactionBuilderBase<CheckCancelBuilder>
{
public:
CheckCancelBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT256::type::value_type> const& checkID, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<CheckCancelBuilder>(ttCHECK_CANCEL, account, sequence, fee)
{
setCheckID(checkID);
}
CheckCancelBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttCHECK_CANCEL)
{
throw std::runtime_error("Invalid transaction type for CheckCancelBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfCheckID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckCancelBuilder&
setCheckID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfCheckID] = value;
return *this;
}
/**
* Build and return the completed CheckCancel wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
CheckCancel
build()
{
return CheckCancel(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,176 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class CheckCashBuilder;
/**
* Transaction: CheckCash
* Type: ttCHECK_CASH (17)
* Delegable: Delegation::delegable
* Amendment: uint256{}
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use CheckCashBuilder to construct new transactions.
*/
class CheckCash : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttCHECK_CASH;
/**
* Construct a CheckCash transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit CheckCash(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for CheckCash");
}
}
// Transaction-specific field getters
/**
* Get sfCheckID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getCheckID() const
{
return this->tx_.at(sfCheckID);
}
/**
* Get sfAmount (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getAmount() const
{
if (hasAmount())
{
return this->tx_.at(sfAmount);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasAmount() const
{
return this->tx_.isFieldPresent(sfAmount);
}
/**
* Get sfDeliverMin (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getDeliverMin() const
{
if (hasDeliverMin())
{
return this->tx_.at(sfDeliverMin);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasDeliverMin() const
{
return this->tx_.isFieldPresent(sfDeliverMin);
}
};
/**
* Builder for CheckCash transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class CheckCashBuilder : public TransactionBuilderBase<CheckCashBuilder>
{
public:
CheckCashBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT256::type::value_type> const& checkID, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<CheckCashBuilder>(ttCHECK_CASH, account, sequence, fee)
{
setCheckID(checkID);
}
CheckCashBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttCHECK_CASH)
{
throw std::runtime_error("Invalid transaction type for CheckCashBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfCheckID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckCashBuilder&
setCheckID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfCheckID] = value;
return *this;
}
/**
* Set sfAmount (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CheckCashBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfDeliverMin (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CheckCashBuilder&
setDeliverMin(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfDeliverMin] = value;
return *this;
}
/**
* Build and return the completed CheckCash wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
CheckCash
build()
{
return CheckCash(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,230 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class CheckCreateBuilder;
/**
* Transaction: CheckCreate
* Type: ttCHECK_CREATE (16)
* Delegable: Delegation::delegable
* Amendment: uint256{}
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use CheckCreateBuilder to construct new transactions.
*/
class CheckCreate : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttCHECK_CREATE;
/**
* Construct a CheckCreate transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit CheckCreate(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for CheckCreate");
}
}
// Transaction-specific field getters
/**
* Get sfDestination (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getDestination() const
{
return this->tx_.at(sfDestination);
}
/**
* Get sfSendMax (soeREQUIRED)
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getSendMax() const
{
return this->tx_.at(sfSendMax);
}
/**
* Get sfExpiration (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getExpiration() const
{
if (hasExpiration())
{
return this->tx_.at(sfExpiration);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasExpiration() const
{
return this->tx_.isFieldPresent(sfExpiration);
}
/**
* Get sfDestinationTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getDestinationTag() const
{
if (hasDestinationTag())
{
return this->tx_.at(sfDestinationTag);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasDestinationTag() const
{
return this->tx_.isFieldPresent(sfDestinationTag);
}
/**
* Get sfInvoiceID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getInvoiceID() const
{
if (hasInvoiceID())
{
return this->tx_.at(sfInvoiceID);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasInvoiceID() const
{
return this->tx_.isFieldPresent(sfInvoiceID);
}
};
/**
* Builder for CheckCreate transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class CheckCreateBuilder : public TransactionBuilderBase<CheckCreateBuilder>
{
public:
CheckCreateBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ACCOUNT::type::value_type> const& destination, std::decay_t<typename SF_AMOUNT::type::value_type> const& sendMax, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<CheckCreateBuilder>(ttCHECK_CREATE, account, sequence, fee)
{
setDestination(destination);
setSendMax(sendMax);
}
CheckCreateBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttCHECK_CREATE)
{
throw std::runtime_error("Invalid transaction type for CheckCreateBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfDestination (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckCreateBuilder&
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfDestination] = value;
return *this;
}
/**
* Set sfSendMax (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CheckCreateBuilder&
setSendMax(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfSendMax] = value;
return *this;
}
/**
* Set sfExpiration (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CheckCreateBuilder&
setExpiration(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfExpiration] = value;
return *this;
}
/**
* Set sfDestinationTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CheckCreateBuilder&
setDestinationTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfDestinationTag] = value;
return *this;
}
/**
* Set sfInvoiceID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CheckCreateBuilder&
setInvoiceID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfInvoiceID] = value;
return *this;
}
/**
* Build and return the completed CheckCreate wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
CheckCreate
build()
{
return CheckCreate(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,146 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class ClawbackBuilder;
/**
* Transaction: Clawback
* Type: ttCLAWBACK (30)
* Delegable: Delegation::delegable
* Amendment: featureClawback
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use ClawbackBuilder to construct new transactions.
*/
class Clawback : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttCLAWBACK;
/**
* Construct a Clawback transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit Clawback(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for Clawback");
}
}
// Transaction-specific field getters
/**
* Get sfAmount (soeREQUIRED)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getAmount() const
{
return this->tx_.at(sfAmount);
}
/**
* Get sfHolder (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getHolder() const
{
if (hasHolder())
{
return this->tx_.at(sfHolder);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasHolder() const
{
return this->tx_.isFieldPresent(sfHolder);
}
};
/**
* Builder for Clawback transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class ClawbackBuilder : public TransactionBuilderBase<ClawbackBuilder>
{
public:
ClawbackBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_AMOUNT::type::value_type> const& amount, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<ClawbackBuilder>(ttCLAWBACK, account, sequence, fee)
{
setAmount(amount);
}
ClawbackBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttCLAWBACK)
{
throw std::runtime_error("Invalid transaction type for ClawbackBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfAmount (soeREQUIRED)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
* @return Reference to this builder for method chaining.
*/
ClawbackBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfHolder (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
ClawbackBuilder&
setHolder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfHolder] = value;
return *this;
}
/**
* Build and return the completed Clawback wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
Clawback
build()
{
return Clawback(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,134 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class CredentialAcceptBuilder;
/**
* Transaction: CredentialAccept
* Type: ttCREDENTIAL_ACCEPT (59)
* Delegable: Delegation::delegable
* Amendment: featureCredentials
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use CredentialAcceptBuilder to construct new transactions.
*/
class CredentialAccept : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttCREDENTIAL_ACCEPT;
/**
* Construct a CredentialAccept transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit CredentialAccept(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for CredentialAccept");
}
}
// Transaction-specific field getters
/**
* Get sfIssuer (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getIssuer() const
{
return this->tx_.at(sfIssuer);
}
/**
* Get sfCredentialType (soeREQUIRED)
*/
[[nodiscard]]
SF_VL::type::value_type
getCredentialType() const
{
return this->tx_.at(sfCredentialType);
}
};
/**
* Builder for CredentialAccept transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class CredentialAcceptBuilder : public TransactionBuilderBase<CredentialAcceptBuilder>
{
public:
CredentialAcceptBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ACCOUNT::type::value_type> const& issuer, std::decay_t<typename SF_VL::type::value_type> const& credentialType, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<CredentialAcceptBuilder>(ttCREDENTIAL_ACCEPT, account, sequence, fee)
{
setIssuer(issuer);
setCredentialType(credentialType);
}
CredentialAcceptBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttCREDENTIAL_ACCEPT)
{
throw std::runtime_error("Invalid transaction type for CredentialAcceptBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfIssuer (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialAcceptBuilder&
setIssuer(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfIssuer] = value;
return *this;
}
/**
* Set sfCredentialType (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialAcceptBuilder&
setCredentialType(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfCredentialType] = value;
return *this;
}
/**
* Build and return the completed CredentialAccept wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
CredentialAccept
build()
{
return CredentialAccept(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,198 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class CredentialCreateBuilder;
/**
* Transaction: CredentialCreate
* Type: ttCREDENTIAL_CREATE (58)
* Delegable: Delegation::delegable
* Amendment: featureCredentials
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use CredentialCreateBuilder to construct new transactions.
*/
class CredentialCreate : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttCREDENTIAL_CREATE;
/**
* Construct a CredentialCreate transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit CredentialCreate(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for CredentialCreate");
}
}
// Transaction-specific field getters
/**
* Get sfSubject (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getSubject() const
{
return this->tx_.at(sfSubject);
}
/**
* Get sfCredentialType (soeREQUIRED)
*/
[[nodiscard]]
SF_VL::type::value_type
getCredentialType() const
{
return this->tx_.at(sfCredentialType);
}
/**
* Get sfExpiration (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getExpiration() const
{
if (hasExpiration())
{
return this->tx_.at(sfExpiration);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasExpiration() const
{
return this->tx_.isFieldPresent(sfExpiration);
}
/**
* Get sfURI (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getURI() const
{
if (hasURI())
{
return this->tx_.at(sfURI);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasURI() const
{
return this->tx_.isFieldPresent(sfURI);
}
};
/**
* Builder for CredentialCreate transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class CredentialCreateBuilder : public TransactionBuilderBase<CredentialCreateBuilder>
{
public:
CredentialCreateBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ACCOUNT::type::value_type> const& subject, std::decay_t<typename SF_VL::type::value_type> const& credentialType, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<CredentialCreateBuilder>(ttCREDENTIAL_CREATE, account, sequence, fee)
{
setSubject(subject);
setCredentialType(credentialType);
}
CredentialCreateBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttCREDENTIAL_CREATE)
{
throw std::runtime_error("Invalid transaction type for CredentialCreateBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfSubject (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialCreateBuilder&
setSubject(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfSubject] = value;
return *this;
}
/**
* Set sfCredentialType (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialCreateBuilder&
setCredentialType(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfCredentialType] = value;
return *this;
}
/**
* Set sfExpiration (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CredentialCreateBuilder&
setExpiration(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfExpiration] = value;
return *this;
}
/**
* Set sfURI (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CredentialCreateBuilder&
setURI(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfURI] = value;
return *this;
}
/**
* Build and return the completed CredentialCreate wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
CredentialCreate
build()
{
return CredentialCreate(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,176 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class CredentialDeleteBuilder;
/**
* Transaction: CredentialDelete
* Type: ttCREDENTIAL_DELETE (60)
* Delegable: Delegation::delegable
* Amendment: featureCredentials
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use CredentialDeleteBuilder to construct new transactions.
*/
class CredentialDelete : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttCREDENTIAL_DELETE;
/**
* Construct a CredentialDelete transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit CredentialDelete(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for CredentialDelete");
}
}
// Transaction-specific field getters
/**
* Get sfSubject (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getSubject() const
{
if (hasSubject())
{
return this->tx_.at(sfSubject);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasSubject() const
{
return this->tx_.isFieldPresent(sfSubject);
}
/**
* Get sfIssuer (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getIssuer() const
{
if (hasIssuer())
{
return this->tx_.at(sfIssuer);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasIssuer() const
{
return this->tx_.isFieldPresent(sfIssuer);
}
/**
* Get sfCredentialType (soeREQUIRED)
*/
[[nodiscard]]
SF_VL::type::value_type
getCredentialType() const
{
return this->tx_.at(sfCredentialType);
}
};
/**
* Builder for CredentialDelete transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class CredentialDeleteBuilder : public TransactionBuilderBase<CredentialDeleteBuilder>
{
public:
CredentialDeleteBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_VL::type::value_type> const& credentialType, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<CredentialDeleteBuilder>(ttCREDENTIAL_DELETE, account, sequence, fee)
{
setCredentialType(credentialType);
}
CredentialDeleteBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttCREDENTIAL_DELETE)
{
throw std::runtime_error("Invalid transaction type for CredentialDeleteBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfSubject (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CredentialDeleteBuilder&
setSubject(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfSubject] = value;
return *this;
}
/**
* Set sfIssuer (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
CredentialDeleteBuilder&
setIssuer(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfIssuer] = value;
return *this;
}
/**
* Set sfCredentialType (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
CredentialDeleteBuilder&
setCredentialType(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfCredentialType] = value;
return *this;
}
/**
* Build and return the completed CredentialDelete wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
CredentialDelete
build()
{
return CredentialDelete(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,90 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class DIDDeleteBuilder;
/**
* Transaction: DIDDelete
* Type: ttDID_DELETE (50)
* Delegable: Delegation::delegable
* Amendment: featureDID
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use DIDDeleteBuilder to construct new transactions.
*/
class DIDDelete : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttDID_DELETE;
/**
* Construct a DIDDelete transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit DIDDelete(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for DIDDelete");
}
}
// Transaction-specific field getters
};
/**
* Builder for DIDDelete transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class DIDDeleteBuilder : public TransactionBuilderBase<DIDDeleteBuilder>
{
public:
DIDDeleteBuilder(SF_ACCOUNT::type::value_type account,
std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<DIDDeleteBuilder>(ttDID_DELETE, account, sequence, fee)
{
}
DIDDeleteBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttDID_DELETE)
{
throw std::runtime_error("Invalid transaction type for DIDDeleteBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Build and return the completed DIDDelete wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
DIDDelete
build()
{
return DIDDelete(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,186 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class DIDSetBuilder;
/**
* Transaction: DIDSet
* Type: ttDID_SET (49)
* Delegable: Delegation::delegable
* Amendment: featureDID
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use DIDSetBuilder to construct new transactions.
*/
class DIDSet : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttDID_SET;
/**
* Construct a DIDSet transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit DIDSet(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for DIDSet");
}
}
// Transaction-specific field getters
/**
* Get sfDIDDocument (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getDIDDocument() const
{
if (hasDIDDocument())
{
return this->tx_.at(sfDIDDocument);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasDIDDocument() const
{
return this->tx_.isFieldPresent(sfDIDDocument);
}
/**
* Get sfURI (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getURI() const
{
if (hasURI())
{
return this->tx_.at(sfURI);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasURI() const
{
return this->tx_.isFieldPresent(sfURI);
}
/**
* Get sfData (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getData() const
{
if (hasData())
{
return this->tx_.at(sfData);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasData() const
{
return this->tx_.isFieldPresent(sfData);
}
};
/**
* Builder for DIDSet transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class DIDSetBuilder : public TransactionBuilderBase<DIDSetBuilder>
{
public:
DIDSetBuilder(SF_ACCOUNT::type::value_type account,
std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<DIDSetBuilder>(ttDID_SET, account, sequence, fee)
{
}
DIDSetBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttDID_SET)
{
throw std::runtime_error("Invalid transaction type for DIDSetBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfDIDDocument (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DIDSetBuilder&
setDIDDocument(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfDIDDocument] = value;
return *this;
}
/**
* Set sfURI (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DIDSetBuilder&
setURI(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfURI] = value;
return *this;
}
/**
* Set sfData (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DIDSetBuilder&
setData(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfData] = value;
return *this;
}
/**
* Build and return the completed DIDSet wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
DIDSet
build()
{
return DIDSet(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,134 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class DelegateSetBuilder;
/**
* Transaction: DelegateSet
* Type: ttDELEGATE_SET (64)
* Delegable: Delegation::notDelegable
* Amendment: featurePermissionDelegationV1_1
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use DelegateSetBuilder to construct new transactions.
*/
class DelegateSet : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttDELEGATE_SET;
/**
* Construct a DelegateSet transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit DelegateSet(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for DelegateSet");
}
}
// Transaction-specific field getters
/**
* Get sfAuthorize (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getAuthorize() const
{
return this->tx_.at(sfAuthorize);
}
/**
* Get sfPermissions (soeREQUIRED)
* Note: This is an untyped field
*/
[[nodiscard]]
STArray const&
getPermissions() const
{
return this->tx_.getFieldArray(sfPermissions);
}
};
/**
* Builder for DelegateSet transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class DelegateSetBuilder : public TransactionBuilderBase<DelegateSetBuilder>
{
public:
DelegateSetBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ACCOUNT::type::value_type> const& authorize, STArray const& permissions, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<DelegateSetBuilder>(ttDELEGATE_SET, account, sequence, fee)
{
setAuthorize(authorize);
setPermissions(permissions);
}
DelegateSetBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttDELEGATE_SET)
{
throw std::runtime_error("Invalid transaction type for DelegateSetBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfAuthorize (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DelegateSetBuilder&
setAuthorize(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAuthorize] = value;
return *this;
}
/**
* Set sfPermissions (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
DelegateSetBuilder&
setPermissions(STArray const& value)
{
object_.setFieldArray(sfPermissions, value);
return *this;
}
/**
* Build and return the completed DelegateSet wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
DelegateSet
build()
{
return DelegateSet(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,214 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class DepositPreauthBuilder;
/**
* Transaction: DepositPreauth
* Type: ttDEPOSIT_PREAUTH (19)
* Delegable: Delegation::delegable
* Amendment: uint256{}
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use DepositPreauthBuilder to construct new transactions.
*/
class DepositPreauth : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttDEPOSIT_PREAUTH;
/**
* Construct a DepositPreauth transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit DepositPreauth(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for DepositPreauth");
}
}
// Transaction-specific field getters
/**
* Get sfAuthorize (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getAuthorize() const
{
if (hasAuthorize())
{
return this->tx_.at(sfAuthorize);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasAuthorize() const
{
return this->tx_.isFieldPresent(sfAuthorize);
}
/**
* Get sfUnauthorize (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getUnauthorize() const
{
if (hasUnauthorize())
{
return this->tx_.at(sfUnauthorize);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasUnauthorize() const
{
return this->tx_.isFieldPresent(sfUnauthorize);
}
/**
* Get sfAuthorizeCredentials (soeOPTIONAL)
* Note: This is an untyped field
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getAuthorizeCredentials() const
{
if (this->tx_.isFieldPresent(sfAuthorizeCredentials))
return this->tx_.getFieldArray(sfAuthorizeCredentials);
return std::nullopt;
}
[[nodiscard]]
bool
hasAuthorizeCredentials() const
{
return this->tx_.isFieldPresent(sfAuthorizeCredentials);
}
/**
* Get sfUnauthorizeCredentials (soeOPTIONAL)
* Note: This is an untyped field
*/
[[nodiscard]]
std::optional<std::reference_wrapper<STArray const>>
getUnauthorizeCredentials() const
{
if (this->tx_.isFieldPresent(sfUnauthorizeCredentials))
return this->tx_.getFieldArray(sfUnauthorizeCredentials);
return std::nullopt;
}
[[nodiscard]]
bool
hasUnauthorizeCredentials() const
{
return this->tx_.isFieldPresent(sfUnauthorizeCredentials);
}
};
/**
* Builder for DepositPreauth transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class DepositPreauthBuilder : public TransactionBuilderBase<DepositPreauthBuilder>
{
public:
DepositPreauthBuilder(SF_ACCOUNT::type::value_type account,
std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<DepositPreauthBuilder>(ttDEPOSIT_PREAUTH, account, sequence, fee)
{
}
DepositPreauthBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttDEPOSIT_PREAUTH)
{
throw std::runtime_error("Invalid transaction type for DepositPreauthBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfAuthorize (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setAuthorize(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfAuthorize] = value;
return *this;
}
/**
* Set sfUnauthorize (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setUnauthorize(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfUnauthorize] = value;
return *this;
}
/**
* Set sfAuthorizeCredentials (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setAuthorizeCredentials(STArray const& value)
{
object_.setFieldArray(sfAuthorizeCredentials, value);
return *this;
}
/**
* Set sfUnauthorizeCredentials (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DepositPreauthBuilder&
setUnauthorizeCredentials(STArray const& value)
{
object_.setFieldArray(sfUnauthorizeCredentials, value);
return *this;
}
/**
* Build and return the completed DepositPreauth wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
DepositPreauth
build()
{
return DepositPreauth(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,134 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class EnableAmendmentBuilder;
/**
* Transaction: EnableAmendment
* Type: ttAMENDMENT (100)
* Delegable: Delegation::notDelegable
* Amendment: uint256{}
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use EnableAmendmentBuilder to construct new transactions.
*/
class EnableAmendment : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttAMENDMENT;
/**
* Construct a EnableAmendment transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit EnableAmendment(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for EnableAmendment");
}
}
// Transaction-specific field getters
/**
* Get sfLedgerSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getLedgerSequence() const
{
return this->tx_.at(sfLedgerSequence);
}
/**
* Get sfAmendment (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getAmendment() const
{
return this->tx_.at(sfAmendment);
}
};
/**
* Builder for EnableAmendment transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class EnableAmendmentBuilder : public TransactionBuilderBase<EnableAmendmentBuilder>
{
public:
EnableAmendmentBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT32::type::value_type> const& ledgerSequence, std::decay_t<typename SF_UINT256::type::value_type> const& amendment, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<EnableAmendmentBuilder>(ttAMENDMENT, account, sequence, fee)
{
setLedgerSequence(ledgerSequence);
setAmendment(amendment);
}
EnableAmendmentBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttAMENDMENT)
{
throw std::runtime_error("Invalid transaction type for EnableAmendmentBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfLedgerSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EnableAmendmentBuilder&
setLedgerSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfLedgerSequence] = value;
return *this;
}
/**
* Set sfAmendment (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EnableAmendmentBuilder&
setAmendment(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfAmendment] = value;
return *this;
}
/**
* Build and return the completed EnableAmendment wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
EnableAmendment
build()
{
return EnableAmendment(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,134 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class EscrowCancelBuilder;
/**
* Transaction: EscrowCancel
* Type: ttESCROW_CANCEL (4)
* Delegable: Delegation::delegable
* Amendment: uint256{}
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use EscrowCancelBuilder to construct new transactions.
*/
class EscrowCancel : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttESCROW_CANCEL;
/**
* Construct a EscrowCancel transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit EscrowCancel(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for EscrowCancel");
}
}
// Transaction-specific field getters
/**
* Get sfOwner (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getOwner() const
{
return this->tx_.at(sfOwner);
}
/**
* Get sfOfferSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getOfferSequence() const
{
return this->tx_.at(sfOfferSequence);
}
};
/**
* Builder for EscrowCancel transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class EscrowCancelBuilder : public TransactionBuilderBase<EscrowCancelBuilder>
{
public:
EscrowCancelBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ACCOUNT::type::value_type> const& owner, std::decay_t<typename SF_UINT32::type::value_type> const& offerSequence, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<EscrowCancelBuilder>(ttESCROW_CANCEL, account, sequence, fee)
{
setOwner(owner);
setOfferSequence(offerSequence);
}
EscrowCancelBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttESCROW_CANCEL)
{
throw std::runtime_error("Invalid transaction type for EscrowCancelBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfOwner (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowCancelBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Set sfOfferSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowCancelBuilder&
setOfferSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfOfferSequence] = value;
return *this;
}
/**
* Build and return the completed EscrowCancel wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
EscrowCancel
build()
{
return EscrowCancel(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,264 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class EscrowCreateBuilder;
/**
* Transaction: EscrowCreate
* Type: ttESCROW_CREATE (1)
* Delegable: Delegation::delegable
* Amendment: uint256{}
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use EscrowCreateBuilder to construct new transactions.
*/
class EscrowCreate : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttESCROW_CREATE;
/**
* Construct a EscrowCreate transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit EscrowCreate(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for EscrowCreate");
}
}
// Transaction-specific field getters
/**
* Get sfDestination (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getDestination() const
{
return this->tx_.at(sfDestination);
}
/**
* Get sfAmount (soeREQUIRED)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getAmount() const
{
return this->tx_.at(sfAmount);
}
/**
* Get sfCondition (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getCondition() const
{
if (hasCondition())
{
return this->tx_.at(sfCondition);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasCondition() const
{
return this->tx_.isFieldPresent(sfCondition);
}
/**
* Get sfCancelAfter (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getCancelAfter() const
{
if (hasCancelAfter())
{
return this->tx_.at(sfCancelAfter);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasCancelAfter() const
{
return this->tx_.isFieldPresent(sfCancelAfter);
}
/**
* Get sfFinishAfter (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getFinishAfter() const
{
if (hasFinishAfter())
{
return this->tx_.at(sfFinishAfter);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasFinishAfter() const
{
return this->tx_.isFieldPresent(sfFinishAfter);
}
/**
* Get sfDestinationTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getDestinationTag() const
{
if (hasDestinationTag())
{
return this->tx_.at(sfDestinationTag);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasDestinationTag() const
{
return this->tx_.isFieldPresent(sfDestinationTag);
}
};
/**
* Builder for EscrowCreate transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class EscrowCreateBuilder : public TransactionBuilderBase<EscrowCreateBuilder>
{
public:
EscrowCreateBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ACCOUNT::type::value_type> const& destination, std::decay_t<typename SF_AMOUNT::type::value_type> const& amount, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<EscrowCreateBuilder>(ttESCROW_CREATE, account, sequence, fee)
{
setDestination(destination);
setAmount(amount);
}
EscrowCreateBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttESCROW_CREATE)
{
throw std::runtime_error("Invalid transaction type for EscrowCreateBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfDestination (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowCreateBuilder&
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfDestination] = value;
return *this;
}
/**
* Set sfAmount (soeREQUIRED)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
* @return Reference to this builder for method chaining.
*/
EscrowCreateBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfCondition (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowCreateBuilder&
setCondition(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfCondition] = value;
return *this;
}
/**
* Set sfCancelAfter (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowCreateBuilder&
setCancelAfter(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfCancelAfter] = value;
return *this;
}
/**
* Set sfFinishAfter (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowCreateBuilder&
setFinishAfter(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfFinishAfter] = value;
return *this;
}
/**
* Set sfDestinationTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowCreateBuilder&
setDestinationTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfDestinationTag] = value;
return *this;
}
/**
* Build and return the completed EscrowCreate wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
EscrowCreate
build()
{
return EscrowCreate(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,230 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class EscrowFinishBuilder;
/**
* Transaction: EscrowFinish
* Type: ttESCROW_FINISH (2)
* Delegable: Delegation::delegable
* Amendment: uint256{}
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use EscrowFinishBuilder to construct new transactions.
*/
class EscrowFinish : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttESCROW_FINISH;
/**
* Construct a EscrowFinish transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit EscrowFinish(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for EscrowFinish");
}
}
// Transaction-specific field getters
/**
* Get sfOwner (soeREQUIRED)
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getOwner() const
{
return this->tx_.at(sfOwner);
}
/**
* Get sfOfferSequence (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT32::type::value_type
getOfferSequence() const
{
return this->tx_.at(sfOfferSequence);
}
/**
* Get sfFulfillment (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getFulfillment() const
{
if (hasFulfillment())
{
return this->tx_.at(sfFulfillment);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasFulfillment() const
{
return this->tx_.isFieldPresent(sfFulfillment);
}
/**
* Get sfCondition (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getCondition() const
{
if (hasCondition())
{
return this->tx_.at(sfCondition);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasCondition() const
{
return this->tx_.isFieldPresent(sfCondition);
}
/**
* Get sfCredentialIDs (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VECTOR256::type::value_type>
getCredentialIDs() const
{
if (hasCredentialIDs())
{
return this->tx_.at(sfCredentialIDs);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasCredentialIDs() const
{
return this->tx_.isFieldPresent(sfCredentialIDs);
}
};
/**
* Builder for EscrowFinish transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class EscrowFinishBuilder : public TransactionBuilderBase<EscrowFinishBuilder>
{
public:
EscrowFinishBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_ACCOUNT::type::value_type> const& owner, std::decay_t<typename SF_UINT32::type::value_type> const& offerSequence, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<EscrowFinishBuilder>(ttESCROW_FINISH, account, sequence, fee)
{
setOwner(owner);
setOfferSequence(offerSequence);
}
EscrowFinishBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttESCROW_FINISH)
{
throw std::runtime_error("Invalid transaction type for EscrowFinishBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfOwner (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowFinishBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Set sfOfferSequence (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
EscrowFinishBuilder&
setOfferSequence(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfOfferSequence] = value;
return *this;
}
/**
* Set sfFulfillment (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowFinishBuilder&
setFulfillment(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfFulfillment] = value;
return *this;
}
/**
* Set sfCondition (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowFinishBuilder&
setCondition(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfCondition] = value;
return *this;
}
/**
* Set sfCredentialIDs (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
EscrowFinishBuilder&
setCredentialIDs(std::decay_t<typename SF_VECTOR256::type::value_type> const& value)
{
object_[sfCredentialIDs] = value;
return *this;
}
/**
* Build and return the completed EscrowFinish wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
EscrowFinish
build()
{
return EscrowFinish(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,144 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class LedgerStateFixBuilder;
/**
* Transaction: LedgerStateFix
* Type: ttLEDGER_STATE_FIX (53)
* Delegable: Delegation::delegable
* Amendment: fixNFTokenPageLinks
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use LedgerStateFixBuilder to construct new transactions.
*/
class LedgerStateFix : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttLEDGER_STATE_FIX;
/**
* Construct a LedgerStateFix transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit LedgerStateFix(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for LedgerStateFix");
}
}
// Transaction-specific field getters
/**
* Get sfLedgerFixType (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT16::type::value_type
getLedgerFixType() const
{
return this->tx_.at(sfLedgerFixType);
}
/**
* Get sfOwner (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getOwner() const
{
if (hasOwner())
{
return this->tx_.at(sfOwner);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasOwner() const
{
return this->tx_.isFieldPresent(sfOwner);
}
};
/**
* Builder for LedgerStateFix transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class LedgerStateFixBuilder : public TransactionBuilderBase<LedgerStateFixBuilder>
{
public:
LedgerStateFixBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT16::type::value_type> const& ledgerFixType, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<LedgerStateFixBuilder>(ttLEDGER_STATE_FIX, account, sequence, fee)
{
setLedgerFixType(ledgerFixType);
}
LedgerStateFixBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttLEDGER_STATE_FIX)
{
throw std::runtime_error("Invalid transaction type for LedgerStateFixBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfLedgerFixType (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LedgerStateFixBuilder&
setLedgerFixType(std::decay_t<typename SF_UINT16::type::value_type> const& value)
{
object_[sfLedgerFixType] = value;
return *this;
}
/**
* Set sfOwner (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LedgerStateFixBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* Build and return the completed LedgerStateFix wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
LedgerStateFix
build()
{
return LedgerStateFix(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,156 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class LoanBrokerCoverClawbackBuilder;
/**
* Transaction: LoanBrokerCoverClawback
* Type: ttLOAN_BROKER_COVER_CLAWBACK (78)
* Delegable: Delegation::delegable
* Amendment: featureLendingProtocol
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use LoanBrokerCoverClawbackBuilder to construct new transactions.
*/
class LoanBrokerCoverClawback : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttLOAN_BROKER_COVER_CLAWBACK;
/**
* Construct a LoanBrokerCoverClawback transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit LoanBrokerCoverClawback(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerCoverClawback");
}
}
// Transaction-specific field getters
/**
* Get sfLoanBrokerID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getLoanBrokerID() const
{
if (hasLoanBrokerID())
{
return this->tx_.at(sfLoanBrokerID);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasLoanBrokerID() const
{
return this->tx_.isFieldPresent(sfLoanBrokerID);
}
/**
* Get sfAmount (soeOPTIONAL)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getAmount() const
{
if (hasAmount())
{
return this->tx_.at(sfAmount);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasAmount() const
{
return this->tx_.isFieldPresent(sfAmount);
}
};
/**
* Builder for LoanBrokerCoverClawback transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class LoanBrokerCoverClawbackBuilder : public TransactionBuilderBase<LoanBrokerCoverClawbackBuilder>
{
public:
LoanBrokerCoverClawbackBuilder(SF_ACCOUNT::type::value_type account,
std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<LoanBrokerCoverClawbackBuilder>(ttLOAN_BROKER_COVER_CLAWBACK, account, sequence, fee)
{
}
LoanBrokerCoverClawbackBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttLOAN_BROKER_COVER_CLAWBACK)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerCoverClawbackBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfLoanBrokerID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LoanBrokerCoverClawbackBuilder&
setLoanBrokerID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfLoanBrokerID] = value;
return *this;
}
/**
* Set sfAmount (soeOPTIONAL)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
* @return Reference to this builder for method chaining.
*/
LoanBrokerCoverClawbackBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Build and return the completed LoanBrokerCoverClawback wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
LoanBrokerCoverClawback
build()
{
return LoanBrokerCoverClawback(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,136 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class LoanBrokerCoverDepositBuilder;
/**
* Transaction: LoanBrokerCoverDeposit
* Type: ttLOAN_BROKER_COVER_DEPOSIT (76)
* Delegable: Delegation::delegable
* Amendment: featureLendingProtocol
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use LoanBrokerCoverDepositBuilder to construct new transactions.
*/
class LoanBrokerCoverDeposit : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttLOAN_BROKER_COVER_DEPOSIT;
/**
* Construct a LoanBrokerCoverDeposit transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit LoanBrokerCoverDeposit(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerCoverDeposit");
}
}
// Transaction-specific field getters
/**
* Get sfLoanBrokerID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getLoanBrokerID() const
{
return this->tx_.at(sfLoanBrokerID);
}
/**
* Get sfAmount (soeREQUIRED)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getAmount() const
{
return this->tx_.at(sfAmount);
}
};
/**
* Builder for LoanBrokerCoverDeposit transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class LoanBrokerCoverDepositBuilder : public TransactionBuilderBase<LoanBrokerCoverDepositBuilder>
{
public:
LoanBrokerCoverDepositBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT256::type::value_type> const& loanBrokerID, std::decay_t<typename SF_AMOUNT::type::value_type> const& amount, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<LoanBrokerCoverDepositBuilder>(ttLOAN_BROKER_COVER_DEPOSIT, account, sequence, fee)
{
setLoanBrokerID(loanBrokerID);
setAmount(amount);
}
LoanBrokerCoverDepositBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttLOAN_BROKER_COVER_DEPOSIT)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerCoverDepositBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfLoanBrokerID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerCoverDepositBuilder&
setLoanBrokerID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfLoanBrokerID] = value;
return *this;
}
/**
* Set sfAmount (soeREQUIRED)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
* @return Reference to this builder for method chaining.
*/
LoanBrokerCoverDepositBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Build and return the completed LoanBrokerCoverDeposit wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
LoanBrokerCoverDeposit
build()
{
return LoanBrokerCoverDeposit(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,200 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class LoanBrokerCoverWithdrawBuilder;
/**
* Transaction: LoanBrokerCoverWithdraw
* Type: ttLOAN_BROKER_COVER_WITHDRAW (77)
* Delegable: Delegation::delegable
* Amendment: featureLendingProtocol
* Privileges: mayAuthorizeMPT
*
* Immutable wrapper around STTx providing type-safe field access.
* Use LoanBrokerCoverWithdrawBuilder to construct new transactions.
*/
class LoanBrokerCoverWithdraw : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttLOAN_BROKER_COVER_WITHDRAW;
/**
* Construct a LoanBrokerCoverWithdraw transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit LoanBrokerCoverWithdraw(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerCoverWithdraw");
}
}
// Transaction-specific field getters
/**
* Get sfLoanBrokerID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getLoanBrokerID() const
{
return this->tx_.at(sfLoanBrokerID);
}
/**
* Get sfAmount (soeREQUIRED)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
*/
[[nodiscard]]
SF_AMOUNT::type::value_type
getAmount() const
{
return this->tx_.at(sfAmount);
}
/**
* Get sfDestination (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getDestination() const
{
if (hasDestination())
{
return this->tx_.at(sfDestination);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasDestination() const
{
return this->tx_.isFieldPresent(sfDestination);
}
/**
* Get sfDestinationTag (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getDestinationTag() const
{
if (hasDestinationTag())
{
return this->tx_.at(sfDestinationTag);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasDestinationTag() const
{
return this->tx_.isFieldPresent(sfDestinationTag);
}
};
/**
* Builder for LoanBrokerCoverWithdraw transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class LoanBrokerCoverWithdrawBuilder : public TransactionBuilderBase<LoanBrokerCoverWithdrawBuilder>
{
public:
LoanBrokerCoverWithdrawBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT256::type::value_type> const& loanBrokerID, std::decay_t<typename SF_AMOUNT::type::value_type> const& amount, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<LoanBrokerCoverWithdrawBuilder>(ttLOAN_BROKER_COVER_WITHDRAW, account, sequence, fee)
{
setLoanBrokerID(loanBrokerID);
setAmount(amount);
}
LoanBrokerCoverWithdrawBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttLOAN_BROKER_COVER_WITHDRAW)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerCoverWithdrawBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfLoanBrokerID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerCoverWithdrawBuilder&
setLoanBrokerID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfLoanBrokerID] = value;
return *this;
}
/**
* Set sfAmount (soeREQUIRED)
* Note: This field supports MPT (Multi-Purpose Token) amounts.
* @return Reference to this builder for method chaining.
*/
LoanBrokerCoverWithdrawBuilder&
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfAmount] = value;
return *this;
}
/**
* Set sfDestination (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LoanBrokerCoverWithdrawBuilder&
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfDestination] = value;
return *this;
}
/**
* Set sfDestinationTag (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LoanBrokerCoverWithdrawBuilder&
setDestinationTag(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfDestinationTag] = value;
return *this;
}
/**
* Build and return the completed LoanBrokerCoverWithdraw wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
LoanBrokerCoverWithdraw
build()
{
return LoanBrokerCoverWithdraw(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,112 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class LoanBrokerDeleteBuilder;
/**
* Transaction: LoanBrokerDelete
* Type: ttLOAN_BROKER_DELETE (75)
* Delegable: Delegation::delegable
* Amendment: featureLendingProtocol
* Privileges: mustDeleteAcct | mayAuthorizeMPT
*
* Immutable wrapper around STTx providing type-safe field access.
* Use LoanBrokerDeleteBuilder to construct new transactions.
*/
class LoanBrokerDelete : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttLOAN_BROKER_DELETE;
/**
* Construct a LoanBrokerDelete transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit LoanBrokerDelete(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerDelete");
}
}
// Transaction-specific field getters
/**
* Get sfLoanBrokerID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getLoanBrokerID() const
{
return this->tx_.at(sfLoanBrokerID);
}
};
/**
* Builder for LoanBrokerDelete transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class LoanBrokerDeleteBuilder : public TransactionBuilderBase<LoanBrokerDeleteBuilder>
{
public:
LoanBrokerDeleteBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT256::type::value_type> const& loanBrokerID, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<LoanBrokerDeleteBuilder>(ttLOAN_BROKER_DELETE, account, sequence, fee)
{
setLoanBrokerID(loanBrokerID);
}
LoanBrokerDeleteBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttLOAN_BROKER_DELETE)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerDeleteBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfLoanBrokerID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerDeleteBuilder&
setLoanBrokerID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfLoanBrokerID] = value;
return *this;
}
/**
* Build and return the completed LoanBrokerDelete wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
LoanBrokerDelete
build()
{
return LoanBrokerDelete(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,304 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class LoanBrokerSetBuilder;
/**
* Transaction: LoanBrokerSet
* Type: ttLOAN_BROKER_SET (74)
* Delegable: Delegation::delegable
* Amendment: featureLendingProtocol
* Privileges: createPseudoAcct | mayAuthorizeMPT
*
* Immutable wrapper around STTx providing type-safe field access.
* Use LoanBrokerSetBuilder to construct new transactions.
*/
class LoanBrokerSet : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttLOAN_BROKER_SET;
/**
* Construct a LoanBrokerSet transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit LoanBrokerSet(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerSet");
}
}
// Transaction-specific field getters
/**
* Get sfVaultID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getVaultID() const
{
return this->tx_.at(sfVaultID);
}
/**
* Get sfLoanBrokerID (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getLoanBrokerID() const
{
if (hasLoanBrokerID())
{
return this->tx_.at(sfLoanBrokerID);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasLoanBrokerID() const
{
return this->tx_.isFieldPresent(sfLoanBrokerID);
}
/**
* Get sfData (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getData() const
{
if (hasData())
{
return this->tx_.at(sfData);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasData() const
{
return this->tx_.isFieldPresent(sfData);
}
/**
* Get sfManagementFeeRate (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT16::type::value_type>
getManagementFeeRate() const
{
if (hasManagementFeeRate())
{
return this->tx_.at(sfManagementFeeRate);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasManagementFeeRate() const
{
return this->tx_.isFieldPresent(sfManagementFeeRate);
}
/**
* Get sfDebtMaximum (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_NUMBER::type::value_type>
getDebtMaximum() const
{
if (hasDebtMaximum())
{
return this->tx_.at(sfDebtMaximum);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasDebtMaximum() const
{
return this->tx_.isFieldPresent(sfDebtMaximum);
}
/**
* Get sfCoverRateMinimum (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getCoverRateMinimum() const
{
if (hasCoverRateMinimum())
{
return this->tx_.at(sfCoverRateMinimum);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasCoverRateMinimum() const
{
return this->tx_.isFieldPresent(sfCoverRateMinimum);
}
/**
* Get sfCoverRateLiquidation (soeOPTIONAL)
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getCoverRateLiquidation() const
{
if (hasCoverRateLiquidation())
{
return this->tx_.at(sfCoverRateLiquidation);
}
return std::nullopt;
}
[[nodiscard]]
bool
hasCoverRateLiquidation() const
{
return this->tx_.isFieldPresent(sfCoverRateLiquidation);
}
};
/**
* Builder for LoanBrokerSet transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class LoanBrokerSetBuilder : public TransactionBuilderBase<LoanBrokerSetBuilder>
{
public:
LoanBrokerSetBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT256::type::value_type> const& vaultID, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<LoanBrokerSetBuilder>(ttLOAN_BROKER_SET, account, sequence, fee)
{
setVaultID(vaultID);
}
LoanBrokerSetBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttLOAN_BROKER_SET)
{
throw std::runtime_error("Invalid transaction type for LoanBrokerSetBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfVaultID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanBrokerSetBuilder&
setVaultID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfVaultID] = value;
return *this;
}
/**
* Set sfLoanBrokerID (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LoanBrokerSetBuilder&
setLoanBrokerID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfLoanBrokerID] = value;
return *this;
}
/**
* Set sfData (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LoanBrokerSetBuilder&
setData(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfData] = value;
return *this;
}
/**
* Set sfManagementFeeRate (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LoanBrokerSetBuilder&
setManagementFeeRate(std::decay_t<typename SF_UINT16::type::value_type> const& value)
{
object_[sfManagementFeeRate] = value;
return *this;
}
/**
* Set sfDebtMaximum (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LoanBrokerSetBuilder&
setDebtMaximum(std::decay_t<typename SF_NUMBER::type::value_type> const& value)
{
object_[sfDebtMaximum] = value;
return *this;
}
/**
* Set sfCoverRateMinimum (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LoanBrokerSetBuilder&
setCoverRateMinimum(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfCoverRateMinimum] = value;
return *this;
}
/**
* Set sfCoverRateLiquidation (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
LoanBrokerSetBuilder&
setCoverRateLiquidation(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfCoverRateLiquidation] = value;
return *this;
}
/**
* Build and return the completed LoanBrokerSet wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
LoanBrokerSet
build()
{
return LoanBrokerSet(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,112 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class LoanDeleteBuilder;
/**
* Transaction: LoanDelete
* Type: ttLOAN_DELETE (81)
* Delegable: Delegation::delegable
* Amendment: featureLendingProtocol
* Privileges: noPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use LoanDeleteBuilder to construct new transactions.
*/
class LoanDelete : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttLOAN_DELETE;
/**
* Construct a LoanDelete transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit LoanDelete(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for LoanDelete");
}
}
// Transaction-specific field getters
/**
* Get sfLoanID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getLoanID() const
{
return this->tx_.at(sfLoanID);
}
};
/**
* Builder for LoanDelete transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class LoanDeleteBuilder : public TransactionBuilderBase<LoanDeleteBuilder>
{
public:
LoanDeleteBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT256::type::value_type> const& loanID, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<LoanDeleteBuilder>(ttLOAN_DELETE, account, sequence, fee)
{
setLoanID(loanID);
}
LoanDeleteBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttLOAN_DELETE)
{
throw std::runtime_error("Invalid transaction type for LoanDeleteBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfLoanID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanDeleteBuilder&
setLoanID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfLoanID] = value;
return *this;
}
/**
* Build and return the completed LoanDelete wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
LoanDelete
build()
{
return LoanDelete(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

View File

@@ -1,112 +0,0 @@
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
// Forward declaration
class LoanManageBuilder;
/**
* Transaction: LoanManage
* Type: ttLOAN_MANAGE (82)
* Delegable: Delegation::delegable
* Amendment: featureLendingProtocol
* Privileges: mayModifyVault
*
* Immutable wrapper around STTx providing type-safe field access.
* Use LoanManageBuilder to construct new transactions.
*/
class LoanManage : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttLOAN_MANAGE;
/**
* Construct a LoanManage transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit LoanManage(STTx const& tx)
: TransactionBase(tx)
{
// Verify transaction type
if (tx.getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for LoanManage");
}
}
// Transaction-specific field getters
/**
* Get sfLoanID (soeREQUIRED)
*/
[[nodiscard]]
SF_UINT256::type::value_type
getLoanID() const
{
return this->tx_.at(sfLoanID);
}
};
/**
* Builder for LoanManage transactions.
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class LoanManageBuilder : public TransactionBuilderBase<LoanManageBuilder>
{
public:
LoanManageBuilder(SF_ACCOUNT::type::value_type account,
std::decay_t<typename SF_UINT256::type::value_type> const& loanID, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<LoanManageBuilder>(ttLOAN_MANAGE, account, sequence, fee)
{
setLoanID(loanID);
}
LoanManageBuilder(STTx const& tx)
{
if (tx.getTxnType() != ttLOAN_MANAGE)
{
throw std::runtime_error("Invalid transaction type for LoanManageBuilder");
}
object_ = tx;
}
// Transaction-specific field setters
/**
* Set sfLoanID (soeREQUIRED)
* @return Reference to this builder for method chaining.
*/
LoanManageBuilder&
setLoanID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfLoanID] = value;
return *this;
}
/**
* Build and return the completed LoanManage wrapper.
* @return The constructed transaction wrapper.
* @throws std::runtime_error if the JSON cannot be parsed into a valid transaction.
*/
LoanManage
build()
{
return LoanManage(STTx(std::move(object_)));
}
};
} // namespace xrpl::transactions

Some files were not shown because too many files have changed in this diff Show More