From 4ff8a9102050424175b9c278bc6fe16f8dda5ab5 Mon Sep 17 00:00:00 2001 From: Mahmoud Aboelenein Date: Fri, 22 Mar 2024 16:22:02 +0200 Subject: [PATCH] update test app code --- example/src/App.tsx | 34 +++++------------------- example/src/components/SendBtc/index.tsx | 4 +-- example/src/components/SendStx/index.tsx | 4 +-- 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/example/src/App.tsx b/example/src/App.tsx index f6ed0c2..152a0e5 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,4 +1,4 @@ -import { AddressPurpose, BitcoinNetworkType, getAddress, type Address } from 'sats-connect'; +import { BitcoinNetworkType, type Address } from 'sats-connect'; import WalletProvider from 'sats-connect'; import './App.css'; import { AddressDisplay, NetworkSelector, SendBtc, SendStx } from './components'; @@ -14,35 +14,15 @@ function App() { const isConnected = addressInfo.length > 0; const onConnect = async () => { - WalletProvider.request('getAccounts', null) - .then((response) => { - console.log(response); - }) - .then((err) => { - console.log(err); - }); - // getAddress({ - // payload: { - // purposes: [ - // AddressPurpose.Stacks, - // AddressPurpose.Payment, - // AddressPurpose.Ordinals, - // ], - // message: "My awesome dapp needs your address info", - // network: { - // type: network, - // }, - // }, - // onFinish: (response) => { - // setAddressInfo(response.addresses); - // }, - // onCancel: () => { - // alert("User cancelled the request"); - // }, - // }); + const response = await WalletProvider.request('getAccounts', null); + if (response.status === 'success') { + setAddressInfo(response.result); + console.log(response.result); + } }; const onDisconnect = () => { + WalletProvider.disconnect(); setAddressInfo([]); }; diff --git a/example/src/components/SendBtc/index.tsx b/example/src/components/SendBtc/index.tsx index 8bb5634..81dd4cd 100644 --- a/example/src/components/SendBtc/index.tsx +++ b/example/src/components/SendBtc/index.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { BitcoinNetworkType, RpcErrorCode, request } from 'sats-connect'; +import WalletProvider, { BitcoinNetworkType, RpcErrorCode } from 'sats-connect'; type Props = { network: BitcoinNetworkType; @@ -11,7 +11,7 @@ const SendBtc = ({ network }: Props) => { const [txnId, setTxnId] = useState(''); const onClick = async () => { - const response = await request('sendTransfer', { + const response = await WalletProvider.request('sendTransfer', { recipients: [ { address: address, diff --git a/example/src/components/SendStx/index.tsx b/example/src/components/SendStx/index.tsx index 6f0275f..67709ba 100644 --- a/example/src/components/SendStx/index.tsx +++ b/example/src/components/SendStx/index.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { BitcoinNetworkType, RpcErrorCode, request } from 'sats-connect'; +import WalletProvider, { BitcoinNetworkType, RpcErrorCode } from 'sats-connect'; type Props = { network: BitcoinNetworkType; @@ -12,7 +12,7 @@ const SendStx = ({ network }: Props) => { const [txnId, setTxnId] = useState(''); const onClick = async () => { - const response = await request('stx_transferStx', { + const response = await WalletProvider.request('stx_transferStx', { recipient: address, amount: +amount, memo: memo === '' ? undefined : memo,