Skip to content

Commit

Permalink
Merge pull request #372 from xmtp-labs/dj/extend-wallets
Browse files Browse the repository at this point in the history
Extend wallets
  • Loading branch information
daria-github authored Sep 27, 2023
2 parents 2707dd9 + e6f240c commit 6181fb8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/controllers/SideNavController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const SideNavController = () => {
const resetXmtpState = useXmtpStore((s) => s.resetXmtpState);
const clientName = useXmtpStore((s) => s.clientName);
const clientAvatar = useXmtpStore((s) => s.clientAvatar);
const { disconnect: disconnectWagmi, reset: resetWagmi } = useDisconnect();
const { reset: resetWagmi } = useDisconnect();

return (
<SideNav
Expand All @@ -20,7 +20,6 @@ export const SideNavController = () => {
onDisconnect={() => {
void disconnect();
wipeKeys(client?.address ?? "");
disconnectWagmi();
resetWagmi();
resetXmtpState();
}}
Expand Down
33 changes: 27 additions & 6 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ import "./polyfills";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "@rainbow-me/rainbowkit/styles.css";
import { getDefaultWallets, RainbowKitProvider } from "@rainbow-me/rainbowkit";
import {
connectorsForWallets,
RainbowKitProvider,
} from "@rainbow-me/rainbowkit";
import { configureChains, createClient, WagmiConfig } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
import { attachmentContentTypeConfig, XMTPProvider } from "@xmtp/react-sdk";
import { mainnet } from "wagmi/chains";
import { infuraProvider } from "wagmi/providers/infura";
import {
coinbaseWallet,
metaMaskWallet,
rainbowWallet,
trustWallet,
walletConnectWallet,
} from "@rainbow-me/rainbowkit/wallets";
import App from "./controllers/AppController";
import { isAppEnvDemo } from "./helpers";
import { mockConnector } from "./helpers/mockConnector";
Expand All @@ -24,11 +34,22 @@ const { chains, provider, webSocketProvider } = configureChains(
],
);

const { connectors } = getDefaultWallets({
appName: "XMTP Inbox Web",
projectId: import.meta.env.VITE_PROJECT_ID,
chains,
});
const projectId = import.meta.env.VITE_PROJECT_ID;
const appName = "XMTP Inbox Web";

const connectors = connectorsForWallets([
{
groupName: "Wallets",
wallets: [
// Alpha order
coinbaseWallet({ appName, chains }),
metaMaskWallet({ chains, projectId }),
rainbowWallet({ chains, projectId }),
trustWallet({ projectId, chains }),
walletConnectWallet({ chains, projectId }),
],
},
]);

const wagmiDemoClient = createClient({
autoConnect: true,
Expand Down
3 changes: 1 addition & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const OnboardingPage = () => {
const { openConnectModal } = useConnectModal();
const { client, isLoading, status, setStatus, resolveCreate, resolveEnable } =
useInitXmtpClient();
const { disconnect: disconnectWagmi, reset: resetWagmi } = useDisconnect();
const { reset: resetWagmi } = useDisconnect();
const { disconnect: disconnectClient } = useClient();

useEffect(() => {
Expand Down Expand Up @@ -61,7 +61,6 @@ const OnboardingPage = () => {
}
setStatus(undefined);
wipeKeys(address ?? "");
disconnectWagmi();
resetWagmi();
resetXmtpState();
}}
Expand Down

1 comment on commit 6181fb8

@vercel
Copy link

@vercel vercel bot commented on 6181fb8 Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.