From 007465a90e0d952eb940052beedbbcf0fea07cc1 Mon Sep 17 00:00:00 2001 From: Sebastien Guillemot Date: Fri, 8 Sep 2023 23:56:50 +0900 Subject: [PATCH] Add missing emulated block conversion in batcher post await --- engine/paima-mw-core/src/helpers/posting.ts | 35 +++++++++++---------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/engine/paima-mw-core/src/helpers/posting.ts b/engine/paima-mw-core/src/helpers/posting.ts index 085933d48..d46286d46 100644 --- a/engine/paima-mw-core/src/helpers/posting.ts +++ b/engine/paima-mw-core/src/helpers/posting.ts @@ -151,6 +151,19 @@ export async function postConciselyEncodedData(gameInput: string): Promise { + if (getEmulatedBlocksActive()) { + const emulatedBlockHeight = await retryPromise( + () => deploymentChainBlockHeightToEmulated(deploymentChainBlockHeight), + EMULATED_CONVERSION_RETRY_DELAY, + EMULATED_CONVERSION_RETRY_COUNT + ); + return emulatedBlockHeight; + } else { + return deploymentChainBlockHeight; + } +} + async function postString( sendWalletTransaction: PostFxn, userAddress: string, @@ -166,22 +179,10 @@ async function postString( TX_VERIFICATION_RETRY_DELAY, TX_VERIFICATION_RETRY_COUNT ); - if (getEmulatedBlocksActive()) { - const emulatedBlockHeight = await retryPromise( - () => deploymentChainBlockHeightToEmulated(deploymentChainBlockHeight), - EMULATED_CONVERSION_RETRY_DELAY, - EMULATED_CONVERSION_RETRY_COUNT - ); - return { - success: true, - result: emulatedBlockHeight, - }; - } else { - return { - success: true, - result: deploymentChainBlockHeight, - }; - } + return { + success: true, + result: await getAdjustedHeight(deploymentChainBlockHeight), + }; } catch (err) { return errorFxn(PaimaMiddlewareErrorCode.ERROR_POSTING_TO_CHAIN, err); } @@ -262,7 +263,7 @@ async function verifyBatcherSubmission(inputHash: string): Promise