Skip to content

Commit 441849d

Browse files
authored
Merge pull request #1305 from near/feat/update_examples
Feat/update examples
2 parents e19bf9a + 36df1c1 commit 441849d

37 files changed

+4346
-1238
lines changed

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

examples/angular/src/app/pages/wallet-selector/wallet-selector.component.ts

+44-29
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ import { setupMintbaseWallet } from "@near-wallet-selector/mintbase-wallet";
2828
import { setupBitteWallet } from "@near-wallet-selector/bitte-wallet";
2929
import { setupOKXWallet } from "@near-wallet-selector/okx-wallet";
3030
import { setupEthereumWallets } from "@near-wallet-selector/ethereum-wallets";
31-
import { createWeb3Modal } from "@web3modal/wagmi";
32-
import { reconnect, http, createConfig, type Config } from "@wagmi/core";
33-
import { type Chain } from "@wagmi/core/chains";
31+
import { WagmiAdapter } from "@reown/appkit-adapter-wagmi";
32+
import { createAppKit } from "@reown/appkit/react";
33+
import { defineChain } from "@reown/appkit/networks";
34+
import type { CreateConnectorFn } from "@wagmi/core";
3435
import { injected, walletConnect } from "@wagmi/connectors";
3536
import { CONTRACT_ID } from "../../../constants";
3637

@@ -41,11 +42,13 @@ declare global {
4142
}
4243
}
4344

44-
// Get a project ID at https://cloud.walletconnect.com
45+
// Get a project ID at https://cloud.reown.com
4546
const projectId = "30147604c5f01d0bc4482ab0665b5697";
4647

47-
const near: Chain = {
48+
const near = defineChain({
4849
id: 398,
50+
caipNetworkId: "eip155:398",
51+
chainNamespace: "eip155",
4952
name: "NEAR Protocol Testnet",
5053
nativeCurrency: {
5154
decimals: 18,
@@ -63,33 +66,42 @@ const near: Chain = {
6366
},
6467
},
6568
testnet: true,
66-
};
69+
});
6770

68-
const wagmiConfig: Config = createConfig({
69-
chains: [near],
70-
transports: {
71-
[near.id]: http(),
72-
},
73-
connectors: [
74-
walletConnect({
75-
projectId,
76-
metadata: {
77-
name: "NEAR Guest Book",
78-
description: "A guest book with comments stored on the NEAR blockchain",
79-
url: "https://near.github.io/wallet-selector",
80-
icons: ["https://near.github.io/wallet-selector/favicon.ico"],
81-
},
82-
showQrModal: false,
83-
}),
84-
injected({ shimDisconnect: true }),
85-
],
71+
const connectors: Array<CreateConnectorFn> = [
72+
walletConnect({
73+
projectId,
74+
metadata: {
75+
name: "NEAR Guest Book",
76+
description: "A guest book with comments stored on the NEAR blockchain",
77+
url: "https://near.github.io/wallet-selector",
78+
icons: ["https://near.github.io/wallet-selector/favicon.ico"],
79+
},
80+
showQrModal: false, // showQrModal must be false
81+
}),
82+
injected({ shimDisconnect: true }),
83+
];
84+
85+
const wagmiAdapter = new WagmiAdapter({
86+
projectId,
87+
connectors,
88+
networks: [near],
8689
});
87-
reconnect(wagmiConfig);
8890

89-
const web3Modal = createWeb3Modal({
90-
wagmiConfig: wagmiConfig,
91+
const web3Modal = createAppKit({
92+
adapters: [wagmiAdapter],
9193
projectId,
92-
enableOnramp: false,
94+
networks: [near],
95+
defaultNetwork: near,
96+
enableWalletConnect: true,
97+
features: {
98+
analytics: true,
99+
swaps: false,
100+
onramp: false,
101+
email: false, // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA.
102+
socials: false, // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA.
103+
},
104+
coinbasePreference: "eoaOnly", // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA.
93105
allWallets: "SHOW",
94106
});
95107

@@ -158,7 +170,10 @@ export class WalletSelectorComponent implements OnInit {
158170
setupNearMobileWallet(),
159171
setupMintbaseWallet({ contractId: CONTRACT_ID }),
160172
setupBitteWallet({ contractId: CONTRACT_ID }),
161-
setupEthereumWallets({ wagmiConfig, web3Modal }),
173+
setupEthereumWallets({
174+
wagmiConfig: wagmiAdapter.wagmiConfig,
175+
web3Modal,
176+
}),
162177
],
163178
});
164179

0 commit comments

Comments
 (0)