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
27#include <xrpl/json/json_value.h>
28#include <xrpl/protocol/SField.h>
29#include <xrpl/protocol/XChainAttestations.h>
30
31namespace ripple {
32namespace test {
33namespace jtx {
34
36
39
41bridge(
42 Account const& lockingChainDoor,
43 Issue const& lockingChainIssue,
44 Account const& issuingChainDoor,
45 Issue const& issuingChainIssue);
46
49 Account const& acc,
50 Json::Value const& bridge,
51 STAmount const& reward,
52 std::optional<STAmount> const& minAccountCreate = std::nullopt);
53
56 Account const& acc,
57 Json::Value const& bridge,
58 std::optional<STAmount> const& reward,
59 std::optional<STAmount> const& minAccountCreate = std::nullopt);
60
63 Account const& acc,
64 Json::Value const& bridge,
65 STAmount const& reward,
66 Account const& otherChainSource);
67
70 Account const& acc,
71 Json::Value const& bridge,
72 std::uint32_t claimID,
73 AnyAmount const& amt,
74 std::optional<Account> const& dst = std::nullopt);
75
78 Account const& acc,
79 Json::Value const& bridge,
80 std::uint32_t claimID,
81 AnyAmount const& amt,
82 Account const& dst);
83
86 Account const& acc,
87 Json::Value const& bridge,
88 Account const& dst,
89 AnyAmount const& amt,
90 AnyAmount const& xChainFee);
91
94 Account const& acc,
95 Json::Value const& bridge,
96 Account const& dst,
97 AnyAmount const& amt);
98
101 jtx::Account const& submittingAccount,
102 Json::Value const& jvBridge,
103 jtx::Account const& sendingAccount,
104 jtx::AnyAmount const& sendingAmount,
105 jtx::Account const& rewardAccount,
106 bool wasLockingChainSend,
107 std::uint64_t claimID,
109 jtx::signer const& signer);
110
113 jtx::Account const& submittingAccount,
114 Json::Value const& jvBridge,
115 jtx::Account const& sendingAccount,
116 jtx::AnyAmount const& sendingAmount,
117 jtx::AnyAmount const& rewardAmount,
118 jtx::Account const& rewardAccount,
119 bool wasLockingChainSend,
120 std::uint64_t createCount,
121 jtx::Account const& dst,
122 jtx::signer const& signer);
123
126 jtx::Account const& submittingAccount,
127 Json::Value const& jvBridge,
128 jtx::Account const& sendingAccount,
129 jtx::AnyAmount const& sendingAmount,
130 std::vector<jtx::Account> const& rewardAccounts,
131 bool wasLockingChainSend,
132 std::uint64_t claimID,
136 std::size_t const fromIdx = 0);
137
140 jtx::Account const& submittingAccount,
141 Json::Value const& jvBridge,
142 jtx::Account const& sendingAccount,
143 jtx::AnyAmount const& sendingAmount,
144 jtx::AnyAmount const& rewardAmount,
145 std::vector<jtx::Account> const& rewardAccounts,
146 bool wasLockingChainSend,
147 std::uint64_t createCount,
148 jtx::Account const& dst,
151 std::size_t const fromIdx = 0);
152
154{
155 // funded accounts
168
169 // unfunded accounts
180
181 IOU const mcUSD;
182 IOU const scUSD;
183
185 Json::Value jvb; // standard xrp bridge def for tx
186 Json::Value jvub; // standard xrp bridge def for tx, unfunded accounts
187
194
195 STAmount const reward; // 1 xrp
196 STAmount const split_reward_quorum; // 250,000 drops
197 STAmount const split_reward_everyone; // 200,000 drops
198
199 STAmount const tiny_reward; // 37 drops
200 STAmount const tiny_reward_split; // 9 drops
202
205
206 static constexpr int drop_per_xrp = 1000000;
207
209
210 void
212
213 void
215
216 void
217 createBridgeObjects(Env& mcEnv, Env& scEnv);
218
221 std::uint64_t createCount,
222 jtx::AnyAmount const& amt,
223 jtx::Account const& dst,
224 std::size_t const numAtts,
225 std::size_t const fromIdx = 0)
226 {
229 jvb,
230 mcCarol,
231 amt,
232 reward,
233 payees,
234 true,
235 createCount,
236 dst,
237 signers,
238 numAtts,
239 fromIdx);
240 }
241
244 Account const& acc,
246 STAmount const& _reward = XRP(1),
247 std::optional<STAmount> const& minAccountCreate = std::nullopt)
248 {
249 return bridge_create(
250 acc,
252 _reward,
253 minAccountCreate);
254 }
255};
256
257} // namespace jtx
258} // namespace test
259} // namespace ripple
260
261#endif
Represents a JSON value.
Definition: json_value.h:150
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:121
Converts to IOU Issue or STAmount.
@ nullValue
'null' value
Definition: json_value.h:39
constexpr std::size_t UT_XCHAIN_DEFAULT_QUORUM
Definition: xchain_bridge.h:38
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:34
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:37
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:105
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:39