create-near-app 7.0.3 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +1 -2
- package/dist/make.js +3 -7
- package/dist/messages.js +1 -1
- package/dist/tracking.js +32 -15
- package/dist/user-input.js +9 -20
- package/package.json +3 -4
- package/templates/frontend/next-app/package.json +21 -13
- package/templates/frontend/next-app/src/app/hello-near/page.js +1 -1
- package/templates/frontend/next-app/src/app/layout.js +3 -4
- package/templates/frontend/next-app/src/components/navigation.js +1 -1
- package/templates/frontend/next-app/src/config.js +18 -1
- package/templates/frontend/next-app/src/wallets/near.js +48 -11
- package/templates/frontend/next-app/src/wallets/web3modal.js +44 -0
- package/templates/frontend/next-page/package.json +21 -13
- package/templates/frontend/next-page/src/components/navigation.js +1 -1
- package/templates/frontend/next-page/src/config.js +18 -1
- package/templates/frontend/next-page/src/pages/_app.js +3 -4
- package/templates/frontend/next-page/src/pages/hello-near/index.js +1 -1
- package/templates/frontend/next-page/src/wallets/near.js +48 -11
- package/templates/frontend/next-page/src/wallets/web3modal.js +44 -0
- package/templates/frontend/components/next-app/package.json +0 -42
- package/templates/frontend/components/next-app/src/app/hello-components/page.js +0 -46
- package/templates/frontend/components/next-app/src/components/cards.js +0 -43
- package/templates/frontend/components/next-app/src/components/vm.js +0 -31
- package/templates/frontend/components/next-app/src/config.js +0 -23
- package/templates/frontend/components/next-app/src/wallets/eth.ts +0 -289
- package/templates/frontend/components/next-page/package.json +0 -42
- package/templates/frontend/components/next-page/src/components/cards.js +0 -43
- package/templates/frontend/components/next-page/src/components/vm.js +0 -29
- package/templates/frontend/components/next-page/src/config.js +0 -23
- package/templates/frontend/components/next-page/src/pages/hello-components/index.js +0 -46
- package/templates/frontend/components/next-page/src/wallets/eth.ts +0 -289
- package/templates/frontend/next-app/src/context.js +0 -13
- package/templates/frontend/next-page/src/context.js +0 -13
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
-
import { distinctUntilChanged, map } from 'rxjs';
|
|
3
2
|
|
|
4
3
|
// near api js
|
|
5
|
-
import { providers } from 'near-api-js';
|
|
4
|
+
import { providers, utils } from 'near-api-js';
|
|
6
5
|
|
|
7
6
|
// wallet selector
|
|
8
7
|
import '@near-wallet-selector/modal-ui/styles.css';
|
|
@@ -15,6 +14,10 @@ import { setupMeteorWallet } from '@near-wallet-selector/meteor-wallet';
|
|
|
15
14
|
import { setupSender } from '@near-wallet-selector/sender';
|
|
16
15
|
import { setupBitteWallet } from '@near-wallet-selector/bitte-wallet';
|
|
17
16
|
|
|
17
|
+
// ethereum wallets
|
|
18
|
+
import { wagmiConfig, web3Modal } from '@/wallets/web3modal';
|
|
19
|
+
import { setupEthereumWallets } from "@near-wallet-selector/ethereum-wallets";
|
|
20
|
+
|
|
18
21
|
const THIRTY_TGAS = '30000000000000';
|
|
19
22
|
const NO_DEPOSIT = '0';
|
|
20
23
|
|
|
@@ -48,6 +51,7 @@ export class Wallet {
|
|
|
48
51
|
setupMeteorWallet(),
|
|
49
52
|
setupSender(),
|
|
50
53
|
setupBitteWallet(),
|
|
54
|
+
setupEthereumWallets({ wagmiConfig, web3Modal, alwaysOnboardDuringSignIn: true }),
|
|
51
55
|
],
|
|
52
56
|
});
|
|
53
57
|
|
|
@@ -55,15 +59,10 @@ export class Wallet {
|
|
|
55
59
|
const isSignedIn = walletSelector.isSignedIn();
|
|
56
60
|
const accountId = isSignedIn ? walletSelector.store.getState().accounts[0].accountId : '';
|
|
57
61
|
|
|
58
|
-
walletSelector.store.observable
|
|
59
|
-
.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
63
|
-
.subscribe(accounts => {
|
|
64
|
-
const signedAccount = accounts.find((account) => account.active)?.accountId;
|
|
65
|
-
accountChangeHook(signedAccount);
|
|
66
|
-
});
|
|
62
|
+
walletSelector.store.observable.subscribe(async (state) => {
|
|
63
|
+
const signedAccount = state?.accounts.find(account => account.active)?.accountId;
|
|
64
|
+
accountChangeHook(signedAccount || '');
|
|
65
|
+
});
|
|
67
66
|
|
|
68
67
|
return accountId;
|
|
69
68
|
};
|
|
@@ -152,6 +151,12 @@ export class Wallet {
|
|
|
152
151
|
return providers.getTransactionLastResult(transaction);
|
|
153
152
|
};
|
|
154
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Gets the balance of an account
|
|
156
|
+
* @param {string} accountId - the account id to get the balance of
|
|
157
|
+
* @returns {Promise<number>} - the balance of the account
|
|
158
|
+
*
|
|
159
|
+
*/
|
|
155
160
|
getBalance = async (accountId) => {
|
|
156
161
|
const walletSelector = await this.selector;
|
|
157
162
|
const { network } = walletSelector.options;
|
|
@@ -167,12 +172,44 @@ export class Wallet {
|
|
|
167
172
|
return account.amount ? Number(utils.format.formatNearAmount(account.amount)) : 0;
|
|
168
173
|
};
|
|
169
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Signs and sends transactions
|
|
177
|
+
* @param {Object[]} transactions - the transactions to sign and send
|
|
178
|
+
* @returns {Promise<Transaction[]>} - the resulting transactions
|
|
179
|
+
*
|
|
180
|
+
*/
|
|
170
181
|
signAndSendTransactions = async ({ transactions }) => {
|
|
171
182
|
const selectedWallet = await (await this.selector).wallet();
|
|
172
183
|
return selectedWallet.signAndSendTransactions({ transactions });
|
|
173
184
|
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
*
|
|
188
|
+
* @param {string} accountId
|
|
189
|
+
* @returns {Promise<Object[]>} - the access keys for the
|
|
190
|
+
*/
|
|
191
|
+
getAccessKeys = async (accountId) => {
|
|
192
|
+
const walletSelector = await this.selector;
|
|
193
|
+
const { network } = walletSelector.options;
|
|
194
|
+
const provider = new providers.JsonRpcProvider({ url: network.nodeUrl });
|
|
195
|
+
|
|
196
|
+
// Retrieve account state from the network
|
|
197
|
+
const keys = await provider.query({
|
|
198
|
+
request_type: 'view_access_key_list',
|
|
199
|
+
account_id: accountId,
|
|
200
|
+
finality: 'final',
|
|
201
|
+
});
|
|
202
|
+
return keys.keys;
|
|
203
|
+
};
|
|
174
204
|
}
|
|
175
205
|
|
|
206
|
+
/**
|
|
207
|
+
* @typedef NearContext
|
|
208
|
+
* @property {import('./wallets/near').Wallet} wallet Current wallet
|
|
209
|
+
* @property {string} signedAccountId The AccountId of the signed user
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
/** @type {import ('react').Context<NearContext>} */
|
|
176
213
|
export const NearContext = createContext({
|
|
177
214
|
wallet: undefined,
|
|
178
215
|
signedAccountId: '',
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { NetworkId, EVMWalletChain } from '@/config';
|
|
2
|
+
import { reconnect, http, createConfig } from "@wagmi/core";
|
|
3
|
+
import { walletConnect, injected } from "@wagmi/connectors";
|
|
4
|
+
import { createWeb3Modal } from "@web3modal/wagmi";
|
|
5
|
+
|
|
6
|
+
// Config
|
|
7
|
+
const near = {
|
|
8
|
+
id: EVMWalletChain.chainId,
|
|
9
|
+
name: EVMWalletChain.name,
|
|
10
|
+
nativeCurrency: {
|
|
11
|
+
decimals: 18,
|
|
12
|
+
name: "NEAR",
|
|
13
|
+
symbol: "NEAR",
|
|
14
|
+
},
|
|
15
|
+
rpcUrls: {
|
|
16
|
+
default: { http: [EVMWalletChain.rpc] },
|
|
17
|
+
public: { http: [EVMWalletChain.rpc] },
|
|
18
|
+
},
|
|
19
|
+
blockExplorers: {
|
|
20
|
+
default: {
|
|
21
|
+
name: "NEAR Explorer",
|
|
22
|
+
url: EVMWalletChain.explorer,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
testnet: NetworkId === "testnet",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Get your projectId at https://cloud.reown.com
|
|
29
|
+
const projectId = '5bb0fe33763b3bea40b8d69e4269b4ae';
|
|
30
|
+
|
|
31
|
+
export const wagmiConfig = createConfig({
|
|
32
|
+
chains: [near],
|
|
33
|
+
transports: { [near.id]: http() },
|
|
34
|
+
connectors: [
|
|
35
|
+
walletConnect({ projectId, showQrModal: false }),
|
|
36
|
+
injected({ shimDisconnect: true }),
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Preserve login state on page reload
|
|
41
|
+
reconnect(wagmiConfig);
|
|
42
|
+
|
|
43
|
+
// Modal for login
|
|
44
|
+
export const web3Modal = createWeb3Modal({ wagmiConfig, projectId });
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hello-near",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"engines": {
|
|
6
|
-
"node": ">=18"
|
|
7
|
-
},
|
|
8
|
-
"scripts": {
|
|
9
|
-
"dev": "next dev",
|
|
10
|
-
"build": "next build",
|
|
11
|
-
"start": "next start",
|
|
12
|
-
"lint": "next lint"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@near-wallet-selector/core": "^8.9.7",
|
|
16
|
-
"@near-wallet-selector/here-wallet": "^8.9.7",
|
|
17
|
-
"@near-wallet-selector/modal-ui": "^8.9.7",
|
|
18
|
-
"@near-wallet-selector/my-near-wallet": "^8.9.7",
|
|
19
|
-
"@web3-onboard/core": "^2.21.5",
|
|
20
|
-
"@web3-onboard/injected-wallets": "^2.10.15",
|
|
21
|
-
"@web3-onboard/ledger": "^2.6.0",
|
|
22
|
-
"@web3-onboard/react": "^2.8.16",
|
|
23
|
-
"@web3-onboard/walletconnect": "^2.5.4",
|
|
24
|
-
"base64-js": "^1.5.1",
|
|
25
|
-
"bootstrap": "^5.3.3",
|
|
26
|
-
"bootstrap-icons": "^1.11.3",
|
|
27
|
-
"ieee754": "^1.2.1",
|
|
28
|
-
"near-api-js": "^3.0.4",
|
|
29
|
-
"near-social-vm": "github:gagdiez/VM",
|
|
30
|
-
"next": "14.2.0",
|
|
31
|
-
"pino-pretty": "^11.0.0",
|
|
32
|
-
"react": "^18",
|
|
33
|
-
"react-dom": "^18"
|
|
34
|
-
},
|
|
35
|
-
"overrides": {
|
|
36
|
-
"near-api-js": "^3.0.4"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"eslint": "^8.57.0",
|
|
40
|
-
"eslint-config-next": "14.2.2"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import dynamic from 'next/dynamic';
|
|
2
|
-
|
|
3
|
-
import styles from '@/app/app.module.css';
|
|
4
|
-
import { Cards } from '@/components/cards';
|
|
5
|
-
import { Components } from '@/config';
|
|
6
|
-
|
|
7
|
-
const Component = dynamic(() => import('@/components/vm'), {
|
|
8
|
-
ssr: false,
|
|
9
|
-
loading: () => <p>Loading Component...</p>,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export default function HelloComponents() {
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
<main className={styles.main}>
|
|
17
|
-
<div className={styles.description}>
|
|
18
|
-
<p>
|
|
19
|
-
Loading components from:
|
|
20
|
-
<code className={styles.code}>{Components.socialDB}</code>
|
|
21
|
-
</p>
|
|
22
|
-
</div>
|
|
23
|
-
<div className={styles.center}>
|
|
24
|
-
<h1>
|
|
25
|
-
<code>Multi-chain</code> Components Made Simple
|
|
26
|
-
</h1>
|
|
27
|
-
</div>
|
|
28
|
-
<div className="row">
|
|
29
|
-
<div className="col-6">
|
|
30
|
-
<Component src={Components.HelloNear} />
|
|
31
|
-
<p className="my-4"> </p>
|
|
32
|
-
<Component src={Components.LoveNear} />
|
|
33
|
-
</div>
|
|
34
|
-
<div className="col-6">
|
|
35
|
-
<Component src={Components.Lido} />
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
<hr />
|
|
39
|
-
|
|
40
|
-
<div className={styles.grid}>
|
|
41
|
-
<Cards />
|
|
42
|
-
</div>
|
|
43
|
-
</main>
|
|
44
|
-
</>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import Link from 'next/link';
|
|
2
|
-
|
|
3
|
-
import styles from '@/app/app.module.css';
|
|
4
|
-
|
|
5
|
-
export const Cards = () => {
|
|
6
|
-
return (
|
|
7
|
-
<div className={styles.grid}>
|
|
8
|
-
<Link
|
|
9
|
-
href="https://docs.near.org/build/web3-apps/quickstart"
|
|
10
|
-
className={styles.card}
|
|
11
|
-
target='_blank'
|
|
12
|
-
rel="noopener noreferrer"
|
|
13
|
-
>
|
|
14
|
-
<h2>
|
|
15
|
-
Near Docs <span>-></span>
|
|
16
|
-
</h2>
|
|
17
|
-
<p>Learn how this application works, and what you can build on Near.</p>
|
|
18
|
-
</Link>
|
|
19
|
-
|
|
20
|
-
<Link
|
|
21
|
-
href="/hello-near"
|
|
22
|
-
className={styles.card}
|
|
23
|
-
rel="noopener noreferrer"
|
|
24
|
-
>
|
|
25
|
-
<h2>
|
|
26
|
-
Near Integration <span>-></span>
|
|
27
|
-
</h2>
|
|
28
|
-
<p>Discover how simple it is to interact with a Near smart contract.</p>
|
|
29
|
-
</Link>
|
|
30
|
-
|
|
31
|
-
<Link
|
|
32
|
-
href="/hello-components"
|
|
33
|
-
className={styles.card}
|
|
34
|
-
rel="noopener noreferrer"
|
|
35
|
-
>
|
|
36
|
-
<h2>
|
|
37
|
-
Web3 Components <span>-></span>
|
|
38
|
-
</h2>
|
|
39
|
-
<p>See how Web3 components can help you to create multi-chain apps.</p>
|
|
40
|
-
</Link>
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useContext } from 'react';
|
|
4
|
-
import { useInitNear, Widget, EthersProviderContext } from 'near-social-vm';
|
|
5
|
-
|
|
6
|
-
import { NearContext } from '@/context';
|
|
7
|
-
import { NetworkId } from '@/config';
|
|
8
|
-
import { useEthersProviderContext } from '@/wallets/eth';
|
|
9
|
-
|
|
10
|
-
export default function Component({ src }) {
|
|
11
|
-
const ethersContext = useEthersProviderContext();
|
|
12
|
-
const { wallet } = useContext(NearContext);
|
|
13
|
-
const { initNear } = useInitNear();
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
wallet && initNear && initNear({ networkId: NetworkId, selector: wallet.selector, config: { allowOtherContracts: true } });
|
|
17
|
-
}, [wallet, initNear]);
|
|
18
|
-
|
|
19
|
-
const href = wallet.networkId === 'mainnet' ?
|
|
20
|
-
`https://near.social/mob.near/widget/WidgetSource?src=${src}` :
|
|
21
|
-
`https://test.near.social/eugenethedream/widget/WidgetSource?src=${src}`;
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div>
|
|
25
|
-
<EthersProviderContext.Provider value={ethersContext}>
|
|
26
|
-
<Widget src={src} />
|
|
27
|
-
</EthersProviderContext.Provider>
|
|
28
|
-
<p className="mt-4 small"> <span className="text-secondary">Source:</span> <a href={href}> {src} </a> </p>
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const contractPerNetwork = {
|
|
2
|
-
mainnet: 'hello.near-examples.near',
|
|
3
|
-
testnet: 'hello.near-examples.testnet',
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
const componentsPerNetwork = {
|
|
7
|
-
mainnet: {
|
|
8
|
-
socialDB: 'social.near',
|
|
9
|
-
Lido: 'zavodil.near/widget/Lido',
|
|
10
|
-
HelloNear: 'gagdiez.near/widget/HelloNear',
|
|
11
|
-
LoveNear: 'gagdiez.near/widget/LoveNear',
|
|
12
|
-
},
|
|
13
|
-
testnet: {
|
|
14
|
-
socialDB: 'v1.social08.testnet',
|
|
15
|
-
Lido: 'influencer.testnet/widget/Lido',
|
|
16
|
-
HelloNear: 'influencer.testnet/widget/HelloNear',
|
|
17
|
-
LoveNear: 'influencer.testnet/widget/LoveNear',
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const NetworkId = 'testnet';
|
|
22
|
-
export const HelloNearContract = contractPerNetwork[NetworkId];
|
|
23
|
-
export const Components = componentsPerNetwork[NetworkId];
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import type { EIP1193Provider } from '@web3-onboard/core';
|
|
3
|
-
import injectedModule from '@web3-onboard/injected-wallets';
|
|
4
|
-
import ledgerModule from '@web3-onboard/ledger';
|
|
5
|
-
import { init, useConnectWallet } from '@web3-onboard/react';
|
|
6
|
-
import walletConnectModule from '@web3-onboard/walletconnect';
|
|
7
|
-
import { useEffect, useState } from 'react';
|
|
8
|
-
import { singletonHook } from 'react-singleton-hook';
|
|
9
|
-
|
|
10
|
-
const web3onboardKey = 'web3-onboard:connectedWallets';
|
|
11
|
-
|
|
12
|
-
const wcV2InitOptions: any = {
|
|
13
|
-
version: 2,
|
|
14
|
-
projectId: '72b7b3359ab477e339a070f615806aa6',
|
|
15
|
-
requiredChains: [1, 56],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const walletConnect = walletConnectModule(wcV2InitOptions);
|
|
19
|
-
const ledger = ledgerModule(wcV2InitOptions);
|
|
20
|
-
const injected = injectedModule();
|
|
21
|
-
|
|
22
|
-
// initialize Onboard
|
|
23
|
-
export const onboard = init({
|
|
24
|
-
wallets: [injected, walletConnect, ledger],
|
|
25
|
-
chains: [
|
|
26
|
-
{
|
|
27
|
-
id: 1,
|
|
28
|
-
token: 'ETH',
|
|
29
|
-
label: 'Ethereum Mainnet',
|
|
30
|
-
rpcUrl: 'https://rpc.ankr.com/eth',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
id: 3,
|
|
34
|
-
token: 'ETH',
|
|
35
|
-
label: 'Ropsten - Ethereum Testnet',
|
|
36
|
-
rpcUrl: 'https://rpc.ankr.com/eth_ropsten',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: 5,
|
|
40
|
-
token: 'ETH',
|
|
41
|
-
label: 'Goerli - Ethereum Testnet',
|
|
42
|
-
rpcUrl: 'https://rpc.ankr.com/eth_goerli',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 10,
|
|
46
|
-
token: 'ETH',
|
|
47
|
-
label: 'Optimism',
|
|
48
|
-
rpcUrl: 'https://rpc.ankr.com/optimism',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
id: 420,
|
|
52
|
-
token: 'ETH',
|
|
53
|
-
label: 'Optimism Goerli Testnet',
|
|
54
|
-
rpcUrl: 'https://optimism-goerli.publicnode.com',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 56,
|
|
58
|
-
token: 'BNB',
|
|
59
|
-
label: 'Binance Smart Chain Mainnet',
|
|
60
|
-
rpcUrl: 'https://bsc.publicnode.com',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
id: 97,
|
|
64
|
-
token: 'tBNB',
|
|
65
|
-
label: 'Binance Smart Chain Testnet',
|
|
66
|
-
rpcUrl: 'https://bsc-testnet.publicnode.com',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
id: 1313161554,
|
|
70
|
-
token: 'ETH',
|
|
71
|
-
label: 'Aurora Mainnet',
|
|
72
|
-
rpcUrl: 'https://mainnet.aurora.dev',
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
id: 1313161555,
|
|
76
|
-
token: 'ETH',
|
|
77
|
-
label: 'Aurora Testnet',
|
|
78
|
-
rpcUrl: 'https://testnet.aurora.dev',
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
id: 137,
|
|
82
|
-
token: 'MATIC',
|
|
83
|
-
label: 'Polygon Mainnet',
|
|
84
|
-
rpcUrl: 'https://rpc.ankr.com/polygon',
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
id: 80001,
|
|
88
|
-
token: 'MATIC',
|
|
89
|
-
label: 'Polygon Testnet Mumbai',
|
|
90
|
-
rpcUrl: 'https://rpc.ankr.com/polygon_mumbai',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 280,
|
|
94
|
-
token: 'ETH',
|
|
95
|
-
label: 'zkSync Era Testnet',
|
|
96
|
-
rpcUrl: 'https://testnet.era.zksync.dev',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
id: 324,
|
|
100
|
-
token: 'ETH',
|
|
101
|
-
label: 'zkSync Era Mainnet',
|
|
102
|
-
rpcUrl: 'https://zksync2-mainnet.zksync.io',
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
id: 1101,
|
|
106
|
-
token: 'ETH',
|
|
107
|
-
label: 'Polygon zkEVM',
|
|
108
|
-
rpcUrl: 'https://zkevm-rpc.com',
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
id: 1442,
|
|
112
|
-
token: 'ETH',
|
|
113
|
-
label: 'Polygon zkEVM Testnet',
|
|
114
|
-
rpcUrl: 'https://rpc.public.zkevm-test.net',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
id: 42161,
|
|
118
|
-
token: 'ETH',
|
|
119
|
-
label: 'Arbitrum One Mainnet',
|
|
120
|
-
rpcUrl: 'https://arb1.arbitrum.io/rpc',
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
id: 42170,
|
|
124
|
-
token: 'ETH',
|
|
125
|
-
label: 'Arbitrum Nova',
|
|
126
|
-
rpcUrl: 'https://nova.arbitrum.io/rpc',
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: 421613,
|
|
130
|
-
token: 'AGOR',
|
|
131
|
-
label: 'Arbitrum Goerli',
|
|
132
|
-
rpcUrl: 'https://goerli-rollup.arbitrum.io/rpc',
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
id: 25,
|
|
136
|
-
token: 'CRO',
|
|
137
|
-
label: 'Cronos Mainnet Beta',
|
|
138
|
-
rpcUrl: 'https://evm.cronos.org',
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
id: 338,
|
|
142
|
-
token: 'TCRO',
|
|
143
|
-
label: 'Cronos Testnet',
|
|
144
|
-
rpcUrl: 'https://evm-t3.cronos.org',
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
id: 100,
|
|
148
|
-
token: 'XDAI',
|
|
149
|
-
label: 'Gnosis',
|
|
150
|
-
rpcUrl: 'https://rpc.ankr.com/gnosis',
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
id: 10200,
|
|
154
|
-
token: 'XDAI',
|
|
155
|
-
label: 'Gnosis Chiado Testnet',
|
|
156
|
-
rpcUrl: 'https://rpc.chiadochain.net',
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
id: 42220,
|
|
160
|
-
token: 'CELO',
|
|
161
|
-
label: 'Celo Mainnet',
|
|
162
|
-
rpcUrl: 'https://rpc.ankr.com/celo',
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
id: 44787,
|
|
166
|
-
token: 'CELO',
|
|
167
|
-
label: 'Celo Alfajores Testnet',
|
|
168
|
-
rpcUrl: 'https://alfajores-forno.celo-testnet.org',
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
id: 43114,
|
|
172
|
-
token: 'AVAX',
|
|
173
|
-
label: 'Avalanche C-Chain',
|
|
174
|
-
rpcUrl: 'https://rpc.ankr.com/avalanche',
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
id: 43113,
|
|
178
|
-
token: 'AVAX',
|
|
179
|
-
label: 'Avalanche Fuji Testnet',
|
|
180
|
-
rpcUrl: 'https://rpc.ankr.com/avalanche_fuji',
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
id: 250,
|
|
184
|
-
token: 'FTM',
|
|
185
|
-
label: 'Fantom Opera',
|
|
186
|
-
rpcUrl: 'https://rpc.ankr.com/fantom',
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
id: 4002,
|
|
190
|
-
token: 'FTM',
|
|
191
|
-
label: 'Fantom Testnet',
|
|
192
|
-
rpcUrl: 'https://rpc.ankr.com/fantom_testnet',
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
id: 1284,
|
|
196
|
-
token: 'GLMR',
|
|
197
|
-
label: 'Moonbeam',
|
|
198
|
-
rpcUrl: 'https://rpc.ankr.com/moonbeam',
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
id: 61,
|
|
202
|
-
token: 'ETC',
|
|
203
|
-
label: 'Ethereum Classic Mainnet',
|
|
204
|
-
rpcUrl: 'https://etc.rivet.link',
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
id: 84531,
|
|
208
|
-
token: 'ETH',
|
|
209
|
-
label: 'Base Goerli Testnet',
|
|
210
|
-
rpcUrl: 'https://goerli.base.org',
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
id: 8453,
|
|
214
|
-
token: 'ETH',
|
|
215
|
-
label: 'Base',
|
|
216
|
-
rpcUrl: 'https://mainnet.base.org',
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
id: 5001,
|
|
220
|
-
token: 'MNT',
|
|
221
|
-
label: 'Mantle Testnet',
|
|
222
|
-
rpcUrl: 'https://rpc.testnet.mantle.xyz',
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
id: 5000,
|
|
226
|
-
token: 'MNT',
|
|
227
|
-
label: 'Mantle',
|
|
228
|
-
rpcUrl: 'https://rpc.mantle.xyz',
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
|
-
appMetadata: {
|
|
232
|
-
name: 'NEAR',
|
|
233
|
-
icon: '/next.svg',
|
|
234
|
-
description: 'NEAR',
|
|
235
|
-
},
|
|
236
|
-
theme: 'dark',
|
|
237
|
-
containerElements: {
|
|
238
|
-
// connectModal: '#near-social-navigation-bar',
|
|
239
|
-
// accountCenter: "#near-social-web3-account",
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
type EthersProviderContext = {
|
|
244
|
-
provider?: EIP1193Provider;
|
|
245
|
-
useConnectWallet: typeof useConnectWallet;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const defaultEthersProviderContext: EthersProviderContext = { useConnectWallet };
|
|
249
|
-
|
|
250
|
-
export const useEthersProviderContext = singletonHook(defaultEthersProviderContext, () => {
|
|
251
|
-
const [{ wallet }] = useConnectWallet();
|
|
252
|
-
const [ethersProvider, setEthersProvider] = useState(defaultEthersProviderContext);
|
|
253
|
-
|
|
254
|
-
useEffect(() => {
|
|
255
|
-
(async () => {
|
|
256
|
-
if (typeof localStorage === 'undefined') return;
|
|
257
|
-
|
|
258
|
-
const walletsSub = onboard.state.select('wallets');
|
|
259
|
-
|
|
260
|
-
walletsSub.subscribe((wallets) => {
|
|
261
|
-
const connectedWallets = wallets.map(({ label }) => label);
|
|
262
|
-
localStorage.setItem(web3onboardKey, JSON.stringify(connectedWallets));
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
const previouslyConnectedWallets = JSON.parse(localStorage.getItem(web3onboardKey) || '[]');
|
|
266
|
-
|
|
267
|
-
if (previouslyConnectedWallets) {
|
|
268
|
-
// You can also auto connect "silently" and disable all onboard modals to avoid them flashing on page load
|
|
269
|
-
await onboard.connectWallet({
|
|
270
|
-
autoSelect: {
|
|
271
|
-
label: previouslyConnectedWallets[0],
|
|
272
|
-
disableModals: true,
|
|
273
|
-
},
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
})();
|
|
277
|
-
}, []);
|
|
278
|
-
|
|
279
|
-
useEffect(() => {
|
|
280
|
-
if (!wallet) return;
|
|
281
|
-
|
|
282
|
-
setEthersProvider({
|
|
283
|
-
provider: wallet.provider,
|
|
284
|
-
useConnectWallet,
|
|
285
|
-
});
|
|
286
|
-
}, [wallet]);
|
|
287
|
-
|
|
288
|
-
return ethersProvider;
|
|
289
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hello-near",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"engines": {
|
|
6
|
-
"node": ">=18"
|
|
7
|
-
},
|
|
8
|
-
"scripts": {
|
|
9
|
-
"dev": "next dev",
|
|
10
|
-
"build": "next build",
|
|
11
|
-
"start": "next start",
|
|
12
|
-
"lint": "next lint"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@near-wallet-selector/core": "^8.9.7",
|
|
16
|
-
"@near-wallet-selector/here-wallet": "^8.9.7",
|
|
17
|
-
"@near-wallet-selector/modal-ui": "^8.9.7",
|
|
18
|
-
"@near-wallet-selector/my-near-wallet": "^8.9.7",
|
|
19
|
-
"@web3-onboard/core": "^2.21.5",
|
|
20
|
-
"@web3-onboard/injected-wallets": "^2.10.15",
|
|
21
|
-
"@web3-onboard/ledger": "^2.6.0",
|
|
22
|
-
"@web3-onboard/react": "^2.8.16",
|
|
23
|
-
"@web3-onboard/walletconnect": "^2.5.4",
|
|
24
|
-
"base64-js": "^1.5.1",
|
|
25
|
-
"bootstrap": "^5.3.3",
|
|
26
|
-
"bootstrap-icons": "^1.11.3",
|
|
27
|
-
"ieee754": "^1.2.1",
|
|
28
|
-
"near-api-js": "^3.0.4",
|
|
29
|
-
"near-social-vm": "github:gagdiez/VM",
|
|
30
|
-
"next": "14.2.0",
|
|
31
|
-
"pino-pretty": "^11.0.0",
|
|
32
|
-
"react": "^18",
|
|
33
|
-
"react-dom": "^18"
|
|
34
|
-
},
|
|
35
|
-
"overrides": {
|
|
36
|
-
"near-api-js": "^3.0.4"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"eslint": "^8.57.0",
|
|
40
|
-
"eslint-config-next": "14.2.2"
|
|
41
|
-
}
|
|
42
|
-
}
|