Closed theblockstalk closed 2 days ago
Looks like this did execute correctly as shown by the unit tests https://github.com/Tonomy-Foundation/Tonomy-ID-SDK/pull/399
It looks like the Hyperion API shows a different output format for the action traces, which may or may not contain all the information we need to understand execution. The https://github.com/telosnetwork/open-block-explorer Does not seem to support passing the action correctly either way... https://t.me/EOSHyperion/28082
Some testing code for structuring actions. Flatten is working but structureArray is not yet.
type Action = any;
function actionToString(action: Action, indentTabs = 0): string {
let out = "\t".repeat(indentTabs)
try {
out += action.act.account + "::" + action.act.name + "()", action.action_ordinal, action.creator_action_ordinal, action.act.account !== action.receiver ? "(notification)" : "";
} catch (e) {
console.log(action);
}
if (out.inline_traces && Array.isArray(out.inline_traces) && out.inline_traces.length > 0) {
for (const inlineTrace of out.inline_traces) {
out += "\n" + actionToString(inlineTrace, indentTabs + 1);
}
}
return out;
}
function flattenActions(actions: Action[]) {
const actionsCopy = JSON.parse(JSON.stringify(actions));
const flatActions: Action[] = [];
for (const action of actionsCopy) {
flatActions.push(action);
actionsCopy.push(...action.inline_traces);
action.inline_traces = [];
}
return flatActions;
}
function findActionWithOrdinal(action: Action, ordinal: number): Action | null {
if (action.action_ordinal === ordinal) {
return action;
}
if (action.inline_traces && Array.isArray(action.inline_traces) && action.inline_traces.length > 0) {
for (const inlineTrace of action.inline_traces) {
const foundAction = findActionWithOrdinal(inlineTrace, ordinal);
if (foundAction) return foundAction;
}
}
return null;
}
function structureActions(actions: Action[]) {
for (const action of actions) {
const creatorAction = actions.find(a => findActionWithOrdinal(a, action.creator_action_ordinal));
if (creatorAction) {
if (!creatorAction.inline_traces || !Array.isArray(creatorAction.inline_traces)) {
creatorAction.inline_traces = [];
}
creatorAction.inline_traces.push(action);
} else {
actions.push([action]);
}
}
return actions;
}
function printActionArray(actions: Action[]) {
let out = "";
for (const action of actions) {
out += actionToString(action) + "\n";
}
console.log(out)
}
function printUnstructuredActions(actions: Action[]) {
const flatActions: Action[] = flattenActions(actions);
printActionArray(flatActions);
structureActions(flatActions);
printActionArray(flatActions);
}
https://explorer.pangea.web4.world/proposal/vestbulk2 https://explorer.pangea.web4.world/transaction/b8c822abb9b9e274c3bb272b8789c83a3a1f8a6ee886df7ddd35fe27d1b04af8
You can see that even though many LEOS tokens were assigned, LEOS was only sent once. It should have been transferred for each assignment.