Skip to content

Commit

Permalink
fix: eth tx tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Nov 18, 2023
1 parent 31fc3bb commit 7a15634
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@bgd-labs/frontend-web3-utils",
"description": "Frontend utilities common to multiple Web3 projects",
"version": "0.4.85",
"version": "0.4.86",
"author": "BGD labs",
"license": "MIT",
"private": false,
Expand Down
5 changes: 1 addition & 4 deletions src/web3/adapters/EthereumAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ export class EthereumAdapter<T extends BaseTx> implements AdapterInterface<T> {
for (let i = 0; i < retryCount; i++) {
try {
const tx = await client.getTransaction({ hash: txData.hash });

console.log('tx in start tx', tx);

// If the transaction is found, wait for the receipt
await this.waitForTxReceipt(txData.hash, tx.nonce);
return; // Exit the function if successful
Expand All @@ -69,7 +66,7 @@ export class EthereumAdapter<T extends BaseTx> implements AdapterInterface<T> {
}
};

private waitForTxReceipt = async (txHash: Hex, txNonce?: number) => {
waitForTxReceipt = async (txHash: Hex, txNonce?: number) => {
const chainId = this.get().transactionsPool[txHash].chainId;
const client = this.get().clients[chainId];
let txWasReplaced = false;
Expand Down
8 changes: 7 additions & 1 deletion src/web3/store/transactionsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,13 @@ export function createTransactionsSlice<T extends BaseTx>({
const txPool = get().addTXToPool(txInitialParams);
const adapter = get().adapters[txInitialParams.adapter];
if (adapter) {
adapter.startTxTracking(txPool[txInitialParams.txKey]);
if (adapter instanceof EthereumAdapter) {
if (isHex(txInitialParams.txKey)) {
adapter.waitForTxReceipt(txInitialParams.txKey);
}
} else {
adapter.startTxTracking(txPool[txInitialParams.txKey]);
}
}
return txPool[txInitialParams.txKey];
} else {
Expand Down

0 comments on commit 7a15634

Please sign in to comment.