Skip to content

Commit

Permalink
fix: withdrawal (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
Romsters authored Jul 26, 2024
1 parent 02c0b98 commit 3c61403
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion composables/zksync/useTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default (getSigner: () => Promise<Signer | undefined>, getProvider: () =>
status.value = "processing";
const signer = await getSigner();
if (!signer) throw new Error("zkSync Signer is not available");
const provider = getProvider();

const getRequiredBridgeAddress = async () => {
if (transaction.tokenAddress === ETH_TOKEN.address) return undefined;
Expand All @@ -48,7 +49,8 @@ export default (getSigner: () => Promise<Signer | undefined>, getProvider: () =>
await validateAddress(transaction.to);

status.value = "waiting-for-signature";
const tx = await signer[transaction.type === "transfer" ? "transfer" : "withdraw"]({
const txRequest = await provider[transaction.type === "transfer" ? "getTransferTx" : "getWithdrawTx"]({
from: await signer.getAddress(),
to: transaction.to,
token: transaction.tokenAddress === ETH_TOKEN.address ? ETH_TOKEN.l1Address! : transaction.tokenAddress,
amount: transaction.amount,
Expand All @@ -59,6 +61,9 @@ export default (getSigner: () => Promise<Signer | undefined>, getProvider: () =>
},
});

const txResponse = await signer.sendTransaction(txRequest);
const tx = getProvider()._wrapTransaction(txResponse);

transactionHash.value = tx.hash;
status.value = "done";

Expand Down

0 comments on commit 3c61403

Please sign in to comment.