From 20a0d3140f34e845b8c649e7c11dc53ab0f4fb3d Mon Sep 17 00:00:00 2001 From: Gonzalo D'Elia Date: Mon, 5 Aug 2024 13:29:11 -0300 Subject: [PATCH] Add initiate withdrawal action (#15) * Add initiateWithdrawal action * 1.4.0 --- package-lock.json | 4 ++-- package.json | 2 +- src/actions/wallet/bitcoin-tunnel-manager.ts | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3a974f4..ab3aa91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hemi-viem", - "version": "1.3.0", + "version": "1.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hemi-viem", - "version": "1.3.0", + "version": "1.4.0", "license": "MIT", "devDependencies": { "husky": "4.3.8", diff --git a/package.json b/package.json index 17aa37c..c2a777c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hemi-viem", - "version": "1.3.0", + "version": "1.4.0", "description": "Viem extension for the Hemi Network", "bugs": { "url": "https://github.com/hemilabs/hemi-viem/issues" diff --git a/src/actions/wallet/bitcoin-tunnel-manager.ts b/src/actions/wallet/bitcoin-tunnel-manager.ts index cdf13b3..ca9a6cf 100644 --- a/src/actions/wallet/bitcoin-tunnel-manager.ts +++ b/src/actions/wallet/bitcoin-tunnel-manager.ts @@ -21,3 +21,23 @@ export function confirmDeposit( functionName: "confirmDeposit", }); } + +export function initiateWithdrawal( + client: Client, + parameters: { + amount: bigint; + btcAddress: string; + from: Address; + ownerAddress: Address; + }, +) { + const { amount, btcAddress, from, ownerAddress } = parameters; + return writeContract(client, { + abi: bitcoinTunnelManagerAbi, + account: from, + address: bitcoinTunnelManagerAddresses[client.chain!.id], + args: [btcAddress, amount, ownerAddress], + chain: client.chain!, + functionName: "initiateWithdrawal", + }); +}