Skip to content

Commit 81884b2

Browse files
committed
Merge pull-request #1081
2 parents b6192df + 27c5cbc commit 81884b2

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

examples/react-wallet-kit/src/components/demo/DemoPanel.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default function DemoPanel() {
5353
handleImportWallet,
5454
handleConnectExternalWallet,
5555
fetchWalletProviders,
56+
handleOnRamp,
5657
} = useTurnkey();
5758

5859
const { pushPage } = useModal();
@@ -112,6 +113,18 @@ export default function DemoPanel() {
112113
}
113114
}, [wallets]);
114115

116+
const handleAddFunds = async () => {
117+
try {
118+
await handleOnRamp({
119+
onrampProvider: "FIAT_ON_RAMP_PROVIDER_MOONPAY",
120+
walletAccount: selectedWalletAccount!,
121+
sandboxMode: true,
122+
});
123+
} catch (error) {
124+
handleError(error);
125+
}
126+
};
127+
115128
function truncateAddress(address: string) {
116129
return `${address.slice(0, 4)}...${address.slice(-4)}`;
117130
}
@@ -385,6 +398,13 @@ export default function DemoPanel() {
385398
>
386399
Sign Message
387400
</Button>
401+
402+
<Button
403+
className="bg-primary-light dark:bg-primary-dark text-primary-text-light dark:text-primary-text-dark rounded-lg px-4 py-2 active:scale-95 transition-transform cursor-pointer"
404+
onClick={handleAddFunds}
405+
>
406+
Add Funds
407+
</Button>
388408
{selectedWallet?.source === WalletSource.Embedded && (
389409
<>
390410
<hr className="border-draggable-background-light dark:border-draggable-background-dark" />

packages/react-wallet-kit/src/providers/client/Provider.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5331,7 +5331,11 @@ export const ClientProvider: React.FC<ClientProviderProps> = ({
53315331
pollingRef.current = null;
53325332
}
53335333
};
5334-
5334+
useEffect(() => {
5335+
return () => {
5336+
cleanup();
5337+
};
5338+
}, []);
53355339
const action = async () => {
53365340
try {
53375341
let onRampWindow: Window | null = null;

0 commit comments

Comments
 (0)