rippled
Loading...
Searching...
No Matches
InnerObjectFormats.cpp
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#include <xrpl/protocol/InnerObjectFormats.h>
21#include <xrpl/protocol/SField.h>
22#include <xrpl/protocol/SOTemplate.h>
23
24namespace ripple {
25
27{
28 // inner objects with the default fields have to be
29 // constructed with STObject::makeInnerObject()
30
31 add(sfSignerEntry.jsonName,
32 sfSignerEntry.getCode(),
33 {
34 {sfAccount, soeREQUIRED},
35 {sfSignerWeight, soeREQUIRED},
36 {sfWalletLocator, soeOPTIONAL},
37 });
38
39 add(sfSigner.jsonName,
40 sfSigner.getCode(),
41 {
42 {sfAccount, soeREQUIRED},
43 {sfSigningPubKey, soeREQUIRED},
44 {sfTxnSignature, soeREQUIRED},
45 });
46
47 add(sfMajority.jsonName,
48 sfMajority.getCode(),
49 {
50 {sfAmendment, soeREQUIRED},
51 {sfCloseTime, soeREQUIRED},
52 });
53
54 add(sfDisabledValidator.jsonName,
55 sfDisabledValidator.getCode(),
56 {
57 {sfPublicKey, soeREQUIRED},
58 {sfFirstLedgerSequence, soeREQUIRED},
59 });
60
61 add(sfNFToken.jsonName,
62 sfNFToken.getCode(),
63 {
64 {sfNFTokenID, soeREQUIRED},
65 {sfURI, soeOPTIONAL},
66 });
67
68 add(sfVoteEntry.jsonName,
69 sfVoteEntry.getCode(),
70 {
71 {sfAccount, soeREQUIRED},
72 {sfTradingFee, soeDEFAULT},
73 {sfVoteWeight, soeREQUIRED},
74 });
75
76 add(sfAuctionSlot.jsonName,
77 sfAuctionSlot.getCode(),
78 {{sfAccount, soeREQUIRED},
79 {sfExpiration, soeREQUIRED},
80 {sfDiscountedFee, soeDEFAULT},
81 {sfPrice, soeREQUIRED},
82 {sfAuthAccounts, soeOPTIONAL}});
83
84 add(sfXChainClaimAttestationCollectionElement.jsonName,
85 sfXChainClaimAttestationCollectionElement.getCode(),
86 {
87 {sfAttestationSignerAccount, soeREQUIRED},
88 {sfPublicKey, soeREQUIRED},
89 {sfSignature, soeREQUIRED},
90 {sfAmount, soeREQUIRED},
91 {sfAccount, soeREQUIRED},
92 {sfAttestationRewardAccount, soeREQUIRED},
93 {sfWasLockingChainSend, soeREQUIRED},
94 {sfXChainClaimID, soeREQUIRED},
95 {sfDestination, soeOPTIONAL},
96 });
97
98 add(sfXChainCreateAccountAttestationCollectionElement.jsonName,
99 sfXChainCreateAccountAttestationCollectionElement.getCode(),
100 {
101 {sfAttestationSignerAccount, soeREQUIRED},
102 {sfPublicKey, soeREQUIRED},
103 {sfSignature, soeREQUIRED},
104 {sfAmount, soeREQUIRED},
105 {sfAccount, soeREQUIRED},
106 {sfAttestationRewardAccount, soeREQUIRED},
107 {sfWasLockingChainSend, soeREQUIRED},
108 {sfXChainAccountCreateCount, soeREQUIRED},
109 {sfDestination, soeREQUIRED},
110 {sfSignatureReward, soeREQUIRED},
111 });
112
113 add(sfXChainClaimProofSig.jsonName,
114 sfXChainClaimProofSig.getCode(),
115 {
116 {sfAttestationSignerAccount, soeREQUIRED},
117 {sfPublicKey, soeREQUIRED},
118 {sfAmount, soeREQUIRED},
119 {sfAttestationRewardAccount, soeREQUIRED},
120 {sfWasLockingChainSend, soeREQUIRED},
121 {sfDestination, soeOPTIONAL},
122 });
123
124 add(sfXChainCreateAccountProofSig.jsonName,
125 sfXChainCreateAccountProofSig.getCode(),
126 {
127 {sfAttestationSignerAccount, soeREQUIRED},
128 {sfPublicKey, soeREQUIRED},
129 {sfAmount, soeREQUIRED},
130 {sfSignatureReward, soeREQUIRED},
131 {sfAttestationRewardAccount, soeREQUIRED},
132 {sfWasLockingChainSend, soeREQUIRED},
133 {sfDestination, soeREQUIRED},
134 });
135
136 add(sfAuthAccount.jsonName,
137 sfAuthAccount.getCode(),
138 {
139 {sfAccount, soeREQUIRED},
140 });
141
142 add(sfPriceData.jsonName,
143 sfPriceData.getCode(),
144 {
145 {sfBaseAsset, soeREQUIRED},
146 {sfQuoteAsset, soeREQUIRED},
147 {sfAssetPrice, soeOPTIONAL},
148 {sfScale, soeDEFAULT},
149 });
150
151 add(sfCredential.jsonName,
152 sfCredential.getCode(),
153 {
154 {sfIssuer, soeREQUIRED},
155 {sfCredentialType, soeREQUIRED},
156 });
157
158 add(sfPermission.jsonName.c_str(),
159 sfPermission.getCode(),
160 {{sfPermissionValue, soeREQUIRED}});
161}
162
163InnerObjectFormats const&
164InnerObjectFormats::getInstance()
165{
166 static InnerObjectFormats instance;
167 return instance;
168}
169
170SOTemplate const*
171InnerObjectFormats::findSOTemplateBySField(SField const& sField) const
172{
173 auto itemPtr = findByType(sField.getCode());
174 if (itemPtr)
175 return &(itemPtr->getSOTemplate());
176
177 return nullptr;
178}
179
180} // namespace ripple
Manages the list of known inner object formats.
InnerObjectFormats()
Create the object.
Item const & add(char const *name, int type, std::initializer_list< SOElement > uniqueFields, std::initializer_list< SOElement > commonFields={})
Add a new format.
Definition: KnownFormats.h:172
Identifies fields.
Definition: SField.h:143
int getCode() const
Definition: SField.h:257
Defines the fields and their attributes within a STObject.
Definition: SOTemplate.h:114
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26