Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mandel's SHiP #659

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 51 additions & 46 deletions contracts/eden/src/eden-micro-chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2170,52 +2170,57 @@ std::vector<subchain::transaction> ship_to_eden_transactions(

for (const auto& transaction_trace : traces)
{
if (auto* trx_trace =
std::get_if<eosio::ship_protocol::transaction_trace_v0>(&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<eosio::ship_protocol::action_trace_v0>(&action_trace))
{
std::optional<subchain::creator_action> creatorAction;
if (act_trace->creator_action_ordinal.value > 0)
{
const auto& creator_action_trace =
std::get<eosio::ship_protocol::action_trace_v0>(
trx_trace->action_traces[act_trace->creator_action_ordinal.value - 1]);
const auto& receipt = std::get<eosio::ship_protocol::action_receipt_v0>(
*creator_action_trace.receipt);
creatorAction = subchain::creator_action{
.seq = receipt.global_sequence,
.receiver = creator_action_trace.receiver,
};
}

std::vector<char> data(act_trace->act.data.pos, act_trace->act.data.end);
eosio::bytes hexData{data};

const auto& receipt =
std::get<eosio::ship_protocol::action_receipt_v0>(*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<subchain::creator_action> 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<char> 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;
Expand Down