From 66ef9040807ea1a97111b4e3ef3b91b9ed050ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lancelot=20de=20Ferri=C3=A8re?= Date: Wed, 24 Jan 2024 09:39:22 +0100 Subject: [PATCH] Fix frontend optimistic processing for new transactions --- src/builder/ChainBriqs.ts | 2 +- src/builder/ChainBriqsLegacy.ts | 2 +- src/builder/UserItem.ts | 4 ++-- src/chain/BlockchainProvider.ts | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/builder/ChainBriqs.ts b/src/builder/ChainBriqs.ts index 862e59ae..3b39bd3b 100644 --- a/src/builder/ChainBriqs.ts +++ b/src/builder/ChainBriqs.ts @@ -135,7 +135,7 @@ export class ChainBriqs implements perUserStorable { promises.set(update, _block.then(data => { const status = data.status; const block = data.block_number; - if (status === 'REJECTED' || ((Date.now() - update.date) > 20 * 60 * 1000 && status === 'NOT_RECEIVED')) { + if (status === 'REVERTED' || ((Date.now() - update.date) > 20 * 60 * 1000 && status === 'NOT_RECEIVED')) { if (update.status === 'TENTATIVE' && update.shouldNotify) this.notifyMintingRejected(update); this.metadata[material].splice(i--, 1); diff --git a/src/builder/ChainBriqsLegacy.ts b/src/builder/ChainBriqsLegacy.ts index b03bb6ce..198067ef 100644 --- a/src/builder/ChainBriqsLegacy.ts +++ b/src/builder/ChainBriqsLegacy.ts @@ -105,7 +105,7 @@ export class LegacyChainBriqs implements perUserStorable { promises.set(update, _block.then(data => { const status = data.status; const block = data.block_number; - if (status === 'REJECTED' || ((Date.now() - update.date) > 20 * 60 * 1000 && status === 'NOT_RECEIVED')) { + if (status === 'REVERTED' || ((Date.now() - update.date) > 20 * 60 * 1000 && status === 'NOT_RECEIVED')) { this.metadata.splice(i--, 1); reprocess = true; return; diff --git a/src/builder/UserItem.ts b/src/builder/UserItem.ts index b45aeedd..61adb98d 100644 --- a/src/builder/UserItem.ts +++ b/src/builder/UserItem.ts @@ -69,7 +69,7 @@ export abstract class GeneralizedUserItem implements perUserStorable { promises.set(update, _block.then(data => { const status = data.status; const block = data.block_number; - if (status === 'REJECTED' || ((Date.now() - update.date) > 1000 * 60 * 60 && status === 'NOT_RECEIVED')) { + if (status === 'REVERTED' || ((Date.now() - update.date) > 1000 * 60 * 60 && status === 'NOT_RECEIVED')) { this.metadata[tokenName].updates.splice(i--, 1); reprocess = true; if (update.status.indexOf('TENTATIVE') !== -1) @@ -78,7 +78,7 @@ export abstract class GeneralizedUserItem implements perUserStorable { this.notifyBurnFailure({ tx_hash: update.tx_hash, token_name: tokenName }); return; } - if (update.status === 'TENTATIVE' && (status === 'PENDING' || status === 'ACCEPTED_ON_L2' || status === 'ACCEPTED_ON_L1')) { + if (update.status === 'TENTATIVE' && status === 'SUCCEEDED') { update.status = 'TENTATIVE_PENDING'; if (block > data.block_number) this.notifyMintPending({ tx_hash: update.tx_hash, token_name: tokenName }); diff --git a/src/chain/BlockchainProvider.ts b/src/chain/BlockchainProvider.ts index 70dfc4c4..679cb9c8 100644 --- a/src/chain/BlockchainProvider.ts +++ b/src/chain/BlockchainProvider.ts @@ -35,14 +35,14 @@ class BlockchainProvider { try { const data = await this.provider?.getTransactionReceipt(tx_hash); return { - block_number: data!.block_number, - status: data!.status, + block_number: data!.block_number as number, + status: (data!.execution_status || 'NOT_RECEIVED') as 'SUCCEEDED' | 'REVERTED' | 'NOT_RECEIVED', } } catch (_) { // Fail in a safe-way for calling code. return { block_number: undefined, - status: 'NOT_RECEIVED', + status: 'NOT_RECEIVED' as const, }; } }