From 952d797863b70659e4cbc10c229b54611ca890f6 Mon Sep 17 00:00:00 2001 From: Todd Fleming Date: Tue, 25 Jan 2022 13:54:59 -0500 Subject: [PATCH] Support mandel's ship --- contracts/eden/src/eden-micro-chain.cpp | 97 +++++++++++++------------ 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/contracts/eden/src/eden-micro-chain.cpp b/contracts/eden/src/eden-micro-chain.cpp index 95b986a22..3adc861bc 100644 --- a/contracts/eden/src/eden-micro-chain.cpp +++ b/contracts/eden/src/eden-micro-chain.cpp @@ -2170,52 +2170,57 @@ std::vector ship_to_eden_transactions( for (const auto& transaction_trace : traces) { - if (auto* trx_trace = - std::get_if(&transaction_trace)) - { - subchain::transaction transaction{ - .id = trx_trace->id, - }; - - for (const auto& action_trace : trx_trace->action_traces) - { - if (auto* act_trace = std::get_if(&action_trace)) - { - std::optional creatorAction; - if (act_trace->creator_action_ordinal.value > 0) - { - const auto& creator_action_trace = - std::get( - trx_trace->action_traces[act_trace->creator_action_ordinal.value - 1]); - const auto& receipt = std::get( - *creator_action_trace.receipt); - creatorAction = subchain::creator_action{ - .seq = receipt.global_sequence, - .receiver = creator_action_trace.receiver, - }; - } - - std::vector data(act_trace->act.data.pos, act_trace->act.data.end); - eosio::bytes hexData{data}; - - const auto& receipt = - std::get(*act_trace->receipt); - - subchain::action action{ - .seq = receipt.global_sequence, - .firstReceiver = act_trace->act.account, - .receiver = act_trace->receiver, - .name = act_trace->act.name, - .creatorAction = creatorAction, - .hexData = std::move(hexData), - }; - - transaction.actions.push_back(std::move(action)); - } - } - - transactions.push_back(std::move(transaction)); - } + std::visit( + [&](const auto& trx_trace) { + subchain::transaction transaction{ + .id = trx_trace.id, + }; + + for (const auto& action_trace : trx_trace.action_traces) + { + std::visit( + [&](const auto& act_trace) { + std::optional creatorAction; + if (act_trace.creator_action_ordinal.value > 0) + { + std::visit( + [&](const auto& creator_action_trace) { + std::visit( + [&](const auto& receipt) { + creatorAction = subchain::creator_action{ + .seq = receipt.global_sequence, + .receiver = creator_action_trace.receiver, + }; + }, + *creator_action_trace.receipt); + }, + trx_trace.action_traces[act_trace.creator_action_ordinal.value - 1]); + } + + std::vector data(act_trace.act.data.pos, act_trace.act.data.end); + eosio::bytes hexData{data}; + + std::visit( + [&](const auto& receipt) { + subchain::action action{ + .seq = receipt.global_sequence, + .firstReceiver = act_trace.act.account, + .receiver = act_trace.receiver, + .name = act_trace.act.name, + .creatorAction = creatorAction, + .hexData = std::move(hexData), + }; + + transaction.actions.push_back(std::move(action)); + }, + *act_trace.receipt); + }, + action_trace); + } + + transactions.push_back(std::move(transaction)); + }, + transaction_trace); } return transactions;