Skip to content

Commit

Permalink
check if connected
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomas committed Dec 29, 2024
1 parent 5801f7a commit e89aca5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions react/react-ethers/src/components/ActionButtonList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const ActionButtonList = ({ sendHash, sendSignMsg, sendBalance }: Action
const { open } = useAppKit();
const { chainId } = useAppKitNetworkCore();
const { switchNetwork } = useAppKitNetwork();
const { address } = useAppKitAccount()
const { isConnected,address } = useAppKitAccount();
const { walletProvider } = useAppKitProvider<Provider>('eip155')

const handleDisconnect = async () => {
Expand Down Expand Up @@ -64,12 +64,16 @@ export const ActionButtonList = ({ sendHash, sendSignMsg, sendBalance }: Action
}
return (
<div >
<button onClick={() => open()}>Open</button>
<button onClick={handleDisconnect}>Disconnect</button>
<button onClick={() => switchNetwork(networks[1]) }>Switch</button>
<button onClick={handleSignMsg}>Sign msg</button>
<button onClick={handleSendTx}>Send tx</button>
<button onClick={handleGetBalance}>Get Balance</button>
{isConnected ? (
<div>
<button onClick={() => open()}>Open</button>
<button onClick={handleDisconnect}>Disconnect</button>
<button onClick={() => switchNetwork(networks[1]) }>Switch</button>
<button onClick={handleSignMsg}>Sign msg</button>
<button onClick={handleSendTx}>Send tx</button>
<button onClick={handleGetBalance}>Get Balance</button>
</div>
) : null}
</div>
)
}

0 comments on commit e89aca5

Please sign in to comment.