mirror of
https://github.com/Xahau/xahaud.git
synced 2026-03-20 11:32:35 +00:00
Compare commits
1 Commits
coverage
...
fixImportI
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f33cad6db |
@@ -1,6 +0,0 @@
|
||||
coverage:
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
target: 60%
|
||||
threshold: 2%
|
||||
29
.github/actions/xahau-ga-build/action.yml
vendored
29
.github/actions/xahau-ga-build/action.yml
vendored
@@ -2,14 +2,6 @@ name: build
|
||||
description: 'Builds the project with ccache integration'
|
||||
|
||||
inputs:
|
||||
cmake-target:
|
||||
description: 'CMake target to build'
|
||||
required: false
|
||||
default: all
|
||||
cmake-args:
|
||||
description: 'Additional CMake arguments'
|
||||
required: false
|
||||
default: null
|
||||
generator:
|
||||
description: 'CMake generator to use'
|
||||
required: true
|
||||
@@ -28,10 +20,6 @@ inputs:
|
||||
description: 'C++ compiler to use'
|
||||
required: false
|
||||
default: ''
|
||||
gcov:
|
||||
description: 'Gcov to use'
|
||||
required: false
|
||||
default: ''
|
||||
compiler-id:
|
||||
description: 'Unique identifier: compiler-version-stdlib[-gccversion] (e.g. clang-14-libstdcxx-gcc11, gcc-13-libstdcxx)'
|
||||
required: false
|
||||
@@ -53,11 +41,10 @@ inputs:
|
||||
required: false
|
||||
default: 'dev'
|
||||
stdlib:
|
||||
description: 'C++ standard library to use (default = compiler default, e.g. GCC always uses libstdc++)'
|
||||
description: 'C++ standard library to use'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- default
|
||||
- libstdcxx
|
||||
- libcxx
|
||||
clang_gcc_toolchain:
|
||||
@@ -100,6 +87,11 @@ runs:
|
||||
export CCACHE_CONFIGPATH="$HOME/.config/ccache/ccache.conf"
|
||||
echo "CCACHE_CONFIGPATH=$CCACHE_CONFIGPATH" >> $GITHUB_ENV
|
||||
|
||||
# Keep config separate from cache_dir so configs aren't swapped when CCACHE_DIR changes between steps
|
||||
mkdir -p ~/.config/ccache
|
||||
export CCACHE_CONFIGPATH="$HOME/.config/ccache/ccache.conf"
|
||||
echo "CCACHE_CONFIGPATH=$CCACHE_CONFIGPATH" >> $GITHUB_ENV
|
||||
|
||||
# Configure ccache settings AFTER cache restore (prevents stale cached config)
|
||||
ccache --set-config=max_size=${{ inputs.ccache_max_size }}
|
||||
ccache --set-config=hash_dir=${{ inputs.ccache_hash_dir }}
|
||||
@@ -130,10 +122,6 @@ runs:
|
||||
export CXX="${{ inputs.cxx }}"
|
||||
fi
|
||||
|
||||
if [ -n "${{ inputs.gcov }}" ]; then
|
||||
ln -sf /usr/bin/${{ inputs.gcov }} /usr/local/bin/gcov
|
||||
fi
|
||||
|
||||
# Create wrapper toolchain that overlays ccache on top of Conan's toolchain
|
||||
# This enables ccache for the main app build without affecting Conan dependency builds
|
||||
if [ "${{ inputs.ccache_enabled }}" = "true" ]; then
|
||||
@@ -197,8 +185,7 @@ runs:
|
||||
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${TOOLCHAIN_FILE} \
|
||||
-DCMAKE_BUILD_TYPE=${{ inputs.configuration }} \
|
||||
-Dtests=TRUE \
|
||||
-Dxrpld=TRUE \
|
||||
${{ inputs.cmake-args }}
|
||||
-Dxrpld=TRUE
|
||||
|
||||
- name: Show ccache config before build
|
||||
if: inputs.ccache_enabled == 'true'
|
||||
@@ -222,7 +209,7 @@ runs:
|
||||
VERBOSE_FLAG="-- -v"
|
||||
fi
|
||||
|
||||
cmake --build . --config ${{ inputs.configuration }} --parallel $(nproc) --target ${{ inputs.cmake-target }} ${VERBOSE_FLAG}
|
||||
cmake --build . --config ${{ inputs.configuration }} --parallel $(nproc) ${VERBOSE_FLAG}
|
||||
|
||||
- name: Show ccache statistics
|
||||
if: inputs.ccache_enabled == 'true'
|
||||
|
||||
119
.github/workflows/xahau-ga-nix.yml
vendored
119
.github/workflows/xahau-ga-nix.yml
vendored
@@ -57,9 +57,8 @@ jobs:
|
||||
"cc": "gcc-11",
|
||||
"cxx": "g++-11",
|
||||
"compiler_version": 11,
|
||||
"stdlib": "default",
|
||||
"configuration": "Debug",
|
||||
"job_type": "build"
|
||||
"stdlib": "libstdcxx",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"compiler_id": "gcc-13-libstdcxx",
|
||||
@@ -67,20 +66,8 @@ jobs:
|
||||
"cc": "gcc-13",
|
||||
"cxx": "g++-13",
|
||||
"compiler_version": 13,
|
||||
"stdlib": "default",
|
||||
"configuration": "Debug",
|
||||
"job_type": "build"
|
||||
},
|
||||
{
|
||||
"compiler_id": "gcc-13-libstdcxx",
|
||||
"compiler": "gcc",
|
||||
"cc": "gcc-13",
|
||||
"cxx": "g++-13",
|
||||
"gcov": "gcov-13",
|
||||
"compiler_version": 13,
|
||||
"stdlib": "default",
|
||||
"configuration": "Debug",
|
||||
"job_type": "coverage"
|
||||
"stdlib": "libstdcxx",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"compiler_id": "clang-14-libstdcxx-gcc11",
|
||||
@@ -90,8 +77,7 @@ jobs:
|
||||
"compiler_version": 14,
|
||||
"stdlib": "libstdcxx",
|
||||
"clang_gcc_toolchain": 11,
|
||||
"configuration": "Debug",
|
||||
"job_type": "build"
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"compiler_id": "clang-16-libstdcxx-gcc13",
|
||||
@@ -101,8 +87,7 @@ jobs:
|
||||
"compiler_version": 16,
|
||||
"stdlib": "libstdcxx",
|
||||
"clang_gcc_toolchain": 13,
|
||||
"configuration": "Debug",
|
||||
"job_type": "build"
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"compiler_id": "clang-17-libcxx",
|
||||
@@ -111,8 +96,7 @@ jobs:
|
||||
"cxx": "clang++-17",
|
||||
"compiler_version": 17,
|
||||
"stdlib": "libcxx",
|
||||
"configuration": "Debug",
|
||||
"job_type": "build"
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
# Clang 18 - testing if it's faster than Clang 17 with libc++
|
||||
@@ -123,16 +107,14 @@ jobs:
|
||||
"cxx": "clang++-18",
|
||||
"compiler_version": 18,
|
||||
"stdlib": "libcxx",
|
||||
"configuration": "Debug",
|
||||
"job_type": "build"
|
||||
"configuration": "Debug"
|
||||
}
|
||||
]
|
||||
|
||||
# Minimal matrix for PRs and feature branches
|
||||
minimal_matrix = [
|
||||
full_matrix[1], # gcc-13 (middle-ground gcc)
|
||||
full_matrix[2], # gcc-13 coverage
|
||||
full_matrix[3] # clang-14 (mature, stable clang)
|
||||
full_matrix[2] # clang-14 (mature, stable clang)
|
||||
]
|
||||
|
||||
# Determine which matrix to use based on the target branch
|
||||
@@ -207,21 +189,14 @@ jobs:
|
||||
# Select the appropriate matrix
|
||||
if use_full:
|
||||
if force_full:
|
||||
print(f"Using FULL matrix (7 configs) - forced by [ci-nix-full-matrix] tag")
|
||||
print(f"Using FULL matrix (6 configs) - forced by [ci-nix-full-matrix] tag")
|
||||
else:
|
||||
print(f"Using FULL matrix (7 configs) - targeting main branch")
|
||||
print(f"Using FULL matrix (6 configs) - targeting main branch")
|
||||
matrix = full_matrix
|
||||
else:
|
||||
print(f"Using MINIMAL matrix (3 configs) - feature branch/PR")
|
||||
print(f"Using MINIMAL matrix (2 configs) - feature branch/PR")
|
||||
matrix = minimal_matrix
|
||||
|
||||
# Add runs_on based on job_type
|
||||
for entry in matrix:
|
||||
if entry.get("job_type") == "coverage":
|
||||
entry["runs_on"] = '["self-hosted", "generic", 24.04]'
|
||||
else:
|
||||
entry["runs_on"] = '["self-hosted", "generic", 20.04]'
|
||||
|
||||
|
||||
# Output the matrix as JSON
|
||||
output = json.dumps({"include": matrix})
|
||||
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
|
||||
@@ -229,7 +204,7 @@ jobs:
|
||||
|
||||
build:
|
||||
needs: matrix-setup
|
||||
runs-on: ${{ fromJSON(matrix.runs_on) }}
|
||||
runs-on: [self-hosted, generic, 20.04]
|
||||
container:
|
||||
image: ubuntu:24.04
|
||||
volumes:
|
||||
@@ -258,7 +233,7 @@ jobs:
|
||||
apt-get install -y software-properties-common
|
||||
add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
||||
apt-get update
|
||||
apt-get install -y git python3 python-is-python3 pipx
|
||||
apt-get install -y python3 python-is-python3 pipx
|
||||
pipx ensurepath
|
||||
apt-get install -y cmake ninja-build ${{ matrix.cc }} ${{ matrix.cxx }} ccache
|
||||
apt-get install -y perl # for openssl build
|
||||
@@ -329,12 +304,6 @@ jobs:
|
||||
pipx install "conan>=2.0,<3"
|
||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
|
||||
# Install gcovr for coverage jobs
|
||||
if [ "${{ matrix.job_type }}" = "coverage" ]; then
|
||||
pipx install "gcovr>=7,<9"
|
||||
apt-get install -y lcov
|
||||
fi
|
||||
|
||||
- name: Check environment
|
||||
run: |
|
||||
echo "PATH:"
|
||||
@@ -344,13 +313,6 @@ jobs:
|
||||
which ${{ matrix.cc }} && ${{ matrix.cc }} --version || echo "${{ matrix.cc }} not found"
|
||||
which ${{ matrix.cxx }} && ${{ matrix.cxx }} --version || echo "${{ matrix.cxx }} not found"
|
||||
which ccache && ccache --version || echo "ccache not found"
|
||||
|
||||
# Check gcovr for coverage jobs
|
||||
if [ "${{ matrix.job_type }}" = "coverage" ]; then
|
||||
which gcov && gcov --version || echo "gcov not found"
|
||||
which gcovr && gcovr --version || echo "gcovr not found"
|
||||
fi
|
||||
|
||||
echo "---- Full Environment ----"
|
||||
env
|
||||
|
||||
@@ -378,7 +340,6 @@ jobs:
|
||||
gha_cache_enabled: 'false' # Disable caching for self hosted runner
|
||||
|
||||
- name: Build
|
||||
if: matrix.job_type == 'build'
|
||||
uses: ./.github/actions/xahau-ga-build
|
||||
with:
|
||||
generator: Ninja
|
||||
@@ -393,26 +354,7 @@ jobs:
|
||||
clang_gcc_toolchain: ${{ matrix.clang_gcc_toolchain || '' }}
|
||||
ccache_max_size: '100G'
|
||||
|
||||
- name: Build (Coverage)
|
||||
if: matrix.job_type == 'coverage'
|
||||
uses: ./.github/actions/xahau-ga-build
|
||||
with:
|
||||
generator: Ninja
|
||||
configuration: ${{ matrix.configuration }}
|
||||
build_dir: ${{ env.build_dir }}
|
||||
cc: ${{ matrix.cc }}
|
||||
cxx: ${{ matrix.cxx }}
|
||||
gcov: ${{ matrix.gcov }}
|
||||
compiler-id: ${{ matrix.compiler_id }}
|
||||
cache_version: ${{ env.CACHE_VERSION }}
|
||||
main_branch: ${{ env.MAIN_BRANCH_NAME }}
|
||||
stdlib: ${{ matrix.stdlib }}
|
||||
cmake-args: '-Dcoverage=ON -Dcoverage_format=xml -DCODE_COVERAGE_VERBOSE=ON -DCMAKE_CXX_FLAGS="-O0" -DCMAKE_C_FLAGS="-O0"'
|
||||
cmake-target: 'coverage'
|
||||
ccache_max_size: '100G'
|
||||
|
||||
- name: Set artifact name
|
||||
if: matrix.job_type == 'build'
|
||||
id: set-artifact-name
|
||||
run: |
|
||||
ARTIFACT_NAME="build-output-nix-${{ github.run_id }}-${{ matrix.compiler }}-${{ matrix.configuration }}"
|
||||
@@ -425,7 +367,6 @@ jobs:
|
||||
ls -la ${{ env.build_dir }} || echo "Build directory not found or empty"
|
||||
|
||||
- name: Run tests
|
||||
if: matrix.job_type == 'build'
|
||||
run: |
|
||||
# Ensure the binary exists before trying to run
|
||||
if [ -f "${{ env.build_dir }}/rippled" ]; then
|
||||
@@ -434,33 +375,3 @@ jobs:
|
||||
echo "Error: rippled executable not found in ${{ env.build_dir }}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Coverage-specific steps
|
||||
- name: Move coverage report
|
||||
if: matrix.job_type == 'coverage'
|
||||
shell: bash
|
||||
run: |
|
||||
mv "${{ env.build_dir }}/coverage.xml" ./
|
||||
|
||||
- name: Archive coverage report
|
||||
if: matrix.job_type == 'coverage'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage.xml
|
||||
path: coverage.xml
|
||||
retention-days: 30
|
||||
|
||||
- name: Upload coverage report
|
||||
if: matrix.job_type == 'coverage'
|
||||
uses: wandalen/wretry.action/main@v3
|
||||
with:
|
||||
action: codecov/codecov-action@v4.3.0
|
||||
with: |
|
||||
files: coverage.xml
|
||||
fail_ci_if_error: true
|
||||
disable_search: true
|
||||
verbose: true
|
||||
plugin: noop
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
attempt_limit: 5
|
||||
attempt_delay: 210000 # in milliseconds
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace detail {
|
||||
// Feature.cpp. Because it's only used to reserve storage, and determine how
|
||||
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
|
||||
// the actual number of amendments. A LogicError on startup will verify this.
|
||||
static constexpr std::size_t numFeatures = 113;
|
||||
static constexpr std::size_t numFeatures = 114;
|
||||
|
||||
/** Amendments that this server supports and the default voting behavior.
|
||||
Whether they are enabled depends on the Rules defined in the validated
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
// If you add an amendment here, then do not forget to increment `numFeatures`
|
||||
// in include/xrpl/protocol/Feature.h.
|
||||
|
||||
XRPL_FIX (ImportIssuer, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(HookAPISerializedType240, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PermissionedDomains, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DynamicNFT, Supported::no, VoteBehavior::DefaultNo)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/AMM.h>
|
||||
#include <xrpld/app/ledger/LedgerMaster.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
@@ -300,6 +301,28 @@ struct ClaimReward_test : public beast::unit_test::suite
|
||||
env(tx, reward::issuer(issuer), ter(tecNO_ISSUER));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// tecNO_PERMISSION
|
||||
// issuer is an AMM account
|
||||
{
|
||||
test::jtx::Env env{*this, network::makeNetworkConfig(21337)};
|
||||
|
||||
auto const alice = Account("alice");
|
||||
auto const issuer = Account("issuer");
|
||||
auto const USD = issuer["USD"];
|
||||
|
||||
env.fund(XRP(1000), alice, issuer);
|
||||
env.close();
|
||||
|
||||
AMM amm(env, issuer, XRP(100), USD(100));
|
||||
|
||||
BEAST_EXPECT(amm.ammExists());
|
||||
|
||||
env(reward::claim(alice),
|
||||
reward::issuer(amm.ammAccount()),
|
||||
ter(tecNO_PERMISSION));
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <test/app/Import_json.h>
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/AMM.h>
|
||||
#include <xrpld/app/ledger/LedgerMaster.h>
|
||||
#include <xrpld/app/misc/AmendmentTable.h>
|
||||
#include <xrpld/app/misc/HashRouter.h>
|
||||
@@ -2635,6 +2636,77 @@ class Import_test : public beast::unit_test::suite
|
||||
ter(temDISABLED));
|
||||
}
|
||||
|
||||
// tecNO_ISSUER, tecNO_PERMISSION
|
||||
// issuer not found, issuer is an AMM account
|
||||
{
|
||||
auto const alice = Account("alice");
|
||||
auto const bob = Account("bob");
|
||||
auto const issuer = Account("issuer");
|
||||
auto const USD = issuer["USD"];
|
||||
|
||||
for (bool const withFixImportIssuer : {true, false})
|
||||
{
|
||||
auto const amend =
|
||||
withFixImportIssuer ? features : features - fixImportIssuer;
|
||||
test::jtx::Env env{
|
||||
*this, network::makeNetworkVLConfig(21337, keys), amend};
|
||||
env.fund(XRP(1000), alice, issuer);
|
||||
env.close();
|
||||
|
||||
// burn 10'000 xrp
|
||||
auto const master = Account("masterpassphrase");
|
||||
env(noop(master), fee(10'000'000'000), ter(tesSUCCESS));
|
||||
env.close();
|
||||
|
||||
env(import::import(
|
||||
alice, import::loadXpop(ImportTCAccountSet::w_seed)),
|
||||
import::issuer(bob),
|
||||
fee(100'000'000),
|
||||
withFixImportIssuer ? ter(tecNO_ISSUER) : ter(tesSUCCESS));
|
||||
env.close();
|
||||
}
|
||||
for (bool const withFixImportIssuer : {true, false})
|
||||
{
|
||||
auto const amend =
|
||||
withFixImportIssuer ? features : features - fixImportIssuer;
|
||||
test::jtx::Env env{
|
||||
*this, network::makeNetworkVLConfig(21337, keys), amend};
|
||||
env.fund(XRP(1000), alice, issuer);
|
||||
env.close();
|
||||
|
||||
// burn 10'000 xrp
|
||||
auto const master = Account("masterpassphrase");
|
||||
env(noop(master), fee(10'000'000'000), ter(tesSUCCESS));
|
||||
env.close();
|
||||
|
||||
AMM amm(env, issuer, XRP(100), USD(100));
|
||||
BEAST_EXPECT(amm.ammExists());
|
||||
|
||||
env(import::import(
|
||||
alice, import::loadXpop(ImportTCAccountSet::w_seed)),
|
||||
import::issuer(amm.ammAccount()),
|
||||
fee(100'000'000),
|
||||
withFixImportIssuer ? ter(tecNO_PERMISSION)
|
||||
: ter(tesSUCCESS));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// env.enableFeature(fixImportIssuer);
|
||||
// env.close();
|
||||
|
||||
// env(import::import(
|
||||
// carol, import::loadXpop(ImportTCAccountSet::w_seed)),
|
||||
// import::issuer(bob),
|
||||
// ter(tecNO_ISSUER));
|
||||
// env.close();
|
||||
// env(import::import(
|
||||
// dave, import::loadXpop(ImportTCAccountSet::w_seed)),
|
||||
// import::issuer(amm.ammAccount()),
|
||||
// // fee(100'000'000),
|
||||
// ter(tecNO_PERMISSION));
|
||||
// env.close();
|
||||
}
|
||||
|
||||
// tefINTERNAL
|
||||
// during preclaim could not parse xpop, bailing.
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/AMM.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -168,6 +169,27 @@ class Invoke_test : public beast::unit_test::suite
|
||||
fee(feeDrops),
|
||||
ter(tecNO_TARGET));
|
||||
}
|
||||
|
||||
// tecNO_PERMISSION
|
||||
// issuer is an AMM account
|
||||
{
|
||||
test::jtx::Env env{*this, network::makeNetworkConfig(21337)};
|
||||
|
||||
auto const alice = Account("alice");
|
||||
auto const issuer = Account("issuer");
|
||||
auto const USD = issuer["USD"];
|
||||
env.fund(XRP(1000), alice, issuer);
|
||||
env.close();
|
||||
|
||||
AMM amm(env, issuer, XRP(100), USD(100));
|
||||
|
||||
BEAST_EXPECT(amm.ammExists());
|
||||
|
||||
env(invoke::invoke(alice),
|
||||
invoke::dest(amm.ammAccount()),
|
||||
ter(tecNO_PERMISSION));
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/AMM.h>
|
||||
#include <xrpld/core/ConfigSections.h>
|
||||
#include <xrpld/ledger/Dir.h>
|
||||
#include <xrpl/basics/chrono.h>
|
||||
@@ -410,6 +411,21 @@ struct Remit_test : public beast::unit_test::suite
|
||||
env.close();
|
||||
}
|
||||
|
||||
// tecNO_PERMISSION - inform account is an AMM
|
||||
{
|
||||
Env env{*this, features};
|
||||
env.fund(XRP(1000), gw, alice, bob);
|
||||
env.close();
|
||||
|
||||
AMM amm(env, gw, XRP(100), USD(100));
|
||||
BEAST_EXPECT(amm.ammExists());
|
||||
|
||||
auto tx = remit::remit(alice, bob);
|
||||
tx[sfInform.jsonName] = to_string(amm.ammAccount());
|
||||
env(tx, alice, ter(tecNO_PERMISSION));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// tecNO_PERMISSION - lsfDisallowIncomingRemit
|
||||
// DA: see testAllowIncoming
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import(jtx::Account const& account, Json::Value const& xpop)
|
||||
void
|
||||
issuer::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
jt.jv[sfIssuer.jsonName] = issuer_.human();
|
||||
jt.jv[sfIssuer.jsonName] = to_string(issuer_);
|
||||
}
|
||||
|
||||
Json::Value
|
||||
|
||||
@@ -66,7 +66,7 @@ blob::operator()(Env& env, JTx& jt) const
|
||||
void
|
||||
dest::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
jt.jv[sfDestination.jsonName] = dest_.human();
|
||||
jt.jv[sfDestination.jsonName] = to_string(dest_);
|
||||
}
|
||||
|
||||
} // namespace invoke
|
||||
|
||||
@@ -29,18 +29,24 @@ namespace reward {
|
||||
// Claim a reward.
|
||||
Json::Value
|
||||
claim(jtx::Account const& account)
|
||||
{
|
||||
return claim(account.id());
|
||||
}
|
||||
|
||||
Json::Value
|
||||
claim(AccountID const& account)
|
||||
{
|
||||
using namespace jtx;
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = jss::ClaimReward;
|
||||
jv[jss::Account] = account.human();
|
||||
jv[jss::Account] = to_string(account);
|
||||
return jv;
|
||||
}
|
||||
|
||||
void
|
||||
issuer::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
jt.jv[sfIssuer.jsonName] = issuer_.human();
|
||||
jt.jv[sfIssuer.jsonName] = to_string(issuer_);
|
||||
}
|
||||
|
||||
} // namespace reward
|
||||
|
||||
@@ -37,10 +37,10 @@ import(jtx::Account const& account, Json::Value const& xpop);
|
||||
class issuer
|
||||
{
|
||||
private:
|
||||
jtx::Account issuer_;
|
||||
AccountID issuer_;
|
||||
|
||||
public:
|
||||
explicit issuer(jtx::Account const& issuer) : issuer_(issuer)
|
||||
explicit issuer(AccountID const& issuer) : issuer_(issuer)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,10 @@ public:
|
||||
class dest
|
||||
{
|
||||
private:
|
||||
jtx::Account dest_;
|
||||
AccountID dest_;
|
||||
|
||||
public:
|
||||
explicit dest(jtx::Account const& dest) : dest_(dest)
|
||||
explicit dest(AccountID const& dest) : dest_(dest)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -34,17 +34,24 @@ namespace reward {
|
||||
Json::Value
|
||||
claim(jtx::Account const& account);
|
||||
|
||||
Json::Value
|
||||
claim(AccountID const& account);
|
||||
|
||||
/** Sets the optional Issuer on a JTx. */
|
||||
class issuer
|
||||
{
|
||||
private:
|
||||
jtx::Account issuer_;
|
||||
AccountID issuer_;
|
||||
|
||||
public:
|
||||
explicit issuer(jtx::Account const& issuer) : issuer_(issuer)
|
||||
{
|
||||
}
|
||||
|
||||
explicit issuer(AccountID const& issuer) : issuer_(issuer)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env&, JTx& jtx) const;
|
||||
};
|
||||
|
||||
@@ -82,8 +82,15 @@ ClaimReward::preclaim(PreclaimContext const& ctx)
|
||||
if ((issuer && isOptOut) || (!issuer && !isOptOut))
|
||||
return temMALFORMED;
|
||||
|
||||
if (issuer && !ctx.view.exists(keylet::account(*issuer)))
|
||||
return tecNO_ISSUER;
|
||||
if (issuer)
|
||||
{
|
||||
auto const sleIssuer = ctx.view.read(keylet::account(*issuer));
|
||||
if (!sleIssuer)
|
||||
return tecNO_ISSUER;
|
||||
|
||||
if (sleIssuer->isFieldPresent(sfAMMID))
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
@@ -870,6 +870,17 @@ Import::preclaim(PreclaimContext const& ctx)
|
||||
if (!ctx.tx.isFieldPresent(sfBlob))
|
||||
return tefINTERNAL;
|
||||
|
||||
if (ctx.tx.isFieldPresent(sfIssuer) &&
|
||||
ctx.view.rules().enabled(fixImportIssuer))
|
||||
{
|
||||
auto const sleIssuer = ctx.view.read(keylet::account(ctx.tx[sfIssuer]));
|
||||
if (!sleIssuer)
|
||||
return tecNO_ISSUER;
|
||||
|
||||
if (sleIssuer->isFieldPresent(sfAMMID))
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
|
||||
// parse blob as json
|
||||
auto const xpop = syntaxCheckXPOP(ctx.tx.getFieldVL(sfBlob), ctx.j);
|
||||
|
||||
|
||||
@@ -64,8 +64,13 @@ Invoke::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (ctx.tx.isFieldPresent(sfDestination))
|
||||
{
|
||||
if (!ctx.view.exists(keylet::account(ctx.tx[sfDestination])))
|
||||
auto const sleDest =
|
||||
ctx.view.read(keylet::account(ctx.tx[sfDestination]));
|
||||
if (!sleDest)
|
||||
return tecNO_TARGET;
|
||||
|
||||
if (sleDest->isFieldPresent(sfAMMID))
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -256,11 +256,18 @@ Remit::doApply()
|
||||
if (ctx_.tx.isFieldPresent(sfInform))
|
||||
{
|
||||
auto const informAcc = ctx_.tx.getAccountID(sfInform);
|
||||
if (!sb.exists(keylet::account(informAcc)))
|
||||
auto const sleInformAcc = sb.read(keylet::account(informAcc));
|
||||
if (!sleInformAcc)
|
||||
{
|
||||
JLOG(j.warn()) << "Remit: sfInform account does not exist.";
|
||||
return tecNO_TARGET;
|
||||
}
|
||||
|
||||
if (sleInformAcc->isFieldPresent(sfAMMID))
|
||||
{
|
||||
JLOG(j.warn()) << "Remit: sfInform account is an AMM.";
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
}
|
||||
|
||||
XRPAmount const accountReserve{sb.fees().accountReserve(0)};
|
||||
|
||||
Reference in New Issue
Block a user