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
19 changes: 19 additions & 0 deletions components/WalletConnectButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { useState } from "react";
import { connectWallet } from "../lib/reownClient";

const WalletConnectButton = () => {
const [connected, setConnected] = useState(false);

const handleConnect = async () => {
const session = await connectWallet();
if (session) setConnected(true);
};

return (
<button onClick={handleConnect}>
{connected ? "Wallet Connected ✅" : "Connect Wallet"}
</button>
);
};

export default WalletConnectButton;
10 changes: 10 additions & 0 deletions index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import WalletConnectButton from "./components/WalletConnectButton";

function App() {
return (
<div>
<h1>Minswap Wallet Connect Integration</h1>
<WalletConnectButton />
</div>
);
}
17 changes: 17 additions & 0 deletions lib/reownClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { CoreClient, AppKit } from "@reown/appkit";

export const initializeReown = async () => {
await CoreClient.initialize({ projectId: "180a7164cfa9e5388daf1160841f65a0" });
await AppKit.initialize({ init: CoreClient });
};

export const connectWallet = async () => {
try {
const session = await AppKit.Modal.open();
console.log("Wallet connected:", session);
return session;
} catch (err) {
console.error(err);
return null;
}
};