Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Fix/eip1559 #2476

Merged
merged 6 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions packages/app/hooks/creator-token/use-creator-token-approve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,36 @@ export const useApproveToken = () => {
maxFeePerGas,
maxPriorityFeePerGas,
});
if (maxFeePerGas) {
const { request } = await publicClient.simulateContract({
address: usdcAddress,
account: walletAddress,
abi: erc20Abi,
functionName: "approve",
args: [creatorTokenContract, maxPrice],
chain: chain,
maxFeePerGas,
maxPriorityFeePerGas,
});
const { request } = await publicClient.simulateContract({
address: usdcAddress,
account: walletAddress,
abi: erc20Abi,
functionName: "approve",
args: [creatorTokenContract, maxPrice],
chain: chain,
});

const hash = await walletClient?.writeContract(request);
console.log("approve transaction hash ", hash);
if (hash) {
const transaction = await publicClient.waitForTransactionReceipt({
hash,
pollingInterval: 2000,
confirmations: 3,
});
if (transaction.status === "success") {
return true;
}
//@ts-ignore
const hash = await walletClient?.writeContract({
...request,
type: "eip1559",
maxFeePerGas,
maxPriorityFeePerGas,
});
console.log("approve transaction hash ", hash);
if (hash) {
const transaction = await publicClient.waitForTransactionReceipt({
hash,
pollingInterval: 2000,
confirmations: 3,
});
if (transaction.status === "success") {
return true;
}
}
} else {
return true;
}
} else {
return true;
}
}
);
Expand Down
15 changes: 6 additions & 9 deletions packages/app/hooks/creator-token/use-creator-token-buy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ export const useCreatorTokenBuy = (params: {
functionName: "buy",
args: [priceToBuyNext.data?.totalPrice],
chain: baseChain,
type: "eip1559",
maxFeePerGas,
maxPriorityFeePerGas,
});
requestPayload = request;
console.log("token amount 1 simulation ", request);
Expand All @@ -105,19 +102,19 @@ export const useCreatorTokenBuy = (params: {
functionName: "bulkBuy",
args: [tokenAmount, priceToBuyNext.data?.totalPrice],
chain: baseChain,
type: "eip1559",
maxFeePerGas,
maxPriorityFeePerGas,
});
console.log("bulk buy request", request);
requestPayload = request;
}

console.log("simulate ", requestPayload);

const transactionHash = await walletClient?.writeContract?.(
requestPayload
);
const transactionHash = await walletClient?.writeContract?.({
...requestPayload,
type: "eip1559",
maxFeePerGas,
maxPriorityFeePerGas,
});

console.log("Buy transaction hash ", requestPayload);
if (transactionHash) {
Expand Down
Loading