Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion components/TopupPage/Deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export function Deposit() {
{hasExternalWallet && (
<Button
className="w-full px-4 py-2 rounded-md flex items-center justify-center gap-2 bg-grey-moss-900 font-archivo text-grey-eggshell hover:bg-grey-eggshell hover:text-grey-moss-900"
onClick={deposit}
onClick={async () => {
await deposit();
connectDisconnect();
}}
disabled={isDepositing}
>
{isDepositing ? "Depositing..." : "Deposit"}
Expand Down
16 changes: 13 additions & 3 deletions hooks/useTopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const useTopup = () => {
const { connectWallet } = useConnectWallet();

const currencyLabel = currency === "usdc" ? "USDC" : "ETH";
const hasExternalWallet = Boolean(externalWallet);
const hasExternalWallet = Boolean(externalWallet?.address);

const { deposit, isDepositing } = useDeposit({
currency,
Expand All @@ -30,11 +30,21 @@ const useTopup = () => {
};
}, [depositAmount, currency]);

const connectDisconnect = () => {
const connectDisconnect = async () => {
if (!hasExternalWallet) {
connectWallet();
} else {
externalWallet?.disconnect();
try {
const provider = await externalWallet?.getEthereumProvider();
if (provider) {
await provider.request({
method: "wallet_revokePermissions",
params: [{ eth_accounts: {} }],
});
}
} finally {
externalWallet?.disconnect();
}
}
};

Expand Down
8 changes: 0 additions & 8 deletions types/global.d.ts

This file was deleted.