20 #include <ripple/rpc/impl/GRPCHelpers.h>
33 template <
class T,
class L>
43 if constexpr (std::is_integral_v<typename T::value_type>)
45 getProto()->set_value(from[field]);
50 getProto()->set_value(v.data(), v.size());
64 getProto()->set_value(
65 reinterpret_cast<const char*
>(data.data()), data.size());
79 for (
size_t i = 0; i < vec.
size(); ++i)
82 getProto()->set_value(elt.
data(), elt.
size());
96 getProto()->mutable_value()->set_address(
125 auto proto = getProto()->mutable_value();
126 proto->set_code(cur.data(), cur.size());
131 template <
class T,
class R>
135 R
const& populateProto,
144 for (
auto it = arr.begin(); it != arr.end(); ++it)
146 populateProto(*it, *getProto());
156 [&to]() {
return to.mutable_clear_flag(); }, from,
sfClearFlag);
164 [&to]() {
return to.mutable_domain(); }, from,
sfDomain);
172 [&to]() {
return to.mutable_email_hash(); }, from,
sfEmailHash);
180 [&to]() {
return to.mutable_message_key(); }, from,
sfMessageKey);
188 [&to]() {
return to.mutable_set_flag(); }, from,
sfSetFlag);
196 [&to]() {
return to.mutable_transfer_rate(); }, from,
sfTransferRate);
204 [&to]() {
return to.mutable_tick_size(); }, from,
sfTickSize);
212 [&to]() {
return to.mutable_expiration(); }, from,
sfExpiration);
220 [&to]() {
return to.mutable_offer_sequence(); }, from,
sfOfferSequence);
228 [&to]() {
return to.mutable_taker_gets(); }, from,
sfTakerGets);
236 [&to]() {
return to.mutable_taker_pays(); }, from,
sfTakerPays);
244 [&to]() {
return to.mutable_destination(); }, from,
sfDestination);
252 [&to]() {
return to.mutable_check_id(); }, from,
sfCheckID);
260 [&to]() {
return to.mutable_amount(); }, from,
sfAmount);
268 [&to]() {
return to.mutable_deliver_min(); }, from,
sfDeliverMin);
276 [&to]() {
return to.mutable_send_max(); }, from,
sfSendMax);
284 [&to]() {
return to.mutable_delivered_amount(); },
294 [&to]() {
return to.mutable_destination_tag(); },
304 [&to]() {
return to.mutable_invoice_id(); }, from,
sfInvoiceID);
312 [&to]() {
return to.mutable_authorize(); }, from,
sfAuthorize);
320 [&to]() {
return to.mutable_unauthorize(); }, from,
sfUnauthorize);
335 [&to]() {
return to.mutable_cancel_after(); }, from,
sfCancelAfter);
343 [&to]() {
return to.mutable_finish_after(); }, from,
sfFinishAfter);
351 [&to]() {
return to.mutable_condition(); }, from,
sfCondition);
359 [&to]() {
return to.mutable_fulfillment(); }, from,
sfFulfillment);
367 [&to]() {
return to.mutable_channel(); }, from,
sfChannel);
375 [&to]() {
return to.mutable_balance(); }, from,
sfBalance);
383 [&to]() {
return to.mutable_payment_channel_signature(); },
393 [&to]() {
return to.mutable_public_key(); }, from,
sfPublicKey);
401 [&to]() {
return to.mutable_settle_delay(); }, from,
sfSettleDelay);
409 [&to]() {
return to.mutable_regular_key(); }, from,
sfRegularKey);
417 [&to]() {
return to.mutable_signer_quorum(); }, from,
sfSignerQuorum);
425 [&to]() {
return to.mutable_count(); }, from,
sfTicketCount);
433 [&to]() {
return to.mutable_limit_amount(); }, from,
sfLimitAmount);
440 [&to]() {
return to.mutable_quality_in(); }, from,
sfQualityIn);
448 [&to]() {
return to.mutable_quality_out(); }, from,
sfQualityOut);
456 [&to]() {
return to.mutable_account(); }, from,
sfAccount);
474 [&to]() {
return to.mutable_signing_public_key(); },
484 [&to]() {
return to.mutable_transaction_signature(); },
494 [&to]() {
return to.mutable_flags(); }, from,
sfFlags);
502 [&to]() {
return to.mutable_ledger_sequence(); },
512 [&to]() {
return to.mutable_validator_to_disable(); },
522 [&to]() {
return to.mutable_validator_to_re_enable(); },
532 [&to]() {
return to.mutable_last_ledger_sequence(); },
542 [&to]() {
return to.mutable_source_tag(); }, from,
sfSourceTag);
550 [&to]() {
return to.mutable_account_transaction_id(); },
560 [&to]() {
return to.mutable_memo_data(); }, from,
sfMemoData);
568 [&to]() {
return to.mutable_memo_format(); }, from,
sfMemoFormat);
576 [&to]() {
return to.mutable_memo_type(); }, from,
sfMemoType);
584 [&to]() {
return to.mutable_sequence(); }, from,
sfSequence);
592 [&to]() {
return to.mutable_amendment(); }, from,
sfAmendment);
600 [&to]() {
return to.mutable_close_time(); }, from,
sfCloseTime);
608 [&to]() {
return to.mutable_signer_weight(); }, from,
sfSignerWeight);
616 [&to]() {
return to.add_amendments(); }, from,
sfAmendments);
624 [&to]() {
return to.mutable_owner_count(); }, from,
sfOwnerCount);
632 [&to]() {
return to.mutable_previous_transaction_id(); },
642 [&to]() {
return to.mutable_previous_transaction_ledger_sequence(); },
652 [&to]() {
return to.mutable_low_limit(); }, from,
sfLowLimit);
660 [&to]() {
return to.mutable_high_limit(); }, from,
sfHighLimit);
668 [&to]() {
return to.mutable_low_node(); }, from,
sfLowNode);
676 [&to]() {
return to.mutable_high_node(); }, from,
sfHighNode);
684 [&to]() {
return to.mutable_low_quality_in(); }, from,
sfLowQualityIn);
692 [&to]() {
return to.mutable_low_quality_out(); },
702 [&to]() {
return to.mutable_high_quality_in(); },
712 [&to]() {
return to.mutable_high_quality_out(); },
722 [&to]() {
return to.mutable_book_directory(); }, from,
sfBookDirectory);
730 [&to]() {
return to.mutable_book_node(); }, from,
sfBookNode);
738 [&to]() {
return to.mutable_owner_node(); }, from,
sfOwnerNode);
746 [&to]() {
return to.mutable_signer_list_id(); }, from,
sfSignerListID);
754 [&to]() {
return to.mutable_wallet_locator(); }, from,
sfWalletLocator);
762 [&to]() {
return to.mutable_ticket_sequence(); },
794 [&to]() {
return to.mutable_root_index(); }, from,
sfRootIndex);
802 [&to]() {
return to.mutable_index_next(); }, from,
sfIndexNext);
810 [&to]() {
return to.mutable_index_previous(); }, from,
sfIndexPrevious);
818 [&to]() {
return to.mutable_taker_pays_currency(); },
828 [&to]() {
return to.mutable_taker_pays_issuer(); },
838 [&to]() {
return to.mutable_taker_gets_currency(); },
848 [&to]() {
return to.mutable_taker_gets_issuer(); },
858 [&to]() {
return to.mutable_destination_node(); },
868 [&to]() {
return to.mutable_base_fee(); }, from,
sfBaseFee);
876 [&to]() {
return to.mutable_reference_fee_units(); },
886 [&to]() {
return to.mutable_previous_page_min(); },
896 [&to]() {
return to.mutable_next_page_min(); }, from,
sfNextPageMin);
904 [&to]() {
return to.mutable_nftoken_id(); }, from,
sfNFTokenID);
919 [&to]() {
return to.mutable_burned_nftokens(); },
929 [&to]() {
return to.mutable_minted_nftokens(); },
939 [&to]() {
return to.mutable_nftoken_minter(); }, from,
sfNFTokenMinter);
947 [&to]() {
return to.mutable_nftoken_broker_fee(); },
957 [&to]() {
return to.mutable_nftoken_buy_offer(); },
967 [&to]() {
return to.mutable_nftoken_sell_offer(); },
977 [&to]() {
return to.mutable_issuer(); }, from,
sfIssuer);
985 [&to]() {
return to.mutable_nftoken_taxon(); }, from,
sfNFTokenTaxon);
993 [&to]() {
return to.mutable_transfer_fee(); }, from,
sfTransferFee);
1001 [&to]() {
return to.mutable_reserve_base(); }, from,
sfReserveBase);
1009 [&to]() {
return to.mutable_reserve_increment(); },
1019 [&to]() {
return to.add_signer_entries(); },
1020 [](
auto& innerObj,
auto& innerProto) {
1035 [&to]() {
return to.add_disabled_validators(); },
1036 [](
auto& innerObj,
auto& innerProto) {
1050 [&to]() {
return to.add_memos(); },
1051 [](
auto& innerObj,
auto& innerProto) {
1066 [&to]() {
return to.add_signers(); },
1067 [](
auto& innerObj,
auto& innerProto) {
1082 [&to]() {
return to.add_majorities(); },
1083 [](
auto innerObj,
auto innerProto) {
1097 [&to]() {
return to.add_nftokens(); },
1098 [](
auto innerObj,
auto innerProto) {
1113 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TEC);
1118 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TEF);
1123 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TEL);
1128 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TEM);
1133 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TER);
1138 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TES);
1399 for (
auto it = pathset.
begin(); it < pathset.
end(); ++it)
1401 STPath const& path = *it;
1403 org::xrpl::rpc::v1::Payment_Path* protoPath = to.add_paths();
1405 for (
auto it2 = path.begin(); it2 != path.end(); ++it2)
1407 org::xrpl::rpc::v1::Payment_PathElement* protoElement =
1408 protoPath->add_elements();
1416 protoElement->mutable_currency()->set_name(
1422 protoElement->mutable_issuer()->set_address(
1429 protoElement->mutable_account()->set_address(
1767 org::xrpl::rpc::v1::AffectedNode& proto,
1773 proto.set_ledger_entry_type(
1774 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_ACCOUNT_ROOT);
1777 proto.set_ledger_entry_type(
1778 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_DIRECTORY_NODE);
1781 proto.set_ledger_entry_type(
1782 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_RIPPLE_STATE);
1785 proto.set_ledger_entry_type(
1786 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_SIGNER_LIST);
1789 proto.set_ledger_entry_type(
1790 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_OFFER);
1793 proto.set_ledger_entry_type(
1794 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_LEDGER_HASHES);
1797 proto.set_ledger_entry_type(
1798 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_AMENDMENTS);
1801 proto.set_ledger_entry_type(
1802 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_FEE_SETTINGS);
1805 proto.set_ledger_entry_type(
1806 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_ESCROW);
1809 proto.set_ledger_entry_type(
1810 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_PAY_CHANNEL);
1813 proto.set_ledger_entry_type(
1814 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_CHECK);
1817 proto.set_ledger_entry_type(
1818 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_DEPOSIT_PREAUTH);
1821 proto.set_ledger_entry_type(
1822 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_NEGATIVE_UNL);
1825 proto.set_ledger_entry_type(
1826 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_TICKET);
1829 proto.set_ledger_entry_type(
1830 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_NFTOKEN_OFFER);
1833 proto.set_ledger_entry_type(
1834 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_NFTOKEN_PAGE);
1909 convert(*getProto(), data, lgrType);
1937 to.set_transaction_index(from->getIndex());
1939 convert(*to.mutable_transaction_result(), from->getResultTER());
1940 to.mutable_transaction_result()->set_result(
1943 if (from->hasDeliveredAmount())
1944 convert(*to.mutable_delivered_amount(), from->getDeliveredAmount());
1946 STArray& nodes = from->getNodes();
1947 for (
auto it = nodes.
begin(); it != nodes.
end(); ++it)
1950 org::xrpl::rpc::v1::AffectedNode* node = to.add_affected_nodes();
1954 node->set_ledger_index(ledgerIndex.
data(), ledgerIndex.
size());
1965 return node->mutable_modified_node()
1966 ->mutable_final_fields();
1973 return node->mutable_modified_node()
1974 ->mutable_previous_fields();
1982 *node->mutable_modified_node(), obj);
1989 return node->mutable_created_node()->mutable_new_fields();
1999 return node->mutable_deleted_node()->mutable_final_fields();
2009 org::xrpl::rpc::v1::QueueData& to,
2014 to.set_txn_count(from.
size());
2022 bool anyAuthChanged =
false;
2025 for (
auto const& tx : from)
2027 org::xrpl::rpc::v1::QueuedTransaction& qt = *to.add_transactions();
2029 if (tx.seqProxy.isSeq())
2031 qt.mutable_sequence()->set_value(tx.seqProxy.value());
2034 lowestSeq = tx.seqProxy.
value();
2035 highestSeq = tx.seqProxy.
value();
2039 qt.mutable_ticket()->set_value(tx.seqProxy.value());
2042 lowestTicket = tx.seqProxy.
value();
2043 highestTicket = tx.seqProxy.
value();
2046 qt.set_fee_level(tx.feeLevel.fee());
2048 qt.mutable_last_ledger_sequence()->set_value(*tx.lastValid);
2050 qt.mutable_fee()->set_drops(tx.consequences.fee().drops());
2052 tx.consequences.potentialSpend() + tx.consequences.fee();
2053 qt.mutable_max_spend_drops()->set_drops(spend.drops());
2054 totalSpend += spend;
2055 bool const authChanged = tx.consequences.isBlocker();
2057 anyAuthChanged =
true;
2058 qt.set_auth_change(authChanged);
2062 to.set_sequence_count(seqCount);
2064 to.set_ticket_count(ticketCount);
2066 to.set_lowest_sequence(*lowestSeq);
2068 to.set_highest_sequence(*highestSeq);
2070 to.set_lowest_ticket(*lowestTicket);
2072 to.set_highest_ticket(*highestTicket);
2074 to.set_auth_change_queued(anyAuthChanged);
2075 to.mutable_max_spend_drops_total()->set_drops(totalSpend.
drops());
2081 org::xrpl::rpc::v1::Transaction& to,
2114 case TxType::ttPAYMENT:
2115 convert(*to.mutable_payment(), fromObj);
2117 case TxType::ttESCROW_CREATE:
2118 convert(*to.mutable_escrow_create(), fromObj);
2120 case TxType::ttESCROW_FINISH:
2121 convert(*to.mutable_escrow_finish(), fromObj);
2123 case TxType::ttACCOUNT_SET:
2124 convert(*to.mutable_account_set(), fromObj);
2126 case TxType::ttESCROW_CANCEL:
2127 convert(*to.mutable_escrow_cancel(), fromObj);
2129 case TxType::ttREGULAR_KEY_SET:
2130 convert(*to.mutable_set_regular_key(), fromObj);
2132 case TxType::ttOFFER_CREATE:
2133 convert(*to.mutable_offer_create(), fromObj);
2135 case TxType::ttOFFER_CANCEL:
2136 convert(*to.mutable_offer_cancel(), fromObj);
2138 case TxType::ttSIGNER_LIST_SET:
2139 convert(*to.mutable_signer_list_set(), fromObj);
2141 case TxType::ttPAYCHAN_CREATE:
2142 convert(*to.mutable_payment_channel_create(), fromObj);
2144 case TxType::ttPAYCHAN_FUND:
2145 convert(*to.mutable_payment_channel_fund(), fromObj);
2147 case TxType::ttPAYCHAN_CLAIM:
2148 convert(*to.mutable_payment_channel_claim(), fromObj);
2150 case TxType::ttCHECK_CREATE:
2151 convert(*to.mutable_check_create(), fromObj);
2153 case TxType::ttCHECK_CASH:
2154 convert(*to.mutable_check_cash(), fromObj);
2156 case TxType::ttCHECK_CANCEL:
2157 convert(*to.mutable_check_cancel(), fromObj);
2159 case TxType::ttDEPOSIT_PREAUTH:
2160 convert(*to.mutable_deposit_preauth(), fromObj);
2162 case TxType::ttTRUST_SET:
2163 convert(*to.mutable_trust_set(), fromObj);
2165 case TxType::ttACCOUNT_DELETE:
2166 convert(*to.mutable_account_delete(), fromObj);
2168 case TxType::ttTICKET_CREATE:
2169 convert(*to.mutable_ticket_create(), fromObj);
2171 case TxType::ttNFTOKEN_MINT:
2172 convert(*to.mutable_nftoken_mint(), fromObj);
2174 case TxType::ttNFTOKEN_BURN:
2175 convert(*to.mutable_nftoken_burn(), fromObj);
2177 case TxType::ttNFTOKEN_CREATE_OFFER:
2178 convert(*to.mutable_nftoken_create_offer(), fromObj);
2180 case TxType::ttNFTOKEN_CANCEL_OFFER:
2181 convert(*to.mutable_nftoken_cancel_offer(), fromObj);
2183 case TxType::ttNFTOKEN_ACCEPT_OFFER:
2184 convert(*to.mutable_nftoken_accept_offer(), fromObj);