Skip to content

Commit bce9f9f

Browse files
lucaspluchonhzhu
authored andcommitted
fix: added batch call + delete useless on-chain call (#75)
1 parent 230bad9 commit bce9f9f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function parseSwap({
3232
transactionHash: Address;
3333
smartContractWallet?: Address;
3434
}) {
35-
const chainId = await publicClient.getChainId();
35+
const chainId = publicClient.chain.id;
3636

3737
if (!isChainIdSupported(chainId)) {
3838
throw new Error(`chainId ${chainId} is unsupported…`);
@@ -47,9 +47,11 @@ export async function parseSwap({
4747
},
4848
}));
4949

50-
const trace = await client.traceCall({ hash });
51-
52-
const transaction = await publicClient.getTransaction({ hash });
50+
const [trace, transaction, transactionReceipt] = await Promise.all([
51+
client.traceCall({ hash }),
52+
publicClient.getTransaction({ hash }),
53+
publicClient.getTransactionReceipt({ hash }),
54+
]);
5355

5456
const { from: taker, value, to } = transaction;
5557

@@ -59,8 +61,6 @@ export async function parseSwap({
5961
recipient: taker,
6062
});
6163

62-
const transactionReceipt = await publicClient.getTransactionReceipt({ hash });
63-
6464
if (transactionReceipt.status === "reverted") {
6565
const chain = SUPPORTED_CHAINS.find((chain) => chain.id === chainId);
6666
const message = `Unable to parse. Transaction ${hash} on ${chain?.name} has reverted.`;

0 commit comments

Comments
 (0)