mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-12 09:40:20 +00:00
Compare commits
11 Commits
mvadari/re
...
bthomee/jq
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be95c2cdf8 | ||
|
|
a929a6a286 | ||
|
|
06581f0041 | ||
|
|
801c4b95a7 | ||
|
|
8f67a2a1cc | ||
|
|
77aa8715f0 | ||
|
|
e67a980849 | ||
|
|
5771c38406 | ||
|
|
ae1b5b6bac | ||
|
|
ecd0136844 | ||
|
|
02f20331d5 |
53
.clang-tidy
53
.clang-tidy
@@ -9,48 +9,101 @@ Checks: "-*,
|
||||
|
||||
cppcoreguidelines-*,
|
||||
-cppcoreguidelines-avoid-c-arrays,
|
||||
-cppcoreguidelines-avoid-capturing-lambda-coroutines,
|
||||
-cppcoreguidelines-avoid-const-or-ref-data-members,
|
||||
-cppcoreguidelines-avoid-do-while,
|
||||
-cppcoreguidelines-avoid-goto,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||
-cppcoreguidelines-avoid-reference-coroutine-parameters,
|
||||
-cppcoreguidelines-c-copy-assignment-signature,
|
||||
-cppcoreguidelines-explicit-virtual-functions,
|
||||
-cppcoreguidelines-interfaces-global-init,
|
||||
-cppcoreguidelines-macro-to-enum,
|
||||
-cppcoreguidelines-macro-usage,
|
||||
-cppcoreguidelines-missing-std-forward,
|
||||
-cppcoreguidelines-narrowing-conversions,
|
||||
-cppcoreguidelines-no-malloc,
|
||||
-cppcoreguidelines-noexcept-destructor,
|
||||
-cppcoreguidelines-noexcept-move-operations,
|
||||
-cppcoreguidelines-noexcept-swap,
|
||||
-cppcoreguidelines-non-private-member-variables-in-classes,
|
||||
-cppcoreguidelines-owning-memory,
|
||||
-cppcoreguidelines-prefer-member-initializer,
|
||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
|
||||
-cppcoreguidelines-pro-bounds-constant-array-index,
|
||||
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
-cppcoreguidelines-pro-type-const-cast,
|
||||
-cppcoreguidelines-pro-type-cstyle-cast,
|
||||
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
-cppcoreguidelines-pro-type-union-access,
|
||||
-cppcoreguidelines-pro-type-vararg,
|
||||
-cppcoreguidelines-slicing,
|
||||
-cppcoreguidelines-special-member-functions,
|
||||
|
||||
llvm-namespace-comment,
|
||||
|
||||
misc-*,
|
||||
-misc-anonymous-namespace-in-header,
|
||||
-misc-confusable-identifiers,
|
||||
-misc-coroutine-hostile-raii,
|
||||
-misc-misleading-bidirectional,
|
||||
-misc-misleading-identifier,
|
||||
-misc-multiple-inheritance,
|
||||
-misc-new-delete-overloads,
|
||||
-misc-no-recursion,
|
||||
-misc-non-copyable-objects,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
-misc-override-with-different-visibility,
|
||||
-misc-predictable-rand,
|
||||
-misc-unconventional-assign-operator,
|
||||
-misc-uniqueptr-reset-release,
|
||||
-misc-unused-parameters,
|
||||
-misc-use-anonymous-namespace,
|
||||
-misc-use-internal-linkage,
|
||||
|
||||
modernize-*,
|
||||
-modernize-avoid-bind,
|
||||
-modernize-avoid-c-arrays,
|
||||
-modernize-avoid-c-style-cast,
|
||||
-modernize-avoid-setjmp-longjmp,
|
||||
-modernize-avoid-variadic-functions,
|
||||
-modernize-deprecated-ios-base-aliases,
|
||||
-modernize-loop-convert,
|
||||
-modernize-macro-to-enum,
|
||||
-modernize-min-max-use-initializer-list,
|
||||
-modernize-raw-string-literal,
|
||||
-modernize-redundant-void-arg,
|
||||
-modernize-replace-auto-ptr,
|
||||
-modernize-replace-disallow-copy-and-assign-macro,
|
||||
-modernize-replace-random-shuffle,
|
||||
-modernize-return-braced-init-list,
|
||||
-modernize-shrink-to-fit,
|
||||
-modernize-unary-static-assert,
|
||||
-modernize-use-auto,
|
||||
-modernize-use-bool-literals,
|
||||
-modernize-use-constraints,
|
||||
-modernize-use-default-member-init,
|
||||
-modernize-use-integer-sign-comparison,
|
||||
-modernize-use-noexcept,
|
||||
-modernize-use-nullptr,
|
||||
-modernize-use-std-format,
|
||||
-modernize-use-std-print,
|
||||
-modernize-use-trailing-return-type,
|
||||
-modernize-use-transparent-functors,
|
||||
-modernize-use-uncaught-exceptions,
|
||||
|
||||
performance-*,
|
||||
-performance-avoid-endl,
|
||||
-performance-enum-size,
|
||||
-performance-inefficient-algorithm,
|
||||
-performance-inefficient-string-concatenation,
|
||||
-performance-no-int-to-ptr,
|
||||
-performance-noexcept-destructor,
|
||||
-performance-noexcept-move-constructor,
|
||||
-performance-noexcept-swap,
|
||||
-performance-type-promotion-in-math-fn,
|
||||
-performance-unnecessary-copy-initialization,
|
||||
-performance-unnecessary-value-param,
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ test.app > xrpl.server
|
||||
test.app > xrpl.shamap
|
||||
test.app > xrpl.tx
|
||||
test.basics > test.jtx
|
||||
test.basics > test.unit_test
|
||||
test.basics > xrpl.basics
|
||||
test.basics > xrpl.core
|
||||
test.basics > xrpld.rpc
|
||||
@@ -161,6 +162,9 @@ test.protocol > test.unit_test
|
||||
test.protocol > xrpl.basics
|
||||
test.protocol > xrpl.json
|
||||
test.protocol > xrpl.protocol
|
||||
test.resource > test.unit_test
|
||||
test.resource > xrpl.basics
|
||||
test.resource > xrpl.resource
|
||||
test.rpc > test.jtx
|
||||
test.rpc > xrpl.basics
|
||||
test.rpc > xrpl.config
|
||||
@@ -184,6 +188,12 @@ test.server > xrpld.core
|
||||
test.server > xrpl.json
|
||||
test.server > xrpl.protocol
|
||||
test.server > xrpl.server
|
||||
test.shamap > test.unit_test
|
||||
test.shamap > xrpl.basics
|
||||
test.shamap > xrpl.config
|
||||
test.shamap > xrpl.nodestore
|
||||
test.shamap > xrpl.protocol
|
||||
test.shamap > xrpl.shamap
|
||||
test.unit_test > xrpl.basics
|
||||
test.unit_test > xrpl.protocol
|
||||
tests.libxrpl > xrpl.basics
|
||||
@@ -195,7 +205,6 @@ tests.libxrpl > xrpl.net
|
||||
tests.libxrpl > xrpl.nodestore
|
||||
tests.libxrpl > xrpl.protocol
|
||||
tests.libxrpl > xrpl.protocol_autogen
|
||||
tests.libxrpl > xrpl.resource
|
||||
tests.libxrpl > xrpl.server
|
||||
tests.libxrpl > xrpl.shamap
|
||||
tests.libxrpl > xrpl.tx
|
||||
|
||||
@@ -90,19 +90,20 @@ repos:
|
||||
- repo: https://github.com/streetsidesoftware/cspell-cli
|
||||
rev: ea11f9efc0bec520073405bc30552da887ba71bc # frozen: v10.0.1
|
||||
hooks:
|
||||
- id: cspell
|
||||
name: check changed files spelling
|
||||
- id: cspell # Spell check changed files
|
||||
exclude: |
|
||||
(?x)^(
|
||||
\.cspell\.config\.yaml|
|
||||
.config/cspell.config.yaml|
|
||||
include/xrpl/protocol_autogen/(transactions|ledger_entries)/.*
|
||||
)$
|
||||
- id: cspell
|
||||
- id: cspell # Spell check the commit message
|
||||
name: check commit message spelling
|
||||
args:
|
||||
- --no-must-find-files
|
||||
- --no-progress
|
||||
- --no-summary
|
||||
- --files
|
||||
- .git/COMMIT_EDITMSG
|
||||
stages: [commit-msg]
|
||||
|
||||
- repo: local
|
||||
|
||||
2
BUILD.md
2
BUILD.md
@@ -25,7 +25,7 @@ You can verify that the required tools are installed and runnable with:
|
||||
| ----------- | --------------- |
|
||||
| GCC | 15.2 |
|
||||
| Clang | 22 |
|
||||
| Apple Clang | 21 |
|
||||
| Apple Clang | 17 |
|
||||
| MSVC | 19.44[^windows] |
|
||||
|
||||
## Operating Systems
|
||||
|
||||
@@ -17,11 +17,9 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
CLANG_TIDY_VERSION = 22
|
||||
|
||||
|
||||
def find_run_clang_tidy() -> str | None:
|
||||
for candidate in (f"run-clang-tidy-{CLANG_TIDY_VERSION}", "run-clang-tidy"):
|
||||
for candidate in ("run-clang-tidy-21", "run-clang-tidy"):
|
||||
if path := shutil.which(candidate):
|
||||
return path
|
||||
return None
|
||||
@@ -46,8 +44,8 @@ def main():
|
||||
run_clang_tidy = find_run_clang_tidy()
|
||||
if not run_clang_tidy:
|
||||
print(
|
||||
f"clang-tidy check failed: TIDY is enabled but neither "
|
||||
f"'run-clang-tidy-{CLANG_TIDY_VERSION}' nor 'run-clang-tidy' was found in PATH.",
|
||||
"clang-tidy check failed: TIDY is enabled but neither "
|
||||
"'run-clang-tidy-21' nor 'run-clang-tidy' was found in PATH.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
@@ -36,7 +36,9 @@ overrides:
|
||||
- /'[^']*'/g # single-quoted strings
|
||||
- /`[^`]*`/g # backtick strings
|
||||
suggestWords:
|
||||
- unsynched->unsynced
|
||||
- xprl->xrpl
|
||||
- xprld->xrpld # cspell: disable-line not sure what this problem is....
|
||||
- unsynched->unsynced # cspell: disable-line not sure what this problem is....
|
||||
- synched->synced
|
||||
- synch->sync
|
||||
words:
|
||||
@@ -279,8 +281,6 @@ words:
|
||||
- sles
|
||||
- soci
|
||||
- socidb
|
||||
- sponsee
|
||||
- sponsees
|
||||
- SRPMS
|
||||
- sslws
|
||||
- statsd
|
||||
@@ -294,6 +294,7 @@ words:
|
||||
- sttx
|
||||
- stvar
|
||||
- stvector
|
||||
- stxchainattestations
|
||||
- summands
|
||||
- superpeer
|
||||
- superpeers
|
||||
@@ -328,7 +329,6 @@ words:
|
||||
- unserviced
|
||||
- unshareable
|
||||
- unshares
|
||||
- unsponsored
|
||||
- unsquelch
|
||||
- unsquelched
|
||||
- unsquelching
|
||||
@@ -347,6 +347,8 @@ words:
|
||||
- writeme
|
||||
- wsrch
|
||||
- wthread
|
||||
- xbridge
|
||||
- xchain
|
||||
- ximinez
|
||||
- XMACRO
|
||||
- xrpkuwait
|
||||
15
docs/build/environment.md
vendored
15
docs/build/environment.md
vendored
@@ -33,10 +33,9 @@ with a single command and without installing anything system-wide:
|
||||
nix --experimental-features 'nix-command flakes' develop
|
||||
```
|
||||
|
||||
On **Linux**, Nix also provides the compiler (GCC); on **macOS**, it provides
|
||||
Clang. If you instead opt to use your system-wide Apple Clang (via
|
||||
`nix develop .#apple-clang`), you need to manage its version yourself (see
|
||||
below).
|
||||
On **Linux**, Nix also provides the compiler (GCC). On **macOS**, the shell uses
|
||||
your **system-wide Apple Clang** as the compiler, so you still need to manage
|
||||
its version (see below).
|
||||
|
||||
See [Using the Nix development shell](./nix.md) for installation and usage
|
||||
details, including how to select a different compiler.
|
||||
@@ -49,10 +48,10 @@ details, including how to select a different compiler.
|
||||
|
||||
### macOS: managing the Apple Clang version
|
||||
|
||||
If you use your system-wide Apple Clang on macOS (via `nix develop .#apple-clang`),
|
||||
the compiler version is whatever your installed Xcode (or Command Line Tools)
|
||||
provides. The following command should return a version greater than or equal to
|
||||
the [minimum required](#tested-compiler-versions):
|
||||
Because the Nix shell uses the system-wide Apple Clang on macOS, the compiler
|
||||
version is whatever your installed Xcode (or Command Line Tools) provides. The
|
||||
following command should return a version greater than or equal to the
|
||||
[minimum required](#tested-compiler-versions):
|
||||
|
||||
```bash
|
||||
clang --version
|
||||
|
||||
40
docs/build/nix.md
vendored
40
docs/build/nix.md
vendored
@@ -9,7 +9,7 @@ This guide explains how to use Nix to set up a reproducible development environm
|
||||
- **Reproducible environment**: Everyone gets the same versions of tools and compilers
|
||||
- **Matches CI**: The Linux CI runs in Docker images built from this exact Nix environment
|
||||
- **No system pollution**: Dependencies are isolated and don't affect your system packages
|
||||
- **Consistent compilers**: The GCC and Clang shells use the same versions as CI
|
||||
- **Multiple compiler versions**: Easily switch between different GCC and Clang versions
|
||||
- **Quick setup**: Get started with a single command
|
||||
- **Works on Linux and macOS**: Consistent experience across platforms
|
||||
|
||||
@@ -31,8 +31,8 @@ This will:
|
||||
|
||||
- Download and set up all required development tools (CMake, Ninja, Conan, etc.)
|
||||
- Configure the appropriate compiler for your platform:
|
||||
- **Linux**: GCC (provided by Nix)
|
||||
- **macOS**: Clang (provided by Nix)
|
||||
- **Linux**: GCC 15.2 (provided by Nix)
|
||||
- **macOS**: Apple Clang (your system compiler)
|
||||
|
||||
The first time you run this command, it will take a few minutes to download and build the environment. Subsequent runs will be much faster.
|
||||
|
||||
@@ -40,12 +40,12 @@ The first time you run this command, it will take a few minutes to download and
|
||||
|
||||
- **Linux**: `nix develop` gives you a shell with all the tooling necessary to
|
||||
develop xrpld and with GCC 15.2 (also provided by Nix). There are no caveats.
|
||||
- **macOS**: `nix develop` gives you a full environment too, with Clang (and
|
||||
every other tool, including Conan) provided by Nix. To use your system-wide
|
||||
Apple Clang instead, enter `nix develop .#apple-clang`. Conan has no binary in
|
||||
the Nix cache for macOS, so it is built from source the first time you enter
|
||||
the shell, which makes the initial setup slower (this is handled
|
||||
automatically; see [`nix/devshell.nix`](../../nix/devshell.nix)).
|
||||
- **macOS**: `nix develop` gives you a full environment too. The compiler is
|
||||
your system-wide Apple Clang, while every other tool — including Conan — is
|
||||
provided by Nix. Conan has no binary in the Nix cache for macOS, so it is
|
||||
built from source the first time you enter the shell, which makes the initial
|
||||
setup slower (this is handled automatically; see
|
||||
[`nix/devshell.nix`](../../nix/devshell.nix)).
|
||||
|
||||
> [!TIP]
|
||||
> To avoid typing `--experimental-features 'nix-command flakes'` every time, you can permanently enable flakes by creating `~/.config/nix/nix.conf`:
|
||||
@@ -62,9 +62,7 @@ The first time you run this command, it will take a few minutes to download and
|
||||
|
||||
### Choosing a different compiler
|
||||
|
||||
A compiler can be chosen by providing its name with the `.#` prefix, e.g. `nix develop .#clang`.
|
||||
The `.#gcc` and `.#clang` shells provide the same GCC and Clang versions used in CI
|
||||
(pinned in [`nix/packages.nix`](../../nix/packages.nix)).
|
||||
A compiler can be chosen by providing its name with the `.#` prefix, e.g. `nix develop .#gcc15`.
|
||||
Use `nix flake show` to see all the available development shells.
|
||||
|
||||
Use `nix develop .#no-compiler` to use the compiler from your system.
|
||||
@@ -72,11 +70,11 @@ Use `nix develop .#no-compiler` to use the compiler from your system.
|
||||
### Example Usage
|
||||
|
||||
```bash
|
||||
# Use GCC (same version as CI)
|
||||
nix develop .#gcc
|
||||
# Use GCC 14
|
||||
nix develop .#gcc14
|
||||
|
||||
# Use Clang (same version as CI)
|
||||
nix develop .#clang
|
||||
# Use Clang 19
|
||||
nix develop .#clang19
|
||||
|
||||
# Use default for your platform
|
||||
nix develop
|
||||
@@ -114,15 +112,7 @@ Once inside the Nix development shell, follow the standard [build instructions](
|
||||
|
||||
[direnv](https://direnv.net/) or [nix-direnv](https://github.com/nix-community/nix-direnv) can automatically activate the Nix development shell when you enter the repository directory.
|
||||
|
||||
This is also the most robust way to use the environment from **any shell** (bash, zsh, fish, …): direnv stays in your current shell and loads the environment _after_ your shell's startup files have run, so the Nix-provided tools take precedence over anything your shell configuration adds to `$PATH`.
|
||||
|
||||
The repository already ships an `.envrc` at its root that activates the Nix flake development shell, so you don't need to create one. To use it:
|
||||
|
||||
1. [Install direnv](https://direnv.net/docs/installation.html) and [hook it into your shell](https://direnv.net/docs/hook.html) (bash, zsh, fish, …). Installing [nix-direnv](https://github.com/nix-community/nix-direnv) as well is recommended: it caches the shell so that activation is near-instant after the first run.
|
||||
2. Run `direnv allow` once in the repository root. direnv will then load (and reload) the Nix development shell automatically whenever you enter the directory.
|
||||
|
||||
> [!NOTE]
|
||||
> direnv only caches the `.direnv` directory (already listed in `.gitignore`); no other repository files are affected.
|
||||
This is also the most robust way to use the environment from **any shell** (bash, zsh, fish, …): direnv stays in your current shell and loads the environment _after_ your shell's startup files have run, so the Nix-provided tools take precedence over anything your shell configuration adds to `$PATH`. To use it, install direnv for your shell, then add an `.envrc` containing `use flake` at the repository root and run `direnv allow`.
|
||||
|
||||
## Conan and Prebuilt Packages
|
||||
|
||||
|
||||
@@ -641,9 +641,6 @@ template <class T>
|
||||
T*
|
||||
SharedWeakUnion<T>::unsafeGetRawPtr() const
|
||||
{
|
||||
// tp_ packs a raw pointer together with a strength bit; recovering the
|
||||
// pointer inherently requires an integer-to-pointer cast.
|
||||
// NOLINTNEXTLINE(performance-no-int-to-ptr)
|
||||
return reinterpret_cast<T*>(tp_ & kPtrMask);
|
||||
}
|
||||
|
||||
|
||||
@@ -211,17 +211,15 @@ operator<<(Stream& s, Slice const& v)
|
||||
}
|
||||
|
||||
template <class T, std::size_t N>
|
||||
Slice
|
||||
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
|
||||
makeSlice(std::array<T, N> const& a)
|
||||
requires(std::is_same_v<T, char> || std::is_same_v<T, unsigned char>)
|
||||
{
|
||||
return Slice(a.data(), a.size());
|
||||
}
|
||||
|
||||
template <class T, class Alloc>
|
||||
Slice
|
||||
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
|
||||
makeSlice(std::vector<T, Alloc> const& v)
|
||||
requires(std::is_same_v<T, char> || std::is_same_v<T, unsigned char>)
|
||||
{
|
||||
return Slice(v.data(), v.size());
|
||||
}
|
||||
|
||||
@@ -212,13 +212,11 @@ public:
|
||||
*/
|
||||
template <class ReturnType = bool>
|
||||
auto
|
||||
insert(key_type const& key, T const& value) -> ReturnType
|
||||
requires(!IsKeyCache);
|
||||
insert(key_type const& key, T const& value) -> std::enable_if_t<!IsKeyCache, ReturnType>;
|
||||
|
||||
template <class ReturnType = bool>
|
||||
auto
|
||||
insert(key_type const& key) -> ReturnType
|
||||
requires IsKeyCache;
|
||||
insert(key_type const& key) -> std::enable_if_t<IsKeyCache, ReturnType>;
|
||||
|
||||
// VFALCO NOTE It looks like this returns a copy of the data in
|
||||
// the output parameter 'data'. This could be expensive.
|
||||
|
||||
@@ -57,10 +57,7 @@ inline TaggedCache<
|
||||
beast::insight::Collector::ptr const& collector)
|
||||
: journal_(journal)
|
||||
, clock_(clock)
|
||||
, stats_(
|
||||
name,
|
||||
[this] { collectMetrics(); },
|
||||
collector)
|
||||
, stats_(name, std::bind(&TaggedCache::collectMetrics, this), collector)
|
||||
, name_(name)
|
||||
, targetSize_(size)
|
||||
, targetAge_(expiration)
|
||||
@@ -503,8 +500,7 @@ template <
|
||||
template <class ReturnType>
|
||||
inline auto
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
insert(key_type const& key, T const& value) -> ReturnType
|
||||
requires(!IsKeyCache)
|
||||
insert(key_type const& key, T const& value) -> std::enable_if_t<!IsKeyCache, ReturnType>
|
||||
{
|
||||
static_assert(
|
||||
std::is_same_v<std::shared_ptr<T>, SharedPointerType> ||
|
||||
@@ -534,8 +530,7 @@ template <
|
||||
template <class ReturnType>
|
||||
inline auto
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
insert(key_type const& key) -> ReturnType
|
||||
requires IsKeyCache
|
||||
insert(key_type const& key) -> std::enable_if_t<IsKeyCache, ReturnType>
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
clock_type::time_point const now(clock_.now());
|
||||
|
||||
@@ -12,9 +12,8 @@ namespace xrpl {
|
||||
*/
|
||||
|
||||
template <class T>
|
||||
std::string
|
||||
std::enable_if_t<std::is_arithmetic_v<T>, std::string>
|
||||
to_string(T t) // NOLINT(readability-identifier-naming)
|
||||
requires(std::is_arithmetic_v<T>)
|
||||
{
|
||||
return std::to_string(t);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
//
|
||||
|
||||
static constexpr std::size_t kBytes = Bits / 8;
|
||||
static_assert(sizeof(data_) == kBytes);
|
||||
static_assert(sizeof(data_) == kBytes, "");
|
||||
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
@@ -280,11 +280,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
template <class Container>
|
||||
explicit BaseUInt(Container const& c)
|
||||
requires(
|
||||
template <
|
||||
class Container,
|
||||
class = std::enable_if_t<
|
||||
detail::IsContiguousContainer<Container>::value &&
|
||||
std::is_trivially_copyable_v<typename Container::value_type>)
|
||||
std::is_trivially_copyable_v<typename Container::value_type>>>
|
||||
explicit BaseUInt(Container const& c)
|
||||
{
|
||||
// Use AlwaysFalseT so the static_assert condition is dependent
|
||||
// and only triggers when this constructor template is instantiated.
|
||||
@@ -294,12 +295,13 @@ public:
|
||||
"Use base_uint::fromRaw instead.");
|
||||
}
|
||||
|
||||
template <class Container>
|
||||
template <
|
||||
class Container,
|
||||
class = std::enable_if_t<
|
||||
detail::IsContiguousContainer<Container>::value &&
|
||||
std::is_trivially_copyable_v<typename Container::value_type>>>
|
||||
static BaseUInt
|
||||
fromRaw(Container const& c)
|
||||
requires(
|
||||
detail::IsContiguousContainer<Container>::value &&
|
||||
std::is_trivially_copyable_v<typename Container::value_type>)
|
||||
{
|
||||
BaseUInt result;
|
||||
XRPL_ASSERT(
|
||||
@@ -310,11 +312,11 @@ public:
|
||||
}
|
||||
|
||||
template <class Container>
|
||||
BaseUInt&
|
||||
std::enable_if_t<
|
||||
detail::IsContiguousContainer<Container>::value &&
|
||||
std::is_trivially_copyable_v<typename Container::value_type>,
|
||||
BaseUInt&>
|
||||
operator=(Container const& c)
|
||||
requires(
|
||||
detail::IsContiguousContainer<Container>::value &&
|
||||
std::is_trivially_copyable_v<typename Container::value_type>)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
c.size() * sizeof(typename Container::value_type) == size(),
|
||||
@@ -595,7 +597,7 @@ template <std::size_t Bits, typename Tag>
|
||||
[[nodiscard]] constexpr bool
|
||||
operator==(BaseUInt<Bits, Tag> const& lhs, BaseUInt<Bits, Tag> const& rhs)
|
||||
{
|
||||
return (lhs <=> rhs) == 0; // NOLINT(modernize-use-nullptr)
|
||||
return (lhs <=> rhs) == 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
54
include/xrpl/basics/comparators.h
Normal file
54
include/xrpl/basics/comparators.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
/*
|
||||
* MSVC 2019 version 16.9.0 added [[nodiscard]] to the std comparison
|
||||
* operator() functions. boost::bimap checks that the comparator is a
|
||||
* BinaryFunction, in part by calling the function and ignoring the value.
|
||||
* These two things don't play well together. These wrapper classes simply
|
||||
* strip [[nodiscard]] from operator() for use in boost::bimap.
|
||||
*
|
||||
* See also:
|
||||
* https://www.boost.org/doc/libs/1_75_0/libs/bimap/doc/html/boost_bimap/the_tutorial/controlling_collection_types.html
|
||||
*/
|
||||
|
||||
template <class T = void>
|
||||
struct less
|
||||
{
|
||||
using result_type = bool;
|
||||
|
||||
constexpr bool
|
||||
operator()(T const& left, T const& right) const
|
||||
{
|
||||
return std::less<T>()(left, right);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T = void>
|
||||
struct equal_to
|
||||
{
|
||||
using result_type = bool;
|
||||
|
||||
constexpr bool
|
||||
operator()(T const& left, T const& right) const
|
||||
{
|
||||
return std::equal_to<T>()(left, right);
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template <class T = void>
|
||||
using less = std::less<T>;
|
||||
|
||||
template <class T = void>
|
||||
using equal_to = std::equal_to<T>;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -138,8 +138,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
ConstIterator(Iterator const& orig) : map(orig.map), ait(orig.ait), mit(orig.mit)
|
||||
ConstIterator(Iterator const& orig)
|
||||
{
|
||||
map = orig.map;
|
||||
ait = orig.ait;
|
||||
mit = orig.mit;
|
||||
}
|
||||
|
||||
const_reference
|
||||
@@ -228,11 +231,11 @@ private:
|
||||
|
||||
public:
|
||||
PartitionedUnorderedMap(std::optional<std::size_t> partitions = std::nullopt)
|
||||
{
|
||||
// Set partitions to the number of hardware threads if the parameter
|
||||
// is either empty or set to 0.
|
||||
: partitions_(
|
||||
partitions && (*partitions != 0u) ? *partitions : std::thread::hardware_concurrency())
|
||||
{
|
||||
partitions_ =
|
||||
partitions && (*partitions != 0u) ? *partitions : std::thread::hardware_concurrency();
|
||||
map_.resize(partitions_);
|
||||
XRPL_ASSERT(
|
||||
partitions_,
|
||||
|
||||
@@ -91,9 +91,8 @@ defaultPrng()
|
||||
*/
|
||||
/** @{ */
|
||||
template <class Engine, class Integral>
|
||||
Integral
|
||||
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||
randInt(Engine& engine, Integral min, Integral max)
|
||||
requires(std::is_integral_v<Integral> && detail::is_engine<Engine>::value)
|
||||
{
|
||||
XRPL_ASSERT(max > min, "xrpl::randInt : max over min inputs");
|
||||
|
||||
@@ -104,41 +103,36 @@ randInt(Engine& engine, Integral min, Integral max)
|
||||
}
|
||||
|
||||
template <class Integral>
|
||||
Integral
|
||||
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||
randInt(Integral min, Integral max)
|
||||
requires(std::is_integral_v<Integral>)
|
||||
{
|
||||
return randInt(defaultPrng(), min, max);
|
||||
}
|
||||
|
||||
template <class Engine, class Integral>
|
||||
Integral
|
||||
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||
randInt(Engine& engine, Integral max)
|
||||
requires(std::is_integral_v<Integral> && detail::is_engine<Engine>::value)
|
||||
{
|
||||
return randInt(engine, Integral(0), max);
|
||||
}
|
||||
|
||||
template <class Integral>
|
||||
Integral
|
||||
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||
randInt(Integral max)
|
||||
requires(std::is_integral_v<Integral>)
|
||||
{
|
||||
return randInt(defaultPrng(), max);
|
||||
}
|
||||
|
||||
template <class Integral, class Engine>
|
||||
Integral
|
||||
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||
randInt(Engine& engine)
|
||||
requires(std::is_integral_v<Integral> && detail::is_engine<Engine>::value)
|
||||
{
|
||||
return randInt(engine, std::numeric_limits<Integral>::max());
|
||||
}
|
||||
|
||||
template <class Integral = int>
|
||||
Integral
|
||||
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||
randInt()
|
||||
requires(std::is_integral_v<Integral>)
|
||||
{
|
||||
return randInt(defaultPrng(), std::numeric_limits<Integral>::max());
|
||||
}
|
||||
@@ -147,20 +141,19 @@ randInt()
|
||||
/** Return a random byte */
|
||||
/** @{ */
|
||||
template <class Byte, class Engine>
|
||||
Byte
|
||||
std::enable_if_t<
|
||||
(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>) &&
|
||||
detail::is_engine<Engine>::value,
|
||||
Byte>
|
||||
randByte(Engine& engine)
|
||||
requires(
|
||||
(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>) &&
|
||||
detail::is_engine<Engine>::value)
|
||||
{
|
||||
return static_cast<Byte>(randInt<Engine, std::uint32_t>(
|
||||
engine, std::numeric_limits<Byte>::min(), std::numeric_limits<Byte>::max()));
|
||||
}
|
||||
|
||||
template <class Byte = std::uint8_t>
|
||||
Byte
|
||||
std::enable_if_t<(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>), Byte>
|
||||
randByte()
|
||||
requires(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>)
|
||||
{
|
||||
return randByte<Byte>(defaultPrng());
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/beast/utility/instrumentation.h> // IWYU pragma: keep
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -17,9 +15,8 @@ concept SafeToCast = (std::is_integral_v<Src> && std::is_integral_v<Dest>) &&
|
||||
: sizeof(Dest) >= sizeof(Src));
|
||||
|
||||
template <class Dest, class Src>
|
||||
constexpr Dest
|
||||
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
|
||||
safeCast(Src s) noexcept
|
||||
requires(std::is_integral_v<Dest> && std::is_integral_v<Src>)
|
||||
{
|
||||
static_assert(
|
||||
std::is_signed_v<Dest> || std::is_unsigned_v<Src>, "Cannot cast signed to unsigned");
|
||||
@@ -31,17 +28,15 @@ safeCast(Src s) noexcept
|
||||
}
|
||||
|
||||
template <class Dest, class Src>
|
||||
constexpr Dest
|
||||
constexpr std::enable_if_t<std::is_enum_v<Dest> && std::is_integral_v<Src>, Dest>
|
||||
safeCast(Src s) noexcept
|
||||
requires(std::is_enum_v<Dest> && std::is_integral_v<Src>)
|
||||
{
|
||||
return static_cast<Dest>(safeCast<std::underlying_type_t<Dest>>(s));
|
||||
}
|
||||
|
||||
template <class Dest, class Src>
|
||||
constexpr Dest
|
||||
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_enum_v<Src>, Dest>
|
||||
safeCast(Src s) noexcept
|
||||
requires(std::is_integral_v<Dest> && std::is_enum_v<Src>)
|
||||
{
|
||||
return safeCast<Dest>(static_cast<std::underlying_type_t<Src>>(s));
|
||||
}
|
||||
@@ -51,9 +46,8 @@ safeCast(Src s) noexcept
|
||||
// underlying types become safe, it can be converted to a safe_cast.
|
||||
|
||||
template <class Dest, class Src>
|
||||
constexpr Dest
|
||||
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
|
||||
unsafeCast(Src s) noexcept
|
||||
requires(std::is_integral_v<Dest> && std::is_integral_v<Src>)
|
||||
{
|
||||
static_assert(
|
||||
!SafeToCast<Src, Dest>,
|
||||
@@ -63,17 +57,15 @@ unsafeCast(Src s) noexcept
|
||||
}
|
||||
|
||||
template <class Dest, class Src>
|
||||
constexpr Dest
|
||||
constexpr std::enable_if_t<std::is_enum_v<Dest> && std::is_integral_v<Src>, Dest>
|
||||
unsafeCast(Src s) noexcept
|
||||
requires(std::is_enum_v<Dest> && std::is_integral_v<Src>)
|
||||
{
|
||||
return static_cast<Dest>(unsafeCast<std::underlying_type_t<Dest>>(s));
|
||||
}
|
||||
|
||||
template <class Dest, class Src>
|
||||
constexpr Dest
|
||||
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_enum_v<Src>, Dest>
|
||||
unsafeCast(Src s) noexcept
|
||||
requires(std::is_integral_v<Dest> && std::is_enum_v<Src>)
|
||||
{
|
||||
return unsafeCast<Dest>(static_cast<std::underlying_type_t<Src>>(s));
|
||||
}
|
||||
|
||||
@@ -46,9 +46,11 @@ public:
|
||||
operator=(ScopeExit&&) = delete;
|
||||
|
||||
template <class EFP>
|
||||
explicit ScopeExit(EFP&& f) noexcept
|
||||
requires(
|
||||
!std::is_same_v<std::remove_cv_t<EFP>, ScopeExit> && std::is_constructible_v<EF, EFP>)
|
||||
explicit ScopeExit(
|
||||
EFP&& f,
|
||||
std::enable_if_t<
|
||||
!std::is_same_v<std::remove_cv_t<EFP>, ScopeExit> &&
|
||||
std::is_constructible_v<EF, EFP>>* = 0) noexcept
|
||||
: exitFunction_{std::forward<EFP>(f)}
|
||||
{
|
||||
static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>);
|
||||
@@ -91,9 +93,11 @@ public:
|
||||
operator=(ScopeFail&&) = delete;
|
||||
|
||||
template <class EFP>
|
||||
explicit ScopeFail(EFP&& f) noexcept
|
||||
requires(
|
||||
!std::is_same_v<std::remove_cv_t<EFP>, ScopeFail> && std::is_constructible_v<EF, EFP>)
|
||||
explicit ScopeFail(
|
||||
EFP&& f,
|
||||
std::enable_if_t<
|
||||
!std::is_same_v<std::remove_cv_t<EFP>, ScopeFail> &&
|
||||
std::is_constructible_v<EF, EFP>>* = 0) noexcept
|
||||
: exitFunction_{std::forward<EFP>(f)}
|
||||
{
|
||||
static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>);
|
||||
@@ -136,11 +140,12 @@ public:
|
||||
operator=(ScopeSuccess&&) = delete;
|
||||
|
||||
template <class EFP>
|
||||
explicit ScopeSuccess(EFP&& f) noexcept(
|
||||
std::is_nothrow_constructible_v<EF, EFP> || std::is_nothrow_constructible_v<EF, EFP&>)
|
||||
requires(
|
||||
explicit ScopeSuccess(
|
||||
EFP&& f,
|
||||
std::enable_if_t<
|
||||
!std::is_same_v<std::remove_cv_t<EFP>, ScopeSuccess> &&
|
||||
std::is_constructible_v<EF, EFP>)
|
||||
std::is_constructible_v<EF, EFP>>* =
|
||||
0) noexcept(std::is_nothrow_constructible_v<EF, EFP> || std::is_nothrow_constructible_v<EF, EFP&>)
|
||||
: exitFunction_{std::forward<EFP>(f)}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ public:
|
||||
|
||||
TaggedInteger() = default;
|
||||
|
||||
template <class OtherInt>
|
||||
explicit constexpr TaggedInteger(OtherInt value) noexcept
|
||||
requires(std::is_integral_v<OtherInt> && sizeof(OtherInt) <= sizeof(Int))
|
||||
: value_(value)
|
||||
template <
|
||||
class OtherInt,
|
||||
class = std::enable_if_t<std::is_integral_v<OtherInt> && sizeof(OtherInt) <= sizeof(Int)>>
|
||||
explicit constexpr TaggedInteger(OtherInt value) noexcept : value_(value)
|
||||
{
|
||||
static_assert(sizeof(TaggedInteger) == sizeof(Int), "tagged_integer is adding padding");
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace beast {
|
||||
|
||||
/** Expire aged container items past the specified age. */
|
||||
template <class AgedContainer, class Rep, class Period>
|
||||
std::size_t
|
||||
std::enable_if_t<IsAgedContainer<AgedContainer>::value, std::size_t>
|
||||
expire(AgedContainer& c, std::chrono::duration<Rep, Period> const& age)
|
||||
requires(IsAgedContainer<AgedContainer>::value)
|
||||
{
|
||||
std::size_t n(0);
|
||||
auto const expired(c.clock().now() - age);
|
||||
|
||||
@@ -30,19 +30,20 @@ public:
|
||||
|
||||
// Disable constructing a const_iterator from a non-const_iterator.
|
||||
// Converting between reverse and non-reverse iterators should be explicit.
|
||||
template <bool OtherIsConst, class OtherIterator>
|
||||
explicit AgedContainerIterator(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
|
||||
requires(
|
||||
template <
|
||||
bool OtherIsConst,
|
||||
class OtherIterator,
|
||||
class = std::enable_if_t<
|
||||
(!OtherIsConst || IsConst) &&
|
||||
!static_cast<bool>(std::is_same_v<Iterator, OtherIterator>))
|
||||
!static_cast<bool>(std::is_same_v<Iterator, OtherIterator>)>>
|
||||
explicit AgedContainerIterator(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
|
||||
: iter_(other.iter_)
|
||||
{
|
||||
}
|
||||
|
||||
// Disable constructing a const_iterator from a non-const_iterator.
|
||||
template <bool OtherIsConst>
|
||||
template <bool OtherIsConst, class = std::enable_if_t<!OtherIsConst || IsConst>>
|
||||
AgedContainerIterator(AgedContainerIterator<OtherIsConst, Iterator> const& other)
|
||||
requires(!OtherIsConst || IsConst)
|
||||
: iter_(other.iter_)
|
||||
{
|
||||
}
|
||||
@@ -51,8 +52,7 @@ public:
|
||||
template <bool OtherIsConst, class OtherIterator>
|
||||
auto
|
||||
operator=(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
|
||||
-> AgedContainerIterator&
|
||||
requires(!OtherIsConst || IsConst)
|
||||
-> std::enable_if_t<!OtherIsConst || IsConst, AgedContainerIterator&>
|
||||
{
|
||||
iter_ = other.iter_;
|
||||
return *this;
|
||||
|
||||
@@ -111,9 +111,10 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
template <
|
||||
class... Args,
|
||||
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
|
||||
Element(time_point const& when, Args&&... args)
|
||||
requires(std::is_constructible_v<value_type, Args...>)
|
||||
: value(std::forward<Args>(args)...), when(when)
|
||||
{
|
||||
}
|
||||
@@ -359,7 +360,6 @@ private:
|
||||
deleteElement(Element const* p)
|
||||
{
|
||||
ElementAllocatorTraits::destroy(config_.alloc(), p);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
|
||||
ElementAllocatorTraits::deallocate(config_.alloc(), const_cast<Element*>(p), 1);
|
||||
}
|
||||
|
||||
@@ -608,25 +608,35 @@ public:
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
template <class K, bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
template <
|
||||
class K,
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
at(K const& k)
|
||||
requires(MaybeMap && !MaybeMulti);
|
||||
at(K const& k);
|
||||
|
||||
template <class K, bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
template <
|
||||
class K,
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
std::conditional<IsMap, T, void*>::type const&
|
||||
at(K const& k) const
|
||||
requires(MaybeMap && !MaybeMulti);
|
||||
at(K const& k) const;
|
||||
|
||||
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
template <
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
operator[](Key const& key)
|
||||
requires(MaybeMap && !MaybeMulti);
|
||||
operator[](Key const& key);
|
||||
|
||||
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
template <
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
operator[](Key&& key)
|
||||
requires(MaybeMap && !MaybeMulti);
|
||||
operator[](Key&& key);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
@@ -760,40 +770,35 @@ public:
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti);
|
||||
insert(value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> iterator
|
||||
requires MaybeMulti;
|
||||
insert(value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>;
|
||||
|
||||
// set
|
||||
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
auto
|
||||
insert(value_type&& value) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti && !MaybeMap);
|
||||
insert(value_type&& value)
|
||||
-> std::enable_if_t<!MaybeMulti && !MaybeMap, std::pair<iterator, bool>>;
|
||||
|
||||
// multiset
|
||||
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
auto
|
||||
insert(value_type&& value) -> iterator
|
||||
requires(MaybeMulti && !MaybeMap);
|
||||
insert(value_type&& value) -> std::enable_if_t<MaybeMulti && !MaybeMap, iterator>;
|
||||
|
||||
//---
|
||||
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
auto
|
||||
insert(const_iterator hint, value_type const& value) -> iterator
|
||||
requires(!MaybeMulti);
|
||||
insert(const_iterator hint, value_type const& value) -> std::enable_if_t<!MaybeMulti, iterator>;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
iterator
|
||||
std::enable_if_t<MaybeMulti, iterator>
|
||||
insert(const_iterator /*hint*/, value_type const& value)
|
||||
requires MaybeMulti
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
return insert(value);
|
||||
@@ -802,14 +807,12 @@ public:
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
auto
|
||||
insert(const_iterator hint, value_type&& value) -> iterator
|
||||
requires(!MaybeMulti);
|
||||
insert(const_iterator hint, value_type&& value) -> std::enable_if_t<!MaybeMulti, iterator>;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
iterator
|
||||
std::enable_if_t<MaybeMulti, iterator>
|
||||
insert(const_iterator /*hint*/, value_type&& value)
|
||||
requires MaybeMulti
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
return insert(std::move(value));
|
||||
@@ -817,18 +820,20 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool MaybeMap = IsMap>
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>
|
||||
std::enable_if_t<
|
||||
MaybeMap && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
insert(P&& value)
|
||||
requires(MaybeMap && std::is_constructible_v<value_type, P &&>)
|
||||
{
|
||||
return emplace(std::forward<P>(value));
|
||||
}
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool MaybeMap = IsMap>
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>
|
||||
std::enable_if_t<
|
||||
MaybeMap && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
insert(const_iterator hint, P&& value)
|
||||
requires(MaybeMap && std::is_constructible_v<value_type, P &&>)
|
||||
{
|
||||
return emplaceHint(hint, std::forward<P>(value));
|
||||
}
|
||||
@@ -850,45 +855,46 @@ public:
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti);
|
||||
emplace(Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool MaybeMulti = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> iterator
|
||||
requires MaybeMulti;
|
||||
emplace(Args&&... args) -> std::enable_if_t<MaybeMulti, iterator>;
|
||||
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti, class... Args>
|
||||
auto
|
||||
emplaceHint(const_iterator hint, Args&&... args) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti);
|
||||
emplaceHint(const_iterator hint, Args&&... args)
|
||||
-> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool MaybeMulti = IsMulti, class... Args>
|
||||
iterator
|
||||
std::enable_if_t<MaybeMulti, iterator>
|
||||
emplaceHint(const_iterator /*hint*/, Args&&... args)
|
||||
requires MaybeMulti
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
return emplace<MaybeMulti>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// The constraint prevents erase (reverse_iterator pos) from compiling
|
||||
template <bool IsConst, class Iterator>
|
||||
// enable_if prevents erase (reverse_iterator pos) from compiling
|
||||
template <
|
||||
bool IsConst,
|
||||
class Iterator,
|
||||
class = std::enable_if_t<!IsBoostReverseIterator<Iterator>::value>>
|
||||
beast::detail::AgedContainerIterator<false, Iterator>
|
||||
erase(beast::detail::AgedContainerIterator<IsConst, Iterator> pos)
|
||||
requires(!IsBoostReverseIterator<Iterator>::value);
|
||||
erase(beast::detail::AgedContainerIterator<IsConst, Iterator> pos);
|
||||
|
||||
// The constraint prevents erase (reverse_iterator first, reverse_iterator last)
|
||||
// enable_if prevents erase (reverse_iterator first, reverse_iterator last)
|
||||
// from compiling
|
||||
template <bool IsConst, class Iterator>
|
||||
template <
|
||||
bool IsConst,
|
||||
class Iterator,
|
||||
class = std::enable_if_t<!IsBoostReverseIterator<Iterator>::value>>
|
||||
beast::detail::AgedContainerIterator<false, Iterator>
|
||||
erase(
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> first,
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> last)
|
||||
requires(!IsBoostReverseIterator<Iterator>::value);
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> last);
|
||||
|
||||
template <class K>
|
||||
auto
|
||||
@@ -899,11 +905,13 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
// The constraint prevents touch (reverse_iterator pos) from compiling
|
||||
template <bool IsConst, class Iterator>
|
||||
// enable_if prevents touch (reverse_iterator pos) from compiling
|
||||
template <
|
||||
bool IsConst,
|
||||
class Iterator,
|
||||
class = std::enable_if_t<!IsBoostReverseIterator<Iterator>::value>>
|
||||
void
|
||||
touch(beast::detail::AgedContainerIterator<IsConst, Iterator> pos)
|
||||
requires(!IsBoostReverseIterator<Iterator>::value)
|
||||
{
|
||||
touch(pos, clock().now());
|
||||
}
|
||||
@@ -1134,25 +1142,25 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
// The constraint prevents erase (reverse_iterator pos, now) from compiling
|
||||
template <bool IsConst, class Iterator>
|
||||
// enable_if prevents erase (reverse_iterator pos, now) from compiling
|
||||
template <
|
||||
bool IsConst,
|
||||
class Iterator,
|
||||
class = std::enable_if_t<!IsBoostReverseIterator<Iterator>::value>>
|
||||
void
|
||||
touch(
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
|
||||
clock_type::time_point const& now)
|
||||
requires(!IsBoostReverseIterator<Iterator>::value);
|
||||
clock_type::time_point const& now);
|
||||
|
||||
template <
|
||||
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
void
|
||||
swapData(AgedOrderedContainer& other) noexcept
|
||||
requires MaybePropagate;
|
||||
std::enable_if_t<MaybePropagate>
|
||||
swapData(AgedOrderedContainer& other) noexcept;
|
||||
|
||||
template <
|
||||
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
void
|
||||
swapData(AgedOrderedContainer& other) noexcept
|
||||
requires(!MaybePropagate);
|
||||
std::enable_if_t<!MaybePropagate>
|
||||
swapData(AgedOrderedContainer& other) noexcept;
|
||||
|
||||
private:
|
||||
ConfigT config_;
|
||||
@@ -1361,10 +1369,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operato
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k)
|
||||
requires(MaybeMap && !MaybeMulti)
|
||||
{
|
||||
auto const iter(cont_.find(k, std::cref(config_.keyCompare())));
|
||||
if (iter == cont_.end())
|
||||
@@ -1373,10 +1380,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K co
|
||||
}
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap, class>
|
||||
std::conditional<IsMap, T, void*>::type const&
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k) const
|
||||
requires(MaybeMap && !MaybeMulti)
|
||||
{
|
||||
auto const iter(cont_.find(k, std::cref(config_.keyCompare())));
|
||||
if (iter == cont_.end())
|
||||
@@ -1385,10 +1391,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K co
|
||||
}
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool MaybeMulti, bool MaybeMap>
|
||||
template <bool MaybeMulti, bool MaybeMap, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](Key const& key)
|
||||
requires(MaybeMap && !MaybeMulti)
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(cont_.insert_check(key, std::cref(config_.keyCompare()), d));
|
||||
@@ -1404,10 +1409,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operato
|
||||
}
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool MaybeMulti, bool MaybeMap>
|
||||
template <bool MaybeMulti, bool MaybeMap, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](Key&& key)
|
||||
requires(MaybeMap && !MaybeMulti)
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(cont_.insert_check(key, std::cref(config_.keyCompare()), d));
|
||||
@@ -1441,8 +1445,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool MaybeMulti>
|
||||
auto
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type const& value) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti)
|
||||
value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(cont_.insert_check(extract(value), std::cref(config_.keyCompare()), d));
|
||||
@@ -1461,8 +1464,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool MaybeMulti>
|
||||
auto
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type const& value) -> iterator
|
||||
requires MaybeMulti
|
||||
value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>
|
||||
{
|
||||
auto const before(cont_.upper_bound(extract(value), std::cref(config_.keyCompare())));
|
||||
Element* const p(newElement(value));
|
||||
@@ -1476,8 +1478,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool MaybeMulti, bool MaybeMap>
|
||||
auto
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(value_type&& value)
|
||||
-> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti && !MaybeMap)
|
||||
-> std::enable_if_t<!MaybeMulti && !MaybeMap, std::pair<iterator, bool>>
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(cont_.insert_check(extract(value), std::cref(config_.keyCompare()), d));
|
||||
@@ -1496,8 +1497,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool MaybeMulti, bool MaybeMap>
|
||||
auto
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(value_type&& value)
|
||||
-> iterator
|
||||
requires(MaybeMulti && !MaybeMap)
|
||||
-> std::enable_if_t<MaybeMulti && !MaybeMap, iterator>
|
||||
{
|
||||
auto const before(cont_.upper_bound(extract(value), std::cref(config_.keyCompare())));
|
||||
Element* const p(newElement(std::move(value)));
|
||||
@@ -1514,8 +1514,7 @@ template <bool MaybeMulti>
|
||||
auto
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
const_iterator hint,
|
||||
value_type const& value) -> iterator
|
||||
requires(!MaybeMulti)
|
||||
value_type const& value) -> std::enable_if_t<!MaybeMulti, iterator>
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(
|
||||
@@ -1536,8 +1535,7 @@ template <bool MaybeMulti>
|
||||
auto
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
const_iterator hint,
|
||||
value_type&& value) -> iterator
|
||||
requires(!MaybeMulti)
|
||||
value_type&& value) -> std::enable_if_t<!MaybeMulti, iterator>
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(
|
||||
@@ -1557,8 +1555,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool MaybeMulti, class... Args>
|
||||
auto
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
||||
-> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti)
|
||||
-> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
|
||||
{
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
// construct element here
|
||||
@@ -1580,8 +1577,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool MaybeMulti, class... Args>
|
||||
auto
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
||||
-> iterator
|
||||
requires MaybeMulti
|
||||
-> std::enable_if_t<MaybeMulti, iterator>
|
||||
{
|
||||
Element* const p(newElement(std::forward<Args>(args)...));
|
||||
auto const before(cont_.upper_bound(extract(p->value), std::cref(config_.keyCompare())));
|
||||
@@ -1596,8 +1592,7 @@ template <bool MaybeMulti, class... Args>
|
||||
auto
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplaceHint(
|
||||
const_iterator hint,
|
||||
Args&&... args) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti)
|
||||
Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
|
||||
{
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
// construct element here
|
||||
@@ -1616,23 +1611,21 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace
|
||||
}
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool IsConst, class Iterator>
|
||||
template <bool IsConst, class Iterator, class>
|
||||
beast::detail::AgedContainerIterator<false, Iterator>
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::erase(
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> pos)
|
||||
requires(!IsBoostReverseIterator<Iterator>::value)
|
||||
{
|
||||
unlinkAndDeleteElement(&*((pos++).iterator()));
|
||||
return beast::detail::AgedContainerIterator<false, Iterator>(pos.iterator());
|
||||
}
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool IsConst, class Iterator>
|
||||
template <bool IsConst, class Iterator, class>
|
||||
beast::detail::AgedContainerIterator<false, Iterator>
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::erase(
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> first,
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> last)
|
||||
requires(!IsBoostReverseIterator<Iterator>::value)
|
||||
{
|
||||
for (; first != last;)
|
||||
unlinkAndDeleteElement(&*((first++).iterator()));
|
||||
@@ -1735,12 +1728,11 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operato
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool IsConst, class Iterator>
|
||||
template <bool IsConst, class Iterator, class>
|
||||
void
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::touch(
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
|
||||
clock_type::time_point const& now)
|
||||
requires(!IsBoostReverseIterator<Iterator>::value)
|
||||
{
|
||||
auto& e(*pos.iterator());
|
||||
e.when = now;
|
||||
@@ -1750,10 +1742,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::touch(
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool MaybePropagate>
|
||||
void
|
||||
std::enable_if_t<MaybePropagate>
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swapData(
|
||||
AgedOrderedContainer& other) noexcept
|
||||
requires MaybePropagate
|
||||
{
|
||||
std::swap(config_.keyCompare(), other.config_.keyCompare());
|
||||
std::swap(config_.alloc(), other.config_.alloc());
|
||||
@@ -1762,10 +1753,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swapDat
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool MaybePropagate>
|
||||
void
|
||||
std::enable_if_t<!MaybePropagate>
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swapData(
|
||||
AgedOrderedContainer& other) noexcept
|
||||
requires(!MaybePropagate)
|
||||
{
|
||||
std::swap(config_.keyCompare(), other.config_.keyCompare());
|
||||
std::swap(config_.clock, other.config_.clock);
|
||||
|
||||
@@ -117,9 +117,10 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
template <
|
||||
class... Args,
|
||||
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
|
||||
Element(time_point const& when, Args&&... args)
|
||||
requires(std::is_constructible_v<value_type, Args...>)
|
||||
: value(std::forward<Args>(args)...), when(when)
|
||||
{
|
||||
}
|
||||
@@ -528,7 +529,6 @@ private:
|
||||
deleteElement(Element const* p)
|
||||
{
|
||||
ElementAllocatorTraits::destroy(config_.alloc(), p);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
|
||||
ElementAllocatorTraits::deallocate(config_.alloc(), const_cast<Element*>(p), 1);
|
||||
}
|
||||
|
||||
@@ -841,25 +841,35 @@ public:
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
template <class K, bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
template <
|
||||
class K,
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
at(K const& k)
|
||||
requires(MaybeMap && !MaybeMulti);
|
||||
at(K const& k);
|
||||
|
||||
template <class K, bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
template <
|
||||
class K,
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
std::conditional<IsMap, T, void*>::type const&
|
||||
at(K const& k) const
|
||||
requires(MaybeMap && !MaybeMulti);
|
||||
at(K const& k) const;
|
||||
|
||||
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
template <
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
operator[](Key const& key)
|
||||
requires(MaybeMap && !MaybeMulti);
|
||||
operator[](Key const& key);
|
||||
|
||||
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
template <
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
operator[](Key&& key)
|
||||
requires(MaybeMap && !MaybeMulti);
|
||||
operator[](Key&& key);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
@@ -957,32 +967,28 @@ public:
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti);
|
||||
insert(value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> iterator
|
||||
requires MaybeMulti;
|
||||
insert(value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>;
|
||||
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
auto
|
||||
insert(value_type&& value) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti && !MaybeMap);
|
||||
insert(value_type&& value)
|
||||
-> std::enable_if_t<!MaybeMulti && !MaybeMap, std::pair<iterator, bool>>;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
|
||||
auto
|
||||
insert(value_type&& value) -> iterator
|
||||
requires(MaybeMulti && !MaybeMap);
|
||||
insert(value_type&& value) -> std::enable_if_t<MaybeMulti && !MaybeMap, iterator>;
|
||||
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
iterator
|
||||
std::enable_if_t<!MaybeMulti, iterator>
|
||||
insert(const_iterator /*hint*/, value_type const& value)
|
||||
requires(!MaybeMulti)
|
||||
{
|
||||
// Hint is ignored but we provide the interface so
|
||||
// callers may use ordered and unordered interchangeably.
|
||||
@@ -991,9 +997,8 @@ public:
|
||||
|
||||
// multimap, multiset
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
iterator
|
||||
std::enable_if_t<MaybeMulti, iterator>
|
||||
insert(const_iterator /*hint*/, value_type const& value)
|
||||
requires MaybeMulti
|
||||
{
|
||||
// VFALCO TODO The hint could be used to let
|
||||
// the client order equal ranges
|
||||
@@ -1002,9 +1007,8 @@ public:
|
||||
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
iterator
|
||||
std::enable_if_t<!MaybeMulti, iterator>
|
||||
insert(const_iterator /*hint*/, value_type&& value)
|
||||
requires(!MaybeMulti)
|
||||
{
|
||||
// Hint is ignored but we provide the interface so
|
||||
// callers may use ordered and unordered interchangeably.
|
||||
@@ -1013,9 +1017,8 @@ public:
|
||||
|
||||
// multimap, multiset
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
iterator
|
||||
std::enable_if_t<MaybeMulti, iterator>
|
||||
insert(const_iterator /*hint*/, value_type&& value)
|
||||
requires MaybeMulti
|
||||
{
|
||||
// VFALCO TODO The hint could be used to let
|
||||
// the client order equal ranges
|
||||
@@ -1024,18 +1027,20 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool MaybeMap = IsMap>
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>
|
||||
std::enable_if_t<
|
||||
MaybeMap && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
insert(P&& value)
|
||||
requires(MaybeMap && std::is_constructible_v<value_type, P &&>)
|
||||
{
|
||||
return emplace(std::forward<P>(value));
|
||||
}
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool MaybeMap = IsMap>
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>
|
||||
std::enable_if_t<
|
||||
MaybeMap && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
insert(const_iterator hint, P&& value)
|
||||
requires(MaybeMap && std::is_constructible_v<value_type, P &&>)
|
||||
{
|
||||
return emplaceHint(hint, std::forward<P>(value));
|
||||
}
|
||||
@@ -1056,26 +1061,23 @@ public:
|
||||
// set, map
|
||||
template <bool MaybeMulti = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti);
|
||||
emplace(Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool MaybeMulti = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> iterator
|
||||
requires MaybeMulti;
|
||||
emplace(Args&&... args) -> std::enable_if_t<MaybeMulti, iterator>;
|
||||
|
||||
// set, map
|
||||
template <bool MaybeMulti = IsMulti, class... Args>
|
||||
auto
|
||||
emplaceHint(const_iterator /*hint*/, Args&&... args) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti);
|
||||
emplaceHint(const_iterator /*hint*/, Args&&... args)
|
||||
-> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool MaybeMulti = IsMulti, class... Args>
|
||||
iterator
|
||||
std::enable_if_t<MaybeMulti, iterator>
|
||||
emplaceHint(const_iterator /*hint*/, Args&&... args)
|
||||
requires MaybeMulti
|
||||
{
|
||||
// VFALCO TODO The hint could be used for multi, to let
|
||||
// the client order equal ranges
|
||||
@@ -1306,7 +1308,7 @@ public:
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool MaybeMulti = IsMulti>
|
||||
bool
|
||||
std::enable_if_t<!MaybeMulti, bool>
|
||||
operator==(AgedUnorderedContainer<
|
||||
false,
|
||||
OtherIsMap,
|
||||
@@ -1315,8 +1317,7 @@ public:
|
||||
OtherDuration,
|
||||
OtherHash,
|
||||
KeyEqual,
|
||||
OtherAllocator> const& other) const
|
||||
requires(!MaybeMulti);
|
||||
OtherAllocator> const& other) const;
|
||||
|
||||
template <
|
||||
bool OtherIsMap,
|
||||
@@ -1326,7 +1327,7 @@ public:
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool MaybeMulti = IsMulti>
|
||||
bool
|
||||
std::enable_if_t<MaybeMulti, bool>
|
||||
operator==(AgedUnorderedContainer<
|
||||
true,
|
||||
OtherIsMap,
|
||||
@@ -1335,8 +1336,7 @@ public:
|
||||
OtherDuration,
|
||||
OtherHash,
|
||||
KeyEqual,
|
||||
OtherAllocator> const& other) const
|
||||
requires MaybeMulti;
|
||||
OtherAllocator> const& other) const;
|
||||
|
||||
template <
|
||||
bool OtherIsMulti,
|
||||
@@ -1381,14 +1381,13 @@ private:
|
||||
// map, set
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
auto
|
||||
insertUnchecked(value_type const& value) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti);
|
||||
insertUnchecked(value_type const& value)
|
||||
-> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool MaybeMulti = IsMulti>
|
||||
auto
|
||||
insertUnchecked(value_type const& value) -> iterator
|
||||
requires MaybeMulti;
|
||||
insertUnchecked(value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>;
|
||||
|
||||
template <class InputIt>
|
||||
void
|
||||
@@ -1429,9 +1428,8 @@ private:
|
||||
|
||||
template <
|
||||
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
void
|
||||
std::enable_if_t<MaybePropagate>
|
||||
swapData(AgedUnorderedContainer& other) noexcept
|
||||
requires MaybePropagate
|
||||
{
|
||||
std::swap(config_.hashFunction(), other.config_.hashFunction());
|
||||
std::swap(config_.keyEq(), other.config_.keyEq());
|
||||
@@ -1441,9 +1439,8 @@ private:
|
||||
|
||||
template <
|
||||
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
void
|
||||
std::enable_if_t<!MaybePropagate>
|
||||
swapData(AgedUnorderedContainer& other) noexcept
|
||||
requires(!MaybePropagate)
|
||||
{
|
||||
std::swap(config_.hashFunction(), other.config_.hashFunction());
|
||||
std::swap(config_.keyEq(), other.config_.keyEq());
|
||||
@@ -2097,10 +2094,9 @@ template <
|
||||
class Hash,
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(K const& k)
|
||||
requires(MaybeMap && !MaybeMulti)
|
||||
{
|
||||
auto const iter(
|
||||
cont_.find(k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual())));
|
||||
@@ -2118,11 +2114,10 @@ template <
|
||||
class Hash,
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap, class>
|
||||
std::conditional<IsMap, T, void*>::type const&
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(
|
||||
K const& k) const
|
||||
requires(MaybeMap && !MaybeMulti)
|
||||
{
|
||||
auto const iter(
|
||||
cont_.find(k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual())));
|
||||
@@ -2140,11 +2135,10 @@ template <
|
||||
class Hash,
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <bool MaybeMulti, bool MaybeMap>
|
||||
template <bool MaybeMulti, bool MaybeMap, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
||||
Key const& key)
|
||||
requires(MaybeMap && !MaybeMulti)
|
||||
{
|
||||
maybeRehash(1);
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -2170,11 +2164,10 @@ template <
|
||||
class Hash,
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <bool MaybeMulti, bool MaybeMap>
|
||||
template <bool MaybeMulti, bool MaybeMap, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
||||
Key&& key)
|
||||
requires(MaybeMap && !MaybeMulti)
|
||||
{
|
||||
maybeRehash(1);
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -2227,8 +2220,7 @@ template <
|
||||
template <bool MaybeMulti>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type const& value) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti)
|
||||
value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
|
||||
{
|
||||
maybeRehash(1);
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -2257,8 +2249,7 @@ template <
|
||||
template <bool MaybeMulti>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type const& value) -> iterator
|
||||
requires MaybeMulti
|
||||
value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>
|
||||
{
|
||||
maybeRehash(1);
|
||||
Element* const p(newElement(value));
|
||||
@@ -2280,8 +2271,7 @@ template <
|
||||
template <bool MaybeMulti, bool MaybeMap>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type&& value) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti && !MaybeMap)
|
||||
value_type&& value) -> std::enable_if_t<!MaybeMulti && !MaybeMap, std::pair<iterator, bool>>
|
||||
{
|
||||
maybeRehash(1);
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -2310,8 +2300,7 @@ template <
|
||||
template <bool MaybeMulti, bool MaybeMap>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type&& value) -> iterator
|
||||
requires(MaybeMulti && !MaybeMap)
|
||||
value_type&& value) -> std::enable_if_t<MaybeMulti && !MaybeMap, iterator>
|
||||
{
|
||||
maybeRehash(1);
|
||||
Element* const p(newElement(std::move(value)));
|
||||
@@ -2320,6 +2309,7 @@ AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>
|
||||
return iterator(iter);
|
||||
}
|
||||
|
||||
#if 1 // Use insert() instead of insert_check() insert_commit()
|
||||
// set, map
|
||||
template <
|
||||
bool IsMulti,
|
||||
@@ -2333,8 +2323,7 @@ template <
|
||||
template <bool MaybeMulti, class... Args>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
||||
Args&&... args) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti)
|
||||
Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
|
||||
{
|
||||
maybeRehash(1);
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
@@ -2349,6 +2338,42 @@ AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>
|
||||
deleteElement(p);
|
||||
return std::make_pair(iterator(result.first), false);
|
||||
}
|
||||
#else // As original, use insert_check() / insert_commit () pair.
|
||||
// set, map
|
||||
template <
|
||||
bool IsMulti,
|
||||
bool IsMap,
|
||||
class Key,
|
||||
class T,
|
||||
class Clock,
|
||||
class Hash,
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
// construct element here
|
||||
element* const p(new_element(std::forward<Args>(args)...));
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(m_cont.insert_check(
|
||||
extract(p->value),
|
||||
std::cref(m_config.hashFunction()),
|
||||
std::cref(m_config.keyValueEqual()),
|
||||
d));
|
||||
if (result.second)
|
||||
{
|
||||
auto const iter(m_cont.insert_commit(*p, d));
|
||||
chronological.list.push_back(*p);
|
||||
return std::make_pair(iterator(iter), true);
|
||||
}
|
||||
delete_element(p);
|
||||
return std::make_pair(iterator(result.first), false);
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
// multiset, multimap
|
||||
template <
|
||||
@@ -2363,8 +2388,7 @@ template <
|
||||
template <bool MaybeMulti, class... Args>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
||||
Args&&... args) -> iterator
|
||||
requires MaybeMulti
|
||||
Args&&... args) -> std::enable_if_t<MaybeMulti, iterator>
|
||||
{
|
||||
maybeRehash(1);
|
||||
Element* const p(newElement(std::forward<Args>(args)...));
|
||||
@@ -2387,8 +2411,7 @@ template <bool MaybeMulti, class... Args>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplaceHint(
|
||||
const_iterator /*hint*/,
|
||||
Args&&... args) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti)
|
||||
Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
|
||||
{
|
||||
maybeRehash(1);
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
@@ -2539,7 +2562,7 @@ template <
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool MaybeMulti>
|
||||
bool
|
||||
std::enable_if_t<!MaybeMulti, bool>
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
||||
AgedUnorderedContainer<
|
||||
false,
|
||||
@@ -2550,7 +2573,6 @@ AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>
|
||||
OtherHash,
|
||||
KeyEqual,
|
||||
OtherAllocator> const& other) const
|
||||
requires(!MaybeMulti)
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
@@ -2580,7 +2602,7 @@ template <
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool MaybeMulti>
|
||||
bool
|
||||
std::enable_if_t<MaybeMulti, bool>
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
||||
AgedUnorderedContainer<
|
||||
true,
|
||||
@@ -2591,7 +2613,6 @@ AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>
|
||||
OtherHash,
|
||||
KeyEqual,
|
||||
OtherAllocator> const& other) const
|
||||
requires MaybeMulti
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
@@ -2628,8 +2649,7 @@ template <
|
||||
template <bool MaybeMulti>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insertUnchecked(
|
||||
value_type const& value) -> std::pair<iterator, bool>
|
||||
requires(!MaybeMulti)
|
||||
value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(cont_.insert_check(
|
||||
@@ -2657,8 +2677,7 @@ template <
|
||||
template <bool MaybeMulti>
|
||||
auto
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insertUnchecked(
|
||||
value_type const& value) -> iterator
|
||||
requires MaybeMulti
|
||||
value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>
|
||||
{
|
||||
Element* const p(newElement(value));
|
||||
chronological.list_.push_back(*p);
|
||||
|
||||
@@ -29,18 +29,16 @@ struct LexicalCast<std::string, In>
|
||||
explicit LexicalCast() = default;
|
||||
|
||||
template <class Arithmetic = In>
|
||||
bool
|
||||
std::enable_if_t<std::is_arithmetic_v<Arithmetic>, bool>
|
||||
operator()(std::string& out, Arithmetic in)
|
||||
requires(std::is_arithmetic_v<Arithmetic>)
|
||||
{
|
||||
out = std::to_string(in);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class Enumeration = In>
|
||||
bool
|
||||
std::enable_if_t<std::is_enum_v<Enumeration>, bool>
|
||||
operator()(std::string& out, Enumeration in)
|
||||
requires(std::is_enum_v<Enumeration>)
|
||||
{
|
||||
out = std::to_string(static_cast<std::underlying_type_t<Enumeration>>(in));
|
||||
return true;
|
||||
@@ -58,9 +56,8 @@ struct LexicalCast<Out, std::string_view>
|
||||
"beast::LexicalCast can only be used with integral types");
|
||||
|
||||
template <class Integral = Out>
|
||||
bool
|
||||
std::enable_if_t<std::is_integral_v<Integral> && !std::is_same_v<Integral, bool>, bool>
|
||||
operator()(Integral& out, std::string_view in) const
|
||||
requires(std::is_integral_v<Integral> && !std::is_same_v<Integral, bool>)
|
||||
{
|
||||
auto first = in.data();
|
||||
auto last = in.data() + in.size();
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
operator=(NodePtr node)
|
||||
{
|
||||
node_ = node;
|
||||
return *this;
|
||||
return static_cast<LockFreeStackIterator&>(*this);
|
||||
}
|
||||
|
||||
LockFreeStackIterator&
|
||||
|
||||
@@ -26,7 +26,7 @@ template <class T>
|
||||
inline void
|
||||
reverseBytes(T& t)
|
||||
{
|
||||
auto* bytes =
|
||||
unsigned char* bytes =
|
||||
static_cast<unsigned char*>(std::memmove(std::addressof(t), std::addressof(t), sizeof(T)));
|
||||
for (unsigned i = 0; i < sizeof(T) / 2; ++i)
|
||||
std::swap(bytes[i], bytes[sizeof(T) - 1 - i]);
|
||||
@@ -200,29 +200,26 @@ struct IsContiguouslyHashable<T[N], HashAlgorithm>
|
||||
// scalars
|
||||
|
||||
template <class Hasher, class T>
|
||||
inline void
|
||||
inline std::enable_if_t<IsContiguouslyHashable<T, Hasher>::value>
|
||||
hash_append(Hasher& h, T const& t) noexcept
|
||||
requires(IsContiguouslyHashable<T, Hasher>::value)
|
||||
{
|
||||
// NOLINTNEXTLINE(bugprone-sizeof-expression)
|
||||
h(static_cast<void const*>(std::addressof(t)), sizeof(t));
|
||||
}
|
||||
|
||||
template <class Hasher, class T>
|
||||
inline void
|
||||
inline std::enable_if_t<
|
||||
!IsContiguouslyHashable<T, Hasher>::value &&
|
||||
(std::is_integral_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>)>
|
||||
hash_append(Hasher& h, T t) noexcept
|
||||
requires(
|
||||
!IsContiguouslyHashable<T, Hasher>::value &&
|
||||
(std::is_integral_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>))
|
||||
{
|
||||
detail::reverseBytes(t);
|
||||
h(std::addressof(t), sizeof(t));
|
||||
}
|
||||
|
||||
template <class Hasher, class T>
|
||||
inline void
|
||||
inline std::enable_if_t<std::is_floating_point_v<T>>
|
||||
hash_append(Hasher& h, T t) noexcept
|
||||
requires(std::is_floating_point_v<T>)
|
||||
{
|
||||
if (t == 0)
|
||||
t = 0;
|
||||
@@ -242,44 +239,36 @@ hash_append(Hasher& h, std::nullptr_t) noexcept
|
||||
// Forward declarations for ADL purposes
|
||||
|
||||
template <class Hasher, class T, std::size_t N>
|
||||
void
|
||||
hash_append(Hasher& h, T (&a)[N]) noexcept
|
||||
requires(!IsContiguouslyHashable<T, Hasher>::value);
|
||||
std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
|
||||
hash_append(Hasher& h, T (&a)[N]) noexcept;
|
||||
|
||||
template <class Hasher, class CharT, class Traits, class Alloc>
|
||||
void
|
||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
|
||||
requires(!IsContiguouslyHashable<CharT, Hasher>::value);
|
||||
std::enable_if_t<!IsContiguouslyHashable<CharT, Hasher>::value>
|
||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
|
||||
|
||||
template <class Hasher, class CharT, class Traits, class Alloc>
|
||||
void
|
||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
|
||||
requires(IsContiguouslyHashable<CharT, Hasher>::value);
|
||||
std::enable_if_t<IsContiguouslyHashable<CharT, Hasher>::value>
|
||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
|
||||
|
||||
template <class Hasher, class T, class U>
|
||||
void
|
||||
hash_append(Hasher& h, std::pair<T, U> const& p) noexcept
|
||||
requires(!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value);
|
||||
std::enable_if_t<!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value>
|
||||
hash_append(Hasher& h, std::pair<T, U> const& p) noexcept;
|
||||
|
||||
template <class Hasher, class T, class Alloc>
|
||||
void
|
||||
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
|
||||
requires(!IsContiguouslyHashable<T, Hasher>::value);
|
||||
std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
|
||||
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept;
|
||||
|
||||
template <class Hasher, class T, class Alloc>
|
||||
void
|
||||
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
|
||||
requires(IsContiguouslyHashable<T, Hasher>::value);
|
||||
std::enable_if_t<IsContiguouslyHashable<T, Hasher>::value>
|
||||
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept;
|
||||
|
||||
template <class Hasher, class T, std::size_t N>
|
||||
void
|
||||
hash_append(Hasher& h, std::array<T, N> const& a) noexcept
|
||||
requires(!IsContiguouslyHashable<std::array<T, N>, Hasher>::value);
|
||||
std::enable_if_t<!IsContiguouslyHashable<std::array<T, N>, Hasher>::value>
|
||||
hash_append(Hasher& h, std::array<T, N> const& a) noexcept;
|
||||
|
||||
template <class Hasher, class... T>
|
||||
void
|
||||
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept
|
||||
requires(!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value);
|
||||
std::enable_if_t<!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value>
|
||||
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept;
|
||||
|
||||
template <class Hasher, class Key, class T, class Hash, class Pred, class Alloc>
|
||||
void
|
||||
@@ -290,13 +279,11 @@ void
|
||||
hash_append(Hasher& h, std::unordered_set<Key, Hash, Pred, Alloc> const& s);
|
||||
|
||||
template <class Hasher, class Key, class Compare, class Alloc>
|
||||
void
|
||||
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
|
||||
requires(!IsContiguouslyHashable<Key, Hasher>::value);
|
||||
std::enable_if_t<!IsContiguouslyHashable<Key, Hasher>::value>
|
||||
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept;
|
||||
template <class Hasher, class Key, class Compare, class Alloc>
|
||||
void
|
||||
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
|
||||
requires(IsContiguouslyHashable<Key, Hasher>::value);
|
||||
std::enable_if_t<IsContiguouslyHashable<Key, Hasher>::value>
|
||||
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept;
|
||||
template <class Hasher, class T0, class T1, class... T>
|
||||
void
|
||||
hash_append(Hasher& h, T0 const& t0, T1 const& t1, T const&... t) noexcept;
|
||||
@@ -304,9 +291,8 @@ hash_append(Hasher& h, T0 const& t0, T1 const& t1, T const&... t) noexcept;
|
||||
// c-array
|
||||
|
||||
template <class Hasher, class T, std::size_t N>
|
||||
void
|
||||
std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
|
||||
hash_append(Hasher& h, T (&a)[N]) noexcept
|
||||
requires(!IsContiguouslyHashable<T, Hasher>::value)
|
||||
{
|
||||
for (auto const& t : a)
|
||||
hash_append(h, t);
|
||||
@@ -315,9 +301,8 @@ hash_append(Hasher& h, T (&a)[N]) noexcept
|
||||
// basic_string
|
||||
|
||||
template <class Hasher, class CharT, class Traits, class Alloc>
|
||||
inline void
|
||||
inline std::enable_if_t<!IsContiguouslyHashable<CharT, Hasher>::value>
|
||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
|
||||
requires(!IsContiguouslyHashable<CharT, Hasher>::value)
|
||||
{
|
||||
for (auto c : s)
|
||||
hash_append(h, c);
|
||||
@@ -325,9 +310,8 @@ hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcep
|
||||
}
|
||||
|
||||
template <class Hasher, class CharT, class Traits, class Alloc>
|
||||
inline void
|
||||
inline std::enable_if_t<IsContiguouslyHashable<CharT, Hasher>::value>
|
||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
|
||||
requires(IsContiguouslyHashable<CharT, Hasher>::value)
|
||||
{
|
||||
h(s.data(), s.size() * sizeof(CharT));
|
||||
hash_append(h, s.size());
|
||||
@@ -336,9 +320,8 @@ hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcep
|
||||
// pair
|
||||
|
||||
template <class Hasher, class T, class U>
|
||||
inline void
|
||||
inline std::enable_if_t<!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value>
|
||||
hash_append(Hasher& h, std::pair<T, U> const& p) noexcept
|
||||
requires(!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value)
|
||||
{
|
||||
hash_append(h, p.first, p.second);
|
||||
}
|
||||
@@ -346,9 +329,8 @@ hash_append(Hasher& h, std::pair<T, U> const& p) noexcept
|
||||
// vector
|
||||
|
||||
template <class Hasher, class T, class Alloc>
|
||||
inline void
|
||||
inline std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
|
||||
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
|
||||
requires(!IsContiguouslyHashable<T, Hasher>::value)
|
||||
{
|
||||
for (auto const& t : v)
|
||||
hash_append(h, t);
|
||||
@@ -356,9 +338,8 @@ hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
|
||||
}
|
||||
|
||||
template <class Hasher, class T, class Alloc>
|
||||
inline void
|
||||
inline std::enable_if_t<IsContiguouslyHashable<T, Hasher>::value>
|
||||
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
|
||||
requires(IsContiguouslyHashable<T, Hasher>::value)
|
||||
{
|
||||
h(v.data(), v.size() * sizeof(T));
|
||||
hash_append(h, v.size());
|
||||
@@ -367,37 +348,57 @@ hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
|
||||
// array
|
||||
|
||||
template <class Hasher, class T, std::size_t N>
|
||||
void
|
||||
std::enable_if_t<!IsContiguouslyHashable<std::array<T, N>, Hasher>::value>
|
||||
hash_append(Hasher& h, std::array<T, N> const& a) noexcept
|
||||
requires(!IsContiguouslyHashable<std::array<T, N>, Hasher>::value)
|
||||
{
|
||||
for (auto const& t : a)
|
||||
hash_append(h, t);
|
||||
}
|
||||
|
||||
template <class Hasher, class Key, class Compare, class Alloc>
|
||||
void
|
||||
std::enable_if_t<!IsContiguouslyHashable<Key, Hasher>::value>
|
||||
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
|
||||
requires(!IsContiguouslyHashable<Key, Hasher>::value)
|
||||
{
|
||||
for (auto const& t : v)
|
||||
hash_append(h, t);
|
||||
}
|
||||
template <class Hasher, class Key, class Compare, class Alloc>
|
||||
void
|
||||
std::enable_if_t<IsContiguouslyHashable<Key, Hasher>::value>
|
||||
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
|
||||
requires(IsContiguouslyHashable<Key, Hasher>::value)
|
||||
{
|
||||
h(&(v.begin()), v.size() * sizeof(Key));
|
||||
}
|
||||
// tuple
|
||||
|
||||
template <class Hasher, class... T>
|
||||
namespace detail {
|
||||
|
||||
inline void
|
||||
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept
|
||||
requires(!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value)
|
||||
forEachItem(...) noexcept
|
||||
{
|
||||
std::apply([&h](auto const&... item) { (hash_append(h, item), ...); }, t);
|
||||
}
|
||||
|
||||
template <class Hasher, class T>
|
||||
inline int
|
||||
hashOne(Hasher& h, T const& t) noexcept
|
||||
{
|
||||
hash_append(h, t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class Hasher, class... T, std::size_t... I>
|
||||
inline void
|
||||
tuple_hash(Hasher& h, std::tuple<T...> const& t, std::index_sequence<I...>) noexcept
|
||||
{
|
||||
for_each_item(hash_one(h, std::get<I>(t))...);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class Hasher, class... T>
|
||||
inline std::enable_if_t<!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value>
|
||||
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept
|
||||
{
|
||||
detail::tuple_hash(h, t, std::index_sequence_for<T...>{});
|
||||
}
|
||||
|
||||
// shared_ptr
|
||||
|
||||
@@ -124,18 +124,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class Seed>
|
||||
explicit Xxhasher(Seed seed)
|
||||
requires(std::is_unsigned_v<Seed>)
|
||||
: seed_(seed)
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
|
||||
explicit Xxhasher(Seed seed) : seed_(seed)
|
||||
{
|
||||
resetBuffers();
|
||||
}
|
||||
|
||||
template <class Seed>
|
||||
Xxhasher(Seed seed, Seed)
|
||||
requires(std::is_unsigned_v<Seed>)
|
||||
: seed_(seed)
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
|
||||
Xxhasher(Seed seed, Seed) : seed_(seed)
|
||||
{
|
||||
resetBuffers();
|
||||
}
|
||||
|
||||
@@ -49,11 +49,6 @@ public:
|
||||
impl_->set(value);
|
||||
}
|
||||
|
||||
// This is a write-through handle: assignment sets the value of the
|
||||
// referenced metric. It is const-qualified and returns Gauge const&
|
||||
// (a non-const Gauge& would require a const_cast), so it does not follow
|
||||
// the conventional assignment-operator signature.
|
||||
// NOLINTNEXTLINE(misc-unconventional-assign-operator)
|
||||
Gauge const&
|
||||
operator=(value_type value) const
|
||||
{
|
||||
|
||||
@@ -23,7 +23,6 @@ typeName()
|
||||
if (auto s = abi::__cxa_demangle(name.c_str(), nullptr, nullptr, nullptr))
|
||||
{
|
||||
name = s;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
|
||||
std::free(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <set>
|
||||
#include <string> // IWYU pragma: keep
|
||||
#include <typeindex> // IWYU pragma: keep
|
||||
#include <unordered_set> // IWYU pragma: keep
|
||||
#include <string>
|
||||
#include <typeindex>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace beast::unit_test {
|
||||
|
||||
|
||||
@@ -45,10 +45,7 @@ public:
|
||||
template <class F, class... Args>
|
||||
explicit Thread(Suite& s, F&& f, Args&&... args) : s_(&s)
|
||||
{
|
||||
std::function<void(void)> b = [f = std::forward<F>(f),
|
||||
... args = std::forward<Args>(args)]() mutable {
|
||||
std::invoke(f, args...);
|
||||
};
|
||||
std::function<void(void)> b = std::bind(std::forward<F>(f), std::forward<Args>(args)...);
|
||||
t_ = std::thread(&Thread::run, this, std::move(b));
|
||||
}
|
||||
|
||||
|
||||
@@ -108,12 +108,12 @@ public:
|
||||
};
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
static_assert(!std::is_default_constructible_v<Sink>);
|
||||
static_assert(!std::is_copy_constructible_v<Sink>);
|
||||
static_assert(!std::is_move_constructible_v<Sink>);
|
||||
static_assert(!std::is_copy_assignable_v<Sink>);
|
||||
static_assert(!std::is_move_assignable_v<Sink>);
|
||||
static_assert(std::is_nothrow_destructible_v<Sink>);
|
||||
static_assert(!std::is_default_constructible_v<Sink>, "");
|
||||
static_assert(!std::is_copy_constructible_v<Sink>, "");
|
||||
static_assert(!std::is_move_constructible_v<Sink>, "");
|
||||
static_assert(!std::is_copy_assignable_v<Sink>, "");
|
||||
static_assert(!std::is_move_assignable_v<Sink>, "");
|
||||
static_assert(std::is_nothrow_destructible_v<Sink>, "");
|
||||
#endif
|
||||
|
||||
/** Returns a Sink which does nothing. */
|
||||
@@ -164,12 +164,12 @@ public:
|
||||
};
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
static_assert(!std::is_default_constructible_v<ScopedStream>);
|
||||
static_assert(std::is_copy_constructible_v<ScopedStream>);
|
||||
static_assert(std::is_move_constructible_v<ScopedStream>);
|
||||
static_assert(!std::is_copy_assignable_v<ScopedStream>);
|
||||
static_assert(!std::is_move_assignable_v<ScopedStream>);
|
||||
static_assert(std::is_nothrow_destructible_v<ScopedStream>);
|
||||
static_assert(!std::is_default_constructible_v<ScopedStream>, "");
|
||||
static_assert(std::is_copy_constructible_v<ScopedStream>, "");
|
||||
static_assert(std::is_move_constructible_v<ScopedStream>, "");
|
||||
static_assert(!std::is_copy_assignable_v<ScopedStream>, "");
|
||||
static_assert(!std::is_move_assignable_v<ScopedStream>, "");
|
||||
static_assert(std::is_nothrow_destructible_v<ScopedStream>, "");
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -246,12 +246,12 @@ public:
|
||||
};
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
static_assert(std::is_default_constructible_v<Stream>);
|
||||
static_assert(std::is_copy_constructible_v<Stream>);
|
||||
static_assert(std::is_move_constructible_v<Stream>);
|
||||
static_assert(!std::is_copy_assignable_v<Stream>);
|
||||
static_assert(!std::is_move_assignable_v<Stream>);
|
||||
static_assert(std::is_nothrow_destructible_v<Stream>);
|
||||
static_assert(std::is_default_constructible_v<Stream>, "");
|
||||
static_assert(std::is_copy_constructible_v<Stream>, "");
|
||||
static_assert(std::is_move_constructible_v<Stream>, "");
|
||||
static_assert(!std::is_copy_assignable_v<Stream>, "");
|
||||
static_assert(!std::is_move_assignable_v<Stream>, "");
|
||||
static_assert(std::is_nothrow_destructible_v<Stream>, "");
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -329,12 +329,12 @@ public:
|
||||
};
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
static_assert(!std::is_default_constructible_v<Journal>);
|
||||
static_assert(std::is_copy_constructible_v<Journal>);
|
||||
static_assert(std::is_move_constructible_v<Journal>);
|
||||
static_assert(std::is_copy_assignable_v<Journal>);
|
||||
static_assert(std::is_move_assignable_v<Journal>);
|
||||
static_assert(std::is_nothrow_destructible_v<Journal>);
|
||||
static_assert(!std::is_default_constructible_v<Journal>, "");
|
||||
static_assert(std::is_copy_constructible_v<Journal>, "");
|
||||
static_assert(std::is_move_constructible_v<Journal>, "");
|
||||
static_assert(std::is_copy_assignable_v<Journal>, "");
|
||||
static_assert(std::is_move_assignable_v<Journal>, "");
|
||||
static_assert(std::is_nothrow_destructible_v<Journal>, "");
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -26,7 +26,9 @@ struct Zero
|
||||
explicit Zero() = default;
|
||||
};
|
||||
|
||||
inline constexpr Zero kZero{};
|
||||
namespace {
|
||||
constexpr Zero kZero{};
|
||||
} // namespace
|
||||
|
||||
/** Default implementation of signum calls the method on the class. */
|
||||
template <typename T>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -13,7 +14,7 @@ rngfill(void* const buffer, std::size_t const bytes, Generator& g)
|
||||
using result_type = Generator::result_type;
|
||||
constexpr std::size_t kResultSize = sizeof(result_type);
|
||||
|
||||
auto* const bufferStart = static_cast<std::uint8_t*>(buffer);
|
||||
std::uint8_t* const bufferStart = static_cast<std::uint8_t*>(buffer);
|
||||
std::size_t const completeIterations = bytes / kResultSize;
|
||||
std::size_t const bytesRemaining = bytes % kResultSize;
|
||||
|
||||
@@ -32,14 +33,16 @@ rngfill(void* const buffer, std::size_t const bytes, Generator& g)
|
||||
}
|
||||
}
|
||||
|
||||
template <class Generator, std::size_t N>
|
||||
template <
|
||||
class Generator,
|
||||
std::size_t N,
|
||||
class = std::enable_if_t<N % sizeof(typename Generator::result_type) == 0>>
|
||||
void
|
||||
rngfill(std::array<std::uint8_t, N>& a, Generator& g)
|
||||
requires(N % sizeof(typename Generator::result_type) == 0)
|
||||
{
|
||||
using result_type = Generator::result_type;
|
||||
auto i = N / sizeof(result_type);
|
||||
auto* p = reinterpret_cast<result_type*>(a.data());
|
||||
result_type* p = reinterpret_cast<result_type*>(a.data());
|
||||
while (i--)
|
||||
*p++ = g();
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ private:
|
||||
}
|
||||
|
||||
[[nodiscard]] HashRouterFlags
|
||||
getFlags() const
|
||||
getFlags(void) const
|
||||
{
|
||||
return flags_;
|
||||
}
|
||||
|
||||
@@ -154,14 +154,16 @@ public:
|
||||
|
||||
@param type The type of job.
|
||||
@param name Name of the job.
|
||||
@param jobHandler Callable with signature void(). Called when the job is executed.
|
||||
@param jobHandler Lambda with signature void (Job&). Called when the
|
||||
job is executed.
|
||||
|
||||
@return true if jobHandler added to queue.
|
||||
*/
|
||||
template <typename JobHandler>
|
||||
template <
|
||||
typename JobHandler,
|
||||
typename = std::enable_if_t<std::is_same_v<decltype(std::declval<JobHandler&&>()()), void>>>
|
||||
bool
|
||||
addJob(JobType type, std::string const& name, JobHandler&& jobHandler)
|
||||
requires(std::is_void_v<std::invoke_result_t<JobHandler>>)
|
||||
{
|
||||
if (auto optionalCountedJob = jobCounter_.wrap(std::forward<JobHandler>(jobHandler)))
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
[[nodiscard]] JobTypeInfo const&
|
||||
get(JobType jt) const
|
||||
{
|
||||
auto const iter = map.find(jt);
|
||||
Map::const_iterator const iter(map.find(jt));
|
||||
XRPL_ASSERT(iter != map.end(), "xrpl::JobTypes::get : valid input");
|
||||
|
||||
if (iter != map.end())
|
||||
|
||||
@@ -154,7 +154,7 @@ private:
|
||||
Location end,
|
||||
unsigned int& unicode);
|
||||
bool
|
||||
addError(std::string const& message, Token& token, Location extra = nullptr);
|
||||
addError(std::string const& message, Token& token, Location extra = 0);
|
||||
bool
|
||||
recoverFromError(TokenType skipUntilToken);
|
||||
bool
|
||||
|
||||
@@ -3,16 +3,14 @@
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/safe_cast.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/ledger/OwnerCounts.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Issue.h> // IWYU pragma: keep
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
#include <xrpl/protocol/MPTIssue.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol/STVector256.h>
|
||||
|
||||
#include <cstdint>
|
||||
@@ -290,7 +288,7 @@ public:
|
||||
// Called when the owner count changes
|
||||
// This is required to support PaymentSandbox
|
||||
virtual void
|
||||
adjustOwnerCountHook(AccountID const& account, OwnerCounts const& cur, OwnerCounts const& next)
|
||||
adjustOwnerCountHook(AccountID const& account, std::uint32_t cur, std::uint32_t next)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -413,23 +411,6 @@ public:
|
||||
emptyDirDelete(Keylet const& directory);
|
||||
};
|
||||
|
||||
/** Bundles the mutable ledger view and the transaction being applied.
|
||||
|
||||
Passed together to avoid threading two separate parameters through every
|
||||
helper that needs both the view (for state reads/writes) and the
|
||||
transaction (for field inspection and metadata).
|
||||
|
||||
Both members are non-owning references; the caller is responsible for
|
||||
ensuring that the referenced objects outlive the ApplyViewContext.
|
||||
|
||||
TODO: replace with ApplyContext after it's untangled with xrpl/tx
|
||||
*/
|
||||
struct ApplyViewContext
|
||||
{
|
||||
ApplyView& view;
|
||||
STTx const& tx;
|
||||
};
|
||||
|
||||
namespace directory {
|
||||
/** Helper functions for managing low-level directory operations.
|
||||
These are not part of the ApplyView interface.
|
||||
|
||||
@@ -141,7 +141,7 @@ template <class Base>
|
||||
class CachedView : public detail::CachedViewImpl
|
||||
{
|
||||
private:
|
||||
static_assert(std::is_base_of_v<DigestAwareReadView, Base>);
|
||||
static_assert(std::is_base_of_v<DigestAwareReadView, Base>, "");
|
||||
|
||||
std::shared_ptr<Base const> sp_;
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
using txs_map = std::map<
|
||||
key_type,
|
||||
TxData,
|
||||
std::less<>,
|
||||
std::less<key_type>,
|
||||
boost::container::pmr::polymorphic_allocator<std::pair<key_type const, TxData>>>;
|
||||
|
||||
// monotonic_resource_ must outlive `items_`. Make a pointer so it may be
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STInteger.h> // IWYU pragma: keep
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
struct OwnerCounts
|
||||
{
|
||||
std::uint32_t owner = 0;
|
||||
std::uint32_t sponsored = 0;
|
||||
std::uint32_t sponsoring = 0;
|
||||
|
||||
OwnerCounts() = default;
|
||||
OwnerCounts(SLE::const_ref sle)
|
||||
: owner(sle->at(sfOwnerCount))
|
||||
, sponsored(sle->at(sfSponsoredOwnerCount))
|
||||
, sponsoring(sle->at(sfSponsoringOwnerCount))
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
owner >= sponsored,
|
||||
"xrpl::OwnerCounts : OwnerCount must be greater than or equal to "
|
||||
"SponsoredOwnerCount");
|
||||
XRPL_ASSERT(sle->getType() == ltACCOUNT_ROOT, "xrpl::OwnerCounts : sle is AccountRoot");
|
||||
}
|
||||
|
||||
[[nodiscard]] std::uint32_t
|
||||
count() const
|
||||
{
|
||||
std::int64_t const x = static_cast<std::int64_t>(owner) - sponsored + sponsoring;
|
||||
if (x < 0)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE("xrpl::OwnerCounts::count : count less than zero");
|
||||
return 0;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
if (x > std::numeric_limits<std::uint32_t>::max())
|
||||
return std::numeric_limits<std::uint32_t>::max(); // LCOV_EXCL_LINE
|
||||
return static_cast<std::uint32_t>(x);
|
||||
}
|
||||
|
||||
auto
|
||||
operator<=>(OwnerCounts const& o) const
|
||||
{
|
||||
if (auto cmp = count() <=> o.count(); cmp != 0) // NOLINT(modernize-use-nullptr)
|
||||
return cmp;
|
||||
if (auto cmp = owner <=> o.owner; cmp != 0) // NOLINT(modernize-use-nullptr)
|
||||
return cmp;
|
||||
if (auto cmp = sponsored <=> o.sponsored; cmp != 0) // NOLINT(modernize-use-nullptr)
|
||||
return cmp;
|
||||
return sponsoring <=> o.sponsoring;
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(OwnerCounts const& o) const
|
||||
{
|
||||
return this == &o ||
|
||||
(owner == o.owner && sponsored == o.sponsored && sponsoring == o.sponsoring);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/OwnerCounts.h>
|
||||
#include <xrpl/ledger/RawView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/ledger/detail/ApplyViewBase.h>
|
||||
@@ -108,12 +107,12 @@ public:
|
||||
issuerSelfDebitMPT(MPTIssue const& issue, std::uint64_t amount, std::int64_t origBalance);
|
||||
|
||||
void
|
||||
ownerCount(AccountID const& id, OwnerCounts const& cur, OwnerCounts const& next);
|
||||
ownerCount(AccountID const& id, std::uint32_t cur, std::uint32_t next);
|
||||
|
||||
// Get the adjusted owner count. Since DeferredCredits is meant to be used
|
||||
// in payments, and payments only decrease owner counts, return the max
|
||||
// remembered owner count.
|
||||
[[nodiscard]] std::optional<OwnerCounts>
|
||||
[[nodiscard]] std::optional<std::uint32_t>
|
||||
ownerCount(AccountID const& id) const;
|
||||
|
||||
void
|
||||
@@ -125,7 +124,7 @@ private:
|
||||
|
||||
std::map<KeyIOU, ValueIOU> creditsIOU_;
|
||||
std::map<MPTID, IssuerValueMPT> creditsMPT_;
|
||||
std::map<AccountID, OwnerCounts> ownerCounts_;
|
||||
std::map<AccountID, std::uint32_t> ownerCounts_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -219,11 +218,10 @@ public:
|
||||
override;
|
||||
|
||||
void
|
||||
adjustOwnerCountHook(AccountID const& account, OwnerCounts const& cur, OwnerCounts const& next)
|
||||
override;
|
||||
adjustOwnerCountHook(AccountID const& account, std::uint32_t cur, std::uint32_t next) override;
|
||||
|
||||
[[nodiscard]] OwnerCounts
|
||||
ownerCountHook(AccountID const& account, OwnerCounts const& count) const override;
|
||||
[[nodiscard]] std::uint32_t
|
||||
ownerCountHook(AccountID const& account, std::uint32_t count) const override;
|
||||
|
||||
/** Apply changes to base view.
|
||||
|
||||
|
||||
@@ -4,17 +4,15 @@
|
||||
#include <xrpl/basics/chrono.h>
|
||||
#include <xrpl/beast/hash/uhash.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/ledger/OwnerCounts.h>
|
||||
#include <xrpl/ledger/detail/ReadViewFwdRange.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Fees.h>
|
||||
#include <xrpl/protocol/Issue.h> // IWYU pragma: keep
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
#include <xrpl/protocol/LedgerHeader.h>
|
||||
#include <xrpl/protocol/MPTIssue.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/Rules.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
@@ -191,8 +189,8 @@ public:
|
||||
// changes that accounts make during a payment. `ownerCountHook` adjusts the
|
||||
// ownerCount so it returns the max value of the ownerCount so far.
|
||||
// This is required to support PaymentSandbox.
|
||||
[[nodiscard]] virtual OwnerCounts
|
||||
ownerCountHook(AccountID const& account, OwnerCounts const& count) const
|
||||
[[nodiscard]] virtual std::uint32_t
|
||||
ownerCountHook(AccountID const& account, std::uint32_t count) const
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,8 @@ canWithdraw(ReadView const& view, STTx const& tx);
|
||||
|
||||
[[nodiscard]] TER
|
||||
doWithdraw(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
STTx const& tx,
|
||||
AccountID const& senderAcct,
|
||||
AccountID const& dstAcct,
|
||||
AccountID const& sourceAcct,
|
||||
|
||||
@@ -105,7 +105,7 @@ private:
|
||||
using items_t = std::map<
|
||||
key_type,
|
||||
SleAction,
|
||||
std::less<>,
|
||||
std::less<key_type>,
|
||||
boost::container::pmr::polymorphic_allocator<std::pair<key_type const, SleAction>>>;
|
||||
// monotonic_resource_ must outlive `items_`. Make a pointer so it may be
|
||||
// easily moved.
|
||||
|
||||
@@ -108,8 +108,8 @@ public:
|
||||
std::optional<value_type> mutable cache_;
|
||||
};
|
||||
|
||||
static_assert(std::is_nothrow_move_constructible<Iterator>{});
|
||||
static_assert(std::is_nothrow_move_assignable<Iterator>{});
|
||||
static_assert(std::is_nothrow_move_constructible<Iterator>{}, "");
|
||||
static_assert(std::is_nothrow_move_assignable<Iterator>{}, "");
|
||||
|
||||
using const_iterator = Iterator;
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@@ -27,293 +26,21 @@ namespace xrpl {
|
||||
[[nodiscard]] bool
|
||||
isGlobalFrozen(ReadView const& view, AccountID const& issuer);
|
||||
|
||||
/** Calculate liquid XRP balance for an account.
|
||||
*
|
||||
* This function may be used to calculate the amount of XRP that
|
||||
* the holder is able to freely spend. It subtracts reserve requirements.
|
||||
*
|
||||
* ownerCountAdj adjusts the owner count in case the caller calculates
|
||||
* before ledger entries are added or removed. Positive to add, negative
|
||||
* to subtract.
|
||||
*
|
||||
* @param view The ledger view to read from
|
||||
* @param id The account ID to check
|
||||
* @param ownerCountAdj Positive to add to count, negative to reduce count
|
||||
* @param j Journal for logging
|
||||
* @return The liquid XRP amount available to the account
|
||||
*/
|
||||
// Calculate liquid XRP balance for an account.
|
||||
// This function may be used to calculate the amount of XRP that
|
||||
// the holder is able to freely spend. It subtracts reserve requirements.
|
||||
//
|
||||
// ownerCountAdj adjusts the owner count in case the caller calculates
|
||||
// before ledger entries are added or removed. Positive to add, negative
|
||||
// to subtract.
|
||||
//
|
||||
// @param ownerCountAdj positive to add to count, negative to reduce count.
|
||||
[[nodiscard]] XRPAmount
|
||||
xrpLiquid(ReadView const& view, AccountID const& id, std::int32_t ownerCountAdj, beast::Journal j);
|
||||
|
||||
struct Adjustment
|
||||
{
|
||||
std::int32_t ownerCountDelta = 0;
|
||||
std::int32_t accountCountDelta = 0;
|
||||
};
|
||||
|
||||
/** Returns the account reserve, in drops.
|
||||
*
|
||||
* Actual owner count can be adjusted by delta in ownerCountAdj
|
||||
* Actual reserve count can be adjusted by delta in accountCountAdj
|
||||
* The reserve is calculated as:
|
||||
* (ownerCount + "sponsoring object count" - "sponsored object count" + additionalOwnerCount) *
|
||||
* increment + (1 if not sponsored account + sponsoringAccountCount) * "reserve base"
|
||||
*
|
||||
* @param view The ledger view to read from
|
||||
* @param sle The ledger entry for the account
|
||||
* @param j Journal for logging
|
||||
* @param adj Adjustment to the owner/account count (default: 0/0). Positive to add, negative to
|
||||
* subtract.
|
||||
* @return The account reserve amount in drops
|
||||
*/
|
||||
[[nodiscard]] XRPAmount
|
||||
accountReserve(ReadView const& view, SLE::const_ref sle, beast::Journal j, Adjustment adj = {});
|
||||
|
||||
/** Convenience overload that accepts AccountID instead of SLE.
|
||||
*
|
||||
* @param view The ledger view to read from
|
||||
* @param id The account ID
|
||||
* @param j Journal for logging
|
||||
* @param adj Adjustment to the owner/account count (default: 0/0). Positive to add, negative to
|
||||
* subtract.
|
||||
* @return The account reserve amount in drops
|
||||
*/
|
||||
[[nodiscard]] inline XRPAmount
|
||||
accountReserve(ReadView const& view, AccountID const& id, beast::Journal j, Adjustment adj = {})
|
||||
{
|
||||
return accountReserve(view, view.read(keylet::account(id)), j, adj);
|
||||
}
|
||||
|
||||
/** Check if an account has sufficient reserve.
|
||||
*
|
||||
* @param view The ledger view to read from
|
||||
* @param tx The transaction being processed
|
||||
* @param accSle The account's ledger entry
|
||||
* @param accBalance The account's balance
|
||||
* @param sponsorSle The sponsor's ledger entry (if applicable)
|
||||
* @param adj Adjustment to the owner/account count (default: 0/0). Positive to add, negative to
|
||||
* subtract.
|
||||
* @param j Journal for logging (default: null sink)
|
||||
* @param insufReserveCode The transaction result code to return if the reserve is insufficient
|
||||
* (default: tecINSUFFICIENT_RESERVE).
|
||||
* @return Transaction result code
|
||||
*/
|
||||
[[nodiscard]] TER
|
||||
checkReserve(
|
||||
ApplyViewContext ctx,
|
||||
SLE::const_ref accSle,
|
||||
XRPAmount accBalance,
|
||||
SLE::const_ref sponsorSle,
|
||||
Adjustment adj,
|
||||
beast::Journal j,
|
||||
TER insufReserveCode = tecINSUFFICIENT_RESERVE);
|
||||
|
||||
/** Check if an account has sufficient reserve, deriving the sponsor internally.
|
||||
*
|
||||
* Equivalent to the overload above, but resolves the sponsor via
|
||||
* getEffectiveTxReserveSponsor(ctx, accSle) instead of taking it explicitly. Use this
|
||||
* in the common case where the sponsor is simply the transaction's reserve
|
||||
* sponsor for accSle. Callers that must force the account's-own-reserve branch
|
||||
* (passing a null sponsor) or supply a different sponsor should use the
|
||||
* explicit overload above.
|
||||
*
|
||||
* @param ctx The apply-view context (view + tx)
|
||||
* @param accSle The account's ledger entry
|
||||
* @param accBalance The account's balance
|
||||
* @param adj Reserve adjustments (owner/account count deltas)
|
||||
* @param j Journal for logging (default: null sink)
|
||||
* @return Transaction result code
|
||||
*/
|
||||
[[nodiscard]] TER
|
||||
checkReserve(
|
||||
ApplyViewContext ctx,
|
||||
SLE::const_ref accSle,
|
||||
XRPAmount accBalance,
|
||||
Adjustment adj,
|
||||
beast::Journal j = beast::Journal{beast::Journal::getNullSink()});
|
||||
|
||||
/** Return number of the objects which reserve is covered by the account(sle) (so called "owner
|
||||
* count"). Actual owner count can be adjusted by delta in ownerCountAdj.
|
||||
*
|
||||
* @param sle The account's ledger entry
|
||||
* @param j Journal for logging
|
||||
* @param ownerCountAdj Adjustment to the owner count (default: 0)
|
||||
* @return The adjusted owner count
|
||||
*/
|
||||
std::uint32_t
|
||||
ownerCount(SLE::const_ref sle, beast::Journal j, std::int32_t ownerCountAdj = 0);
|
||||
|
||||
/** Increase owner-count fields when the caller supplies the sponsor.
|
||||
*
|
||||
* This helper does not create a ledger object. It updates reserve accounting
|
||||
* after the caller has created/updated an object.
|
||||
* If sponsorSle is provided, this also adjusts the account's sponsored count
|
||||
* and the sponsor's sponsoring count.
|
||||
*
|
||||
* @param view The apply view for making changes
|
||||
* @param accountSle The account's ledger entry
|
||||
* @param sponsorSle The sponsor's ledger entry (if applicable)
|
||||
* @param count Amount to add to the owner count
|
||||
* @param j Journal for logging
|
||||
*/
|
||||
/** Adjust the owner count up or down. */
|
||||
void
|
||||
increaseOwnerCount(
|
||||
ApplyView& view,
|
||||
SLE::ref accountSle,
|
||||
SLE::ref sponsorSle,
|
||||
std::uint32_t count,
|
||||
beast::Journal j);
|
||||
|
||||
/** Increase owner-count fields, deriving the tx reserve sponsor internally.
|
||||
*
|
||||
* Equivalent to the overload above, but resolves the sponsor via
|
||||
* getEffectiveTxReserveSponsor(ctx, accountSle) instead of taking it explicitly. Use
|
||||
* this when the sponsor is the transaction's reserve sponsor for accountSle
|
||||
* (the common create path). Deletion paths, which derive the sponsor from an
|
||||
* object's sfSponsor field, should keep using the explicit overload.
|
||||
*
|
||||
* @param ctx The apply-view context (view + tx)
|
||||
* @param accountSle The account's ledger entry
|
||||
* @param count Amount to add to the owner count
|
||||
* @param j Journal for logging
|
||||
*/
|
||||
void
|
||||
increaseOwnerCount(
|
||||
ApplyViewContext ctx,
|
||||
SLE::ref accountSle,
|
||||
std::uint32_t count,
|
||||
beast::Journal j);
|
||||
|
||||
/** Convenience overload that accepts AccountID instead of SLE references.
|
||||
*
|
||||
* @param view The apply view for making changes
|
||||
* @param account The account ID
|
||||
* @param sponsor The optional sponsor account ID
|
||||
* @param count Amount to add to the owner count
|
||||
* @param j Journal for logging
|
||||
*/
|
||||
inline void
|
||||
increaseOwnerCount(
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
std::optional<AccountID> const& sponsor,
|
||||
std::uint32_t count,
|
||||
beast::Journal j)
|
||||
{
|
||||
increaseOwnerCount(
|
||||
view,
|
||||
view.peek(keylet::account(account)),
|
||||
sponsor ? view.peek(keylet::account(*sponsor)) : SLE::pointer(),
|
||||
count,
|
||||
j);
|
||||
}
|
||||
|
||||
/** Decrease owner-count fields when the caller supplies the sponsor.
|
||||
*
|
||||
* This helper does not delete a ledger object. It updates reserve accounting
|
||||
* after the caller has removed an owner-counted reserve, or for special
|
||||
* owner-count changes whose sponsor cannot be derived from an object's
|
||||
* sfSponsor field.
|
||||
*
|
||||
* @param view The apply view for making changes
|
||||
* @param accountSle The account's ledger entry
|
||||
* @param sponsorSle The sponsor's ledger entry (if applicable)
|
||||
* @param count Amount to remove from the owner count
|
||||
* @param j Journal for logging
|
||||
*/
|
||||
void
|
||||
decreaseOwnerCount(
|
||||
ApplyView& view,
|
||||
SLE::ref accountSle,
|
||||
SLE::ref sponsorSle,
|
||||
std::uint32_t count,
|
||||
beast::Journal j);
|
||||
|
||||
/** Convenience overload that accepts AccountID instead of SLE references.
|
||||
*
|
||||
* @param view The apply view for making changes
|
||||
* @param account The account ID
|
||||
* @param sponsor The optional sponsor account ID
|
||||
* @param count Amount to remove from the owner count
|
||||
* @param j Journal for logging
|
||||
*/
|
||||
inline void
|
||||
decreaseOwnerCount(
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
std::optional<AccountID> const& sponsor,
|
||||
std::uint32_t count,
|
||||
beast::Journal j)
|
||||
{
|
||||
decreaseOwnerCount(
|
||||
view,
|
||||
view.peek(keylet::account(account)),
|
||||
sponsor ? view.peek(keylet::account(*sponsor)) : SLE::pointer(),
|
||||
count,
|
||||
j);
|
||||
}
|
||||
|
||||
/** Decrease owner-count fields for an existing ledger object.
|
||||
*
|
||||
* This helper derives the reserve sponsor from objectSle's sfSponsor field,
|
||||
* then updates the same owner-count fields as decreaseOwnerCount. Use this
|
||||
* when removing an existing object whose reserve sponsor is stored on that
|
||||
* object.
|
||||
*
|
||||
* @param view The apply view for making changes
|
||||
* @param accountSle The account's ledger entry
|
||||
* @param objectSle The object's ledger entry
|
||||
* @param count Amount to remove from the owner count
|
||||
* @param j Journal for logging
|
||||
*/
|
||||
void
|
||||
decreaseOwnerCountForObject(
|
||||
ApplyView& view,
|
||||
SLE::ref accountSle,
|
||||
SLE::ref objectSle,
|
||||
std::uint32_t count,
|
||||
beast::Journal j);
|
||||
|
||||
/** Convenience overload that accepts AccountID instead of account SLE reference.
|
||||
*
|
||||
* @param view The apply view for making changes
|
||||
* @param account The account ID
|
||||
* @param objectSle The object's ledger entry
|
||||
* @param count Amount to remove from the owner count
|
||||
* @param j Journal for logging
|
||||
*/
|
||||
inline void
|
||||
decreaseOwnerCountForObject(
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
SLE::ref objectSle,
|
||||
std::uint32_t count,
|
||||
beast::Journal j)
|
||||
{
|
||||
SLE::ref accountSle = view.peek(keylet::account(account));
|
||||
decreaseOwnerCountForObject(view, accountSle, objectSle, count, j);
|
||||
}
|
||||
|
||||
/** Adjust a LoanBroker's owner count.
|
||||
*
|
||||
* A LoanBroker's sfOwnerCount tracks the number of outstanding loans on
|
||||
* that broker; it is not a reserve-backed owner count and is distinct
|
||||
* from the broker's pseudo-account's owner count. Loans can never carry a
|
||||
* reserve sponsor (LoanSet rejects reserve sponsorship at preflight), so
|
||||
* this never involves sponsor accounting and never invokes the
|
||||
* ownerCountHook used for ACCOUNT_ROOT reserve tracking.
|
||||
*
|
||||
* @param view The apply view for making changes
|
||||
* @param brokerSle The LoanBroker's ledger entry
|
||||
* @param delta Amount to add (positive) or remove (negative) from the count
|
||||
* @param j Journal for logging
|
||||
*/
|
||||
void
|
||||
adjustLoanBrokerOwnerCount(
|
||||
ApplyView& view,
|
||||
SLE::ref brokerSle,
|
||||
std::int32_t delta,
|
||||
beast::Journal j);
|
||||
adjustOwnerCount(ApplyView& view, SLE::ref sle, std::int32_t amount, beast::Journal j);
|
||||
|
||||
/** Returns IOU issuer transfer fee as Rate. Rate specifies
|
||||
* the fee as fractions of 1 billion. For example, 1% transfer rate
|
||||
|
||||
@@ -19,7 +19,11 @@ namespace xrpl {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <class V, class N>
|
||||
template <
|
||||
class V,
|
||||
class N,
|
||||
class = std::enable_if_t<
|
||||
std::is_same_v<std::remove_cv_t<N>, SLE> && std::is_base_of_v<ReadView, V>>>
|
||||
bool
|
||||
internalDirNext(
|
||||
V& view,
|
||||
@@ -27,7 +31,6 @@ internalDirNext(
|
||||
std::shared_ptr<N>& page,
|
||||
unsigned int& index,
|
||||
uint256& entry)
|
||||
requires(std::is_same_v<std::remove_cv_t<N>, SLE> && std::is_base_of_v<ReadView, V>)
|
||||
{
|
||||
auto const& svIndexes = page->getFieldV256(sfIndexes);
|
||||
XRPL_ASSERT(index <= svIndexes.size(), "xrpl::detail::internalDirNext : index inside range");
|
||||
@@ -65,7 +68,11 @@ internalDirNext(
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class V, class N>
|
||||
template <
|
||||
class V,
|
||||
class N,
|
||||
class = std::enable_if_t<
|
||||
std::is_same_v<std::remove_cv_t<N>, SLE> && std::is_base_of_v<ReadView, V>>>
|
||||
bool
|
||||
internalDirFirst(
|
||||
V& view,
|
||||
@@ -73,7 +80,6 @@ internalDirFirst(
|
||||
std::shared_ptr<N>& page,
|
||||
unsigned int& index,
|
||||
uint256& entry)
|
||||
requires(std::is_same_v<std::remove_cv_t<N>, SLE> && std::is_base_of_v<ReadView, V>)
|
||||
{
|
||||
if constexpr (std::is_const_v<N>)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
|
||||
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
|
||||
#include <xrpl/ledger/helpers/RippleStateHelpers.h>
|
||||
#include <xrpl/ledger/helpers/SponsorHelpers.h>
|
||||
#include <xrpl/ledger/helpers/TokenHelpers.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Concepts.h>
|
||||
@@ -23,15 +22,17 @@
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
template <ValidIssueType T>
|
||||
TER
|
||||
escrowUnlockApplyHelper(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
Rate lockedRate,
|
||||
SLE::ref sleDest,
|
||||
XRPAmount xrpBalance,
|
||||
STAmount const& xrpBalance,
|
||||
STAmount const& amount,
|
||||
AccountID const& issuer,
|
||||
AccountID const& sender,
|
||||
@@ -42,10 +43,10 @@ escrowUnlockApplyHelper(
|
||||
template <>
|
||||
inline TER
|
||||
escrowUnlockApplyHelper<Issue>(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
Rate lockedRate,
|
||||
SLE::ref sleDest,
|
||||
XRPAmount xrpBalance,
|
||||
STAmount const& xrpBalance,
|
||||
STAmount const& amount,
|
||||
AccountID const& issuer,
|
||||
AccountID const& sender,
|
||||
@@ -53,7 +54,7 @@ escrowUnlockApplyHelper<Issue>(
|
||||
bool createAsset,
|
||||
beast::Journal journal)
|
||||
{
|
||||
auto const& issue = amount.get<Issue>();
|
||||
Issue const& issue = amount.get<Issue>();
|
||||
Keylet const trustLineKey = keylet::trustLine(receiver, issue);
|
||||
bool const recvLow = issuer > receiver;
|
||||
bool const senderIssuer = issuer == sender;
|
||||
@@ -65,26 +66,16 @@ escrowUnlockApplyHelper<Issue>(
|
||||
if (receiverIssuer)
|
||||
return tesSUCCESS;
|
||||
|
||||
if (!ctx.view.exists(trustLineKey) && createAsset)
|
||||
if (!view.exists(trustLineKey) && createAsset)
|
||||
{
|
||||
// Can the account cover the trust line's reserve?
|
||||
auto const sponsorSle = getEffectiveTxReserveSponsor(ctx, sleDest);
|
||||
if (!sponsorSle)
|
||||
return sponsorSle.error(); // LCOV_EXCL_LINE
|
||||
|
||||
if (auto const ret = checkReserve(
|
||||
ctx,
|
||||
sleDest,
|
||||
xrpBalance,
|
||||
*sponsorSle,
|
||||
{.ownerCountDelta = 1},
|
||||
journal,
|
||||
tecNO_LINE_INSUF_RESERVE);
|
||||
!isTesSuccess(ret))
|
||||
if (std::uint32_t const ownerCount = {sleDest->at(sfOwnerCount)};
|
||||
xrpBalance < view.fees().accountReserve(ownerCount + 1))
|
||||
{
|
||||
JLOG(journal.trace()) << "Trust line does not exist. "
|
||||
"Insufficient reserve to create line.";
|
||||
return ret;
|
||||
|
||||
return tecNO_LINE_INSUF_RESERVE;
|
||||
}
|
||||
|
||||
Currency const currency = issue.currency;
|
||||
@@ -92,7 +83,7 @@ escrowUnlockApplyHelper<Issue>(
|
||||
initialBalance.get<Issue>().account = noAccount();
|
||||
|
||||
if (TER const ter = trustCreate(
|
||||
ctx.view, // payment sandbox
|
||||
view, // payment sandbox
|
||||
recvLow, // is dest low?
|
||||
issuer, // source
|
||||
receiver, // destination
|
||||
@@ -106,20 +97,19 @@ escrowUnlockApplyHelper<Issue>(
|
||||
Issue(currency, receiver), // limit of zero
|
||||
0, // quality in
|
||||
0, // quality out
|
||||
*sponsorSle, // sponsor
|
||||
journal); // journal
|
||||
!isTesSuccess(ter))
|
||||
{
|
||||
return ter; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
ctx.view.update(sleDest);
|
||||
view.update(sleDest);
|
||||
}
|
||||
|
||||
if (!ctx.view.exists(trustLineKey) && !receiverIssuer)
|
||||
if (!view.exists(trustLineKey) && !receiverIssuer)
|
||||
return tecNO_LINE;
|
||||
|
||||
auto const xferRate = transferRate(ctx.view, amount);
|
||||
auto const xferRate = transferRate(view, amount);
|
||||
// update if issuer rate is less than locked rate
|
||||
if (xferRate < lockedRate)
|
||||
lockedRate = xferRate;
|
||||
@@ -147,7 +137,7 @@ escrowUnlockApplyHelper<Issue>(
|
||||
// of the funds
|
||||
if (!createAsset)
|
||||
{
|
||||
auto const sleRippleState = ctx.view.peek(trustLineKey);
|
||||
auto const sleRippleState = view.peek(trustLineKey);
|
||||
if (!sleRippleState)
|
||||
return tecINTERNAL; // LCOV_EXCL_LINE
|
||||
|
||||
@@ -173,7 +163,7 @@ escrowUnlockApplyHelper<Issue>(
|
||||
// if destination is not the issuer then transfer funds
|
||||
if (!receiverIssuer)
|
||||
{
|
||||
auto const ter = directSendNoFee(ctx.view, issuer, receiver, finalAmt, true, journal);
|
||||
auto const ter = directSendNoFee(view, issuer, receiver, finalAmt, true, journal);
|
||||
if (!isTesSuccess(ter))
|
||||
return ter; // LCOV_EXCL_LINE
|
||||
}
|
||||
@@ -183,10 +173,10 @@ escrowUnlockApplyHelper<Issue>(
|
||||
template <>
|
||||
inline TER
|
||||
escrowUnlockApplyHelper<MPTIssue>(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
Rate lockedRate,
|
||||
SLE::ref sleDest,
|
||||
XRPAmount xrpBalance,
|
||||
STAmount const& xrpBalance,
|
||||
STAmount const& amount,
|
||||
AccountID const& issuer,
|
||||
AccountID const& sender,
|
||||
@@ -199,32 +189,27 @@ escrowUnlockApplyHelper<MPTIssue>(
|
||||
|
||||
auto const mptID = amount.get<MPTIssue>().getMptID();
|
||||
auto const issuanceKey = keylet::mptokenIssuance(mptID);
|
||||
auto const mptKeylet = keylet::mptoken(issuanceKey.key, receiver);
|
||||
if (!ctx.view.exists(mptKeylet) && createAsset && !receiverIssuer)
|
||||
if (!view.exists(keylet::mptoken(issuanceKey.key, receiver)) && createAsset && !receiverIssuer)
|
||||
{
|
||||
auto const sponsorSle = getEffectiveTxReserveSponsor(ctx, sleDest);
|
||||
if (!sponsorSle)
|
||||
return sponsorSle.error(); // LCOV_EXCL_LINE
|
||||
if (std::uint32_t const ownerCount = {sleDest->at(sfOwnerCount)};
|
||||
xrpBalance < view.fees().accountReserve(ownerCount + 1))
|
||||
{
|
||||
return tecINSUFFICIENT_RESERVE;
|
||||
}
|
||||
|
||||
if (auto const ret = checkReserve(
|
||||
ctx, sleDest, xrpBalance, *sponsorSle, {.ownerCountDelta = 1}, journal);
|
||||
!isTesSuccess(ret))
|
||||
return ret;
|
||||
|
||||
if (auto const ter = createMPToken(ctx.view, mptID, receiver, *sponsorSle, 0);
|
||||
!isTesSuccess(ter))
|
||||
if (auto const ter = createMPToken(view, mptID, receiver, 0); !isTesSuccess(ter))
|
||||
{
|
||||
return ter; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
// update owner count.
|
||||
increaseOwnerCount(ctx.view, sleDest, *sponsorSle, 1, journal);
|
||||
adjustOwnerCount(view, sleDest, 1, journal);
|
||||
}
|
||||
|
||||
if (!ctx.view.exists(mptKeylet) && !receiverIssuer)
|
||||
if (!view.exists(keylet::mptoken(issuanceKey.key, receiver)) && !receiverIssuer)
|
||||
return tecNO_PERMISSION;
|
||||
|
||||
auto const xferRate = transferRate(ctx.view, amount);
|
||||
auto const xferRate = transferRate(view, amount);
|
||||
// update if issuer rate is less than locked rate
|
||||
if (xferRate < lockedRate)
|
||||
lockedRate = xferRate;
|
||||
@@ -247,11 +232,11 @@ escrowUnlockApplyHelper<MPTIssue>(
|
||||
finalAmt = amount.value() - xferFee;
|
||||
}
|
||||
return unlockEscrowMPT(
|
||||
ctx.view,
|
||||
view,
|
||||
sender,
|
||||
receiver,
|
||||
finalAmt,
|
||||
ctx.view.rules().enabled(fixTokenEscrowV1) ? amount : finalAmt,
|
||||
view.rules().enabled(fixTokenEscrowV1) ? amount : finalAmt,
|
||||
journal);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/protocol/Asset.h>
|
||||
#include <xrpl/protocol/LedgerFormats.h> // IWYU pragma: keep
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/Rules.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
|
||||
@@ -86,7 +86,7 @@ canAddHolding(ReadView const& view, MPTIssue const& mptIssue);
|
||||
|
||||
[[nodiscard]] TER
|
||||
authorizeMPToken(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
XRPAmount const& priorBalance,
|
||||
MPTID const& mptIssuanceID,
|
||||
AccountID const& account,
|
||||
@@ -117,7 +117,7 @@ requireAuth(
|
||||
*/
|
||||
[[nodiscard]] TER
|
||||
enforceMPTokenAuthorization(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
MPTID const& mptIssuanceID,
|
||||
AccountID const& account,
|
||||
XRPAmount const& priorBalance,
|
||||
@@ -203,7 +203,7 @@ canMPTTradeAndTransfer(
|
||||
|
||||
[[nodiscard]] TER
|
||||
addEmptyHolding(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
AccountID const& accountID,
|
||||
XRPAmount priorBalance,
|
||||
MPTIssue const& mptIssue,
|
||||
@@ -211,7 +211,7 @@ addEmptyHolding(
|
||||
|
||||
[[nodiscard]] TER
|
||||
removeEmptyHolding(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
AccountID const& accountID,
|
||||
MPTIssue const& mptIssue,
|
||||
beast::Journal journal);
|
||||
@@ -243,7 +243,6 @@ createMPToken(
|
||||
ApplyView& view,
|
||||
MPTID const& mptIssuanceID,
|
||||
AccountID const& account,
|
||||
SLE::ref sponsorSle,
|
||||
std::uint32_t const flags);
|
||||
|
||||
TER
|
||||
@@ -251,7 +250,6 @@ checkCreateMPT(
|
||||
xrpl::ApplyView& view,
|
||||
xrpl::MPTIssue const& mptIssue,
|
||||
xrpl::AccountID const& holder,
|
||||
SLE::ref sponsorSle,
|
||||
beast::Journal j);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STArray.h> // IWYU pragma: keep
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
constexpr std::uint32_t kMinOracleReserveCount = 1;
|
||||
constexpr std::uint32_t kMaxOracleReserveCount = 2;
|
||||
constexpr std::size_t kOracleReserveCountThreshold = 5;
|
||||
|
||||
template <typename T>
|
||||
requires requires(T const& t) { t.size(); }
|
||||
inline std::uint32_t
|
||||
calculateOracleReserve(T const& priceDataSeries)
|
||||
{
|
||||
return priceDataSeries.size() > kOracleReserveCountThreshold ? kMaxOracleReserveCount
|
||||
: kMinOracleReserveCount;
|
||||
}
|
||||
|
||||
inline std::uint32_t
|
||||
calculateOracleReserve(SLE::const_ref oracleSle)
|
||||
{
|
||||
return calculateOracleReserve(oracleSle->getFieldArray(sfPriceDataSeries));
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -156,7 +156,6 @@ trustCreate(
|
||||
// Issuer should be the account being set.
|
||||
std::uint32_t uQualityIn,
|
||||
std::uint32_t uQualityOut,
|
||||
SLE::ref sponsorSle,
|
||||
beast::Journal j);
|
||||
|
||||
[[nodiscard]] TER
|
||||
@@ -179,7 +178,6 @@ issueIOU(
|
||||
AccountID const& account,
|
||||
STAmount const& amount,
|
||||
Issue const& issue,
|
||||
SLE::ref sponsorSle,
|
||||
beast::Journal j);
|
||||
|
||||
[[nodiscard]] TER
|
||||
@@ -237,7 +235,7 @@ canTransfer(ReadView const& view, Issue const& issue, AccountID const& from, Acc
|
||||
/// canAddHolding() in preflight with the same View and Asset
|
||||
[[nodiscard]] TER
|
||||
addEmptyHolding(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
AccountID const& accountID,
|
||||
XRPAmount priorBalance,
|
||||
Issue const& issue,
|
||||
@@ -245,7 +243,7 @@ addEmptyHolding(
|
||||
|
||||
[[nodiscard]] TER
|
||||
removeEmptyHolding(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
AccountID const& accountID,
|
||||
Issue const& issue,
|
||||
beast::Journal journal);
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/TxFormats.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/** Whether the given transaction type may use reserve sponsorship (v1).
|
||||
*
|
||||
* Reserve sponsorship is restricted to an explicit allow-list of transaction
|
||||
* types; all others reject spfSponsorReserve at preflight.
|
||||
*/
|
||||
bool
|
||||
isReserveSponsorAllowed(TxType txType);
|
||||
|
||||
/** Whether the transaction's fee is sponsored (sfSponsor present + spfSponsorFee set). */
|
||||
inline bool
|
||||
isFeeSponsored(STTx const& tx)
|
||||
{
|
||||
return tx.isFieldPresent(sfSponsor) && ((tx.getFieldU32(sfSponsorFlags) & spfSponsorFee) != 0u);
|
||||
}
|
||||
|
||||
/** Whether the transaction's reserve is sponsored (sfSponsor present + spfSponsorReserve set). */
|
||||
inline bool
|
||||
isReserveSponsored(STTx const& tx)
|
||||
{
|
||||
return tx.isFieldPresent(sfSponsor) &&
|
||||
((tx.getFieldU32(sfSponsorFlags) & spfSponsorReserve) != 0u);
|
||||
}
|
||||
|
||||
/** Return the AccountID of the transaction's reserve sponsor, or nullopt if unsponsored. */
|
||||
std::optional<AccountID>
|
||||
getTxReserveSponsorID(STTx const& tx);
|
||||
|
||||
/** Return a mutable SLE for the transaction's reserve sponsor account.
|
||||
*
|
||||
* @param ctx The apply-view context (view + tx)
|
||||
* @return The sponsor account SLE, a null pointer if the tx is not
|
||||
* reserve-sponsored, or tecINTERNAL if the sponsor account cannot
|
||||
* be loaded (an already-checked invariant).
|
||||
*/
|
||||
std::expected<SLE::pointer, TER>
|
||||
getTxReserveSponsor(ApplyViewContext ctx);
|
||||
|
||||
/** Return a read-only SLE for the transaction's reserve sponsor account.
|
||||
*
|
||||
* @param view The ledger read view
|
||||
* @param tx The transaction to inspect
|
||||
* @return The sponsor account SLE, a null pointer if the tx is not
|
||||
* reserve-sponsored, or tecINTERNAL if the sponsor account cannot
|
||||
* be loaded (an already-checked invariant).
|
||||
*/
|
||||
std::expected<SLE::const_pointer, TER>
|
||||
getTxReserveSponsor(ReadView const& view, STTx const& tx);
|
||||
|
||||
/** The transaction's reserve sponsor for the given account, if applicable.
|
||||
*
|
||||
* A reserve sponsor only covers the transaction submitter's own objects, so
|
||||
* this returns the tx reserve sponsor SLE only when accountSle is the tx's own
|
||||
* (non-pseudo) account; otherwise it returns a null sponsor pointer. This is
|
||||
* the single source of truth for the "sponsor applies to tx.Account only" rule
|
||||
* that the sponsor-deriving helper overloads in AccountRootHelpers rely on.
|
||||
*
|
||||
* @param ctx The apply-view context (view + tx)
|
||||
* @param accountSle The account whose sponsor is being resolved
|
||||
* @return The sponsor SLE (nullptr if unsponsored), or tecINTERNAL if the
|
||||
* sponsor account cannot be loaded (an already-checked invariant)
|
||||
*/
|
||||
[[nodiscard]] std::expected<SLE::pointer, TER>
|
||||
getEffectiveTxReserveSponsor(ApplyViewContext ctx, SLE::const_ref accountSle);
|
||||
|
||||
/** Return the AccountID stored in the given sponsor field of a ledger entry, or nullopt if absent.
|
||||
*/
|
||||
std::optional<AccountID>
|
||||
getLedgerEntryReserveSponsorID(SLE::const_ref sle, SF_ACCOUNT const& field = sfSponsor);
|
||||
|
||||
/** Return a mutable SLE for the reserve sponsor recorded on a ledger entry.
|
||||
*
|
||||
* Reads the sponsor AccountID from @p field on @p sle and peeks the
|
||||
* corresponding account root in @p view.
|
||||
*
|
||||
* @param view The mutable apply view
|
||||
* @param sle The ledger entry whose sponsor field is inspected
|
||||
* @param field The field that holds the sponsor AccountID (defaults to sfSponsor)
|
||||
* @return The sponsor account SLE, or a null pointer if the entry is unsponsored.
|
||||
*/
|
||||
SLE::pointer
|
||||
getLedgerEntryReserveSponsor(
|
||||
ApplyView& view,
|
||||
SLE::const_ref sle,
|
||||
SF_ACCOUNT const& field = sfSponsor);
|
||||
|
||||
/** Stamp a reserve sponsor onto a ledger entry using an explicit sponsor SLE.
|
||||
*
|
||||
* Sets @p field on @p sle to the AccountID from @p sponsorSle. A no-op when
|
||||
* @p sponsorSle is null (unsponsored). For RippleState entries the field must
|
||||
* be sfHighSponsor or sfLowSponsor; for all other entry types it must be
|
||||
* sfSponsor.
|
||||
*
|
||||
* @param sle The ledger entry to stamp
|
||||
* @param sponsorSle The sponsor's account root SLE (null → no-op)
|
||||
* @param field The sponsor field to set (defaults to sfSponsor)
|
||||
*/
|
||||
void
|
||||
addSponsorToLedgerEntry(
|
||||
SLE::ref sle,
|
||||
SLE::const_ref sponsorSle,
|
||||
SF_ACCOUNT const& field = sfSponsor);
|
||||
|
||||
/** Stamp the transaction's reserve sponsor onto a newly-created ledger entry.
|
||||
*
|
||||
* Equivalent to the overload above, but resolves the sponsor via
|
||||
* getTxReserveSponsor(ctx) instead of taking it explicitly. A no-op when the
|
||||
* transaction is not reserve-sponsored. The entry is assumed to be owned by
|
||||
* the transaction submitter, which is the only account a tx reserve sponsor
|
||||
* can cover.
|
||||
*/
|
||||
void
|
||||
addSponsorToLedgerEntry(ApplyViewContext ctx, SLE::ref sle, SF_ACCOUNT const& field = sfSponsor);
|
||||
|
||||
/** Remove the reserve sponsor field from a ledger entry.
|
||||
*
|
||||
* A no-op when @p field is not present on @p sle. For RippleState entries
|
||||
* the field must be sfHighSponsor or sfLowSponsor; for all other entry types
|
||||
* it must be sfSponsor.
|
||||
*
|
||||
* @param sle The ledger entry to modify
|
||||
* @param field The sponsor field to clear (defaults to sfSponsor)
|
||||
*/
|
||||
void
|
||||
removeSponsorFromLedgerEntry(SLE::ref sle, SF_ACCOUNT const& field = sfSponsor);
|
||||
|
||||
/** Whether @p account is the owner of a ledger entry for sponsorship purposes.
|
||||
*
|
||||
* Ownership rules vary by entry type. For RippleState entries the owner is
|
||||
* whichever side of the trust line holds the reserve. For credentials, the
|
||||
* owner is the subject once accepted and the issuer before acceptance.
|
||||
*
|
||||
* @param view The ledger read view (used for SignerList lookup)
|
||||
* @param sle The ledger entry whose owner is checked
|
||||
* @param account The candidate account to match against
|
||||
* @return true if @p account owns @p sle, false otherwise.
|
||||
*/
|
||||
bool
|
||||
isLedgerEntryOwner(ReadView const& view, SLE const& sle, AccountID const& account);
|
||||
|
||||
/** Whether this ledger entry type can have a reserve sponsor attached to it. */
|
||||
bool
|
||||
isLedgerEntrySupportedBySponsorship(SLE const& sle);
|
||||
|
||||
/** Return the number of owner-count units the ledger entry consumes.
|
||||
*
|
||||
* Most entries cost 1. Exceptions: Oracles scale with their price-data series
|
||||
* size, Vaults cost 2 (vault + pseudo-account), and legacy SignerList entries
|
||||
* (pre-MultiSignReserve) cost 2 + signer count.
|
||||
*/
|
||||
std::uint32_t
|
||||
getLedgerEntryOwnerCount(SLE const& sle);
|
||||
|
||||
/** Return the SField used to store the reserve sponsor for @p owner on @p sle.
|
||||
*
|
||||
* For most entry types this is sfSponsor. RippleState entries use
|
||||
* sfHighSponsor or sfLowSponsor depending on which side of the trust line
|
||||
* @p owner holds.
|
||||
*
|
||||
* @param sle The ledger entry
|
||||
* @param owner The account whose sponsor field is needed
|
||||
* @return sfHighSponsor, sfLowSponsor, or sfSponsor as appropriate.
|
||||
*/
|
||||
SF_ACCOUNT const&
|
||||
getLedgerEntrySponsorField(SLE const& sle, AccountID const& owner);
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <xrpl/protocol/MPTIssue.h>
|
||||
#include <xrpl/protocol/Rate.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
@@ -303,7 +302,7 @@ canAddHolding(ReadView const& view, Asset const& asset);
|
||||
|
||||
[[nodiscard]] TER
|
||||
addEmptyHolding(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
AccountID const& accountID,
|
||||
XRPAmount priorBalance,
|
||||
Asset const& asset,
|
||||
@@ -311,7 +310,7 @@ addEmptyHolding(
|
||||
|
||||
[[nodiscard]] TER
|
||||
removeEmptyHolding(
|
||||
ApplyViewContext ctx,
|
||||
ApplyView& view,
|
||||
AccountID const& accountID,
|
||||
Asset const& asset,
|
||||
beast::Journal journal);
|
||||
@@ -372,7 +371,6 @@ accountSend(
|
||||
AccountID const& to,
|
||||
STAmount const& saAmount,
|
||||
beast::Journal j,
|
||||
SLE::ref sponsorSle = {},
|
||||
WaiveTransferFee waiveFee = WaiveTransferFee::No,
|
||||
AllowMPTOverflow allowOverflow = AllowMPTOverflow::No);
|
||||
|
||||
|
||||
@@ -120,9 +120,12 @@ public:
|
||||
socket_->next_layer().async_receive(
|
||||
boost::asio::buffer(buffer_),
|
||||
boost::asio::socket_base::message_peek,
|
||||
[this, cbFunc](error_code const& ec, size_t bytesTransferred) {
|
||||
handleAutodetect(cbFunc, ec, bytesTransferred);
|
||||
});
|
||||
std::bind(
|
||||
&AutoSocket::handleAutodetect,
|
||||
this,
|
||||
cbFunc,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/tls1.h>
|
||||
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
@@ -83,12 +84,13 @@ public:
|
||||
*
|
||||
* @return error_code indicating failures, if any
|
||||
*/
|
||||
template <class T>
|
||||
template <
|
||||
class T,
|
||||
class = std::enable_if_t<
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>>>
|
||||
boost::system::error_code
|
||||
preConnectVerify(T& strm, std::string const& host)
|
||||
requires(
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
if (!SSL_set_tlsext_host_name(strm.native_handle(), host.c_str()))
|
||||
@@ -102,7 +104,11 @@ public:
|
||||
return ec;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <
|
||||
class T,
|
||||
class = std::enable_if_t<
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>>>
|
||||
/**
|
||||
* @brief invoked after connect/async_connect but before sending data
|
||||
* on an ssl stream - to setup name verification.
|
||||
@@ -112,9 +118,6 @@ public:
|
||||
*/
|
||||
boost::system::error_code
|
||||
postConnectVerify(T& strm, std::string const& host)
|
||||
requires(
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
|
||||
@@ -124,9 +127,8 @@ public:
|
||||
if (!ec)
|
||||
{
|
||||
strm.set_verify_callback(
|
||||
[host, j = j_](bool preverified, boost::asio::ssl::verify_context& ctx) {
|
||||
return rfc6125Verify(host, preverified, ctx, j);
|
||||
},
|
||||
std::bind(
|
||||
&rfc6125Verify, host, std::placeholders::_1, std::placeholders::_2, j_),
|
||||
ec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ public:
|
||||
createObject();
|
||||
|
||||
private:
|
||||
bool success_{false};
|
||||
bool success_;
|
||||
|
||||
void const* key_;
|
||||
NodeObjectType objectType_{NodeObjectType::Unknown};
|
||||
unsigned char const* objectData_{nullptr};
|
||||
NodeObjectType objectType_;
|
||||
unsigned char const* objectData_;
|
||||
int dataBytes_;
|
||||
};
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ lz4Compress(void const* in, std::size_t inSize, BufferFactory&& bf)
|
||||
std::array<std::uint8_t, varint_traits<std::size_t>::kMax> vi{};
|
||||
auto const n = writeVarint(vi.data(), inSize);
|
||||
auto const outMax = LZ4_compressBound(inSize);
|
||||
auto* out = reinterpret_cast<std::uint8_t*>(bf(n + outMax));
|
||||
std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(n + outMax));
|
||||
result.first = out;
|
||||
std::memcpy(out, vi.data(), n);
|
||||
auto const outSize = LZ4_compress_default(
|
||||
@@ -90,7 +90,7 @@ nodeobjectDecompress(void const* in, std::size_t inSize, BufferFactory&& bf)
|
||||
{
|
||||
using namespace nudb::detail;
|
||||
|
||||
auto const* p = reinterpret_cast<std::uint8_t const*>(in);
|
||||
std::uint8_t const* p = reinterpret_cast<std::uint8_t const*>(in);
|
||||
std::size_t type = 0;
|
||||
auto const vn = readVarint(p, inSize, type);
|
||||
if (vn == 0)
|
||||
@@ -237,7 +237,7 @@ nodeobjectCompress(void const* in, std::size_t inSize, BufferFactory&& bf)
|
||||
auto const vs = sizeVarint(type);
|
||||
result.second = vs + field<std::uint16_t>::size + // mask
|
||||
(n * 32); // hashes
|
||||
auto* out = reinterpret_cast<std::uint8_t*>(bf(result.second));
|
||||
std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(result.second));
|
||||
result.first = out;
|
||||
ostream os(out, result.second);
|
||||
write<varint>(os, type);
|
||||
@@ -249,7 +249,7 @@ nodeobjectCompress(void const* in, std::size_t inSize, BufferFactory&& bf)
|
||||
auto const type = 3U;
|
||||
auto const vs = sizeVarint(type);
|
||||
result.second = vs + (n * 32); // hashes
|
||||
auto* out = reinterpret_cast<std::uint8_t*>(bf(result.second));
|
||||
std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(result.second));
|
||||
result.first = out;
|
||||
ostream os(out, result.second);
|
||||
write<varint>(os, type);
|
||||
|
||||
@@ -39,7 +39,7 @@ readVarint(void const* buf, std::size_t buflen, std::size_t& t)
|
||||
if (buflen == 0)
|
||||
return 0;
|
||||
t = 0;
|
||||
auto const* p = reinterpret_cast<std::uint8_t const*>(buf);
|
||||
std::uint8_t const* p = reinterpret_cast<std::uint8_t const*>(buf);
|
||||
std::size_t n = 0;
|
||||
while (p[n] & 0x80)
|
||||
{
|
||||
@@ -68,10 +68,9 @@ readVarint(void const* buf, std::size_t buflen, std::size_t& t)
|
||||
return used;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class T, std::enable_if_t<std::is_unsigned_v<T>>* = nullptr>
|
||||
std::size_t
|
||||
sizeVarint(T v)
|
||||
requires(std::is_unsigned_v<T>)
|
||||
{
|
||||
std::size_t n = 0;
|
||||
do
|
||||
@@ -87,7 +86,7 @@ std::size_t
|
||||
writeVarint(void* p0, std::size_t v)
|
||||
{
|
||||
// NOLINTNEXTLINE(misc-const-correctness)
|
||||
auto* p = reinterpret_cast<std::uint8_t*>(p0);
|
||||
std::uint8_t* p = reinterpret_cast<std::uint8_t*>(p0);
|
||||
do
|
||||
{
|
||||
std::uint8_t d = v % 127;
|
||||
@@ -101,10 +100,9 @@ writeVarint(void* p0, std::size_t v)
|
||||
|
||||
// input stream
|
||||
|
||||
template <class T>
|
||||
template <class T, std::enable_if_t<std::is_same_v<T, varint>>* = nullptr>
|
||||
void
|
||||
read(nudb::detail::istream& is, std::size_t& u)
|
||||
requires(std::is_same_v<T, varint>)
|
||||
{
|
||||
auto p0 = is(1);
|
||||
auto p1 = p0;
|
||||
@@ -115,10 +113,9 @@ read(nudb::detail::istream& is, std::size_t& u)
|
||||
|
||||
// output stream
|
||||
|
||||
template <class T>
|
||||
template <class T, std::enable_if_t<std::is_same_v<T, varint>>* = nullptr>
|
||||
void
|
||||
write(nudb::detail::ostream& os, std::size_t t)
|
||||
requires(std::is_same_v<T, varint>)
|
||||
{
|
||||
writeVarint(os.data(sizeVarint(t)), t);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits> // IWYU pragma: keep
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ operator==(Book const& lhs, Book const& rhs)
|
||||
[[nodiscard]] constexpr std::weak_ordering
|
||||
operator<=>(Book const& lhs, Book const& rhs)
|
||||
{
|
||||
if (auto const c{lhs.in <=> rhs.in}; c != 0) // NOLINT(modernize-use-nullptr)
|
||||
if (auto const c{lhs.in <=> rhs.in}; c != 0)
|
||||
return c;
|
||||
if (auto const c{lhs.out <=> rhs.out}; c != 0) // NOLINT(modernize-use-nullptr)
|
||||
if (auto const c{lhs.out <=> rhs.out}; c != 0)
|
||||
return c;
|
||||
|
||||
// Manually compare optionals
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -38,13 +39,13 @@ struct Fees
|
||||
|
||||
/** Returns the account reserve given the owner count, in drops.
|
||||
|
||||
The reserve is calculated as the reserve base times the number of accounts plus the reserve
|
||||
increment times the number of increments.
|
||||
The reserve is calculated as the reserve base plus
|
||||
the reserve increment times the number of increments.
|
||||
*/
|
||||
[[nodiscard]] XRPAmount
|
||||
accountReserve(std::uint32_t ownerCount, std::uint32_t accountCount) const
|
||||
accountReserve(std::size_t ownerCount) const
|
||||
{
|
||||
return (reserve * accountCount) + (increment * ownerCount);
|
||||
return reserve + ownerCount * increment;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/STXChainBridge.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
@@ -141,10 +142,6 @@ ticket(uint256 const& key)
|
||||
Keylet
|
||||
signerList(AccountID const& account) noexcept;
|
||||
|
||||
/** A Sponsorship */
|
||||
Keylet
|
||||
sponsorship(AccountID const& sponsor, AccountID const& sponsee) noexcept;
|
||||
|
||||
/** A Check */
|
||||
/** @{ */
|
||||
Keylet
|
||||
@@ -254,6 +251,17 @@ amm(uint256 const& amm) noexcept;
|
||||
Keylet
|
||||
delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept;
|
||||
|
||||
Keylet
|
||||
bridge(STXChainBridge const& bridge, STXChainBridge::ChainType chainType);
|
||||
|
||||
// `seq` is stored as `sfXChainClaimID` in the object
|
||||
Keylet
|
||||
xChainClaimID(STXChainBridge const& bridge, std::uint64_t seq);
|
||||
|
||||
// `seq` is stored as `sfXChainAccountCreateCount` in the object
|
||||
Keylet
|
||||
xChainCreateAccountClaimID(STXChainBridge const& bridge, std::uint64_t seq);
|
||||
|
||||
Keylet
|
||||
did(AccountID const& account) noexcept;
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ operator==(Issue const& lhs, Issue const& rhs)
|
||||
[[nodiscard]] constexpr std::weak_ordering
|
||||
operator<=>(Issue const& lhs, Issue const& rhs)
|
||||
{
|
||||
if (auto const c{lhs.currency <=> rhs.currency}; c != 0) // NOLINT(modernize-use-nullptr)
|
||||
if (auto const c{lhs.currency <=> rhs.currency}; c != 0)
|
||||
return c;
|
||||
|
||||
if (isXRP(lhs.currency))
|
||||
|
||||
@@ -208,11 +208,7 @@ enum LedgerEntryType : std::uint16_t {
|
||||
LEDGER_OBJECT(Loan, \
|
||||
LSF_FLAG(lsfLoanDefault, 0x00010000) \
|
||||
LSF_FLAG(lsfLoanImpaired, 0x00020000) \
|
||||
LSF_FLAG(lsfLoanOverpayment, 0x00040000)) /* True, loan allows overpayments */ \
|
||||
\
|
||||
LEDGER_OBJECT(Sponsorship, \
|
||||
LSF_FLAG(lsfSponsorshipRequireSignForFee, 0x00010000) \
|
||||
LSF_FLAG(lsfSponsorshipRequireSignForReserve, 0x00020000))
|
||||
LSF_FLAG(lsfLoanOverpayment, 0x00040000)) /* True, loan allows overpayments */
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ public:
|
||||
auto const maxVMantissa = mantissa(maxV);
|
||||
auto const expDiff = exponent(maxV) - exponent(minV);
|
||||
|
||||
auto const minVD = static_cast<double>(minVMantissa);
|
||||
double const minVD = static_cast<double>(minVMantissa);
|
||||
double const maxVD =
|
||||
(expDiff != 0) ? maxVMantissa * pow(10, expDiff) : static_cast<double>(maxVMantissa);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class STBitString;
|
||||
template <class>
|
||||
class STInteger;
|
||||
class STNumber;
|
||||
class STXChainBridge;
|
||||
class STVector256;
|
||||
class STCurrency;
|
||||
|
||||
@@ -70,7 +71,7 @@ class STCurrency;
|
||||
STYPE(STI_UINT384, 22) \
|
||||
STYPE(STI_UINT512, 23) \
|
||||
STYPE(STI_ISSUE, 24) \
|
||||
/* 25 is unused */ \
|
||||
STYPE(STI_XCHAIN_BRIDGE, 25) \
|
||||
STYPE(STI_CURRENCY, 26) \
|
||||
\
|
||||
/* high-level types */ \
|
||||
@@ -352,6 +353,7 @@ using SF_CURRENCY = TypedField<STCurrency>;
|
||||
using SF_NUMBER = TypedField<STNumber>;
|
||||
using SF_VL = TypedField<STBlob>;
|
||||
using SF_VECTOR256 = TypedField<STVector256>;
|
||||
using SF_XCHAIN_BRIDGE = TypedField<STXChainBridge>;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -32,13 +32,17 @@ public:
|
||||
STArray() = default;
|
||||
STArray(STArray const&) = default;
|
||||
|
||||
template <class Iter>
|
||||
explicit STArray(Iter first, Iter last)
|
||||
requires(std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>);
|
||||
template <
|
||||
class Iter,
|
||||
class = std::enable_if_t<
|
||||
std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>>>
|
||||
explicit STArray(Iter first, Iter last);
|
||||
|
||||
template <class Iter>
|
||||
STArray(SField const& f, Iter first, Iter last)
|
||||
requires(std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>);
|
||||
template <
|
||||
class Iter,
|
||||
class = std::enable_if_t<
|
||||
std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>>>
|
||||
STArray(SField const& f, Iter first, Iter last);
|
||||
|
||||
STArray&
|
||||
operator=(STArray const&) = default;
|
||||
@@ -166,17 +170,13 @@ private:
|
||||
friend class detail::STVar;
|
||||
};
|
||||
|
||||
template <class Iter>
|
||||
STArray::STArray(Iter first, Iter last)
|
||||
requires(std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>)
|
||||
: v_(first, last)
|
||||
template <class Iter, class>
|
||||
STArray::STArray(Iter first, Iter last) : v_(first, last)
|
||||
{
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
STArray::STArray(SField const& f, Iter first, Iter last)
|
||||
requires(std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>)
|
||||
: STBase(f), v_(first, last)
|
||||
template <class Iter, class>
|
||||
STArray::STArray(SField const& f, Iter first, Iter last) : STBase(f), v_(first, last)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ template <int Bits>
|
||||
bool
|
||||
STBitString<Bits>::isEquivalent(STBase const& t) const
|
||||
{
|
||||
auto const* v = dynamic_cast<STBitString const*>(&t);
|
||||
STBitString const* v = dynamic_cast<STBitString const*>(&t);
|
||||
return v && (value_ == v->value_);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ template <typename Integer>
|
||||
inline bool
|
||||
STInteger<Integer>::isEquivalent(STBase const& t) const
|
||||
{
|
||||
auto const* v = dynamic_cast<STInteger const*>(&t);
|
||||
STInteger const* v = dynamic_cast<STInteger const*>(&t);
|
||||
return v && (value_ == v->value_);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <xrpl/protocol/HashPrefix.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/SOTemplate.h>
|
||||
#include <xrpl/protocol/STAccount.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/STBase.h>
|
||||
#include <xrpl/protocol/STBitString.h>
|
||||
@@ -230,10 +229,10 @@ public:
|
||||
[[nodiscard]] AccountID
|
||||
getAccountID(SField const& field) const;
|
||||
|
||||
/** The account responsible for the authorization: the delegate when
|
||||
/** The account responsible for the fee and authorization: the delegate when
|
||||
sfDelegate is present, otherwise the account. */
|
||||
[[nodiscard]] AccountID
|
||||
getInitiator() const;
|
||||
getFeePayer() const;
|
||||
|
||||
[[nodiscard]] Blob
|
||||
getFieldVL(SField const& field) const;
|
||||
@@ -556,14 +555,9 @@ public:
|
||||
ValueProxy&
|
||||
operator=(ValueProxy const&) = delete;
|
||||
|
||||
// Write-through proxy: assignment sets the referenced field to the given
|
||||
// value, so it intentionally takes the assigned value rather than a
|
||||
// ValueProxy.
|
||||
template <class U>
|
||||
// NOLINTNEXTLINE(misc-unconventional-assign-operator)
|
||||
ValueProxy&
|
||||
operator=(U&& u)
|
||||
requires(std::is_assignable_v<T, U>);
|
||||
std::enable_if_t<std::is_assignable_v<T, U>, ValueProxy&>
|
||||
operator=(U&& u);
|
||||
|
||||
// Convenience operators for value types supporting
|
||||
// arithmetic operations
|
||||
@@ -697,9 +691,8 @@ public:
|
||||
operator=(optional_type const& v);
|
||||
|
||||
template <class U>
|
||||
OptionalProxy&
|
||||
operator=(U&& u)
|
||||
requires(std::is_assignable_v<T, U>);
|
||||
std::enable_if_t<std::is_assignable_v<T, U>, OptionalProxy&>
|
||||
operator=(U&& u);
|
||||
|
||||
private:
|
||||
friend class STObject;
|
||||
@@ -805,10 +798,8 @@ STObject::Proxy<T>::assign(U&& u)
|
||||
|
||||
template <class T>
|
||||
template <class U>
|
||||
// NOLINTNEXTLINE(misc-unconventional-assign-operator)
|
||||
STObject::ValueProxy<T>&
|
||||
std::enable_if_t<std::is_assignable_v<T, U>, STObject::ValueProxy<T>&>
|
||||
STObject::ValueProxy<T>::operator=(U&& u)
|
||||
requires(std::is_assignable_v<T, U>)
|
||||
{
|
||||
this->assign(std::forward<U>(u));
|
||||
return *this;
|
||||
@@ -911,9 +902,8 @@ STObject::OptionalProxy<T>::operator=(optional_type const& v) -> OptionalProxy&
|
||||
|
||||
template <class T>
|
||||
template <class U>
|
||||
STObject::OptionalProxy<T>&
|
||||
std::enable_if_t<std::is_assignable_v<T, U>, STObject::OptionalProxy<T>&>
|
||||
STObject::OptionalProxy<T>::operator=(U&& u)
|
||||
requires(std::is_assignable_v<T, U>)
|
||||
{
|
||||
this->assign(std::forward<U>(u));
|
||||
return *this;
|
||||
@@ -1251,7 +1241,7 @@ template <typename T, typename V>
|
||||
void
|
||||
STObject::setFieldUsingSetValue(SField const& field, V value)
|
||||
{
|
||||
static_assert(!std::is_lvalue_reference_v<V>);
|
||||
static_assert(!std::is_lvalue_reference_v<V>, "");
|
||||
|
||||
STBase* rf = getPField(field, true);
|
||||
|
||||
|
||||
@@ -240,9 +240,6 @@ private:
|
||||
|
||||
inline STPathElement::STPathElement() : type_(TypeNone), isOffer_(true)
|
||||
{
|
||||
// hashValue_ is derived from the whole object, so it is computed in the body
|
||||
// once every other member is initialized (as in the other constructors).
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
|
||||
hashValue_ = getHash(*this);
|
||||
}
|
||||
|
||||
@@ -318,9 +315,6 @@ inline STPathElement::STPathElement(
|
||||
assetID_.visit(
|
||||
[&](Currency const&) { type_ = type_ & (~Type::TypeMpt); },
|
||||
[&](MPTID const&) { type_ = type_ & (~Type::TypeCurrency); });
|
||||
// hashValue_ must be computed after type_ is adjusted above, so this cannot
|
||||
// be a member initializer.
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
|
||||
hashValue_ = getHash(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,9 +141,6 @@ public:
|
||||
[[nodiscard]] std::vector<uint256> const&
|
||||
getBatchTransactionIDs() const;
|
||||
|
||||
[[nodiscard]] AccountID
|
||||
getFeePayerID() const;
|
||||
|
||||
private:
|
||||
/** Check the signature.
|
||||
@param rules The current ledger rules.
|
||||
|
||||
224
include/xrpl/protocol/STXChainBridge.h
Normal file
224
include/xrpl/protocol/STXChainBridge.h
Normal file
@@ -0,0 +1,224 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/CountedObject.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STAccount.h>
|
||||
#include <xrpl/protocol/STBase.h>
|
||||
#include <xrpl/protocol/STIssue.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
class Serializer;
|
||||
class STObject;
|
||||
|
||||
class STXChainBridge final : public STBase, public CountedObject<STXChainBridge>
|
||||
{
|
||||
STAccount lockingChainDoor_{sfLockingChainDoor};
|
||||
STIssue lockingChainIssue_{sfLockingChainIssue};
|
||||
STAccount issuingChainDoor_{sfIssuingChainDoor};
|
||||
STIssue issuingChainIssue_{sfIssuingChainIssue};
|
||||
|
||||
public:
|
||||
using value_type = STXChainBridge;
|
||||
|
||||
enum class ChainType { Locking, Issuing };
|
||||
|
||||
static ChainType
|
||||
otherChain(ChainType ct);
|
||||
|
||||
static ChainType
|
||||
srcChain(bool wasLockingChainSend);
|
||||
|
||||
static ChainType
|
||||
dstChain(bool wasLockingChainSend);
|
||||
|
||||
STXChainBridge();
|
||||
|
||||
explicit STXChainBridge(SField const& name);
|
||||
|
||||
STXChainBridge(STXChainBridge const& rhs) = default;
|
||||
|
||||
STXChainBridge(STObject const& o);
|
||||
|
||||
STXChainBridge(
|
||||
AccountID const& srcChainDoor,
|
||||
Issue const& srcChainIssue,
|
||||
AccountID const& dstChainDoor,
|
||||
Issue const& dstChainIssue);
|
||||
|
||||
explicit STXChainBridge(json::Value const& v);
|
||||
|
||||
explicit STXChainBridge(SField const& name, json::Value const& v);
|
||||
|
||||
explicit STXChainBridge(SerialIter& sit, SField const& name);
|
||||
|
||||
STXChainBridge&
|
||||
operator=(STXChainBridge const& rhs) = default;
|
||||
|
||||
[[nodiscard]] std::string
|
||||
getText() const override;
|
||||
|
||||
[[nodiscard]] STObject
|
||||
toSTObject() const;
|
||||
|
||||
[[nodiscard]] AccountID const&
|
||||
lockingChainDoor() const;
|
||||
|
||||
[[nodiscard]] Issue const&
|
||||
lockingChainIssue() const;
|
||||
|
||||
[[nodiscard]] AccountID const&
|
||||
issuingChainDoor() const;
|
||||
|
||||
[[nodiscard]] Issue const&
|
||||
issuingChainIssue() const;
|
||||
|
||||
[[nodiscard]] AccountID const&
|
||||
door(ChainType ct) const;
|
||||
|
||||
[[nodiscard]] Issue const&
|
||||
issue(ChainType ct) const;
|
||||
|
||||
[[nodiscard]] SerializedTypeID
|
||||
getSType() const override;
|
||||
|
||||
[[nodiscard]] json::Value getJson(JsonOptions) const override;
|
||||
|
||||
void
|
||||
add(Serializer& s) const override;
|
||||
|
||||
[[nodiscard]] bool
|
||||
isEquivalent(STBase const& t) const override;
|
||||
|
||||
[[nodiscard]] bool
|
||||
isDefault() const override;
|
||||
|
||||
[[nodiscard]] value_type const&
|
||||
value() const noexcept;
|
||||
|
||||
private:
|
||||
static std::unique_ptr<STXChainBridge>
|
||||
construct(SerialIter&, SField const& name);
|
||||
|
||||
STBase*
|
||||
copy(std::size_t n, void* buf) const override;
|
||||
STBase*
|
||||
move(std::size_t n, void* buf) override;
|
||||
|
||||
friend bool
|
||||
operator==(STXChainBridge const& lhs, STXChainBridge const& rhs);
|
||||
|
||||
friend bool
|
||||
operator<(STXChainBridge const& lhs, STXChainBridge const& rhs);
|
||||
};
|
||||
|
||||
inline bool
|
||||
operator==(STXChainBridge const& lhs, STXChainBridge const& rhs)
|
||||
{
|
||||
return std::tie(
|
||||
lhs.lockingChainDoor_,
|
||||
lhs.lockingChainIssue_,
|
||||
lhs.issuingChainDoor_,
|
||||
lhs.issuingChainIssue_) ==
|
||||
std::tie(
|
||||
rhs.lockingChainDoor_,
|
||||
rhs.lockingChainIssue_,
|
||||
rhs.issuingChainDoor_,
|
||||
rhs.issuingChainIssue_);
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator<(STXChainBridge const& lhs, STXChainBridge const& rhs)
|
||||
{
|
||||
return std::tie(
|
||||
lhs.lockingChainDoor_,
|
||||
lhs.lockingChainIssue_,
|
||||
lhs.issuingChainDoor_,
|
||||
lhs.issuingChainIssue_) <
|
||||
std::tie(
|
||||
rhs.lockingChainDoor_,
|
||||
rhs.lockingChainIssue_,
|
||||
rhs.issuingChainDoor_,
|
||||
rhs.issuingChainIssue_);
|
||||
}
|
||||
|
||||
inline AccountID const&
|
||||
STXChainBridge::lockingChainDoor() const
|
||||
{
|
||||
return lockingChainDoor_.value();
|
||||
};
|
||||
|
||||
inline Issue const&
|
||||
STXChainBridge::lockingChainIssue() const
|
||||
{
|
||||
return lockingChainIssue_.value().get<Issue>();
|
||||
};
|
||||
|
||||
inline AccountID const&
|
||||
STXChainBridge::issuingChainDoor() const
|
||||
{
|
||||
return issuingChainDoor_.value();
|
||||
};
|
||||
|
||||
inline Issue const&
|
||||
STXChainBridge::issuingChainIssue() const
|
||||
{
|
||||
return issuingChainIssue_.value().get<Issue>();
|
||||
};
|
||||
|
||||
inline STXChainBridge::value_type const&
|
||||
STXChainBridge::value() const noexcept
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline AccountID const&
|
||||
STXChainBridge::door(ChainType ct) const
|
||||
{
|
||||
if (ct == ChainType::Locking)
|
||||
return lockingChainDoor();
|
||||
return issuingChainDoor();
|
||||
}
|
||||
|
||||
inline Issue const&
|
||||
STXChainBridge::issue(ChainType ct) const
|
||||
{
|
||||
if (ct == ChainType::Locking)
|
||||
return lockingChainIssue();
|
||||
return issuingChainIssue();
|
||||
}
|
||||
|
||||
inline STXChainBridge::ChainType
|
||||
STXChainBridge::otherChain(ChainType ct)
|
||||
{
|
||||
if (ct == ChainType::Locking)
|
||||
return ChainType::Issuing;
|
||||
return ChainType::Locking;
|
||||
}
|
||||
|
||||
inline STXChainBridge::ChainType
|
||||
STXChainBridge::srcChain(bool wasLockingChainSend)
|
||||
{
|
||||
if (wasLockingChainSend)
|
||||
return ChainType::Locking;
|
||||
return ChainType::Issuing;
|
||||
}
|
||||
|
||||
inline STXChainBridge::ChainType
|
||||
STXChainBridge::dstChain(bool wasLockingChainSend)
|
||||
{
|
||||
if (wasLockingChainSend)
|
||||
return ChainType::Issuing;
|
||||
return ChainType::Locking;
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -334,7 +334,7 @@ public:
|
||||
template <int N>
|
||||
explicit SerialIter(std::uint8_t const (&data)[N]) : SerialIter(&data[0], N)
|
||||
{
|
||||
static_assert(N > 0);
|
||||
static_assert(N > 0, "");
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
|
||||
@@ -225,7 +225,6 @@ enum TERcodes : TERUnderlyingType {
|
||||
// create a pseudo-account
|
||||
terNO_DELEGATE_PERMISSION, // Delegate does not have permission
|
||||
terLOCKED, // MPT is locked
|
||||
terNO_PERMISSION, // No permission but retry
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -369,7 +368,6 @@ enum TECcodes : TERUnderlyingType {
|
||||
// reclaimed after those networks reset.
|
||||
tecNO_DELEGATE_PERMISSION = 198,
|
||||
tecBAD_PROOF = 199,
|
||||
tecNO_SPONSOR_PERMISSION = 200,
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -413,7 +411,7 @@ TERtoInt(TECcodes v)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Template class that is specific to selected ranges of error codes. The
|
||||
// Trait tells the requires-clause which ranges are allowed.
|
||||
// Trait tells std::enable_if which ranges are allowed.
|
||||
template <template <typename> class Trait>
|
||||
class TERSubset
|
||||
{
|
||||
@@ -439,11 +437,11 @@ public:
|
||||
return TERSubset(from);
|
||||
}
|
||||
|
||||
// Trait tells the requires-clause which types are allowed for construction.
|
||||
template <typename T>
|
||||
constexpr TERSubset(T rhs)
|
||||
requires(Trait<std::remove_cv_t<std::remove_reference_t<T>>>::value)
|
||||
: code_(TERtoInt(rhs))
|
||||
// Trait tells enable_if which types are allowed for construction.
|
||||
template <
|
||||
typename T,
|
||||
typename = std::enable_if_t<Trait<std::remove_cv_t<std::remove_reference_t<T>>>::value>>
|
||||
constexpr TERSubset(T rhs) : code_(TERtoInt(rhs))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -453,11 +451,10 @@ public:
|
||||
constexpr TERSubset&
|
||||
operator=(TERSubset&& rhs) = default;
|
||||
|
||||
// Trait tells the requires-clause which types are allowed for assignment.
|
||||
// Trait tells enable_if which types are allowed for assignment.
|
||||
template <typename T>
|
||||
constexpr auto
|
||||
operator=(T rhs) -> TERSubset&
|
||||
requires(Trait<T>::value)
|
||||
operator=(T rhs) -> std::enable_if_t<Trait<T>::value, TERSubset&>
|
||||
{
|
||||
code_ = TERtoInt(rhs);
|
||||
return *this;
|
||||
@@ -511,60 +508,54 @@ public:
|
||||
// Only enabled if both arguments return int if TERtiInt is called with them.
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator==(L const& lhs, R const& rhs) -> bool
|
||||
requires(
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
|
||||
std::is_same_v<decltype(TERtoInt(rhs)), int>)
|
||||
operator==(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) == TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator!=(L const& lhs, R const& rhs) -> bool
|
||||
requires(
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
|
||||
std::is_same_v<decltype(TERtoInt(rhs)), int>)
|
||||
operator!=(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) != TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator<(L const& lhs, R const& rhs) -> bool
|
||||
requires(
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
|
||||
std::is_same_v<decltype(TERtoInt(rhs)), int>)
|
||||
operator<(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) < TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator<=(L const& lhs, R const& rhs) -> bool
|
||||
requires(
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
|
||||
std::is_same_v<decltype(TERtoInt(rhs)), int>)
|
||||
operator<=(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) <= TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator>(L const& lhs, R const& rhs) -> bool
|
||||
requires(
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
|
||||
std::is_same_v<decltype(TERtoInt(rhs)), int>)
|
||||
operator>(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) > TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator>=(L const& lhs, R const& rhs) -> bool
|
||||
requires(
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
|
||||
std::is_same_v<decltype(TERtoInt(rhs)), int>)
|
||||
operator>=(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) >= TERtoInt(rhs);
|
||||
}
|
||||
|
||||
@@ -102,8 +102,7 @@ inline constexpr FlagValue tfUniversalMask = ~tfUniversal;
|
||||
TRANSACTION(Payment, \
|
||||
TF_FLAG(tfNoRippleDirect, 0x00010000) \
|
||||
TF_FLAG(tfPartialPayment, 0x00020000) \
|
||||
TF_FLAG(tfLimitQuality, 0x00040000) \
|
||||
TF_FLAG(tfSponsorCreatedAccount, 0x00080000), \
|
||||
TF_FLAG(tfLimitQuality, 0x00040000), \
|
||||
MASK_ADJ(0)) \
|
||||
\
|
||||
TRANSACTION(TrustSet, \
|
||||
@@ -142,7 +141,7 @@ inline constexpr FlagValue tfUniversalMask = ~tfUniversal;
|
||||
TF_FLAG(tfMPTCanTrade, lsfMPTCanTrade) \
|
||||
TF_FLAG(tfMPTCanTransfer, lsfMPTCanTransfer) \
|
||||
TF_FLAG(tfMPTCanClawback, lsfMPTCanClawback) \
|
||||
TF_FLAG(tfMPTCanHoldConfidentialBalance, lsfMPTCanHoldConfidentialBalance), \
|
||||
TF_FLAG(tfMPTCanHoldConfidentialBalance, lsfMPTCanHoldConfidentialBalance), \
|
||||
MASK_ADJ(0)) \
|
||||
\
|
||||
TRANSACTION(MPTokenAuthorize, \
|
||||
@@ -181,6 +180,10 @@ inline constexpr FlagValue tfUniversalMask = ~tfUniversal;
|
||||
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), \
|
||||
@@ -212,20 +215,6 @@ inline constexpr FlagValue tfUniversalMask = ~tfUniversal;
|
||||
TF_FLAG(tfLoanDefault, 0x00010000) \
|
||||
TF_FLAG(tfLoanImpair, 0x00020000) \
|
||||
TF_FLAG(tfLoanUnimpair, 0x00040000), \
|
||||
MASK_ADJ(0)) \
|
||||
\
|
||||
TRANSACTION(SponsorshipSet, \
|
||||
TF_FLAG(tfSponsorshipSetRequireSignForFee, 0x00010000) \
|
||||
TF_FLAG(tfSponsorshipClearRequireSignForFee, 0x00020000) \
|
||||
TF_FLAG(tfSponsorshipSetRequireSignForReserve, 0x00040000) \
|
||||
TF_FLAG(tfSponsorshipClearRequireSignForReserve, 0x00080000) \
|
||||
TF_FLAG(tfDeleteObject, 0x00100000), \
|
||||
MASK_ADJ(0)) \
|
||||
\
|
||||
TRANSACTION(SponsorshipTransfer, \
|
||||
TF_FLAG(tfSponsorshipEnd, 0x00010000) \
|
||||
TF_FLAG(tfSponsorshipCreate, 0x00020000) \
|
||||
TF_FLAG(tfSponsorshipReassign, 0x00040000), \
|
||||
MASK_ADJ(0))
|
||||
|
||||
// clang-format on
|
||||
@@ -455,12 +444,6 @@ getAsfFlagMap()
|
||||
#pragma pop_macro("ACCOUNTSET_FLAG_TO_MAP")
|
||||
#pragma pop_macro("ACCOUNTSET_FLAGS")
|
||||
|
||||
// Sponsor flags (spf)
|
||||
|
||||
inline constexpr FlagValue spfSponsorFee = 1;
|
||||
inline constexpr FlagValue spfSponsorReserve = 2;
|
||||
inline constexpr FlagValue spfSponsorFlagMask = ~(spfSponsorFee | spfSponsorReserve);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
// NOLINTEND(readability-identifier-naming)
|
||||
|
||||
471
include/xrpl/protocol/XChainAttestations.h
Normal file
471
include/xrpl/protocol/XChainAttestations.h
Normal file
@@ -0,0 +1,471 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/Buffer.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/PublicKey.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
#include <xrpl/protocol/STXChainBridge.h>
|
||||
#include <xrpl/protocol/SecretKey.h>
|
||||
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
namespace Attestations {
|
||||
|
||||
struct AttestationBase
|
||||
{
|
||||
// Account associated with the public key
|
||||
AccountID attestationSignerAccount;
|
||||
// Public key from the witness server attesting to the event
|
||||
PublicKey publicKey;
|
||||
// Signature from the witness server attesting to the event
|
||||
Buffer signature;
|
||||
// Account on the sending chain that triggered the event (sent the
|
||||
// transaction)
|
||||
AccountID sendingAccount;
|
||||
// Amount transferred on the sending chain
|
||||
STAmount sendingAmount;
|
||||
// Account on the destination chain that collects a share of the attestation
|
||||
// reward
|
||||
AccountID rewardAccount;
|
||||
// Amount was transferred on the locking chain
|
||||
bool wasLockingChainSend;
|
||||
|
||||
explicit AttestationBase(
|
||||
AccountID attestationSignerAccount,
|
||||
PublicKey const& publicKey,
|
||||
Buffer signature,
|
||||
AccountID const& sendingAccount,
|
||||
STAmount sendingAmount,
|
||||
AccountID const& rewardAccount,
|
||||
bool wasLockingChainSend);
|
||||
|
||||
AttestationBase(AttestationBase const&) = default;
|
||||
|
||||
virtual ~AttestationBase() = default;
|
||||
|
||||
AttestationBase&
|
||||
operator=(AttestationBase const&) = default;
|
||||
|
||||
// verify that the signature attests to the data.
|
||||
[[nodiscard]] bool
|
||||
verify(STXChainBridge const& bridge) const;
|
||||
|
||||
protected:
|
||||
explicit AttestationBase(STObject const& o);
|
||||
explicit AttestationBase(json::Value const& v);
|
||||
|
||||
[[nodiscard]] static bool
|
||||
equalHelper(AttestationBase const& lhs, AttestationBase const& rhs);
|
||||
|
||||
[[nodiscard]] static bool
|
||||
sameEventHelper(AttestationBase const& lhs, AttestationBase const& rhs);
|
||||
|
||||
void
|
||||
addHelper(STObject& o) const;
|
||||
|
||||
private:
|
||||
[[nodiscard]] virtual std::vector<std::uint8_t>
|
||||
message(STXChainBridge const& bridge) const = 0;
|
||||
};
|
||||
|
||||
// Attest to a regular cross-chain transfer
|
||||
struct AttestationClaim : AttestationBase
|
||||
{
|
||||
std::uint64_t claimID;
|
||||
std::optional<AccountID> dst;
|
||||
|
||||
explicit AttestationClaim(
|
||||
AccountID attestationSignerAccount,
|
||||
PublicKey const& publicKey,
|
||||
Buffer signature,
|
||||
AccountID const& sendingAccount,
|
||||
STAmount const& sendingAmount,
|
||||
AccountID const& rewardAccount,
|
||||
bool wasLockingChainSend,
|
||||
std::uint64_t claimId,
|
||||
std::optional<AccountID> const& dst);
|
||||
|
||||
explicit AttestationClaim(
|
||||
STXChainBridge const& bridge,
|
||||
AccountID attestationSignerAccount,
|
||||
PublicKey const& publicKey,
|
||||
SecretKey const& secretKey,
|
||||
AccountID const& sendingAccount,
|
||||
STAmount const& sendingAmount,
|
||||
AccountID const& rewardAccount,
|
||||
bool wasLockingChainSend,
|
||||
std::uint64_t claimId,
|
||||
std::optional<AccountID> const& dst);
|
||||
|
||||
explicit AttestationClaim(STObject const& o);
|
||||
explicit AttestationClaim(json::Value const& v);
|
||||
|
||||
[[nodiscard]] STObject
|
||||
toSTObject() const;
|
||||
|
||||
// return true if the two attestations attest to the same thing
|
||||
[[nodiscard]] bool
|
||||
sameEvent(AttestationClaim const& rhs) const;
|
||||
|
||||
[[nodiscard]] static std::vector<std::uint8_t>
|
||||
message(
|
||||
STXChainBridge const& bridge,
|
||||
AccountID const& sendingAccount,
|
||||
STAmount const& sendingAmount,
|
||||
AccountID const& rewardAccount,
|
||||
bool wasLockingChainSend,
|
||||
std::uint64_t claimID,
|
||||
std::optional<AccountID> const& dst);
|
||||
|
||||
[[nodiscard]] bool
|
||||
validAmounts() const;
|
||||
|
||||
private:
|
||||
[[nodiscard]] std::vector<std::uint8_t>
|
||||
message(STXChainBridge const& bridge) const override;
|
||||
|
||||
friend bool
|
||||
operator==(AttestationClaim const& lhs, AttestationClaim const& rhs);
|
||||
};
|
||||
|
||||
struct CmpByClaimID
|
||||
{
|
||||
bool
|
||||
operator()(AttestationClaim const& lhs, AttestationClaim const& rhs) const
|
||||
{
|
||||
return lhs.claimID < rhs.claimID;
|
||||
}
|
||||
};
|
||||
|
||||
// Attest to a cross-chain transfer that creates an account
|
||||
struct AttestationCreateAccount : AttestationBase
|
||||
{
|
||||
// createCount on the sending chain. This is the value of the `CreateCount`
|
||||
// field of the bridge on the sending chain when the transaction was
|
||||
// executed.
|
||||
std::uint64_t createCount;
|
||||
// Account to create on the destination chain
|
||||
AccountID toCreate;
|
||||
// Total amount of the reward pool
|
||||
STAmount rewardAmount;
|
||||
|
||||
explicit AttestationCreateAccount(STObject const& o);
|
||||
|
||||
explicit AttestationCreateAccount(json::Value const& v);
|
||||
|
||||
explicit AttestationCreateAccount(
|
||||
AccountID attestationSignerAccount,
|
||||
PublicKey const& publicKey,
|
||||
Buffer signature,
|
||||
AccountID const& sendingAccount,
|
||||
STAmount const& sendingAmount,
|
||||
STAmount rewardAmount,
|
||||
AccountID const& rewardAccount,
|
||||
bool wasLockingChainSend,
|
||||
std::uint64_t createCount,
|
||||
AccountID const& toCreate);
|
||||
|
||||
explicit AttestationCreateAccount(
|
||||
STXChainBridge const& bridge,
|
||||
AccountID attestationSignerAccount,
|
||||
PublicKey const& publicKey,
|
||||
SecretKey const& secretKey,
|
||||
AccountID const& sendingAccount,
|
||||
STAmount const& sendingAmount,
|
||||
STAmount const& rewardAmount,
|
||||
AccountID const& rewardAccount,
|
||||
bool wasLockingChainSend,
|
||||
std::uint64_t createCount,
|
||||
AccountID const& toCreate);
|
||||
|
||||
[[nodiscard]] STObject
|
||||
toSTObject() const;
|
||||
|
||||
// return true if the two attestations attest to the same thing
|
||||
[[nodiscard]] bool
|
||||
sameEvent(AttestationCreateAccount const& rhs) const;
|
||||
|
||||
friend bool
|
||||
operator==(AttestationCreateAccount const& lhs, AttestationCreateAccount const& rhs);
|
||||
|
||||
[[nodiscard]] static std::vector<std::uint8_t>
|
||||
message(
|
||||
STXChainBridge const& bridge,
|
||||
AccountID const& sendingAccount,
|
||||
STAmount const& sendingAmount,
|
||||
STAmount const& rewardAmount,
|
||||
AccountID const& rewardAccount,
|
||||
bool wasLockingChainSend,
|
||||
std::uint64_t createCount,
|
||||
AccountID const& dst);
|
||||
|
||||
[[nodiscard]] bool
|
||||
validAmounts() const;
|
||||
|
||||
private:
|
||||
[[nodiscard]] std::vector<std::uint8_t>
|
||||
message(STXChainBridge const& bridge) const override;
|
||||
};
|
||||
|
||||
struct CmpByCreateCount
|
||||
{
|
||||
bool
|
||||
operator()(AttestationCreateAccount const& lhs, AttestationCreateAccount const& rhs) const
|
||||
{
|
||||
return lhs.createCount < rhs.createCount;
|
||||
}
|
||||
};
|
||||
|
||||
}; // namespace Attestations
|
||||
|
||||
// Result when checking when two attestation match.
|
||||
enum class AttestationMatch {
|
||||
// One of the fields doesn't match, and it isn't the dst field
|
||||
NonDstMismatch,
|
||||
// all of the fields match, except the dst field
|
||||
MatchExceptDst,
|
||||
// all of the fields match
|
||||
Match
|
||||
};
|
||||
|
||||
struct XChainClaimAttestation
|
||||
{
|
||||
using TSignedAttestation = Attestations::AttestationClaim;
|
||||
static SField const& arrayFieldName;
|
||||
|
||||
AccountID keyAccount;
|
||||
PublicKey publicKey;
|
||||
STAmount amount;
|
||||
AccountID rewardAccount;
|
||||
bool wasLockingChainSend;
|
||||
std::optional<AccountID> dst;
|
||||
|
||||
struct MatchFields
|
||||
{
|
||||
STAmount amount;
|
||||
bool wasLockingChainSend;
|
||||
std::optional<AccountID> dst;
|
||||
MatchFields(TSignedAttestation const& att);
|
||||
MatchFields(STAmount a, bool b, std::optional<AccountID> const& d)
|
||||
: amount{std::move(a)}, wasLockingChainSend{b}, dst{d}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
explicit XChainClaimAttestation(
|
||||
AccountID const& keyAccount,
|
||||
PublicKey const& publicKey,
|
||||
STAmount const& amount,
|
||||
AccountID const& rewardAccount,
|
||||
bool wasLockingChainSend,
|
||||
std::optional<AccountID> const& dst);
|
||||
|
||||
explicit XChainClaimAttestation(
|
||||
STAccount const& keyAccount,
|
||||
PublicKey const& publicKey,
|
||||
STAmount const& amount,
|
||||
STAccount const& rewardAccount,
|
||||
bool wasLockingChainSend,
|
||||
std::optional<STAccount> const& dst);
|
||||
|
||||
explicit XChainClaimAttestation(TSignedAttestation const& claimAtt);
|
||||
|
||||
explicit XChainClaimAttestation(STObject const& o);
|
||||
|
||||
explicit XChainClaimAttestation(json::Value const& v);
|
||||
|
||||
[[nodiscard]] AttestationMatch
|
||||
match(MatchFields const& rhs) const;
|
||||
|
||||
[[nodiscard]] STObject
|
||||
toSTObject() const;
|
||||
|
||||
friend bool
|
||||
operator==(XChainClaimAttestation const& lhs, XChainClaimAttestation const& rhs);
|
||||
};
|
||||
|
||||
struct XChainCreateAccountAttestation
|
||||
{
|
||||
using TSignedAttestation = Attestations::AttestationCreateAccount;
|
||||
static SField const& arrayFieldName;
|
||||
|
||||
AccountID keyAccount;
|
||||
PublicKey publicKey;
|
||||
STAmount amount;
|
||||
STAmount rewardAmount;
|
||||
AccountID rewardAccount;
|
||||
bool wasLockingChainSend;
|
||||
AccountID dst;
|
||||
|
||||
struct MatchFields
|
||||
{
|
||||
STAmount amount;
|
||||
STAmount rewardAmount;
|
||||
bool wasLockingChainSend;
|
||||
AccountID dst;
|
||||
|
||||
MatchFields(TSignedAttestation const& att);
|
||||
};
|
||||
|
||||
explicit XChainCreateAccountAttestation(
|
||||
AccountID const& keyAccount,
|
||||
PublicKey const& publicKey,
|
||||
STAmount const& amount,
|
||||
STAmount const& rewardAmount,
|
||||
AccountID const& rewardAccount,
|
||||
bool wasLockingChainSend,
|
||||
AccountID const& dst);
|
||||
|
||||
explicit XChainCreateAccountAttestation(TSignedAttestation const& claimAtt);
|
||||
|
||||
explicit XChainCreateAccountAttestation(STObject const& o);
|
||||
|
||||
explicit XChainCreateAccountAttestation(json::Value const& v);
|
||||
|
||||
[[nodiscard]] STObject
|
||||
toSTObject() const;
|
||||
|
||||
[[nodiscard]] AttestationMatch
|
||||
match(MatchFields const& rhs) const;
|
||||
|
||||
friend bool
|
||||
operator==(
|
||||
XChainCreateAccountAttestation const& lhs,
|
||||
XChainCreateAccountAttestation const& rhs);
|
||||
};
|
||||
|
||||
// Attestations from witness servers for a particular claim ID and bridge.
|
||||
// Only one attestation per signature is allowed.
|
||||
template <class TAttestation>
|
||||
class XChainAttestationsBase
|
||||
{
|
||||
public:
|
||||
using AttCollection = std::vector<TAttestation>;
|
||||
|
||||
private:
|
||||
// Set a max number of allowed attestations to limit the amount of memory
|
||||
// allocated and processing time. This number is much larger than the actual
|
||||
// number of attestation a server would ever expect.
|
||||
static constexpr std::uint32_t kMaxAttestations = 256;
|
||||
AttCollection attestations_;
|
||||
|
||||
protected:
|
||||
// Prevent slicing to the base class
|
||||
~XChainAttestationsBase() = default;
|
||||
|
||||
public:
|
||||
XChainAttestationsBase() = default;
|
||||
XChainAttestationsBase(XChainAttestationsBase const& rhs) = default;
|
||||
XChainAttestationsBase&
|
||||
operator=(XChainAttestationsBase const& rhs) = default;
|
||||
|
||||
explicit XChainAttestationsBase(AttCollection&& sigs);
|
||||
|
||||
explicit XChainAttestationsBase(json::Value const& v);
|
||||
|
||||
explicit XChainAttestationsBase(STArray const& arr);
|
||||
|
||||
[[nodiscard]] STArray
|
||||
toSTArray() const;
|
||||
|
||||
[[nodiscard]] AttCollection::const_iterator
|
||||
begin() const;
|
||||
|
||||
[[nodiscard]] AttCollection::const_iterator
|
||||
end() const;
|
||||
|
||||
AttCollection::iterator
|
||||
begin();
|
||||
|
||||
AttCollection::iterator
|
||||
end();
|
||||
|
||||
template <class F>
|
||||
std::size_t
|
||||
eraseIf(F&& f);
|
||||
|
||||
[[nodiscard]] std::size_t
|
||||
size() const;
|
||||
|
||||
[[nodiscard]] bool
|
||||
empty() const;
|
||||
|
||||
[[nodiscard]] AttCollection const&
|
||||
attestations() const;
|
||||
|
||||
template <class T>
|
||||
void
|
||||
emplaceBack(T&& att);
|
||||
};
|
||||
|
||||
template <class TAttestation>
|
||||
[[nodiscard]] inline bool
|
||||
operator==(
|
||||
XChainAttestationsBase<TAttestation> const& lhs,
|
||||
XChainAttestationsBase<TAttestation> const& rhs)
|
||||
{
|
||||
return lhs.attestations() == rhs.attestations();
|
||||
}
|
||||
|
||||
template <class TAttestation>
|
||||
inline XChainAttestationsBase<TAttestation>::AttCollection const&
|
||||
XChainAttestationsBase<TAttestation>::attestations() const
|
||||
{
|
||||
return attestations_;
|
||||
};
|
||||
|
||||
template <class TAttestation>
|
||||
template <class T>
|
||||
inline void
|
||||
XChainAttestationsBase<TAttestation>::emplaceBack(T&& att)
|
||||
{
|
||||
attestations_.emplace_back(std::forward<T>(att));
|
||||
};
|
||||
|
||||
template <class TAttestation>
|
||||
template <class F>
|
||||
inline std::size_t
|
||||
XChainAttestationsBase<TAttestation>::eraseIf(F&& f)
|
||||
{
|
||||
return std::erase_if(attestations_, std::forward<F>(f));
|
||||
}
|
||||
|
||||
template <class TAttestation>
|
||||
inline std::size_t
|
||||
XChainAttestationsBase<TAttestation>::size() const
|
||||
{
|
||||
return attestations_.size();
|
||||
}
|
||||
|
||||
template <class TAttestation>
|
||||
inline bool
|
||||
XChainAttestationsBase<TAttestation>::empty() const
|
||||
{
|
||||
return attestations_.empty();
|
||||
}
|
||||
|
||||
class XChainClaimAttestations final : public XChainAttestationsBase<XChainClaimAttestation>
|
||||
{
|
||||
using TBase = XChainAttestationsBase<XChainClaimAttestation>;
|
||||
using TBase::TBase;
|
||||
};
|
||||
|
||||
class XChainCreateAccountAttestations final
|
||||
: public XChainAttestationsBase<XChainCreateAccountAttestation>
|
||||
{
|
||||
using TBase = XChainAttestationsBase<XChainCreateAccountAttestation>;
|
||||
using TBase::TBase;
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -50,13 +50,14 @@ public:
|
||||
STVar&
|
||||
operator=(STVar&& rhs);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
|
||||
STVar(STBase&& t) : p_(t.move(kMaxSize, &d_))
|
||||
STVar(STBase&& t) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
|
||||
{
|
||||
p_ = t.move(kMaxSize, &d_);
|
||||
}
|
||||
|
||||
STVar(STBase const& t) : p_(t.copy(kMaxSize, &d_))
|
||||
STVar(STBase const& t)
|
||||
{
|
||||
p_ = t.copy(kMaxSize, &d_);
|
||||
}
|
||||
|
||||
STVar(DefaultObjectT, SField const& name);
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
// Add new amendments to the top of this list.
|
||||
// Keep it sorted in reverse chronological order.
|
||||
|
||||
XRPL_FEATURE(Sponsor, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(BatchV1_1, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(BatchV1_1, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(LendingProtocolV1_1, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(ConfidentialTransfer, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(ConfidentialTransfer, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (Cleanup3_3_0, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (Cleanup3_2_0, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(MPTokensV2, Supported::No, VoteBehavior::DefaultNo)
|
||||
@@ -55,13 +54,14 @@ XRPL_FIX (ReducedOffersV2, Supported::Yes, VoteBehavior::DefaultNo
|
||||
XRPL_FEATURE(NFTokenMintOffer, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMv1_1, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PreviousTxnID, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (XChainRewardRounding, Supported::Yes, VoteBehavior::Obsolete)
|
||||
XRPL_FIX (XChainRewardRounding, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (EmptyDID, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PriceOracle, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMOverflowOffer, Supported::Yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (FillOrKill, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DID, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XChainBridge, Supported::Yes, VoteBehavior::Obsolete)
|
||||
XRPL_FIX (DisallowIncomingV1, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XChainBridge, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(AMM, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XRPFees, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::Yes, VoteBehavior::DefaultYes)
|
||||
@@ -100,7 +100,6 @@ XRPL_RETIRE_FIX(1623)
|
||||
XRPL_RETIRE_FIX(1781)
|
||||
XRPL_RETIRE_FIX(AmendmentMajorityCalc)
|
||||
XRPL_RETIRE_FIX(CheckThreading)
|
||||
XRPL_RETIRE_FIX(DisallowIncomingV1)
|
||||
XRPL_RETIRE_FIX(InnerObjTemplate)
|
||||
XRPL_RETIRE_FIX(MasterKeyAsRegularKey)
|
||||
XRPL_RETIRE_FIX(NonFungibleTokensV1_2)
|
||||
|
||||
@@ -127,32 +127,29 @@ LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ticket, ({
|
||||
\sa keylet::account
|
||||
*/
|
||||
LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, account, ({
|
||||
{sfAccount, SoeRequired},
|
||||
{sfSequence, SoeRequired},
|
||||
{sfBalance, SoeRequired},
|
||||
{sfOwnerCount, SoeRequired},
|
||||
{sfPreviousTxnID, SoeRequired},
|
||||
{sfPreviousTxnLgrSeq, SoeRequired},
|
||||
{sfAccountTxnID, SoeOptional},
|
||||
{sfRegularKey, SoeOptional},
|
||||
{sfEmailHash, SoeOptional},
|
||||
{sfWalletLocator, SoeOptional},
|
||||
{sfWalletSize, SoeOptional},
|
||||
{sfMessageKey, SoeOptional},
|
||||
{sfTransferRate, SoeOptional},
|
||||
{sfDomain, SoeOptional},
|
||||
{sfTickSize, SoeOptional},
|
||||
{sfTicketCount, SoeOptional},
|
||||
{sfNFTokenMinter, SoeOptional},
|
||||
{sfMintedNFTokens, SoeDefault},
|
||||
{sfBurnedNFTokens, SoeDefault},
|
||||
{sfFirstNFTokenSequence, SoeOptional},
|
||||
{sfSponsoredOwnerCount, SoeDefault},
|
||||
{sfSponsoringOwnerCount, SoeDefault},
|
||||
{sfSponsoringAccountCount, SoeDefault},
|
||||
{sfAMMID, SoeOptional}, // pseudo-account designator
|
||||
{sfVaultID, SoeOptional}, // pseudo-account designator
|
||||
{sfLoanBrokerID, SoeOptional}, // pseudo-account designator
|
||||
{sfAccount, SoeRequired},
|
||||
{sfSequence, SoeRequired},
|
||||
{sfBalance, SoeRequired},
|
||||
{sfOwnerCount, SoeRequired},
|
||||
{sfPreviousTxnID, SoeRequired},
|
||||
{sfPreviousTxnLgrSeq, SoeRequired},
|
||||
{sfAccountTxnID, SoeOptional},
|
||||
{sfRegularKey, SoeOptional},
|
||||
{sfEmailHash, SoeOptional},
|
||||
{sfWalletLocator, SoeOptional},
|
||||
{sfWalletSize, SoeOptional},
|
||||
{sfMessageKey, SoeOptional},
|
||||
{sfTransferRate, SoeOptional},
|
||||
{sfDomain, SoeOptional},
|
||||
{sfTickSize, SoeOptional},
|
||||
{sfTicketCount, SoeOptional},
|
||||
{sfNFTokenMinter, SoeOptional},
|
||||
{sfMintedNFTokens, SoeDefault},
|
||||
{sfBurnedNFTokens, SoeDefault},
|
||||
{sfFirstNFTokenSequence, SoeOptional},
|
||||
{sfAMMID, SoeOptional}, // pseudo-account designator
|
||||
{sfVaultID, SoeOptional}, // pseudo-account designator
|
||||
{sfLoanBrokerID, SoeOptional}, // pseudo-account designator
|
||||
}))
|
||||
|
||||
/** A ledger object which contains a list of object identifiers.
|
||||
@@ -206,6 +203,23 @@ LEDGER_ENTRY(ltLEDGER_HASHES, 0x0068, LedgerHashes, hashes, ({
|
||||
{sfHashes, SoeRequired},
|
||||
}))
|
||||
|
||||
/** The ledger object which lists details about sidechains.
|
||||
|
||||
\sa keylet::bridge
|
||||
*/
|
||||
LEDGER_ENTRY(ltBRIDGE, 0x0069, Bridge, bridge, ({
|
||||
{sfAccount, SoeRequired},
|
||||
{sfSignatureReward, SoeRequired},
|
||||
{sfMinAccountCreateAmount, SoeOptional},
|
||||
{sfXChainBridge, SoeRequired},
|
||||
{sfXChainClaimID, SoeRequired},
|
||||
{sfXChainAccountCreateCount, SoeRequired},
|
||||
{sfXChainAccountClaimCount, SoeRequired},
|
||||
{sfOwnerNode, SoeRequired},
|
||||
{sfPreviousTxnID, SoeRequired},
|
||||
{sfPreviousTxnLgrSeq, SoeRequired},
|
||||
}))
|
||||
|
||||
/** A ledger object which describes an offer on the DEX.
|
||||
|
||||
\sa keylet::offer
|
||||
@@ -238,6 +252,22 @@ LEDGER_ENTRY_DUPLICATE(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, deposit_preaut
|
||||
{sfAuthorizeCredentials, SoeOptional},
|
||||
}))
|
||||
|
||||
/** A claim id for a cross chain transaction.
|
||||
|
||||
\sa keylet::xChainClaimID
|
||||
*/
|
||||
LEDGER_ENTRY(ltXCHAIN_OWNED_CLAIM_ID, 0x0071, XChainOwnedClaimID, xchain_owned_claim_id, ({
|
||||
{sfAccount, SoeRequired},
|
||||
{sfXChainBridge, SoeRequired},
|
||||
{sfXChainClaimID, SoeRequired},
|
||||
{sfOtherChainSource, SoeRequired},
|
||||
{sfXChainClaimAttestations, SoeRequired},
|
||||
{sfSignatureReward, SoeRequired},
|
||||
{sfOwnerNode, SoeRequired},
|
||||
{sfPreviousTxnID, SoeRequired},
|
||||
{sfPreviousTxnLgrSeq, SoeRequired},
|
||||
}))
|
||||
|
||||
/** A ledger object which describes a bidirectional trust line.
|
||||
|
||||
@note Per Vinnie Falco this should be renamed to ltTRUST_LINE
|
||||
@@ -256,8 +286,6 @@ LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, state, ({
|
||||
{sfHighNode, SoeOptional},
|
||||
{sfHighQualityIn, SoeOptional},
|
||||
{sfHighQualityOut, SoeOptional},
|
||||
{sfHighSponsor, SoeOptional},
|
||||
{sfLowSponsor, SoeOptional},
|
||||
}))
|
||||
|
||||
/** The ledger object which lists the network's fee settings.
|
||||
@@ -280,6 +308,20 @@ LEDGER_ENTRY(ltFEE_SETTINGS, 0x0073, FeeSettings, fee, ({
|
||||
{sfPreviousTxnLgrSeq, SoeOptional},
|
||||
}))
|
||||
|
||||
/** A claim id for a cross chain create account transaction.
|
||||
|
||||
\sa keylet::xChainCreateAccountClaimID
|
||||
*/
|
||||
LEDGER_ENTRY(ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, 0x0074, XChainOwnedCreateAccountClaimID, xchain_owned_create_account_claim_id, ({
|
||||
{sfAccount, SoeRequired},
|
||||
{sfXChainBridge, SoeRequired},
|
||||
{sfXChainAccountCreateCount, SoeRequired},
|
||||
{sfXChainCreateAccountAttestations, SoeRequired},
|
||||
{sfOwnerNode, SoeRequired},
|
||||
{sfPreviousTxnID, SoeRequired},
|
||||
{sfPreviousTxnLgrSeq, SoeRequired},
|
||||
}))
|
||||
|
||||
/** A ledger object describing a single escrow.
|
||||
|
||||
\sa keylet::escrow
|
||||
@@ -574,20 +616,5 @@ LEDGER_ENTRY(ltLOAN, 0x0089, Loan, loan, ({
|
||||
{sfLoanScale, SoeDefault},
|
||||
}))
|
||||
|
||||
/** A ledger object representing a sponsorship.
|
||||
\sa keylet::sponsorship
|
||||
*/
|
||||
LEDGER_ENTRY(ltSPONSORSHIP, 0x0090, Sponsorship, sponsorship, ({
|
||||
{sfPreviousTxnID, SoeRequired},
|
||||
{sfPreviousTxnLgrSeq, SoeRequired},
|
||||
{sfOwner, SoeRequired},
|
||||
{sfSponsee, SoeRequired},
|
||||
{sfFeeAmount, SoeOptional},
|
||||
{sfMaxFee, SoeOptional},
|
||||
{sfRemainingOwnerCount, SoeDefault},
|
||||
{sfOwnerNode, SoeRequired},
|
||||
{sfSponseeNode, SoeRequired},
|
||||
}))
|
||||
|
||||
#undef EXPAND
|
||||
#undef LEDGER_ENTRY_DUPLICATE
|
||||
|
||||
@@ -23,7 +23,7 @@ TYPED_SFIELD(sfAssetScale, UINT8, 5)
|
||||
TYPED_SFIELD(sfTickSize, UINT8, 16)
|
||||
TYPED_SFIELD(sfUNLModifyDisabling, UINT8, 17)
|
||||
TYPED_SFIELD(sfHookResult, UINT8, 18)
|
||||
// 19 unused
|
||||
TYPED_SFIELD(sfWasLockingChainSend, UINT8, 19)
|
||||
TYPED_SFIELD(sfWithdrawalPolicy, UINT8, 20)
|
||||
|
||||
// 16-bit integers (common)
|
||||
@@ -114,11 +114,6 @@ TYPED_SFIELD(sfLateInterestRate, UINT32, 66) // 1/10 basis points (bi
|
||||
TYPED_SFIELD(sfCloseInterestRate, UINT32, 67) // 1/10 basis points (bips)
|
||||
TYPED_SFIELD(sfOverpaymentInterestRate, UINT32, 68) // 1/10 basis points (bips)
|
||||
TYPED_SFIELD(sfConfidentialBalanceVersion, UINT32, 69)
|
||||
TYPED_SFIELD(sfSponsoredOwnerCount, UINT32, 70)
|
||||
TYPED_SFIELD(sfSponsoringOwnerCount, UINT32, 71)
|
||||
TYPED_SFIELD(sfSponsoringAccountCount, UINT32, 72)
|
||||
TYPED_SFIELD(sfRemainingOwnerCount, UINT32, 73)
|
||||
TYPED_SFIELD(sfSponsorFlags, UINT32, 74)
|
||||
|
||||
// 64-bit integers (common)
|
||||
TYPED_SFIELD(sfIndexNext, UINT64, 1)
|
||||
@@ -140,7 +135,9 @@ TYPED_SFIELD(sfHookOn, UINT64, 16)
|
||||
TYPED_SFIELD(sfHookInstructionCount, UINT64, 17)
|
||||
TYPED_SFIELD(sfHookReturnCode, UINT64, 18)
|
||||
TYPED_SFIELD(sfReferenceCount, UINT64, 19)
|
||||
// 20-22 unused
|
||||
TYPED_SFIELD(sfXChainClaimID, UINT64, 20)
|
||||
TYPED_SFIELD(sfXChainAccountCreateCount, UINT64, 21)
|
||||
TYPED_SFIELD(sfXChainAccountClaimCount, UINT64, 22)
|
||||
TYPED_SFIELD(sfAssetPrice, UINT64, 23)
|
||||
TYPED_SFIELD(sfMaximumAmount, UINT64, 24, SField::kSmdBaseTen|SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfOutstandingAmount, UINT64, 25, SField::kSmdBaseTen|SField::kSmdDefault)
|
||||
@@ -151,7 +148,6 @@ TYPED_SFIELD(sfLockedAmount, UINT64, 29, SField::kSmdBaseTen|SFie
|
||||
TYPED_SFIELD(sfVaultNode, UINT64, 30)
|
||||
TYPED_SFIELD(sfLoanBrokerNode, UINT64, 31)
|
||||
TYPED_SFIELD(sfConfidentialOutstandingAmount, UINT64, 32, SField::kSmdBaseTen|SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfSponseeNode, UINT64, 33)
|
||||
|
||||
// 128-bit
|
||||
TYPED_SFIELD(sfEmailHash, UINT128, 1)
|
||||
@@ -213,7 +209,6 @@ TYPED_SFIELD(sfLoanBrokerID, UINT256, 37,
|
||||
TYPED_SFIELD(sfLoanID, UINT256, 38)
|
||||
TYPED_SFIELD(sfReferenceHolding, UINT256, 39)
|
||||
TYPED_SFIELD(sfBlindingFactor, UINT256, 40)
|
||||
TYPED_SFIELD(sfObjectID, UINT256, 41)
|
||||
|
||||
// number (common)
|
||||
TYPED_SFIELD(sfNumber, NUMBER, 1)
|
||||
@@ -273,8 +268,6 @@ TYPED_SFIELD(sfPrice, AMOUNT, 28)
|
||||
TYPED_SFIELD(sfSignatureReward, AMOUNT, 29)
|
||||
TYPED_SFIELD(sfMinAccountCreateAmount, AMOUNT, 30)
|
||||
TYPED_SFIELD(sfLPTokenBalance, AMOUNT, 31)
|
||||
TYPED_SFIELD(sfFeeAmount, AMOUNT, 32)
|
||||
TYPED_SFIELD(sfMaxFee, AMOUNT, 33)
|
||||
|
||||
// variable length (common)
|
||||
TYPED_SFIELD(sfPublicKey, VL, 1)
|
||||
@@ -341,15 +334,15 @@ TYPED_SFIELD(sfDelegate, ACCOUNT, 12)
|
||||
|
||||
// account (uncommon)
|
||||
TYPED_SFIELD(sfHookAccount, ACCOUNT, 16)
|
||||
// 17-23 are unused
|
||||
TYPED_SFIELD(sfOtherChainSource, ACCOUNT, 18)
|
||||
TYPED_SFIELD(sfOtherChainDestination, ACCOUNT, 19)
|
||||
TYPED_SFIELD(sfAttestationSignerAccount, ACCOUNT, 20)
|
||||
TYPED_SFIELD(sfAttestationRewardAccount, ACCOUNT, 21)
|
||||
TYPED_SFIELD(sfLockingChainDoor, ACCOUNT, 22)
|
||||
TYPED_SFIELD(sfIssuingChainDoor, ACCOUNT, 23)
|
||||
TYPED_SFIELD(sfSubject, ACCOUNT, 24)
|
||||
TYPED_SFIELD(sfBorrower, ACCOUNT, 25)
|
||||
TYPED_SFIELD(sfCounterparty, ACCOUNT, 26)
|
||||
TYPED_SFIELD(sfSponsor, ACCOUNT, 27)
|
||||
TYPED_SFIELD(sfHighSponsor, ACCOUNT, 28)
|
||||
TYPED_SFIELD(sfLowSponsor, ACCOUNT, 29)
|
||||
TYPED_SFIELD(sfCounterpartySponsor, ACCOUNT, 30)
|
||||
TYPED_SFIELD(sfSponsee, ACCOUNT, 31)
|
||||
|
||||
// vector of 256-bit
|
||||
TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::kSmdNever)
|
||||
@@ -366,10 +359,14 @@ TYPED_SFIELD(sfBaseAsset, CURRENCY, 1)
|
||||
TYPED_SFIELD(sfQuoteAsset, CURRENCY, 2)
|
||||
|
||||
// issue
|
||||
// 1 and 2 are unused
|
||||
TYPED_SFIELD(sfLockingChainIssue, ISSUE, 1)
|
||||
TYPED_SFIELD(sfIssuingChainIssue, ISSUE, 2)
|
||||
TYPED_SFIELD(sfAsset, ISSUE, 3)
|
||||
TYPED_SFIELD(sfAsset2, ISSUE, 4)
|
||||
|
||||
// bridge
|
||||
TYPED_SFIELD(sfXChainBridge, XCHAIN_BRIDGE, 1)
|
||||
|
||||
// inner object
|
||||
// OBJECT/1 is reserved for end of object
|
||||
UNTYPED_SFIELD(sfTransactionMetaData, OBJECT, 2)
|
||||
@@ -400,14 +397,16 @@ UNTYPED_SFIELD(sfHookGrant, OBJECT, 24)
|
||||
UNTYPED_SFIELD(sfVoteEntry, OBJECT, 25)
|
||||
UNTYPED_SFIELD(sfAuctionSlot, OBJECT, 26)
|
||||
UNTYPED_SFIELD(sfAuthAccount, OBJECT, 27)
|
||||
// 28 to 31 unused
|
||||
UNTYPED_SFIELD(sfXChainClaimProofSig, OBJECT, 28)
|
||||
UNTYPED_SFIELD(sfXChainCreateAccountProofSig, OBJECT, 29)
|
||||
UNTYPED_SFIELD(sfXChainClaimAttestationCollectionElement, OBJECT, 30)
|
||||
UNTYPED_SFIELD(sfXChainCreateAccountAttestationCollectionElement, OBJECT, 31)
|
||||
UNTYPED_SFIELD(sfPriceData, OBJECT, 32)
|
||||
UNTYPED_SFIELD(sfCredential, OBJECT, 33)
|
||||
UNTYPED_SFIELD(sfRawTransaction, OBJECT, 34)
|
||||
UNTYPED_SFIELD(sfBatchSigner, OBJECT, 35)
|
||||
UNTYPED_SFIELD(sfBook, OBJECT, 36)
|
||||
UNTYPED_SFIELD(sfCounterpartySignature, OBJECT, 37, SField::kSmdDefault, SField::kNotSigning)
|
||||
UNTYPED_SFIELD(sfSponsorSignature, OBJECT, 38, SField::kSmdDefault, SField::kNotSigning)
|
||||
|
||||
// array of objects (common)
|
||||
// ARRAY/1 is reserved for end of array
|
||||
@@ -431,7 +430,9 @@ UNTYPED_SFIELD(sfDisabledValidators, ARRAY, 17)
|
||||
UNTYPED_SFIELD(sfHookExecutions, ARRAY, 18)
|
||||
UNTYPED_SFIELD(sfHookParameters, ARRAY, 19)
|
||||
UNTYPED_SFIELD(sfHookGrants, ARRAY, 20)
|
||||
// 21-23 unused
|
||||
UNTYPED_SFIELD(sfXChainClaimAttestations, ARRAY, 21)
|
||||
UNTYPED_SFIELD(sfXChainCreateAccountAttestations, ARRAY, 22)
|
||||
// 23 unused
|
||||
UNTYPED_SFIELD(sfPriceDataSeries, ARRAY, 24)
|
||||
UNTYPED_SFIELD(sfAuthAccounts, ARRAY, 25)
|
||||
UNTYPED_SFIELD(sfAuthorizeCredentials, ARRAY, 26)
|
||||
|
||||
@@ -509,7 +509,120 @@ TRANSACTION(ttAMM_DELETE, 40, AMMDelete,
|
||||
{sfAsset2, SoeRequired, SoeMptSupported},
|
||||
}))
|
||||
|
||||
// 41 to 48 are unused
|
||||
/** This transactions creates a crosschain sequence number */
|
||||
#if TRANSACTION_INCLUDE
|
||||
# include <xrpl/tx/transactors/bridge/XChainBridge.h>
|
||||
#endif
|
||||
TRANSACTION(ttXCHAIN_CREATE_CLAIM_ID, 41, XChainCreateClaimID,
|
||||
Delegation::Delegable,
|
||||
featureXChainBridge,
|
||||
NoPriv,
|
||||
({
|
||||
{sfXChainBridge, SoeRequired},
|
||||
{sfSignatureReward, SoeRequired},
|
||||
{sfOtherChainSource, SoeRequired},
|
||||
}))
|
||||
|
||||
/** This transactions initiates a crosschain transaction */
|
||||
TRANSACTION(ttXCHAIN_COMMIT, 42, XChainCommit,
|
||||
Delegation::Delegable,
|
||||
featureXChainBridge,
|
||||
NoPriv,
|
||||
({
|
||||
{sfXChainBridge, SoeRequired},
|
||||
{sfXChainClaimID, SoeRequired},
|
||||
{sfAmount, SoeRequired},
|
||||
{sfOtherChainDestination, SoeOptional},
|
||||
}))
|
||||
|
||||
/** This transaction completes a crosschain transaction */
|
||||
TRANSACTION(ttXCHAIN_CLAIM, 43, XChainClaim,
|
||||
Delegation::Delegable,
|
||||
featureXChainBridge,
|
||||
NoPriv,
|
||||
({
|
||||
{sfXChainBridge, SoeRequired},
|
||||
{sfXChainClaimID, SoeRequired},
|
||||
{sfDestination, SoeRequired},
|
||||
{sfDestinationTag, SoeOptional},
|
||||
{sfAmount, SoeRequired},
|
||||
}))
|
||||
|
||||
/** This transaction initiates a crosschain account create transaction */
|
||||
TRANSACTION(ttXCHAIN_ACCOUNT_CREATE_COMMIT, 44, XChainAccountCreateCommit,
|
||||
Delegation::Delegable,
|
||||
featureXChainBridge,
|
||||
NoPriv,
|
||||
({
|
||||
{sfXChainBridge, SoeRequired},
|
||||
{sfDestination, SoeRequired},
|
||||
{sfAmount, SoeRequired},
|
||||
{sfSignatureReward, SoeRequired},
|
||||
}))
|
||||
|
||||
/** This transaction adds an attestation to a claim */
|
||||
TRANSACTION(ttXCHAIN_ADD_CLAIM_ATTESTATION, 45, XChainAddClaimAttestation,
|
||||
Delegation::Delegable,
|
||||
featureXChainBridge,
|
||||
CreateAcct,
|
||||
({
|
||||
{sfXChainBridge, SoeRequired},
|
||||
|
||||
{sfAttestationSignerAccount, SoeRequired},
|
||||
{sfPublicKey, SoeRequired},
|
||||
{sfSignature, SoeRequired},
|
||||
{sfOtherChainSource, SoeRequired},
|
||||
{sfAmount, SoeRequired},
|
||||
{sfAttestationRewardAccount, SoeRequired},
|
||||
{sfWasLockingChainSend, SoeRequired},
|
||||
|
||||
{sfXChainClaimID, SoeRequired},
|
||||
{sfDestination, SoeOptional},
|
||||
}))
|
||||
|
||||
/** This transaction adds an attestation to an account */
|
||||
TRANSACTION(ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION, 46,
|
||||
XChainAddAccountCreateAttestation,
|
||||
Delegation::Delegable,
|
||||
featureXChainBridge,
|
||||
CreateAcct,
|
||||
({
|
||||
{sfXChainBridge, SoeRequired},
|
||||
|
||||
{sfAttestationSignerAccount, SoeRequired},
|
||||
{sfPublicKey, SoeRequired},
|
||||
{sfSignature, SoeRequired},
|
||||
{sfOtherChainSource, SoeRequired},
|
||||
{sfAmount, SoeRequired},
|
||||
{sfAttestationRewardAccount, SoeRequired},
|
||||
{sfWasLockingChainSend, SoeRequired},
|
||||
|
||||
{sfXChainAccountCreateCount, SoeRequired},
|
||||
{sfDestination, SoeRequired},
|
||||
{sfSignatureReward, SoeRequired},
|
||||
}))
|
||||
|
||||
/** This transaction modifies a sidechain */
|
||||
TRANSACTION(ttXCHAIN_MODIFY_BRIDGE, 47, XChainModifyBridge,
|
||||
Delegation::Delegable,
|
||||
featureXChainBridge,
|
||||
NoPriv,
|
||||
({
|
||||
{sfXChainBridge, SoeRequired},
|
||||
{sfSignatureReward, SoeOptional},
|
||||
{sfMinAccountCreateAmount, SoeOptional},
|
||||
}))
|
||||
|
||||
/** This transactions creates a sidechain */
|
||||
TRANSACTION(ttXCHAIN_CREATE_BRIDGE, 48, XChainCreateBridge,
|
||||
Delegation::Delegable,
|
||||
featureXChainBridge,
|
||||
NoPriv,
|
||||
({
|
||||
{sfXChainBridge, SoeRequired},
|
||||
{sfSignatureReward, SoeRequired},
|
||||
{sfMinAccountCreateAmount, SoeOptional},
|
||||
}))
|
||||
|
||||
/** This transaction type creates or updates a DID */
|
||||
#if TRANSACTION_INCLUDE
|
||||
@@ -1052,35 +1165,6 @@ TRANSACTION(ttCONFIDENTIAL_MPT_CLAWBACK, 89, ConfidentialMPTClawback,
|
||||
{sfZKProof, SoeRequired},
|
||||
}))
|
||||
|
||||
/** This transaction transfers sponsorship on an object/account. */
|
||||
#if TRANSACTION_INCLUDE
|
||||
# include <xrpl/tx/transactors/sponsor/SponsorshipTransfer.h>
|
||||
#endif
|
||||
TRANSACTION(ttSPONSORSHIP_TRANSFER, 90, SponsorshipTransfer,
|
||||
Delegation::NotDelegable,
|
||||
featureSponsor,
|
||||
NoPriv,
|
||||
({
|
||||
{sfObjectID, SoeOptional},
|
||||
{sfSponsee, SoeOptional},
|
||||
}))
|
||||
|
||||
/** This transaction creates a Sponsorship object. */
|
||||
#if TRANSACTION_INCLUDE
|
||||
# include <xrpl/tx/transactors/sponsor/SponsorshipSet.h>
|
||||
#endif
|
||||
TRANSACTION(ttSPONSORSHIP_SET, 91, SponsorshipSet,
|
||||
Delegation::Delegable,
|
||||
featureSponsor,
|
||||
NoPriv,
|
||||
({
|
||||
{sfCounterpartySponsor, SoeOptional},
|
||||
{sfSponsee, SoeOptional},
|
||||
{sfFeeAmount, SoeOptional},
|
||||
{sfMaxFee, SoeOptional},
|
||||
{sfRemainingOwnerCount, SoeOptional},
|
||||
}))
|
||||
|
||||
/** This system-generated transaction type is used to update the status of the various amendments.
|
||||
|
||||
For details, see: https://xrpl.org/amendments.html
|
||||
|
||||
@@ -157,6 +157,7 @@ JSS(both); // in: Subscribe, Unsubscribe
|
||||
JSS(both_sides); // in: Subscribe, Unsubscribe
|
||||
JSS(branch); // out: server_info
|
||||
JSS(broadcast); // out: SubmitTransaction
|
||||
JSS(bridge_account); // in: LedgerEntry
|
||||
JSS(build_path); // in: TransactionSign
|
||||
JSS(build_version); // out: NetworkOPs
|
||||
JSS(cancel_after); // out: AccountChannels
|
||||
@@ -557,9 +558,6 @@ JSS(source_account); // in: PathRequest, RipplePathFind
|
||||
JSS(source_amount); // in: PathRequest, RipplePathFind
|
||||
JSS(source_currencies); // in: PathRequest, RipplePathFind
|
||||
JSS(source_tag); // out: AccountChannels
|
||||
JSS(sponsee); // in: LedgerEntry
|
||||
JSS(sponsor); // in: LedgerEntry
|
||||
JSS(sponsored); // in: AccountObjects
|
||||
JSS(stand_alone); // out: NetworkOPs
|
||||
JSS(standard_deviation); // out: get_aggregate_price
|
||||
JSS(start); // in: TxHistory
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <xrpl/protocol/STInteger.h>
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol/STXChainBridge.h>
|
||||
#include <xrpl/protocol/SecretKey.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
#include <xrpl/protocol/TxFormats.h>
|
||||
|
||||
@@ -447,78 +447,6 @@ public:
|
||||
return this->sle_->isFieldPresent(sfFirstNFTokenSequence);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSponsoredOwnerCount (SoeDefault)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_UINT32::type::value_type>
|
||||
getSponsoredOwnerCount() const
|
||||
{
|
||||
if (hasSponsoredOwnerCount())
|
||||
return this->sle_->at(sfSponsoredOwnerCount);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfSponsoredOwnerCount is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasSponsoredOwnerCount() const
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfSponsoredOwnerCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSponsoringOwnerCount (SoeDefault)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_UINT32::type::value_type>
|
||||
getSponsoringOwnerCount() const
|
||||
{
|
||||
if (hasSponsoringOwnerCount())
|
||||
return this->sle_->at(sfSponsoringOwnerCount);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfSponsoringOwnerCount is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasSponsoringOwnerCount() const
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfSponsoringOwnerCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSponsoringAccountCount (SoeDefault)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_UINT32::type::value_type>
|
||||
getSponsoringAccountCount() const
|
||||
{
|
||||
if (hasSponsoringAccountCount())
|
||||
return this->sle_->at(sfSponsoringAccountCount);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfSponsoringAccountCount is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasSponsoringAccountCount() const
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfSponsoringAccountCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfAMMID (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
@@ -858,39 +786,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSponsoredOwnerCount (SoeDefault)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
AccountRootBuilder&
|
||||
setSponsoredOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSponsoredOwnerCount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSponsoringOwnerCount (SoeDefault)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
AccountRootBuilder&
|
||||
setSponsoringOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSponsoringOwnerCount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSponsoringAccountCount (SoeDefault)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
AccountRootBuilder&
|
||||
setSponsoringAccountCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSponsoringAccountCount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfAMMID (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
|
||||
346
include/xrpl/protocol_autogen/ledger_entries/Bridge.h
Normal file
346
include/xrpl/protocol_autogen/ledger_entries/Bridge.h
Normal file
@@ -0,0 +1,346 @@
|
||||
// This file is auto-generated. Do not edit.
|
||||
#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 {
|
||||
|
||||
class BridgeBuilder;
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
|
||||
/**
|
||||
* @brief 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_pointer sle)
|
||||
: LedgerEntryBase(std::move(sle))
|
||||
{
|
||||
// Verify ledger entry type
|
||||
if (sle_->getType() != entryType)
|
||||
{
|
||||
throw std::runtime_error("Invalid ledger entry type for Bridge");
|
||||
}
|
||||
}
|
||||
|
||||
// Ledger entry-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfAccount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getAccount() const
|
||||
{
|
||||
return this->sle_->at(sfAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSignatureReward (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_AMOUNT::type::value_type
|
||||
getSignatureReward() const
|
||||
{
|
||||
return this->sle_->at(sfSignatureReward);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfMinAccountCreateAmount (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
|
||||
getMinAccountCreateAmount() const
|
||||
{
|
||||
if (hasMinAccountCreateAmount())
|
||||
return this->sle_->at(sfMinAccountCreateAmount);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfMinAccountCreateAmount is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasMinAccountCreateAmount() const
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfMinAccountCreateAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainBridge (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_XCHAIN_BRIDGE::type::value_type
|
||||
getXChainBridge() const
|
||||
{
|
||||
return this->sle_->at(sfXChainBridge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainClaimID (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getXChainClaimID() const
|
||||
{
|
||||
return this->sle_->at(sfXChainClaimID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainAccountCreateCount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getXChainAccountCreateCount() const
|
||||
{
|
||||
return this->sle_->at(sfXChainAccountCreateCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainAccountClaimCount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getXChainAccountClaimCount() const
|
||||
{
|
||||
return this->sle_->at(sfXChainAccountClaimCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfOwnerNode (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getOwnerNode() const
|
||||
{
|
||||
return this->sle_->at(sfOwnerNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfPreviousTxnID (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT256::type::value_type
|
||||
getPreviousTxnID() const
|
||||
{
|
||||
return this->sle_->at(sfPreviousTxnID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfPreviousTxnLgrSeq (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT32::type::value_type
|
||||
getPreviousTxnLgrSeq() const
|
||||
{
|
||||
return this->sle_->at(sfPreviousTxnLgrSeq);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Builder for Bridge ledger entries.
|
||||
*
|
||||
* Provides a fluent interface for constructing ledger entries with method chaining.
|
||||
* Uses STObject internally for flexible ledger entry construction.
|
||||
* Inherits common field setters from LedgerEntryBuilderBase.
|
||||
*/
|
||||
class BridgeBuilder : public LedgerEntryBuilderBase<BridgeBuilder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new BridgeBuilder with required fields.
|
||||
* @param account The sfAccount field value.
|
||||
* @param signatureReward The sfSignatureReward field value.
|
||||
* @param xChainBridge The sfXChainBridge field value.
|
||||
* @param xChainClaimID The sfXChainClaimID field value.
|
||||
* @param xChainAccountCreateCount The sfXChainAccountCreateCount field value.
|
||||
* @param xChainAccountClaimCount The sfXChainAccountClaimCount field value.
|
||||
* @param ownerNode The sfOwnerNode field value.
|
||||
* @param previousTxnID The sfPreviousTxnID field value.
|
||||
* @param previousTxnLgrSeq The sfPreviousTxnLgrSeq field value.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a BridgeBuilder from an existing SLE object.
|
||||
* @param sle The existing ledger entry to copy from.
|
||||
* @throws std::runtime_error if the ledger entry type doesn't match.
|
||||
*/
|
||||
BridgeBuilder(SLE::const_pointer sle)
|
||||
{
|
||||
if (sle->at(sfLedgerEntryType) != ltBRIDGE)
|
||||
{
|
||||
throw std::runtime_error("Invalid ledger entry type for Bridge");
|
||||
}
|
||||
object_ = *sle;
|
||||
}
|
||||
|
||||
/** @brief Ledger entry-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the completed Bridge wrapper.
|
||||
* @param index The ledger entry index.
|
||||
* @return The constructed ledger entry wrapper.
|
||||
*/
|
||||
Bridge
|
||||
build(uint256 const& index)
|
||||
{
|
||||
return Bridge{std::make_shared<SLE>(std::move(object_), index)};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::ledger_entries
|
||||
@@ -243,54 +243,6 @@ public:
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfHighQualityOut);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfHighSponsor (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
|
||||
getHighSponsor() const
|
||||
{
|
||||
if (hasHighSponsor())
|
||||
return this->sle_->at(sfHighSponsor);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfHighSponsor is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasHighSponsor() const
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfHighSponsor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfLowSponsor (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
|
||||
getLowSponsor() const
|
||||
{
|
||||
if (hasLowSponsor())
|
||||
return this->sle_->at(sfLowSponsor);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfLowSponsor is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasLowSponsor() const
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfLowSponsor);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -458,28 +410,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfHighSponsor (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
RippleStateBuilder&
|
||||
setHighSponsor(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfHighSponsor] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfLowSponsor (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
RippleStateBuilder&
|
||||
setLowSponsor(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfLowSponsor] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the completed RippleState wrapper.
|
||||
* @param index The ledger entry index.
|
||||
|
||||
@@ -1,344 +0,0 @@
|
||||
// This file is auto-generated. Do not edit.
|
||||
#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 {
|
||||
|
||||
class SponsorshipBuilder;
|
||||
|
||||
/**
|
||||
* @brief Ledger Entry: Sponsorship
|
||||
*
|
||||
* Type: ltSPONSORSHIP (0x0090)
|
||||
* RPC Name: sponsorship
|
||||
*
|
||||
* Immutable wrapper around SLE providing type-safe field access.
|
||||
* Use SponsorshipBuilder to construct new ledger entries.
|
||||
*/
|
||||
class Sponsorship : public LedgerEntryBase
|
||||
{
|
||||
public:
|
||||
static constexpr LedgerEntryType entryType = ltSPONSORSHIP;
|
||||
|
||||
/**
|
||||
* @brief Construct a Sponsorship ledger entry wrapper from an existing SLE object.
|
||||
* @throws std::runtime_error if the ledger entry type doesn't match.
|
||||
*/
|
||||
explicit Sponsorship(SLE::const_pointer sle)
|
||||
: LedgerEntryBase(std::move(sle))
|
||||
{
|
||||
// Verify ledger entry type
|
||||
if (sle_->getType() != entryType)
|
||||
{
|
||||
throw std::runtime_error("Invalid ledger entry type for Sponsorship");
|
||||
}
|
||||
}
|
||||
|
||||
// Ledger entry-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfPreviousTxnID (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT256::type::value_type
|
||||
getPreviousTxnID() const
|
||||
{
|
||||
return this->sle_->at(sfPreviousTxnID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfPreviousTxnLgrSeq (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT32::type::value_type
|
||||
getPreviousTxnLgrSeq() const
|
||||
{
|
||||
return this->sle_->at(sfPreviousTxnLgrSeq);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfOwner (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getOwner() const
|
||||
{
|
||||
return this->sle_->at(sfOwner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSponsee (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getSponsee() const
|
||||
{
|
||||
return this->sle_->at(sfSponsee);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfFeeAmount (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
|
||||
getFeeAmount() const
|
||||
{
|
||||
if (hasFeeAmount())
|
||||
return this->sle_->at(sfFeeAmount);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfFeeAmount is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasFeeAmount() const
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfFeeAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfMaxFee (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
|
||||
getMaxFee() const
|
||||
{
|
||||
if (hasMaxFee())
|
||||
return this->sle_->at(sfMaxFee);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfMaxFee is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasMaxFee() const
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfMaxFee);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfRemainingOwnerCount (SoeDefault)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_UINT32::type::value_type>
|
||||
getRemainingOwnerCount() const
|
||||
{
|
||||
if (hasRemainingOwnerCount())
|
||||
return this->sle_->at(sfRemainingOwnerCount);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfRemainingOwnerCount is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasRemainingOwnerCount() const
|
||||
{
|
||||
return this->sle_->isFieldPresent(sfRemainingOwnerCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfOwnerNode (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getOwnerNode() const
|
||||
{
|
||||
return this->sle_->at(sfOwnerNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSponseeNode (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getSponseeNode() const
|
||||
{
|
||||
return this->sle_->at(sfSponseeNode);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Builder for Sponsorship ledger entries.
|
||||
*
|
||||
* Provides a fluent interface for constructing ledger entries with method chaining.
|
||||
* Uses STObject internally for flexible ledger entry construction.
|
||||
* Inherits common field setters from LedgerEntryBuilderBase.
|
||||
*/
|
||||
class SponsorshipBuilder : public LedgerEntryBuilderBase<SponsorshipBuilder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new SponsorshipBuilder with required fields.
|
||||
* @param previousTxnID The sfPreviousTxnID field value.
|
||||
* @param previousTxnLgrSeq The sfPreviousTxnLgrSeq field value.
|
||||
* @param owner The sfOwner field value.
|
||||
* @param sponsee The sfSponsee field value.
|
||||
* @param ownerNode The sfOwnerNode field value.
|
||||
* @param sponseeNode The sfSponseeNode field value.
|
||||
*/
|
||||
SponsorshipBuilder(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_ACCOUNT::type::value_type> const& owner,std::decay_t<typename SF_ACCOUNT::type::value_type> const& sponsee,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT64::type::value_type> const& sponseeNode)
|
||||
: LedgerEntryBuilderBase<SponsorshipBuilder>(ltSPONSORSHIP)
|
||||
{
|
||||
setPreviousTxnID(previousTxnID);
|
||||
setPreviousTxnLgrSeq(previousTxnLgrSeq);
|
||||
setOwner(owner);
|
||||
setSponsee(sponsee);
|
||||
setOwnerNode(ownerNode);
|
||||
setSponseeNode(sponseeNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a SponsorshipBuilder from an existing SLE object.
|
||||
* @param sle The existing ledger entry to copy from.
|
||||
* @throws std::runtime_error if the ledger entry type doesn't match.
|
||||
*/
|
||||
SponsorshipBuilder(SLE::const_pointer sle)
|
||||
{
|
||||
if (sle->at(sfLedgerEntryType) != ltSPONSORSHIP)
|
||||
{
|
||||
throw std::runtime_error("Invalid ledger entry type for Sponsorship");
|
||||
}
|
||||
object_ = *sle;
|
||||
}
|
||||
|
||||
/** @brief Ledger entry-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief Set sfPreviousTxnID (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipBuilder&
|
||||
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
|
||||
{
|
||||
object_[sfPreviousTxnID] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfPreviousTxnLgrSeq (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipBuilder&
|
||||
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
|
||||
{
|
||||
object_[sfPreviousTxnLgrSeq] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfOwner (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipBuilder&
|
||||
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfOwner] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSponsee (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipBuilder&
|
||||
setSponsee(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSponsee] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfFeeAmount (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipBuilder&
|
||||
setFeeAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfFeeAmount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfMaxFee (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipBuilder&
|
||||
setMaxFee(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfMaxFee] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfRemainingOwnerCount (SoeDefault)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipBuilder&
|
||||
setRemainingOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
|
||||
{
|
||||
object_[sfRemainingOwnerCount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfOwnerNode (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipBuilder&
|
||||
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
|
||||
{
|
||||
object_[sfOwnerNode] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSponseeNode (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipBuilder&
|
||||
setSponseeNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSponseeNode] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the completed Sponsorship wrapper.
|
||||
* @param index The ledger entry index.
|
||||
* @return The constructed ledger entry wrapper.
|
||||
*/
|
||||
Sponsorship
|
||||
build(uint256 const& index)
|
||||
{
|
||||
return Sponsorship{std::make_shared<SLE>(std::move(object_), index)};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::ledger_entries
|
||||
@@ -0,0 +1,312 @@
|
||||
// This file is auto-generated. Do not edit.
|
||||
#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 {
|
||||
|
||||
class XChainOwnedClaimIDBuilder;
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
|
||||
/**
|
||||
* @brief 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_pointer sle)
|
||||
: LedgerEntryBase(std::move(sle))
|
||||
{
|
||||
// Verify ledger entry type
|
||||
if (sle_->getType() != entryType)
|
||||
{
|
||||
throw std::runtime_error("Invalid ledger entry type for XChainOwnedClaimID");
|
||||
}
|
||||
}
|
||||
|
||||
// Ledger entry-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfAccount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getAccount() const
|
||||
{
|
||||
return this->sle_->at(sfAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainBridge (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_XCHAIN_BRIDGE::type::value_type
|
||||
getXChainBridge() const
|
||||
{
|
||||
return this->sle_->at(sfXChainBridge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainClaimID (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getXChainClaimID() const
|
||||
{
|
||||
return this->sle_->at(sfXChainClaimID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfOtherChainSource (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getOtherChainSource() const
|
||||
{
|
||||
return this->sle_->at(sfOtherChainSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainClaimAttestations (SoeRequired)
|
||||
* @note This is an untyped field (unknown).
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
STArray const&
|
||||
getXChainClaimAttestations() const
|
||||
{
|
||||
return this->sle_->getFieldArray(sfXChainClaimAttestations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSignatureReward (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_AMOUNT::type::value_type
|
||||
getSignatureReward() const
|
||||
{
|
||||
return this->sle_->at(sfSignatureReward);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfOwnerNode (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getOwnerNode() const
|
||||
{
|
||||
return this->sle_->at(sfOwnerNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfPreviousTxnID (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT256::type::value_type
|
||||
getPreviousTxnID() const
|
||||
{
|
||||
return this->sle_->at(sfPreviousTxnID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfPreviousTxnLgrSeq (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT32::type::value_type
|
||||
getPreviousTxnLgrSeq() const
|
||||
{
|
||||
return this->sle_->at(sfPreviousTxnLgrSeq);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Builder for XChainOwnedClaimID ledger entries.
|
||||
*
|
||||
* Provides a fluent interface for constructing ledger entries with method chaining.
|
||||
* Uses STObject internally for flexible ledger entry construction.
|
||||
* Inherits common field setters from LedgerEntryBuilderBase.
|
||||
*/
|
||||
class XChainOwnedClaimIDBuilder : public LedgerEntryBuilderBase<XChainOwnedClaimIDBuilder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new XChainOwnedClaimIDBuilder with required fields.
|
||||
* @param account The sfAccount field value.
|
||||
* @param xChainBridge The sfXChainBridge field value.
|
||||
* @param xChainClaimID The sfXChainClaimID field value.
|
||||
* @param otherChainSource The sfOtherChainSource field value.
|
||||
* @param xChainClaimAttestations The sfXChainClaimAttestations field value.
|
||||
* @param signatureReward The sfSignatureReward field value.
|
||||
* @param ownerNode The sfOwnerNode field value.
|
||||
* @param previousTxnID The sfPreviousTxnID field value.
|
||||
* @param previousTxnLgrSeq The sfPreviousTxnLgrSeq field value.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a XChainOwnedClaimIDBuilder from an existing SLE object.
|
||||
* @param sle The existing ledger entry to copy from.
|
||||
* @throws std::runtime_error if the ledger entry type doesn't match.
|
||||
*/
|
||||
XChainOwnedClaimIDBuilder(SLE::const_pointer sle)
|
||||
{
|
||||
if (sle->at(sfLedgerEntryType) != ltXCHAIN_OWNED_CLAIM_ID)
|
||||
{
|
||||
throw std::runtime_error("Invalid ledger entry type for XChainOwnedClaimID");
|
||||
}
|
||||
object_ = *sle;
|
||||
}
|
||||
|
||||
/** @brief Ledger entry-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfXChainClaimAttestations (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainOwnedClaimIDBuilder&
|
||||
setXChainClaimAttestations(STArray const& value)
|
||||
{
|
||||
object_.setFieldArray(sfXChainClaimAttestations, value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the completed XChainOwnedClaimID wrapper.
|
||||
* @param index The ledger entry index.
|
||||
* @return The constructed ledger entry wrapper.
|
||||
*/
|
||||
XChainOwnedClaimID
|
||||
build(uint256 const& index)
|
||||
{
|
||||
return XChainOwnedClaimID{std::make_shared<SLE>(std::move(object_), index)};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::ledger_entries
|
||||
@@ -0,0 +1,264 @@
|
||||
// This file is auto-generated. Do not edit.
|
||||
#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 {
|
||||
|
||||
class XChainOwnedCreateAccountClaimIDBuilder;
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
|
||||
/**
|
||||
* @brief 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_pointer sle)
|
||||
: LedgerEntryBase(std::move(sle))
|
||||
{
|
||||
// Verify ledger entry type
|
||||
if (sle_->getType() != entryType)
|
||||
{
|
||||
throw std::runtime_error("Invalid ledger entry type for XChainOwnedCreateAccountClaimID");
|
||||
}
|
||||
}
|
||||
|
||||
// Ledger entry-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfAccount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getAccount() const
|
||||
{
|
||||
return this->sle_->at(sfAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainBridge (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_XCHAIN_BRIDGE::type::value_type
|
||||
getXChainBridge() const
|
||||
{
|
||||
return this->sle_->at(sfXChainBridge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainAccountCreateCount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getXChainAccountCreateCount() const
|
||||
{
|
||||
return this->sle_->at(sfXChainAccountCreateCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainCreateAccountAttestations (SoeRequired)
|
||||
* @note This is an untyped field (unknown).
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
STArray const&
|
||||
getXChainCreateAccountAttestations() const
|
||||
{
|
||||
return this->sle_->getFieldArray(sfXChainCreateAccountAttestations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfOwnerNode (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getOwnerNode() const
|
||||
{
|
||||
return this->sle_->at(sfOwnerNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfPreviousTxnID (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT256::type::value_type
|
||||
getPreviousTxnID() const
|
||||
{
|
||||
return this->sle_->at(sfPreviousTxnID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfPreviousTxnLgrSeq (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT32::type::value_type
|
||||
getPreviousTxnLgrSeq() const
|
||||
{
|
||||
return this->sle_->at(sfPreviousTxnLgrSeq);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Builder for XChainOwnedCreateAccountClaimID ledger entries.
|
||||
*
|
||||
* Provides a fluent interface for constructing ledger entries with method chaining.
|
||||
* Uses STObject internally for flexible ledger entry construction.
|
||||
* Inherits common field setters from LedgerEntryBuilderBase.
|
||||
*/
|
||||
class XChainOwnedCreateAccountClaimIDBuilder : public LedgerEntryBuilderBase<XChainOwnedCreateAccountClaimIDBuilder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new XChainOwnedCreateAccountClaimIDBuilder with required fields.
|
||||
* @param account The sfAccount field value.
|
||||
* @param xChainBridge The sfXChainBridge field value.
|
||||
* @param xChainAccountCreateCount The sfXChainAccountCreateCount field value.
|
||||
* @param xChainCreateAccountAttestations The sfXChainCreateAccountAttestations field value.
|
||||
* @param ownerNode The sfOwnerNode field value.
|
||||
* @param previousTxnID The sfPreviousTxnID field value.
|
||||
* @param previousTxnLgrSeq The sfPreviousTxnLgrSeq field value.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a XChainOwnedCreateAccountClaimIDBuilder from an existing SLE object.
|
||||
* @param sle The existing ledger entry to copy from.
|
||||
* @throws std::runtime_error if the ledger entry type doesn't match.
|
||||
*/
|
||||
XChainOwnedCreateAccountClaimIDBuilder(SLE::const_pointer sle)
|
||||
{
|
||||
if (sle->at(sfLedgerEntryType) != ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID)
|
||||
{
|
||||
throw std::runtime_error("Invalid ledger entry type for XChainOwnedCreateAccountClaimID");
|
||||
}
|
||||
object_ = *sle;
|
||||
}
|
||||
|
||||
/** @brief Ledger entry-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfXChainCreateAccountAttestations (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainOwnedCreateAccountClaimIDBuilder&
|
||||
setXChainCreateAccountAttestations(STArray const& value)
|
||||
{
|
||||
object_.setFieldArray(sfXChainCreateAccountAttestations, value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the completed XChainOwnedCreateAccountClaimID wrapper.
|
||||
* @param index The ledger entry index.
|
||||
* @return The constructed ledger entry wrapper.
|
||||
*/
|
||||
XChainOwnedCreateAccountClaimID
|
||||
build(uint256 const& index)
|
||||
{
|
||||
return XChainOwnedCreateAccountClaimID{std::make_shared<SLE>(std::move(object_), index)};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::ledger_entries
|
||||
@@ -1,290 +0,0 @@
|
||||
// This file is auto-generated. Do not edit.
|
||||
#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 {
|
||||
|
||||
class SponsorshipSetBuilder;
|
||||
|
||||
/**
|
||||
* @brief Transaction: SponsorshipSet
|
||||
*
|
||||
* Type: ttSPONSORSHIP_SET (91)
|
||||
* Delegable: Delegation::Delegable
|
||||
* Amendment: featureSponsor
|
||||
* Privileges: NoPriv
|
||||
*
|
||||
* Immutable wrapper around STTx providing type-safe field access.
|
||||
* Use SponsorshipSetBuilder to construct new transactions.
|
||||
*/
|
||||
class SponsorshipSet : public TransactionBase
|
||||
{
|
||||
public:
|
||||
static constexpr xrpl::TxType txType = ttSPONSORSHIP_SET;
|
||||
|
||||
/**
|
||||
* @brief Construct a SponsorshipSet transaction wrapper from an existing STTx object.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
explicit SponsorshipSet(std::shared_ptr<STTx const> tx)
|
||||
: TransactionBase(std::move(tx))
|
||||
{
|
||||
// Verify transaction type
|
||||
if (tx_->getTxnType() != txType)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for SponsorshipSet");
|
||||
}
|
||||
}
|
||||
|
||||
// Transaction-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfCounterpartySponsor (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
|
||||
getCounterpartySponsor() const
|
||||
{
|
||||
if (hasCounterpartySponsor())
|
||||
{
|
||||
return this->tx_->at(sfCounterpartySponsor);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfCounterpartySponsor is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasCounterpartySponsor() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfCounterpartySponsor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSponsee (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
|
||||
getSponsee() const
|
||||
{
|
||||
if (hasSponsee())
|
||||
{
|
||||
return this->tx_->at(sfSponsee);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfSponsee is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasSponsee() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfSponsee);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfFeeAmount (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
|
||||
getFeeAmount() const
|
||||
{
|
||||
if (hasFeeAmount())
|
||||
{
|
||||
return this->tx_->at(sfFeeAmount);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfFeeAmount is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasFeeAmount() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfFeeAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfMaxFee (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
|
||||
getMaxFee() const
|
||||
{
|
||||
if (hasMaxFee())
|
||||
{
|
||||
return this->tx_->at(sfMaxFee);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfMaxFee is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasMaxFee() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfMaxFee);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfRemainingOwnerCount (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_UINT32::type::value_type>
|
||||
getRemainingOwnerCount() const
|
||||
{
|
||||
if (hasRemainingOwnerCount())
|
||||
{
|
||||
return this->tx_->at(sfRemainingOwnerCount);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfRemainingOwnerCount is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasRemainingOwnerCount() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfRemainingOwnerCount);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Builder for SponsorshipSet transactions.
|
||||
*
|
||||
* Provides a fluent interface for constructing transactions with method chaining.
|
||||
* Uses STObject internally for flexible transaction construction.
|
||||
* Inherits common field setters from TransactionBuilderBase.
|
||||
*/
|
||||
class SponsorshipSetBuilder : public TransactionBuilderBase<SponsorshipSetBuilder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new SponsorshipSetBuilder with required fields.
|
||||
* @param account The account initiating the transaction.
|
||||
* @param sequence Optional sequence number for the transaction.
|
||||
* @param fee Optional fee for the transaction.
|
||||
*/
|
||||
SponsorshipSetBuilder(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<SponsorshipSetBuilder>(ttSPONSORSHIP_SET, account, sequence, fee)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a SponsorshipSetBuilder from an existing STTx object.
|
||||
* @param tx The existing transaction to copy from.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
SponsorshipSetBuilder(std::shared_ptr<STTx const> tx)
|
||||
{
|
||||
if (tx->getTxnType() != ttSPONSORSHIP_SET)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for SponsorshipSetBuilder");
|
||||
}
|
||||
object_ = *tx;
|
||||
}
|
||||
|
||||
/** @brief Transaction-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief Set sfCounterpartySponsor (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipSetBuilder&
|
||||
setCounterpartySponsor(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfCounterpartySponsor] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSponsee (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipSetBuilder&
|
||||
setSponsee(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSponsee] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfFeeAmount (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipSetBuilder&
|
||||
setFeeAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfFeeAmount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfMaxFee (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipSetBuilder&
|
||||
setMaxFee(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfMaxFee] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfRemainingOwnerCount (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipSetBuilder&
|
||||
setRemainingOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
|
||||
{
|
||||
object_[sfRemainingOwnerCount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the SponsorshipSet wrapper.
|
||||
* @param publicKey The public key for signing.
|
||||
* @param secretKey The secret key for signing.
|
||||
* @return The constructed transaction wrapper.
|
||||
*/
|
||||
SponsorshipSet
|
||||
build(PublicKey const& publicKey, SecretKey const& secretKey)
|
||||
{
|
||||
sign(publicKey, secretKey);
|
||||
return SponsorshipSet{std::make_shared<STTx>(std::move(object_))};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::transactions
|
||||
@@ -1,179 +0,0 @@
|
||||
// This file is auto-generated. Do not edit.
|
||||
#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 {
|
||||
|
||||
class SponsorshipTransferBuilder;
|
||||
|
||||
/**
|
||||
* @brief Transaction: SponsorshipTransfer
|
||||
*
|
||||
* Type: ttSPONSORSHIP_TRANSFER (90)
|
||||
* Delegable: Delegation::NotDelegable
|
||||
* Amendment: featureSponsor
|
||||
* Privileges: NoPriv
|
||||
*
|
||||
* Immutable wrapper around STTx providing type-safe field access.
|
||||
* Use SponsorshipTransferBuilder to construct new transactions.
|
||||
*/
|
||||
class SponsorshipTransfer : public TransactionBase
|
||||
{
|
||||
public:
|
||||
static constexpr xrpl::TxType txType = ttSPONSORSHIP_TRANSFER;
|
||||
|
||||
/**
|
||||
* @brief Construct a SponsorshipTransfer transaction wrapper from an existing STTx object.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
explicit SponsorshipTransfer(std::shared_ptr<STTx const> tx)
|
||||
: TransactionBase(std::move(tx))
|
||||
{
|
||||
// Verify transaction type
|
||||
if (tx_->getTxnType() != txType)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for SponsorshipTransfer");
|
||||
}
|
||||
}
|
||||
|
||||
// Transaction-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfObjectID (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_UINT256::type::value_type>
|
||||
getObjectID() const
|
||||
{
|
||||
if (hasObjectID())
|
||||
{
|
||||
return this->tx_->at(sfObjectID);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfObjectID is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasObjectID() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfObjectID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSponsee (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
|
||||
getSponsee() const
|
||||
{
|
||||
if (hasSponsee())
|
||||
{
|
||||
return this->tx_->at(sfSponsee);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfSponsee is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasSponsee() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfSponsee);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Builder for SponsorshipTransfer transactions.
|
||||
*
|
||||
* Provides a fluent interface for constructing transactions with method chaining.
|
||||
* Uses STObject internally for flexible transaction construction.
|
||||
* Inherits common field setters from TransactionBuilderBase.
|
||||
*/
|
||||
class SponsorshipTransferBuilder : public TransactionBuilderBase<SponsorshipTransferBuilder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new SponsorshipTransferBuilder with required fields.
|
||||
* @param account The account initiating the transaction.
|
||||
* @param sequence Optional sequence number for the transaction.
|
||||
* @param fee Optional fee for the transaction.
|
||||
*/
|
||||
SponsorshipTransferBuilder(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<SponsorshipTransferBuilder>(ttSPONSORSHIP_TRANSFER, account, sequence, fee)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a SponsorshipTransferBuilder from an existing STTx object.
|
||||
* @param tx The existing transaction to copy from.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
SponsorshipTransferBuilder(std::shared_ptr<STTx const> tx)
|
||||
{
|
||||
if (tx->getTxnType() != ttSPONSORSHIP_TRANSFER)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for SponsorshipTransferBuilder");
|
||||
}
|
||||
object_ = *tx;
|
||||
}
|
||||
|
||||
/** @brief Transaction-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief Set sfObjectID (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipTransferBuilder&
|
||||
setObjectID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
|
||||
{
|
||||
object_[sfObjectID] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSponsee (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
SponsorshipTransferBuilder&
|
||||
setSponsee(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSponsee] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the SponsorshipTransfer wrapper.
|
||||
* @param publicKey The public key for signing.
|
||||
* @param secretKey The secret key for signing.
|
||||
* @return The constructed transaction wrapper.
|
||||
*/
|
||||
SponsorshipTransfer
|
||||
build(PublicKey const& publicKey, SecretKey const& secretKey)
|
||||
{
|
||||
sign(publicKey, secretKey);
|
||||
return SponsorshipTransfer{std::make_shared<STTx>(std::move(object_))};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::transactions
|
||||
@@ -0,0 +1,201 @@
|
||||
// This file is auto-generated. Do not edit.
|
||||
#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 {
|
||||
|
||||
class XChainAccountCreateCommitBuilder;
|
||||
|
||||
/**
|
||||
* @brief Transaction: XChainAccountCreateCommit
|
||||
*
|
||||
* Type: ttXCHAIN_ACCOUNT_CREATE_COMMIT (44)
|
||||
* Delegable: Delegation::Delegable
|
||||
* Amendment: featureXChainBridge
|
||||
* Privileges: NoPriv
|
||||
*
|
||||
* Immutable wrapper around STTx providing type-safe field access.
|
||||
* Use XChainAccountCreateCommitBuilder to construct new transactions.
|
||||
*/
|
||||
class XChainAccountCreateCommit : public TransactionBase
|
||||
{
|
||||
public:
|
||||
static constexpr xrpl::TxType txType = ttXCHAIN_ACCOUNT_CREATE_COMMIT;
|
||||
|
||||
/**
|
||||
* @brief Construct a XChainAccountCreateCommit transaction wrapper from an existing STTx object.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
explicit XChainAccountCreateCommit(std::shared_ptr<STTx const> tx)
|
||||
: TransactionBase(std::move(tx))
|
||||
{
|
||||
// Verify transaction type
|
||||
if (tx_->getTxnType() != txType)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for XChainAccountCreateCommit");
|
||||
}
|
||||
}
|
||||
|
||||
// Transaction-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainBridge (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_XCHAIN_BRIDGE::type::value_type
|
||||
getXChainBridge() const
|
||||
{
|
||||
return this->tx_->at(sfXChainBridge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfDestination (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getDestination() const
|
||||
{
|
||||
return this->tx_->at(sfDestination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfAmount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_AMOUNT::type::value_type
|
||||
getAmount() const
|
||||
{
|
||||
return this->tx_->at(sfAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSignatureReward (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_AMOUNT::type::value_type
|
||||
getSignatureReward() const
|
||||
{
|
||||
return this->tx_->at(sfSignatureReward);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Builder for XChainAccountCreateCommit transactions.
|
||||
*
|
||||
* Provides a fluent interface for constructing transactions with method chaining.
|
||||
* Uses STObject internally for flexible transaction construction.
|
||||
* Inherits common field setters from TransactionBuilderBase.
|
||||
*/
|
||||
class XChainAccountCreateCommitBuilder : public TransactionBuilderBase<XChainAccountCreateCommitBuilder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new XChainAccountCreateCommitBuilder with required fields.
|
||||
* @param account The account initiating the transaction.
|
||||
* @param xChainBridge The sfXChainBridge field value.
|
||||
* @param destination The sfDestination field value.
|
||||
* @param amount The sfAmount field value.
|
||||
* @param signatureReward The sfSignatureReward field value.
|
||||
* @param sequence Optional sequence number for the transaction.
|
||||
* @param fee Optional fee for the transaction.
|
||||
*/
|
||||
XChainAccountCreateCommitBuilder(SF_ACCOUNT::type::value_type account,
|
||||
std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& xChainBridge, 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& signatureReward, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
|
||||
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
|
||||
)
|
||||
: TransactionBuilderBase<XChainAccountCreateCommitBuilder>(ttXCHAIN_ACCOUNT_CREATE_COMMIT, account, sequence, fee)
|
||||
{
|
||||
setXChainBridge(xChainBridge);
|
||||
setDestination(destination);
|
||||
setAmount(amount);
|
||||
setSignatureReward(signatureReward);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a XChainAccountCreateCommitBuilder from an existing STTx object.
|
||||
* @param tx The existing transaction to copy from.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
XChainAccountCreateCommitBuilder(std::shared_ptr<STTx const> tx)
|
||||
{
|
||||
if (tx->getTxnType() != ttXCHAIN_ACCOUNT_CREATE_COMMIT)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for XChainAccountCreateCommitBuilder");
|
||||
}
|
||||
object_ = *tx;
|
||||
}
|
||||
|
||||
/** @brief Transaction-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief Set sfXChainBridge (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAccountCreateCommitBuilder&
|
||||
setXChainBridge(std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& value)
|
||||
{
|
||||
object_[sfXChainBridge] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfDestination (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAccountCreateCommitBuilder&
|
||||
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfDestination] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfAmount (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAccountCreateCommitBuilder&
|
||||
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfAmount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSignatureReward (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAccountCreateCommitBuilder&
|
||||
setSignatureReward(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSignatureReward] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the XChainAccountCreateCommit wrapper.
|
||||
* @param publicKey The public key for signing.
|
||||
* @param secretKey The secret key for signing.
|
||||
* @return The constructed transaction wrapper.
|
||||
*/
|
||||
XChainAccountCreateCommit
|
||||
build(PublicKey const& publicKey, SecretKey const& secretKey)
|
||||
{
|
||||
sign(publicKey, secretKey);
|
||||
return XChainAccountCreateCommit{std::make_shared<STTx>(std::move(object_))};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::transactions
|
||||
@@ -0,0 +1,369 @@
|
||||
// This file is auto-generated. Do not edit.
|
||||
#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 {
|
||||
|
||||
class XChainAddAccountCreateAttestationBuilder;
|
||||
|
||||
/**
|
||||
* @brief Transaction: XChainAddAccountCreateAttestation
|
||||
*
|
||||
* Type: ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION (46)
|
||||
* Delegable: Delegation::Delegable
|
||||
* Amendment: featureXChainBridge
|
||||
* Privileges: CreateAcct
|
||||
*
|
||||
* Immutable wrapper around STTx providing type-safe field access.
|
||||
* Use XChainAddAccountCreateAttestationBuilder to construct new transactions.
|
||||
*/
|
||||
class XChainAddAccountCreateAttestation : public TransactionBase
|
||||
{
|
||||
public:
|
||||
static constexpr xrpl::TxType txType = ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION;
|
||||
|
||||
/**
|
||||
* @brief Construct a XChainAddAccountCreateAttestation transaction wrapper from an existing STTx object.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
explicit XChainAddAccountCreateAttestation(std::shared_ptr<STTx const> tx)
|
||||
: TransactionBase(std::move(tx))
|
||||
{
|
||||
// Verify transaction type
|
||||
if (tx_->getTxnType() != txType)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for XChainAddAccountCreateAttestation");
|
||||
}
|
||||
}
|
||||
|
||||
// Transaction-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainBridge (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_XCHAIN_BRIDGE::type::value_type
|
||||
getXChainBridge() const
|
||||
{
|
||||
return this->tx_->at(sfXChainBridge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfAttestationSignerAccount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getAttestationSignerAccount() const
|
||||
{
|
||||
return this->tx_->at(sfAttestationSignerAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfPublicKey (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_VL::type::value_type
|
||||
getPublicKey() const
|
||||
{
|
||||
return this->tx_->at(sfPublicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSignature (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_VL::type::value_type
|
||||
getSignature() const
|
||||
{
|
||||
return this->tx_->at(sfSignature);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfOtherChainSource (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getOtherChainSource() const
|
||||
{
|
||||
return this->tx_->at(sfOtherChainSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfAmount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_AMOUNT::type::value_type
|
||||
getAmount() const
|
||||
{
|
||||
return this->tx_->at(sfAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfAttestationRewardAccount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getAttestationRewardAccount() const
|
||||
{
|
||||
return this->tx_->at(sfAttestationRewardAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfWasLockingChainSend (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT8::type::value_type
|
||||
getWasLockingChainSend() const
|
||||
{
|
||||
return this->tx_->at(sfWasLockingChainSend);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainAccountCreateCount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getXChainAccountCreateCount() const
|
||||
{
|
||||
return this->tx_->at(sfXChainAccountCreateCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfDestination (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getDestination() const
|
||||
{
|
||||
return this->tx_->at(sfDestination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSignatureReward (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_AMOUNT::type::value_type
|
||||
getSignatureReward() const
|
||||
{
|
||||
return this->tx_->at(sfSignatureReward);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Builder for XChainAddAccountCreateAttestation transactions.
|
||||
*
|
||||
* Provides a fluent interface for constructing transactions with method chaining.
|
||||
* Uses STObject internally for flexible transaction construction.
|
||||
* Inherits common field setters from TransactionBuilderBase.
|
||||
*/
|
||||
class XChainAddAccountCreateAttestationBuilder : public TransactionBuilderBase<XChainAddAccountCreateAttestationBuilder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new XChainAddAccountCreateAttestationBuilder with required fields.
|
||||
* @param account The account initiating the transaction.
|
||||
* @param xChainBridge The sfXChainBridge field value.
|
||||
* @param attestationSignerAccount The sfAttestationSignerAccount field value.
|
||||
* @param publicKey The sfPublicKey field value.
|
||||
* @param signature The sfSignature field value.
|
||||
* @param otherChainSource The sfOtherChainSource field value.
|
||||
* @param amount The sfAmount field value.
|
||||
* @param attestationRewardAccount The sfAttestationRewardAccount field value.
|
||||
* @param wasLockingChainSend The sfWasLockingChainSend field value.
|
||||
* @param xChainAccountCreateCount The sfXChainAccountCreateCount field value.
|
||||
* @param destination The sfDestination field value.
|
||||
* @param signatureReward The sfSignatureReward field value.
|
||||
* @param sequence Optional sequence number for the transaction.
|
||||
* @param fee Optional fee for the transaction.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder(SF_ACCOUNT::type::value_type account,
|
||||
std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& xChainBridge, std::decay_t<typename SF_ACCOUNT::type::value_type> const& attestationSignerAccount, std::decay_t<typename SF_VL::type::value_type> const& publicKey, std::decay_t<typename SF_VL::type::value_type> const& signature, std::decay_t<typename SF_ACCOUNT::type::value_type> const& otherChainSource, std::decay_t<typename SF_AMOUNT::type::value_type> const& amount, std::decay_t<typename SF_ACCOUNT::type::value_type> const& attestationRewardAccount, std::decay_t<typename SF_UINT8::type::value_type> const& wasLockingChainSend, std::decay_t<typename SF_UINT64::type::value_type> const& xChainAccountCreateCount, std::decay_t<typename SF_ACCOUNT::type::value_type> const& destination, std::decay_t<typename SF_AMOUNT::type::value_type> const& signatureReward, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
|
||||
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
|
||||
)
|
||||
: TransactionBuilderBase<XChainAddAccountCreateAttestationBuilder>(ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION, account, sequence, fee)
|
||||
{
|
||||
setXChainBridge(xChainBridge);
|
||||
setAttestationSignerAccount(attestationSignerAccount);
|
||||
setPublicKey(publicKey);
|
||||
setSignature(signature);
|
||||
setOtherChainSource(otherChainSource);
|
||||
setAmount(amount);
|
||||
setAttestationRewardAccount(attestationRewardAccount);
|
||||
setWasLockingChainSend(wasLockingChainSend);
|
||||
setXChainAccountCreateCount(xChainAccountCreateCount);
|
||||
setDestination(destination);
|
||||
setSignatureReward(signatureReward);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a XChainAddAccountCreateAttestationBuilder from an existing STTx object.
|
||||
* @param tx The existing transaction to copy from.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder(std::shared_ptr<STTx const> tx)
|
||||
{
|
||||
if (tx->getTxnType() != ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for XChainAddAccountCreateAttestationBuilder");
|
||||
}
|
||||
object_ = *tx;
|
||||
}
|
||||
|
||||
/** @brief Transaction-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief Set sfXChainBridge (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setXChainBridge(std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& value)
|
||||
{
|
||||
object_[sfXChainBridge] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfAttestationSignerAccount (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setAttestationSignerAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfAttestationSignerAccount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfPublicKey (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setPublicKey(std::decay_t<typename SF_VL::type::value_type> const& value)
|
||||
{
|
||||
object_[sfPublicKey] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSignature (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setSignature(std::decay_t<typename SF_VL::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSignature] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfOtherChainSource (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setOtherChainSource(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfOtherChainSource] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfAmount (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfAmount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfAttestationRewardAccount (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setAttestationRewardAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfAttestationRewardAccount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfWasLockingChainSend (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setWasLockingChainSend(std::decay_t<typename SF_UINT8::type::value_type> const& value)
|
||||
{
|
||||
object_[sfWasLockingChainSend] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfXChainAccountCreateCount (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setXChainAccountCreateCount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
|
||||
{
|
||||
object_[sfXChainAccountCreateCount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfDestination (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfDestination] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSignatureReward (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddAccountCreateAttestationBuilder&
|
||||
setSignatureReward(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSignatureReward] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the XChainAddAccountCreateAttestation wrapper.
|
||||
* @param publicKey The public key for signing.
|
||||
* @param secretKey The secret key for signing.
|
||||
* @return The constructed transaction wrapper.
|
||||
*/
|
||||
XChainAddAccountCreateAttestation
|
||||
build(PublicKey const& publicKey, SecretKey const& secretKey)
|
||||
{
|
||||
sign(publicKey, secretKey);
|
||||
return XChainAddAccountCreateAttestation{std::make_shared<STTx>(std::move(object_))};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::transactions
|
||||
@@ -0,0 +1,358 @@
|
||||
// This file is auto-generated. Do not edit.
|
||||
#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 {
|
||||
|
||||
class XChainAddClaimAttestationBuilder;
|
||||
|
||||
/**
|
||||
* @brief Transaction: XChainAddClaimAttestation
|
||||
*
|
||||
* Type: ttXCHAIN_ADD_CLAIM_ATTESTATION (45)
|
||||
* Delegable: Delegation::Delegable
|
||||
* Amendment: featureXChainBridge
|
||||
* Privileges: CreateAcct
|
||||
*
|
||||
* Immutable wrapper around STTx providing type-safe field access.
|
||||
* Use XChainAddClaimAttestationBuilder to construct new transactions.
|
||||
*/
|
||||
class XChainAddClaimAttestation : public TransactionBase
|
||||
{
|
||||
public:
|
||||
static constexpr xrpl::TxType txType = ttXCHAIN_ADD_CLAIM_ATTESTATION;
|
||||
|
||||
/**
|
||||
* @brief Construct a XChainAddClaimAttestation transaction wrapper from an existing STTx object.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
explicit XChainAddClaimAttestation(std::shared_ptr<STTx const> tx)
|
||||
: TransactionBase(std::move(tx))
|
||||
{
|
||||
// Verify transaction type
|
||||
if (tx_->getTxnType() != txType)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for XChainAddClaimAttestation");
|
||||
}
|
||||
}
|
||||
|
||||
// Transaction-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainBridge (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_XCHAIN_BRIDGE::type::value_type
|
||||
getXChainBridge() const
|
||||
{
|
||||
return this->tx_->at(sfXChainBridge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfAttestationSignerAccount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getAttestationSignerAccount() const
|
||||
{
|
||||
return this->tx_->at(sfAttestationSignerAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfPublicKey (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_VL::type::value_type
|
||||
getPublicKey() const
|
||||
{
|
||||
return this->tx_->at(sfPublicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfSignature (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_VL::type::value_type
|
||||
getSignature() const
|
||||
{
|
||||
return this->tx_->at(sfSignature);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfOtherChainSource (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getOtherChainSource() const
|
||||
{
|
||||
return this->tx_->at(sfOtherChainSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfAmount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_AMOUNT::type::value_type
|
||||
getAmount() const
|
||||
{
|
||||
return this->tx_->at(sfAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfAttestationRewardAccount (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_ACCOUNT::type::value_type
|
||||
getAttestationRewardAccount() const
|
||||
{
|
||||
return this->tx_->at(sfAttestationRewardAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfWasLockingChainSend (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT8::type::value_type
|
||||
getWasLockingChainSend() const
|
||||
{
|
||||
return this->tx_->at(sfWasLockingChainSend);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfXChainClaimID (SoeRequired)
|
||||
* @return The field value.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT64::type::value_type
|
||||
getXChainClaimID() const
|
||||
{
|
||||
return this->tx_->at(sfXChainClaimID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfDestination (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
|
||||
getDestination() const
|
||||
{
|
||||
if (hasDestination())
|
||||
{
|
||||
return this->tx_->at(sfDestination);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfDestination is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasDestination() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfDestination);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Builder for XChainAddClaimAttestation transactions.
|
||||
*
|
||||
* Provides a fluent interface for constructing transactions with method chaining.
|
||||
* Uses STObject internally for flexible transaction construction.
|
||||
* Inherits common field setters from TransactionBuilderBase.
|
||||
*/
|
||||
class XChainAddClaimAttestationBuilder : public TransactionBuilderBase<XChainAddClaimAttestationBuilder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new XChainAddClaimAttestationBuilder with required fields.
|
||||
* @param account The account initiating the transaction.
|
||||
* @param xChainBridge The sfXChainBridge field value.
|
||||
* @param attestationSignerAccount The sfAttestationSignerAccount field value.
|
||||
* @param publicKey The sfPublicKey field value.
|
||||
* @param signature The sfSignature field value.
|
||||
* @param otherChainSource The sfOtherChainSource field value.
|
||||
* @param amount The sfAmount field value.
|
||||
* @param attestationRewardAccount The sfAttestationRewardAccount field value.
|
||||
* @param wasLockingChainSend The sfWasLockingChainSend field value.
|
||||
* @param xChainClaimID The sfXChainClaimID field value.
|
||||
* @param sequence Optional sequence number for the transaction.
|
||||
* @param fee Optional fee for the transaction.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder(SF_ACCOUNT::type::value_type account,
|
||||
std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& xChainBridge, std::decay_t<typename SF_ACCOUNT::type::value_type> const& attestationSignerAccount, std::decay_t<typename SF_VL::type::value_type> const& publicKey, std::decay_t<typename SF_VL::type::value_type> const& signature, std::decay_t<typename SF_ACCOUNT::type::value_type> const& otherChainSource, std::decay_t<typename SF_AMOUNT::type::value_type> const& amount, std::decay_t<typename SF_ACCOUNT::type::value_type> const& attestationRewardAccount, std::decay_t<typename SF_UINT8::type::value_type> const& wasLockingChainSend, std::decay_t<typename SF_UINT64::type::value_type> const& xChainClaimID, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
|
||||
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
|
||||
)
|
||||
: TransactionBuilderBase<XChainAddClaimAttestationBuilder>(ttXCHAIN_ADD_CLAIM_ATTESTATION, account, sequence, fee)
|
||||
{
|
||||
setXChainBridge(xChainBridge);
|
||||
setAttestationSignerAccount(attestationSignerAccount);
|
||||
setPublicKey(publicKey);
|
||||
setSignature(signature);
|
||||
setOtherChainSource(otherChainSource);
|
||||
setAmount(amount);
|
||||
setAttestationRewardAccount(attestationRewardAccount);
|
||||
setWasLockingChainSend(wasLockingChainSend);
|
||||
setXChainClaimID(xChainClaimID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a XChainAddClaimAttestationBuilder from an existing STTx object.
|
||||
* @param tx The existing transaction to copy from.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder(std::shared_ptr<STTx const> tx)
|
||||
{
|
||||
if (tx->getTxnType() != ttXCHAIN_ADD_CLAIM_ATTESTATION)
|
||||
{
|
||||
throw std::runtime_error("Invalid transaction type for XChainAddClaimAttestationBuilder");
|
||||
}
|
||||
object_ = *tx;
|
||||
}
|
||||
|
||||
/** @brief Transaction-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief Set sfXChainBridge (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setXChainBridge(std::decay_t<typename SF_XCHAIN_BRIDGE::type::value_type> const& value)
|
||||
{
|
||||
object_[sfXChainBridge] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfAttestationSignerAccount (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setAttestationSignerAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfAttestationSignerAccount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfPublicKey (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setPublicKey(std::decay_t<typename SF_VL::type::value_type> const& value)
|
||||
{
|
||||
object_[sfPublicKey] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfSignature (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setSignature(std::decay_t<typename SF_VL::type::value_type> const& value)
|
||||
{
|
||||
object_[sfSignature] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfOtherChainSource (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setOtherChainSource(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfOtherChainSource] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfAmount (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfAmount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfAttestationRewardAccount (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setAttestationRewardAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfAttestationRewardAccount] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfWasLockingChainSend (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setWasLockingChainSend(std::decay_t<typename SF_UINT8::type::value_type> const& value)
|
||||
{
|
||||
object_[sfWasLockingChainSend] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfXChainClaimID (SoeRequired)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setXChainClaimID(std::decay_t<typename SF_UINT64::type::value_type> const& value)
|
||||
{
|
||||
object_[sfXChainClaimID] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfDestination (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
XChainAddClaimAttestationBuilder&
|
||||
setDestination(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
||||
{
|
||||
object_[sfDestination] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the XChainAddClaimAttestation wrapper.
|
||||
* @param publicKey The public key for signing.
|
||||
* @param secretKey The secret key for signing.
|
||||
* @return The constructed transaction wrapper.
|
||||
*/
|
||||
XChainAddClaimAttestation
|
||||
build(PublicKey const& publicKey, SecretKey const& secretKey)
|
||||
{
|
||||
sign(publicKey, secretKey);
|
||||
return XChainAddClaimAttestation{std::make_shared<STTx>(std::move(object_))};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::transactions
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user