Skip to content

Commit

Permalink
Fix frontend optimistic processing for new transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
wraitii committed Jan 24, 2024
1 parent 9dca0a2 commit 66ef904
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/builder/ChainBriqs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/builder/ChainBriqsLegacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/builder/UserItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 });
Expand Down
6 changes: 3 additions & 3 deletions src/chain/BlockchainProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}
Expand Down

0 comments on commit 66ef904

Please sign in to comment.