Skip to content

Commit 3e88a21

Browse files
authored
Merge pull request #42 from aniket866/patch-1
Fixes issue 30
2 parents f526786 + 545c39d commit 3e88a21

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/contract-client.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,24 @@ export class ContractClient implements IContractClient {
8383

8484
private async approveToken(token: string, amount: bigint): Promise<void> {
8585
try {
86-
await this.writeContract({
86+
const hash = await this.writeContract({
8787
address: token as Address,
8888
abi: erc20Abi,
89-
functionName: 'approve',
90-
args: [this.contractAddress, amount]
91-
})
89+
functionName: "approve",
90+
args: [this.contractAddress, amount],
91+
});
92+
93+
if (!this.publicClient) {
94+
throw new Error("Public client is not available");
95+
}
96+
97+
await this.publicClient.waitForTransactionReceipt({ hash });
9298
} catch (error) {
9399
throw new Error(`Token approval failed: ${(error as Error).message}`);
94100
}
95101
}
96102

103+
97104
async isPoolInstantiated(token: Address): Promise<boolean> {
98105
return this.safeRead("isPoolInstantiated", false, async () => {
99106
const data = await this.publicClient!.readContract({
@@ -898,4 +905,4 @@ export class ContractClient implements IContractClient {
898905
const totalTime = (feeEvents[feeEvents.length - 1].timestamp - feeEvents[0].timestamp) / (60 * 60 * 24); //days
899906
return totalFees / (totalTime * Number(totalLiquidity));
900907
}
901-
}
908+
}

0 commit comments

Comments
 (0)