From 5df5ca5e37098054abdb6f2515f8b683e45e6bc5 Mon Sep 17 00:00:00 2001 From: Comdex Date: Tue, 11 Apr 2023 18:54:35 +0800 Subject: [PATCH] fix fetchActions --- src/lib/fetch.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index cd5c2028bb..00cca4483d 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -805,7 +805,7 @@ async function fetchActions( let actionsList: { actions: string[][]; hash: string }[] = []; fetchedActions.forEach((fetchedAction) => { - const { actionData } = fetchedAction; + let { actionData } = fetchedAction; let latestActionsHash = Field(fetchedAction.actionState.actionStateTwo); let actionState = Field(fetchedAction.actionState.actionStateOne); @@ -813,10 +813,13 @@ async function fetchActions( throw new Error( `No action data was found for the account ${publicKey} with the latest action state ${actionState}` ); - + + actionData.reverse(); let { accountUpdateId: currentAccountUpdateId } = actionData[0]; let currentActionList: string[][] = []; + + actionData.forEach((action, i) => { const { accountUpdateId, data } = action; const isLastAction = i === actionData.length - 1; @@ -824,7 +827,6 @@ async function fetchActions( if (isSameAccountUpdate && !isLastAction) { currentActionList.push(data); - currentAccountUpdateId = accountUpdateId; return; } else if (isSameAccountUpdate && isLastAction) { currentActionList.push(data); @@ -837,7 +839,7 @@ async function fetchActions( actions: currentActionList, hash: Ledger.fieldToBase58(Field(latestActionsHash)), }); - currentAccountUpdateId = accountUpdateId; + currentActionList = [data]; }