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

update wagmi #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"@near-wallet-selector/react-hook": "^8.9.15",
"@near-wallet-selector/sender": "^8.10.0",
"@near-wallet-selector/welldone-wallet": "^8.10.0",
"@web3modal/wagmi": "^5.1.11",
"@reown/appkit": "^1.6.9",
"@reown/appkit-adapter-wagmi": "^1.6.9",
"bootstrap": "^5",
"bootstrap-icons": "^1.11.3",
"near-api-js": "^5.0.1",
"next": "14.2.5",
"next": "15.2.1",
"react": "^18",
"react-dom": "^18",
"wagmi": "^2.13.3"
"react-dom": "^18"
},
"devDependencies": {
"encoding": "^0.1.13",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import { setupHereWallet } from '@near-wallet-selector/here-wallet';
import { setupNearMobileWallet } from '@near-wallet-selector/near-mobile-wallet';
import { setupWelldoneWallet } from '@near-wallet-selector/welldone-wallet';
import { WalletSelectorProvider } from '@near-wallet-selector/react-hook';
import { wagmiConfig, web3Modal } from '@/wallets/web3modal';
import { wagmiAdapter, web3Modal } from '@/wallets/web3modal';
import { Navigation } from '@/components/Navigation';
import { NetworkId, CounterContract } from '@/config';

const walletSelectorConfig = {
network: NetworkId,
createAccessKeyFor: CounterContract,
modules: [
setupEthereumWallets({ wagmiConfig, web3Modal, alwaysOnboardDuringSignIn: true }),
setupEthereumWallets({ wagmiConfig: wagmiAdapter.wagmiConfig, web3Modal }),
setupBitteWallet(),
setupMeteorWallet(),
setupMeteorWalletApp({contractId: CounterContract}),
Expand Down
72 changes: 38 additions & 34 deletions frontend/src/wallets/web3modal.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
import { injected,walletConnect } from '@wagmi/connectors';
import { createConfig,http, reconnect } from '@wagmi/core';
import { createWeb3Modal } from '@web3modal/wagmi';

import { EVMWalletChain,NetworkId } from '@/config';

// Config
const near = {
id: EVMWalletChain.chainId,
name: EVMWalletChain.name,
nativeCurrency: {
decimals: 18,
name: 'NEAR',
symbol: 'NEAR',
},
rpcUrls: {
default: { http: [EVMWalletChain.rpc] },
public: { http: [EVMWalletChain.rpc] },
},
blockExplorers: {
default: {
name: 'NEAR Explorer',
url: EVMWalletChain.explorer,
},
},
testnet: NetworkId === 'testnet',
};
import { createAppKit } from "@reown/appkit/react";
import { reconnect } from "@wagmi/core";
import { nearTestnet } from "@reown/appkit/networks";
import { WagmiAdapter } from "@reown/appkit-adapter-wagmi";

// Get your projectId at https://cloud.reown.com
const projectId = '5bb0fe33763b3bea40b8d69e4269b4ae';

export const wagmiConfig = createConfig({
chains: [near],
transports: { [near.id]: http() },
connectors: [walletConnect({ projectId, showQrModal: false }), injected({ shimDisconnect: true })],
const connectors = [
walletConnect({
projectId,
metadata: {
name: "Counters",
description: "Examples demonstrating integrations with NEAR blockchain",
url: "https://near.github.io/wallet-selector",
icons: ["https://near.github.io/wallet-selector/favicon.ico"],
},
showQrModal: false, // showQrModal must be false
}),
injected({ shimDisconnect: true }),
];

export const wagmiAdapter = new WagmiAdapter({
projectId,
connectors,
networks: [nearTestnet],
});

// Preserve login state on page reload
reconnect(wagmiConfig);
reconnect(wagmiAdapter.wagmiConfig);

// Modal for login
export const web3Modal = createWeb3Modal({ wagmiConfig, projectId });
export const web3Modal = createAppKit({
adapters: [wagmiAdapter],
projectId,
networks: [nearTestnet],
defaultNetwork: nearTestnet,
enableWalletConnect: true,
features: {
analytics: true,
swaps: false,
onramp: false,
email: false, // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA.
socials: false, // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA.
},
coinbasePreference: "eoaOnly", // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA.
});