Skip to content

Commit

Permalink
update test app code
Browse files Browse the repository at this point in the history
  • Loading branch information
m-aboelenein committed Mar 22, 2024
1 parent dfa7e80 commit 4ff8a91
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
34 changes: 7 additions & 27 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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([]);
};

Expand Down
4 changes: 2 additions & 2 deletions example/src/components/SendBtc/index.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions example/src/components/SendStx/index.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 4ff8a91

Please sign in to comment.