Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when no wallet is attached to the browser #110

Merged
merged 4 commits into from
Apr 19, 2024
Merged
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
Binary file modified bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions context/Web3Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { http, createConfig } from "wagmi";
import { injected } from "wagmi/connectors";
import { walletConnect } from "wagmi/connectors";
import { walletConnect, coinbaseWallet } from "wagmi/connectors";
import {
PUB_APP_DESCRIPTION,
PUB_APP_NAME,
Expand All @@ -10,6 +10,7 @@ import {
PUB_WALLET_ICON,
PUB_WEB3_ENDPOINT,
} from "@/constants";
import { mainnet } from "viem/chains";

// wagmi config
const metadata = {
Expand All @@ -20,18 +21,18 @@ const metadata = {
};

export const config = createConfig({
chains: [PUB_CHAIN],
chains: [PUB_CHAIN, mainnet],
ssr: true,
transports: {
[PUB_CHAIN.id]: http(PUB_WEB3_ENDPOINT, { batch: true }),
[mainnet.id]: http(PUB_WEB3_ENDPOINT, { batch: true }),
},
connectors: [
walletConnect({
projectId: PUB_WALLET_CONNECT_PROJECT_ID,
metadata,
showQrModal: false,
}),
injected({ shimDisconnect: true }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we want to use the injected one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, it comes by default with the Metamask id. If you add it, it shows metamask twice

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, nice catch then!

// coinbaseWallet({ appName: metadata.name, appLogoUrl: metadata.icons[0] }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Not enabled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right now coinbaseWallet only works without SSR. If we enable it, it fulls the console with errors.
We can enable it if we go to prod, but at least when developing it's quite annoying

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't find a fix then we should consider rolling back enabling SSR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The warning/error appears in general in Next, doesn't matter if SSR in wagmi or not.

To be clear, it does work. It just shows an error in the console because the backend fails to run that piece of the code.

],
});
9 changes: 9 additions & 0 deletions context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ createWeb3Modal({
wagmiConfig: config,
projectId: PUB_WALLET_CONNECT_PROJECT_ID,
enableAnalytics: false, // Optional - defaults to your Cloud configuration
enableOnramp: true, // Optional
themeMode: "light",
allWallets: "SHOW",
featuredWalletIds: [
"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",
"1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",
"18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1",
"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",
],
});

export function RootContextProvider({ children, initialState }: { children: ReactNode; initialState?: State }) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@tanstack/react-query": "^5.28.8",
"@tanstack/react-query-persist-client": "^5.28.8",
"@typescript-eslint/eslint-plugin": "latest",
"@web3modal/wagmi": "^4.1.1",
"@web3modal/wagmi": "^4.1.9",
"classnames": "^2.5.1",
"dayjs": "^1.11.10",
"dompurify": "^3.0.11",
Expand All @@ -38,7 +38,7 @@
"react-dom": "^18.2.0",
"tailwindcss-fluid-type": "^2.0.6",
"viem": "^2.9.2",
"wagmi": "^2.5.12"
"wagmi": "^2.5.20"
},
"devDependencies": {
"@aragon/osx-commons-configs": "^0.2.0",
Expand Down
Loading
Loading