Updated buy flux. Already able to lock.

This commit is contained in:
Filipe Soccol
2025-06-18 12:01:42 -03:00
parent fa2def812c
commit c7b2f1643c
10 changed files with 4157 additions and 3444 deletions

View File

@@ -8,18 +8,17 @@ export const addLock = async (
tokenAddress: string,
amount: number
): Promise<string> => {
const { address, abi, client } = await getContract();
const { address, abi, wallet, client } = await getContract();
const parsedAmount = parseEther(amount.toString());
const { request } = await client.simulateContract({
address,
abi,
functionName: "addLock",
args: [sellerAddress, tokenAddress, parsedAmount],
functionName: "lock",
args: [sellerAddress, tokenAddress, parsedAmount, [], []],
});
const hash = await client.writeContract(request);
console.log(wallet);
const hash = await wallet.writeContract(request);
const receipt = await client.waitForTransactionReceipt({ hash });
return receipt.status ? receipt.logs[0].topics[2] : "";
@@ -29,33 +28,33 @@ export const withdrawDeposit = async (
amount: string,
token: TokenEnum
): Promise<boolean> => {
const { address, abi, client } = await getContract();
const { address, abi, wallet, client } = await getContract();
const tokenAddress = getTokenAddress(token);
const { request } = await client.simulateContract({
address,
abi,
functionName: "withdrawDeposit",
args: [tokenAddress, parseEther(amount)],
functionName: "withdraw",
args: [tokenAddress, parseEther(amount), []],
});
const hash = await client.writeContract(request);
const hash = await wallet.writeContract(request);
const receipt = await client.waitForTransactionReceipt({ hash });
return receipt.status;
};
export const releaseLock = async (solicitation: any): Promise<any> => {
const { address, abi, client } = await getContract();
const { address, abi, wallet, client } = await getContract();
const { request } = await client.simulateContract({
address,
abi,
functionName: "releaseLock",
functionName: "release",
args: [solicitation.lockId, solicitation.e2eId],
});
const hash = await client.writeContract(request);
const hash = await wallet.writeContract(request);
return client.waitForTransactionReceipt({ hash });
};