diff --git a/CHANGELOG.md b/CHANGELOG.md index e9ff71d070..f6d00daa08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased](https://github.com/o1-labs/o1js/compare/26363465d...HEAD) -> No unreleased changes yet +### Fixed + +- Add a parameter to `checkZkappTransaction` for block length to check for transaction inclusion. This fixes a case where `Transaction.wait()` only checked the latest block, which led to an error once the transaction was included in a block that was not the latest. https://github.com/o1-labs/o1js/pull/1239 ## [0.14.1](https://github.com/o1-labs/o1js/compare/e8e7510e1...26363465d) diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 8723d5ba1e..768410c1b5 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -481,8 +481,8 @@ type LastBlockQueryFailureCheckResponse = { }[]; }; -const lastBlockQueryFailureCheck = `{ - bestChain(maxLength: 1) { +const lastBlockQueryFailureCheck = (length: number) => `{ + bestChain(maxLength: ${length}) { transactions { zkappCommands { hash @@ -496,10 +496,11 @@ const lastBlockQueryFailureCheck = `{ }`; async function fetchLatestBlockZkappStatus( + blockLength: number, graphqlEndpoint = networkConfig.minaEndpoint ) { let [resp, error] = await makeGraphqlRequest( - lastBlockQueryFailureCheck, + lastBlockQueryFailureCheck(blockLength), graphqlEndpoint, networkConfig.minaFallbackEndpoints ); @@ -513,9 +514,8 @@ async function fetchLatestBlockZkappStatus( return bestChain; } -async function checkZkappTransaction(txnId: string) { - let bestChainBlocks = await fetchLatestBlockZkappStatus(); - +async function checkZkappTransaction(txnId: string, blockLength = 20) { + let bestChainBlocks = await fetchLatestBlockZkappStatus(blockLength); for (let block of bestChainBlocks.bestChain) { for (let zkappCommand of block.transactions.zkappCommands) { if (zkappCommand.hash === txnId) {