From 0d2fa5e836ce84da7478bd225bf320c8b5007e7f Mon Sep 17 00:00:00 2001 From: lordmike007 Date: Sun, 30 Jun 2024 22:39:46 +0530 Subject: [PATCH] fix: Made OP_Return as second output, fixed type errors --- app/btcintegration/page.tsx | 27 ++++++++++++++++++++------- app/btcintegration/xverse-utils.ts | 6 ++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/btcintegration/page.tsx b/app/btcintegration/page.tsx index f429a5d..81f8754 100644 --- a/app/btcintegration/page.tsx +++ b/app/btcintegration/page.tsx @@ -17,10 +17,23 @@ interface ConnectedAddressData { pubKey: string } +export type Params = { + contract: string + message: string + amount: number + tss: string +} + +declare global { + interface Window { + unisat: any + } +} + const BtcIntegration = () => { const [contractAddress, setContractAddress] = useState("") const [message, setMessage] = useState("") - const [amount, setAmount] = useState() + const [amount, setAmount] = useState() const [selectedWallet, setSelectedWallet] = useState("XDefi") const sendTransaction = async () => { @@ -50,7 +63,7 @@ const BtcIntegration = () => { } } - const callXDefi = async (params) => { + const callXDefi = async (params: Params) => { if (!window.xfi) return alert("XDEFI wallet not installed") const wallet = window.xfi window.xfi.bitcoin.changeNetwork("testnet") @@ -71,7 +84,7 @@ const BtcIntegration = () => { }, ], } - window.xfi.bitcoin.request(tx, (err, res) => { + window.xfi.bitcoin.request(tx, (err: Error, res: Response) => { if (err) { return alert(`Couldn't send transaction, ${JSON.stringify(err)}`) } else if (res) { @@ -80,7 +93,7 @@ const BtcIntegration = () => { }) } - const callUniSat = async (params) => { + const callUniSat = async (params: Params) => { if (!window.unisat) return alert("Unisat wallet not installed") try { await window.unisat.requestAccounts() @@ -94,7 +107,7 @@ const BtcIntegration = () => { } } - const callXverse = async (params) => { + const callXverse = async (params: Params) => { const response = await Wallet.request("getAccounts", { purposes: [AddressPurpose.Payment], message: "Test app wants to know your addresses!", @@ -128,7 +141,7 @@ const BtcIntegration = () => { type="number" value={amount} onChange={(e) => { - setAmount(e.target.value) + setAmount(Number(e.target.value)) }} placeholder="0" /> @@ -159,7 +172,7 @@ const BtcIntegration = () => {