diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..36261a8bbbf7970587f67cbea93300bd7efa2acf --- /dev/null +++ b/.DS_Store @@ -0,0 +1 @@ +Bud1  Ilocblob distIlocblobA.������distlg1Scomp"�KdistmoDDblobz��v_�AdistmodDblobz��v_�Adistph1ScompHPLICENSEIlocblob�.������ package.jsonIlocblob.������ README.mdIlocblob�.������srcIlocblob�.������srclg1Scomp�r2srcmoDDblobi���v_�AsrcmodDblobi���v_�Asrcph1Scomp�  @� @� @� @ E DSDB `� @� @� @ \ No newline at end of file diff --git a/dist/.DS_Store b/dist/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fa3c255214adb50928648a92af5d2a37a3545760 --- /dev/null +++ b/dist/.DS_Store @@ -0,0 +1 @@ +Bud1lg1Scompnodelg1Scomp���nodemoDDblob=��v_�AnodemodDblob����v_�Anodeph1ScompӠweblg1Scompb:ywebmoDDblob���v_�AwebmodDblob���v_�Awebph1Scompt�  @� @� @� @ EDSDB `� @� @� @ \ No newline at end of file diff --git a/dist/node/.DS_Store b/dist/node/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..09e203631742c5c0bd39a637475b2a347ed9f618 --- /dev/null +++ b/dist/node/.DS_Store @@ -0,0 +1 @@ +Bud1  ingslg1S bindingslg1Scomp�@bindingsmoDDblob�� �v_�AbindingsmodDblob�� �v_�Abindingsph1Scomp�@liblg1Scomp$��libmoDDblob�6�v_�AlibmodDblob�6�v_�Alibph1Scomp0 mina-signerlg1Scomp0� mina-signermoDDblob�a��v_�A mina-signermodDblob�a��v_�A mina-signerph1Scomp`  @� @� @� @ E DSDB `� @� @� @ \ No newline at end of file diff --git a/dist/node/bindings/.DS_Store b/dist/node/bindings/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..878400976783200cace4438ff29806dbae421aba --- /dev/null +++ b/dist/node/bindings/.DS_Store @@ -0,0 +1,3 @@ +Bud1 +iledlg1Scompiledlg1Scomp{ �compiledmoDDblob����v_�AcompiledmodDblob����v_�Acompiledph1Scomp{Pcryptolg1Scompi�cryptomoDDblob�S��v_�AcryptomodDblob�S��v_�Acryptoph1Scomp�jslg1Scomp�jsmoDDblob֪��v_�AjsmodDblob֪��v_�Ajsph1Scomp0liblg1Scomp��libmoDDblob����v_�AlibmodDblob����v_�Alibph1Scomp0mina-transactionlg1Scomp��mina-transactionmoDDblob{C��v_�Amina-transactionmodDblob{C��v_�Amina-transactionph1Scomp�  @� @� @� @ E +DSDB `� @� @� @ \ No newline at end of file diff --git a/dist/node/lib/.DS_Store b/dist/node/lib/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..608ae457ae7c2130411b550e47d0e8225ba4b544 --- /dev/null +++ b/dist/node/lib/.DS_Store @@ -0,0 +1,3 @@ +Bud1 +lg1Scompminalg1Scomp �minamoDDblob0���v_�AminamodDblob0���v_�Aminaph1ScompPmllg1Scomp=�mlmoDDblob�|��v_�AmlmodDblob�|��v_�Amlph1Scomp� proof-systemlg1Scomp � proof-systemmoDDblob ��v_�A proof-systemmodDblob ��v_�A proof-systemph1Scomp�provablelg1Scomp� provablemoDDblob;���v_�AprovablemodDblob;���v_�Aprovableph1Scomp�testinglg1Scomp/�testingmoDDblob�Y��v_�AtestingmodDblob�Y��v_�Atestingph1Scomp`utillg1Scomp�utilmoDDblob^H��v_�AutilmodDblob^H��v_�Autilph1Scomp�  @� @� @� @ E +DSDB `� @� @� @ \ No newline at end of file diff --git a/dist/node/lib/mina/fetch.js b/dist/node/lib/mina/fetch.js index c104c944476e65e020505b2d37dd6aa04e6f8ddd..d31f464a311831a8de9e8d4d74cec2b4c41569ee 100644 --- a/dist/node/lib/mina/fetch.js +++ b/dist/node/lib/mina/fetch.js @@ -274,8 +274,8 @@ async function checkZkappTransaction(transactionHash, blockLength = 20) { let failureReason = zkappCommand.failureReason .reverse() .map((failure) => { - return [failure.failures.map((failureItem) => failureItem)]; - }); + return [failure.failures.map((failureItem) => failureItem)]; + }); return { success: false, failureReason, @@ -403,6 +403,26 @@ async function fetchActions(accountInfo, graphqlEndpoint = networkConfig.archive addCachedActions({ publicKey, tokenId }, actionsList, graphqlEndpoint); return actionsList; } + +function permute(arr) { + const result = []; + + function generatePermutation(current, remaining) { + if (remaining.length === 0) { + result.push(current); + } else { + for (let i = 0; i < remaining.length; i++) { + const next = current.concat(remaining[i]); + const rest = remaining.slice(0, i).concat(remaining.slice(i + 1)); + generatePermutation(next, rest); + } + } + } + + generatePermutation([], arr); + return result; +} + /** * Given a graphQL response from #getActionsQuery, process the actions into a canonical actions list */ @@ -413,18 +433,26 @@ export function createActionsList(accountInfo, fetchedActions) { // correct for archive node sending one block too many if (fetchedActions.length !== 0 && fetchedActions[0].actionState.actionStateOne === - actionStates.fromActionState) { + actionStates.fromActionState) { fetchedActions = fetchedActions.slice(1); } - fetchedActions.forEach((actionBlock) => { + // console.log('Fetched actions', fetchedActions); + for (const actionBlock of fetchedActions) { let { actionData } = actionBlock; let latestActionState = Field(actionBlock.actionState.actionStateTwo); let actionState = actionBlock.actionState.actionStateOne; if (actionData.length === 0) throw Error(`No action data was found for the account ${publicKey} with the latest action state ${actionState}`); + actionData = actionData.sort((a1, a2) => { return Number(a1.accountUpdateId) < Number(a2.accountUpdateId) ? -1 : 1; }); + + if (actionBlock.actionState.actionStateOne == global.errorAtHash) { + const permutation = permute(actionData) + actionData = permutation[global.permutation]; + } + // split actions by account update let actionsByAccountUpdate = []; let currentAccountUpdateId = 'none'; @@ -447,13 +475,20 @@ export function createActionsList(accountInfo, fetchedActions) { const finalActionState = latestActionState.toString(); const expectedActionState = actionState; if (finalActionState !== expectedActionState) { - throw new Error(`Failed to derive correct actions hash for ${publicKey}. - Derived hash: ${finalActionState}, expected hash: ${expectedActionState}). - All action hashes derived: ${JSON.stringify(actionsList, null, 2)} - Please try a different Archive Node API endpoint. - `); + global.errorAtHash = expectedActionState; + global.permutation = typeof global.permutation !== "undefined" ? global.permutation + 1 : 0; + return createActionsList(accountInfo, fetchedActions) + + // throw new Error(`Failed to derive correct actions hash for ${publicKey}. + // Derived hash: ${finalActionState}, expected hash: ${expectedActionState}). + // All action hashes derived: ${JSON.stringify(actionsList, null, 2)} + // Please try a different Archive Node API endpoint. + // `); } - }); + }; + global.errorAtHash = undefined; + global.permutation = undefined; + return actionsList; } /** diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b1b0a32c8ed1218f1e3fdd7d5c3866cd3f3ad4e4 --- /dev/null +++ b/src/.DS_Store @@ -0,0 +1,3 @@ +Bud1 +ingslg1Sbindingslg1Scomp�H�bindingsmoDDblob����v_�AbindingsmodDblob����v_�Abindingsph1Scomp�Pbuildlg1Scomp^XbuildmoDDblob�D��v_�AbuildmodDblob�D��v_�Abuildph1Scomp�exampleslg1Scomp-HexamplesmoDDblob���v_�AexamplesmodDblob���v_�Aexamplesph1Scomp�liblg1Scompi�libmoDDblob�W��v_�AlibmodDblob�W��v_�Alibph1Scomp� mina-signerlg1Scomp�@ mina-signermoDDblob�l��v_�A mina-signermodDblob�l��v_�A mina-signerph1Scomp�testslg1ScompC�testsmoDDblob>���v_�AtestsmodDblob>���v_�Atestsph1Scomp`  @� @� @� @ E +DSDB `� @� @� @