rippled
Loading...
Searching...
No Matches
xchain_bridge.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_TEST_JTX_XCHAINBRIDGE_H_INCLUDED
21#define RIPPLE_TEST_JTX_XCHAINBRIDGE_H_INCLUDED
22
23#include <test/jtx/Account.h>
24#include <test/jtx/amount.h>
25#include <test/jtx/multisign.h>
26#include <xrpl/json/json_value.h>
27#include <xrpl/protocol/SField.h>
28#include <xrpl/protocol/XChainAttestations.h>
29
30namespace ripple {
31namespace test {
32namespace jtx {
33
35
38
40bridge(
41 Account const& lockingChainDoor,
42 Issue const& lockingChainIssue,
43 Account const& issuingChainDoor,
44 Issue const& issuingChainIssue);
45
48 Account const& acc,
49 Json::Value const& bridge,
50 STAmount const& reward,
51 std::optional<STAmount> const& minAccountCreate = std::nullopt);
52
55 Account const& acc,
56 Json::Value const& bridge,
57 std::optional<STAmount> const& reward,
58 std::optional<STAmount> const& minAccountCreate = std::nullopt);
59
62 Account const& acc,
63 Json::Value const& bridge,
64 STAmount const& reward,
65 Account const& otherChainSource);
66
69 Account const& acc,
70 Json::Value const& bridge,
71 std::uint32_t claimID,
72 AnyAmount const& amt,
73 std::optional<Account> const& dst = std::nullopt);
74
77 Account const& acc,
78 Json::Value const& bridge,
79 std::uint32_t claimID,
80 AnyAmount const& amt,
81 Account const& dst);
82
85 Account const& acc,
86 Json::Value const& bridge,
87 Account const& dst,
88 AnyAmount const& amt,
89 AnyAmount const& xChainFee);
90
93 Account const& acc,
94 Json::Value const& bridge,
95 Account const& dst,
96 AnyAmount const& amt);
97
100 jtx::Account const& submittingAccount,
101 Json::Value const& jvBridge,
102 jtx::Account const& sendingAccount,
103 jtx::AnyAmount const& sendingAmount,
104 jtx::Account const& rewardAccount,
105 bool wasLockingChainSend,
106 std::uint64_t claimID,
108 jtx::signer const& signer);
109
112 jtx::Account const& submittingAccount,
113 Json::Value const& jvBridge,
114 jtx::Account const& sendingAccount,
115 jtx::AnyAmount const& sendingAmount,
116 jtx::AnyAmount const& rewardAmount,
117 jtx::Account const& rewardAccount,
118 bool wasLockingChainSend,
119 std::uint64_t createCount,
120 jtx::Account const& dst,
121 jtx::signer const& signer);
122
125 jtx::Account const& submittingAccount,
126 Json::Value const& jvBridge,
127 jtx::Account const& sendingAccount,
128 jtx::AnyAmount const& sendingAmount,
129 std::vector<jtx::Account> const& rewardAccounts,
130 bool wasLockingChainSend,
131 std::uint64_t claimID,
135 std::size_t const fromIdx = 0);
136
139 jtx::Account const& submittingAccount,
140 Json::Value const& jvBridge,
141 jtx::Account const& sendingAccount,
142 jtx::AnyAmount const& sendingAmount,
143 jtx::AnyAmount const& rewardAmount,
144 std::vector<jtx::Account> const& rewardAccounts,
145 bool wasLockingChainSend,
146 std::uint64_t createCount,
147 jtx::Account const& dst,
150 std::size_t const fromIdx = 0);
151
153{
154 // funded accounts
167
168 // unfunded accounts
179
180 IOU const mcUSD;
181 IOU const scUSD;
182
184 Json::Value jvb; // standard xrp bridge def for tx
185 Json::Value jvub; // standard xrp bridge def for tx, unfunded accounts
186
193
194 STAmount const reward; // 1 xrp
195 STAmount const split_reward_quorum; // 250,000 drops
196 STAmount const split_reward_everyone; // 200,000 drops
197
198 const STAmount tiny_reward; // 37 drops
199 const STAmount tiny_reward_split; // 9 drops
201
204
205 static constexpr int drop_per_xrp = 1000000;
206
208
209 void
211
212 void
214
215 void
216 createBridgeObjects(Env& mcEnv, Env& scEnv);
217
220 std::uint64_t createCount,
221 jtx::AnyAmount const& amt,
222 jtx::Account const& dst,
223 std::size_t const numAtts,
224 std::size_t const fromIdx = 0)
225 {
228 jvb,
229 mcCarol,
230 amt,
231 reward,
232 payees,
233 true,
234 createCount,
235 dst,
236 signers,
237 numAtts,
238 fromIdx);
239 }
240
243 Account const& acc,
245 STAmount const& _reward = XRP(1),
246 std::optional<STAmount> const& minAccountCreate = std::nullopt)
247 {
248 return bridge_create(
249 acc,
251 _reward,
252 minAccountCreate);
253 }
254};
255
256} // namespace jtx
257} // namespace test
258} // namespace ripple
259
260#endif
Represents a JSON value.
Definition: json_value.h:148
A currency issued by an account.
Definition: Issue.h:36
Immutable cryptographic account descriptor.
Definition: Account.h:39
A transaction testing environment.
Definition: Env.h:118
Converts to IOU Issue or STAmount.
@ nullValue
'null' value
Definition: json_value.h:37
constexpr std::size_t UT_XCHAIN_DEFAULT_QUORUM
Definition: xchain_bridge.h:37
Json::Value create_account_attestation(jtx::Account const &submittingAccount, Json::Value const &jvBridge, jtx::Account const &sendingAccount, jtx::AnyAmount const &sendingAmount, jtx::AnyAmount const &rewardAmount, jtx::Account const &rewardAccount, bool wasLockingChainSend, std::uint64_t createCount, jtx::Account const &dst, jtx::signer const &signer)
JValueVec claim_attestations(jtx::Account const &submittingAccount, Json::Value const &jvBridge, jtx::Account const &sendingAccount, jtx::AnyAmount const &sendingAmount, std::vector< jtx::Account > const &rewardAccounts, bool wasLockingChainSend, std::uint64_t claimID, std::optional< jtx::Account > const &dst, std::vector< jtx::signer > const &signers, std::size_t const numAtts, std::size_t const fromIdx)
Json::Value bridge_create(Account const &acc, Json::Value const &bridge, STAmount const &reward, std::optional< STAmount > const &minAccountCreate)
Json::Value claim_attestation(jtx::Account const &submittingAccount, Json::Value const &jvBridge, jtx::Account const &sendingAccount, jtx::AnyAmount const &sendingAmount, jtx::Account const &rewardAccount, bool wasLockingChainSend, std::uint64_t claimID, std::optional< jtx::Account > const &dst, jtx::signer const &signer)
Json::Value bridge(Account const &lockingChainDoor, Issue const &lockingChainIssue, Account const &issuingChainDoor, Issue const &issuingChainIssue)
Json::Value signers(Account const &account, std::uint32_t quorum, std::vector< signer > const &v)
Definition: multisign.cpp:33
Json::Value sidechain_xchain_account_claim(Account const &acc, Json::Value const &bridge, Account const &dst, AnyAmount const &amt)
Json::Value sidechain_xchain_account_create(Account const &acc, Json::Value const &bridge, Account const &dst, AnyAmount const &amt, AnyAmount const &reward)
Json::Value xchain_claim(Account const &acc, Json::Value const &bridge, std::uint32_t claimID, AnyAmount const &amt, Account const &dst)
constexpr std::size_t UT_XCHAIN_DEFAULT_NUM_SIGNERS
Definition: xchain_bridge.h:36
JValueVec create_account_attestations(jtx::Account const &submittingAccount, Json::Value const &jvBridge, jtx::Account const &sendingAccount, jtx::AnyAmount const &sendingAmount, jtx::AnyAmount const &rewardAmount, std::vector< jtx::Account > const &rewardAccounts, bool wasLockingChainSend, std::uint64_t createCount, jtx::Account const &dst, std::vector< jtx::signer > const &signers, std::size_t const numAtts, std::size_t const fromIdx)
Json::Value xchain_create_claim_id(Account const &acc, Json::Value const &bridge, STAmount const &reward, Account const &otherChainSource)
Json::Value bridge_modify(Account const &acc, Json::Value const &bridge, std::optional< STAmount > const &reward, std::optional< STAmount > const &minAccountCreate)
Json::Value xchain_commit(Account const &acc, Json::Value const &bridge, std::uint32_t claimID, AnyAmount const &amt, std::optional< Account > const &dst)
XRP_t const XRP
Converts to XRP Issue or STAmount.
Definition: amount.cpp:104
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
Amount specifier with an option for any issuer.
JValueVec att_create_acct_vec(std::uint64_t createCount, jtx::AnyAmount const &amt, jtx::Account const &dst, std::size_t const numAtts, std::size_t const fromIdx=0)
std::vector< Account > const payee
std::vector< signer > const alt_signers
Json::Value create_bridge(Account const &acc, Json::Value const &bridge=Json::nullValue, STAmount const &_reward=XRP(1), std::optional< STAmount > const &minAccountCreate=std::nullopt)
std::vector< Account > const payees
std::vector< signer > const signers
void createBridgeObjects(Env &mcEnv, Env &scEnv)
A signer in a SignerList.
Definition: multisign.h:38