create-near-app 6.4.4 → 7.0.0-beta.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.
Files changed (41) hide show
  1. package/dist/app.js +2 -1
  2. package/dist/make.js +7 -3
  3. package/dist/messages.js +3 -3
  4. package/dist/tracking.js +2 -1
  5. package/dist/user-input.js +21 -12
  6. package/package.json +1 -1
  7. package/templates/frontend/components/next-app/package.json +41 -0
  8. package/templates/frontend/{next-app → components/next-app}/src/app/hello-components/page.js +12 -9
  9. package/templates/frontend/components/next-app/src/components/cards.js +43 -0
  10. package/templates/frontend/{next-app/src/components/vm-component.js → components/next-app/src/components/vm.js} +8 -6
  11. package/templates/frontend/components/next-app/src/config.js +23 -0
  12. package/templates/frontend/components/next-page/package.json +41 -0
  13. package/templates/frontend/components/next-page/src/components/cards.js +43 -0
  14. package/templates/frontend/{next-page/src/components/vm-component.js → components/next-page/src/components/vm.js} +4 -4
  15. package/templates/frontend/components/next-page/src/config.js +23 -0
  16. package/templates/frontend/{next-page → components/next-page}/src/pages/hello-components/index.js +3 -4
  17. package/templates/frontend/next-app/package.json +5 -14
  18. package/templates/frontend/next-app/src/app/globals.css +0 -1
  19. package/templates/frontend/next-app/src/app/hello-near/page.js +7 -8
  20. package/templates/frontend/next-app/src/app/layout.js +11 -22
  21. package/templates/frontend/next-app/src/app/page.js +2 -4
  22. package/templates/frontend/next-app/src/components/cards.js +25 -41
  23. package/templates/frontend/next-app/src/components/navigation.js +3 -3
  24. package/templates/frontend/next-app/src/config.js +1 -17
  25. package/templates/frontend/next-app/src/context.js +13 -0
  26. package/templates/frontend/{next-page/src/wallets/near-wallet.js → next-app/src/wallets/near.js} +15 -14
  27. package/templates/frontend/next-page/.eslintrc.json +3 -0
  28. package/templates/frontend/next-page/package.json +6 -18
  29. package/templates/frontend/next-page/src/components/cards.js +25 -41
  30. package/templates/frontend/next-page/src/components/navigation.js +3 -3
  31. package/templates/frontend/next-page/src/config.js +1 -17
  32. package/templates/frontend/next-page/src/context.js +13 -0
  33. package/templates/frontend/next-page/src/pages/_app.js +17 -4
  34. package/templates/frontend/next-page/src/pages/hello-near/index.js +5 -9
  35. package/templates/frontend/next-page/src/pages/index.js +2 -4
  36. package/templates/frontend/next-page/src/styles/globals.css +0 -1
  37. package/templates/frontend/{next-app/src/wallets/near-wallet.js → next-page/src/wallets/near.js} +15 -14
  38. package/templates/frontend/next-page/src/layout.js +0 -33
  39. package/templates/frontend/next-page/src/pages/_document.js +0 -17
  40. /package/templates/frontend/{next-app/src/wallets/web3-wallet.ts → components/next-app/src/wallets/eth.ts} +0 -0
  41. /package/templates/frontend/{next-page/src/wallets/web3-wallet.ts → components/next-page/src/wallets/eth.ts} +0 -0
package/dist/app.js CHANGED
@@ -34,13 +34,14 @@ const show = __importStar(require("./messages"));
34
34
  const prompt = await (0, user_input_1.promptAndGetConfig)();
35
35
  if (prompt === undefined)
36
36
  return;
37
- const { config: { projectName, contract, frontend, install, }, projectPath, } = prompt;
37
+ const { config: { projectName, contract, frontend, components, install, }, projectPath, } = prompt;
38
38
  show.creatingApp();
39
39
  let createSuccess;
40
40
  try {
41
41
  createSuccess = await (0, make_1.createProject)({
42
42
  contract,
43
43
  frontend,
44
+ components,
44
45
  templatesDir: path_1.default.resolve(__dirname, '../templates'),
45
46
  projectPath,
46
47
  });
package/dist/make.js CHANGED
@@ -32,12 +32,12 @@ const cross_spawn_1 = __importDefault(require("cross-spawn"));
32
32
  const fs_1 = __importDefault(require("fs"));
33
33
  const ncp_1 = require("ncp");
34
34
  const path_1 = __importDefault(require("path"));
35
- async function createProject({ contract, frontend, projectPath, templatesDir }) {
35
+ async function createProject({ contract, frontend, components, projectPath, templatesDir }) {
36
36
  if (contract !== 'none') {
37
37
  await createContract({ contract, projectPath, templatesDir });
38
38
  }
39
39
  else {
40
- await createGateway({ frontend, projectPath, templatesDir });
40
+ await createGateway({ frontend, components, projectPath, templatesDir });
41
41
  }
42
42
  return true;
43
43
  }
@@ -48,10 +48,14 @@ async function createContract({ contract, projectPath, templatesDir }) {
48
48
  fs_1.default.mkdirSync(projectPath, { recursive: true });
49
49
  await copyDir(sourceContractDir, projectPath);
50
50
  }
51
- async function createGateway({ frontend, projectPath, templatesDir }) {
51
+ async function createGateway({ frontend, components, projectPath, templatesDir }) {
52
52
  const sourceFrontendDir = path_1.default.resolve(`${templatesDir}/frontend/${frontend}`);
53
53
  fs_1.default.mkdirSync(projectPath, { recursive: true });
54
54
  await copyDir(sourceFrontendDir, projectPath);
55
+ if (components) {
56
+ const sourceComponentsDir = path_1.default.resolve(`${templatesDir}/frontend/components/${frontend}`);
57
+ await copyDir(sourceComponentsDir, projectPath);
58
+ }
55
59
  }
56
60
  // Wrap `ncp` tool to wait for the copy to finish when using `await`
57
61
  function copyDir(source, dest) {
package/dist/messages.js CHANGED
@@ -34,7 +34,7 @@ const frontendTemplates = {
34
34
  };
35
35
  const successFrontendToText = (frontend) => frontend === 'none'
36
36
  ? ''
37
- : (0, chalk_1.default) `a gateway using ${frontendTemplates[frontend]}`;
37
+ : (0, chalk_1.default) `a web-app using ${frontendTemplates[frontend]}`;
38
38
  exports.successFrontendToText = successFrontendToText;
39
39
  const setupSuccess = (projectName, contract, frontend, install) => (0, exports.show)((0, chalk_1.default) `
40
40
  {green ======================================================}
@@ -72,10 +72,10 @@ const gatewayInstructions = (projectName, frontend, install) => frontend === 'no
72
72
  {blue cd {bold ${projectName}}}
73
73
  ${!install
74
74
  ? (0, chalk_1.default) ` - {inverse Install all dependencies}
75
- {blue pnpm {bold install}}`
75
+ {blue npm {bold install}}`
76
76
  : 'Then:'}
77
77
  - {inverse Start your app}:
78
- {blue pnpm {bold run dev}}`;
78
+ {blue npm {bold run dev}}`;
79
79
  exports.gatewayInstructions = gatewayInstructions;
80
80
  const argsError = (msg) => (0, exports.show)((0, chalk_1.default) `{red Arguments error: {white ${msg}}}
81
81
 
package/dist/tracking.js CHANGED
@@ -10,7 +10,7 @@ const MIXPANEL_TOKEN = '24177ef1ec09ffea5cb6f68909c66a61';
10
10
  const tracker = mixpanel_1.default.init(MIXPANEL_TOKEN);
11
11
  exports.trackingMessage = (0, chalk_1.default) `Near collects anonymous information on the commands used. No personal information that could identify you is shared`;
12
12
  // TODO: track different failures & install usage
13
- const trackUsage = async (frontend, contract) => {
13
+ const trackUsage = async (frontend, components, contract) => {
14
14
  // prevents logging from CI
15
15
  if (process.env.NEAR_ENV === 'ci' || process.env.NODE_ENV === 'ci') {
16
16
  console.log('Mixpanel logging is skipped in CI env');
@@ -19,6 +19,7 @@ const trackUsage = async (frontend, contract) => {
19
19
  try {
20
20
  const mixPanelProperties = {
21
21
  frontend,
22
+ components,
22
23
  contract,
23
24
  os: process.platform,
24
25
  nodeVersion: process.versions.node,
@@ -46,20 +46,24 @@ async function getUserArgs() {
46
46
  const options = commander_1.program.opts();
47
47
  const [projectName] = commander_1.program.args;
48
48
  const { contract, frontend, install } = options;
49
- return { contract, frontend, projectName, install };
49
+ return { contract, frontend, components: false, projectName, install };
50
50
  }
51
51
  exports.getUserArgs = getUserArgs;
52
52
  const appChoices = [
53
- { title: 'A Near Gateway (Web App)', description: 'A multi-chain App that talks with Near contracts and Near components', value: 'gateway' },
54
- { title: 'A Near Smart Contract', description: 'A smart contract to be deployed in the Near Blockchain', value: 'contract' },
53
+ { title: 'A Web App', description: 'A Web App that talks with Near contracts', value: 'gateway' },
54
+ { title: 'A Smart Contract', description: 'A smart contract to be deployed in the Near Blockchain', value: 'contract' },
55
55
  ];
56
56
  const contractChoices = [
57
57
  { title: 'JS/TS Contract', description: 'A Near contract written in javascript/typescript', value: 'ts' },
58
58
  { title: 'Rust Contract', description: 'A Near contract written in Rust', value: 'rs' },
59
59
  ];
60
60
  const frontendChoices = [
61
- { title: 'NextJs (Classic)', description: 'A composable app built using Next.js, React and Near components', value: 'next-page' },
62
- { title: 'NextJS (App Router)', description: 'A composable app built using Next.js, React and Near components', value: 'next-app' },
61
+ { title: 'NextJs (Classic)', description: 'A web-app built using Next.js Page Router', value: 'next-page' },
62
+ { title: 'NextJS (App Router)', description: 'A web-app built using Next.js new App Router', value: 'next-app' },
63
+ ];
64
+ const componentChoices = [
65
+ { title: 'No', value: false },
66
+ { title: 'Yes', value: true },
63
67
  ];
64
68
  const appPrompt = {
65
69
  type: 'select',
@@ -70,9 +74,15 @@ const appPrompt = {
70
74
  const frontendPrompt = {
71
75
  type: 'select',
72
76
  name: 'frontend',
73
- message: 'Select a framework for your frontend (Gateway)',
77
+ message: 'Select a framework for your frontend',
74
78
  choices: frontendChoices,
75
79
  };
80
+ const componentsPrompt = {
81
+ type: 'select',
82
+ name: 'components',
83
+ message: 'Are you planning in using on-chain NEAR Components (aka BOS Components)?',
84
+ choices: componentChoices,
85
+ };
76
86
  const contractPrompt = [
77
87
  {
78
88
  type: 'select',
@@ -102,15 +112,15 @@ async function getUserAnswers() {
102
112
  const { app } = await promptUser(appPrompt);
103
113
  if (app === 'gateway') {
104
114
  // If gateway, ask for the framework to use
105
- const { frontend, projectName, install } = await promptUser([frontendPrompt, namePrompts, npmPrompt]);
106
- return { frontend, contract: 'none', projectName, install };
115
+ const { frontend, components, projectName, install } = await promptUser([frontendPrompt, componentsPrompt, namePrompts, npmPrompt]);
116
+ return { frontend, components, contract: 'none', projectName, install };
107
117
  }
108
118
  else {
109
119
  // If contract, ask for the language for the contract
110
120
  let { contract } = await promptUser(contractPrompt);
111
121
  const { projectName } = await promptUser(namePrompts);
112
122
  const install = contract === 'ts' ? (await promptUser(npmPrompt)).install : false;
113
- return { frontend: 'none', contract, projectName, install };
123
+ return { frontend: 'none', components: false, contract, projectName, install };
114
124
  }
115
125
  }
116
126
  exports.getUserAnswers = getUserAnswers;
@@ -135,8 +145,8 @@ async function promptAndGetConfig() {
135
145
  if (!validateUserArgs(args))
136
146
  return;
137
147
  // track user input
138
- const { frontend, contract } = args;
139
- (0, tracking_1.trackUsage)(frontend, contract);
148
+ const { frontend, components, contract } = args;
149
+ (0, tracking_1.trackUsage)(frontend, components, contract);
140
150
  let path = (0, exports.projectPath)(args.projectName);
141
151
  if (fs_1.default.existsSync(path)) {
142
152
  return show.directoryExists(path);
@@ -160,7 +170,6 @@ const validateUserArgs = (args) => {
160
170
  return false;
161
171
  }
162
172
  if ((args.contract === 'none') === (args.frontend === 'none')) {
163
- console.log(args.contract, args.frontend);
164
173
  show.argsError('Please create a contract OR a frontend');
165
174
  return false;
166
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-near-app",
3
- "version": "6.4.4",
3
+ "version": "7.0.0-beta.0",
4
4
  "description": "Quickly scaffold your dApp on NEAR Blockchain",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -0,0 +1,41 @@
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
+ "ieee754": "^1.2.1",
27
+ "near-api-js": "^3.0.4",
28
+ "near-social-vm": "github:gagdiez/VM",
29
+ "next": "14.2.0",
30
+ "pino-pretty": "^11.0.0",
31
+ "react": "^18",
32
+ "react-dom": "^18"
33
+ },
34
+ "overrides": {
35
+ "near-api-js": "^3.0.4"
36
+ },
37
+ "devDependencies": {
38
+ "eslint": "^8.57.0",
39
+ "eslint-config-next": "14.2.2"
40
+ }
41
+ }
@@ -1,14 +1,16 @@
1
- 'use client';
2
1
  import dynamic from 'next/dynamic';
3
2
 
4
3
  import styles from '@/app/app.module.css';
5
- import { DocsCard, HelloNearCard } from '@/components/cards';
4
+ import { Cards } from '@/components/cards';
6
5
  import { Components } from '@/config';
7
6
 
8
- const Component = dynamic(() => import('@/components/vm-component'), { ssr: false });
7
+ const Component = dynamic(() => import('@/components/vm'), {
8
+ ssr: false,
9
+ loading: () => <p>Loading Component...</p>,
10
+ });
9
11
 
10
- export default function HelloComponents() {
11
12
 
13
+ export default function HelloComponents() {
12
14
  return (
13
15
  <>
14
16
  <main className={styles.main}>
@@ -19,9 +21,11 @@ export default function HelloComponents() {
19
21
  </p>
20
22
  </div>
21
23
  <div className={styles.center}>
22
- <h1> <code>Multi-chain</code> Components Made Simple </h1>
24
+ <h1>
25
+ <code>Multi-chain</code> Components Made Simple
26
+ </h1>
23
27
  </div>
24
- <div className='row'>
28
+ <div className="row">
25
29
  <div className="col-6">
26
30
  <Component src={Components.HelloNear} />
27
31
  <p className="my-4">&nbsp;</p>
@@ -34,10 +38,9 @@ export default function HelloComponents() {
34
38
  <hr />
35
39
 
36
40
  <div className={styles.grid}>
37
- <DocsCard />
38
- <HelloNearCard />
41
+ <Cards />
39
42
  </div>
40
43
  </main>
41
44
  </>
42
45
  );
43
- }
46
+ }
@@ -0,0 +1,43 @@
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>-&gt;</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>-&gt;</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>-&gt;</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,13 +1,15 @@
1
- import { Widget, EthersProviderContext } from 'near-social-vm';
2
- import { useEthersProviderContext } from '@/wallets/web3-wallet';
3
- import { useInitNear } from 'near-social-vm';
4
- import { useEffect } from 'react';
5
- import { useStore } from '@/app/layout';
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';
6
7
  import { NetworkId } from '@/config';
8
+ import { useEthersProviderContext } from '@/wallets/eth';
7
9
 
8
10
  export default function Component({ src }) {
9
11
  const ethersContext = useEthersProviderContext();
10
- const { wallet } = useStore();
12
+ const { wallet } = useContext(NearContext);
11
13
  const { initNear } = useInitNear();
12
14
 
13
15
  useEffect(() => {
@@ -0,0 +1,23 @@
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];
@@ -0,0 +1,41 @@
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
+ "ieee754": "^1.2.1",
27
+ "near-api-js": "^3.0.4",
28
+ "near-social-vm": "github:gagdiez/VM",
29
+ "next": "14.2.0",
30
+ "pino-pretty": "^11.0.0",
31
+ "react": "^18",
32
+ "react-dom": "^18"
33
+ },
34
+ "overrides": {
35
+ "near-api-js": "^3.0.4"
36
+ },
37
+ "devDependencies": {
38
+ "eslint": "^8.57.0",
39
+ "eslint-config-next": "14.2.2"
40
+ }
41
+ }
@@ -0,0 +1,43 @@
1
+ import Link from 'next/link';
2
+
3
+ import styles from '@/styles/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>-&gt;</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>-&gt;</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>-&gt;</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,13 +1,13 @@
1
- import { useEffect } from 'react';
1
+ import { useEffect, useContext } from 'react';
2
2
  import { useInitNear, Widget, EthersProviderContext } from 'near-social-vm';
3
3
 
4
- import { useEthersProviderContext } from '@/wallets/web3-wallet';
4
+ import { NearContext } from '@/context';
5
5
  import { NetworkId } from '@/config';
6
- import { useStore } from '@/layout';
6
+ import { useEthersProviderContext } from '@/wallets/eth';
7
7
 
8
8
  export default function Component({ src }) {
9
9
  const ethersContext = useEthersProviderContext();
10
- const { wallet } = useStore();
10
+ const { wallet } = useContext(NearContext);
11
11
  const { initNear } = useInitNear();
12
12
 
13
13
  useEffect(() => {
@@ -0,0 +1,23 @@
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,10 +1,10 @@
1
1
  import dynamic from 'next/dynamic';
2
2
 
3
3
  import styles from '@/styles/app.module.css';
4
- import { DocsCard, HelloNearCard } from '@/components/cards';
4
+ import { Cards } from '@/components/cards';
5
5
  import { Components } from '@/config';
6
6
 
7
- const Component = dynamic(() => import('@/components/vm-component'), {
7
+ const Component = dynamic(() => import('@/components/vm'), {
8
8
  ssr: false,
9
9
  loading: () => <p>Loading Component...</p>,
10
10
  });
@@ -38,8 +38,7 @@ export default function HelloComponents() {
38
38
  <hr />
39
39
 
40
40
  <div className={styles.grid}>
41
- <DocsCard />
42
- <HelloNearCard />
41
+ <Cards />
43
42
  </div>
44
43
  </main>
45
44
  </>
@@ -16,26 +16,17 @@
16
16
  "@near-wallet-selector/here-wallet": "^8.9.7",
17
17
  "@near-wallet-selector/modal-ui": "^8.9.7",
18
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
- "ieee754": "^1.2.1",
19
+ "bootstrap": "^5",
26
20
  "near-api-js": "^3.0.4",
27
- "near-social-vm": "github:gagdiez/VM" ,
28
- "next": "14.2.0",
29
- "pino-pretty": "^11.0.0",
21
+ "next": "14.2.3",
30
22
  "react": "^18",
31
- "react-dom": "^18",
32
- "zustand": "^4.5.2"
23
+ "react-dom": "^18"
33
24
  },
34
25
  "overrides": {
35
26
  "near-api-js": "^3.0.4"
36
27
  },
37
28
  "devDependencies": {
38
- "eslint": "^8.57.0",
39
- "eslint-config-next": "14.2.2"
29
+ "eslint": "^8",
30
+ "eslint-config-next": "14.2.3"
40
31
  }
41
32
  }
@@ -1,5 +1,4 @@
1
1
  @import 'bootstrap';
2
- @import 'bootstrap-icons';
3
2
 
4
3
  :root {
5
4
  --max-width: 1100px;
@@ -1,17 +1,17 @@
1
1
  'use client';
2
+ import { useState, useEffect, useContext } from 'react';
2
3
 
3
- import { DocsCard, HelloComponentsCard } from '@/components/cards';
4
- import { useState, useEffect } from 'react';
5
- import { HelloNearContract } from '../../config';
6
- import styles from '../app.module.css';
4
+ import styles from '@/app/app.module.css';
5
+ import { Cards } from '@/components/cards';
7
6
 
8
- import { useStore } from '../layout';
7
+ import { NearContext } from '@/context';
8
+ import { HelloNearContract } from '@/config';
9
9
 
10
10
  // Contract that the app will interact with
11
11
  const CONTRACT = HelloNearContract;
12
12
 
13
13
  export default function HelloNear() {
14
- const { signedAccountId, wallet } = useStore();
14
+ const { signedAccountId, wallet } = useContext(NearContext);
15
15
 
16
16
  const [greeting, setGreeting] = useState('loading...');
17
17
  const [newGreeting, setNewGreeting] = useState('loading...');
@@ -62,8 +62,7 @@ export default function HelloNear() {
62
62
  </div>
63
63
  </div>
64
64
  <div className={styles.grid}>
65
- <DocsCard />
66
- <HelloComponentsCard />
65
+ <Cards />
67
66
  </div>
68
67
  </main>
69
68
  );
@@ -1,40 +1,29 @@
1
1
  'use client';
2
2
 
3
- // react
4
- import { useEffect } from 'react';
5
- import { create as createStore } from 'zustand';
3
+ import { useEffect, useState } from 'react';
6
4
 
7
- // app
8
- import './globals.css';
5
+ import '@/app/globals.css';
6
+ import { NearContext } from '@/context';
9
7
  import { Navigation } from '@/components/navigation';
10
8
  import { NetworkId, HelloNearContract } from '@/config';
11
9
 
12
- // wallet-selector
13
- import { Wallet } from '@/wallets/near-wallet';
10
+ import { Wallet } from '@/wallets/near';
14
11
 
15
- // store to share wallet and signedAccountId
16
- export const useStore = createStore((set) => ({
17
- wallet: undefined,
18
- signedAccountId: '',
19
- setWallet: (wallet) => set({ wallet }),
20
- setSignedAccountId: (signedAccountId) => set({ signedAccountId })
21
- }));
12
+ const wallet = new Wallet({ networkId: NetworkId, createAccessKeyFor: HelloNearContract });
22
13
 
23
14
  // Layout Component
24
15
  export default function RootLayout({ children }) {
25
- const { setWallet, setSignedAccountId } = useStore();
16
+ const [signedAccountId, setSignedAccountId] = useState('');
26
17
 
27
- useEffect(() => {
28
- const wallet = new Wallet({ networkId: NetworkId, createAccessKeyFor: HelloNearContract });
29
- wallet.startUp(setSignedAccountId);
30
- setWallet(wallet);
31
- }, []);
18
+ useEffect(() => { wallet.startUp(setSignedAccountId); }, []);
32
19
 
33
20
  return (
34
21
  <html lang="en">
35
22
  <body>
36
- <Navigation />
37
- {children}
23
+ <NearContext.Provider value={{ wallet, signedAccountId }}>
24
+ <Navigation />
25
+ {children}
26
+ </NearContext.Provider>
38
27
  </body>
39
28
  </html>
40
29
  );
@@ -3,7 +3,7 @@ import Image from 'next/image';
3
3
  import NearLogo from '/public/near.svg';
4
4
  import NextLogo from '/public/next.svg';
5
5
  import styles from './app.module.css';
6
- import { DocsCard, HelloComponentsCard, HelloNearCard } from '@/components/cards';
6
+ import { Cards } from '@/components/cards';
7
7
 
8
8
  export default function Home() {
9
9
  return (
@@ -31,9 +31,7 @@ export default function Home() {
31
31
  </div>
32
32
 
33
33
  <div className={styles.grid}>
34
- <HelloComponentsCard />
35
- <HelloNearCard />
36
- <DocsCard />
34
+ <Cards />
37
35
  </div>
38
36
  </main>
39
37
  );
@@ -1,48 +1,32 @@
1
1
  import Link from 'next/link';
2
2
 
3
- import styles from '../app/app.module.css';
3
+ import styles from '@/app/app.module.css';
4
4
 
5
- export const DocsCard = () => {
5
+ export const Cards = () => {
6
6
  return (
7
- <Link
8
- href="https://docs.near.org/build/web3-apps/quickstart"
9
- className={styles.card}
10
- target='_blank'
11
- rel="noopener noreferrer"
12
- >
13
- <h2>
14
- Near Docs <span>-&gt;</span>
15
- </h2>
16
- <p>Learn how this application works, and what you can build on Near.</p>
17
- </Link>);
18
- };
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>-&gt;</span>
16
+ </h2>
17
+ <p>Learn how this application works, and what you can build on Near.</p>
18
+ </Link>
19
19
 
20
- export const HelloNearCard = () => {
21
- return (
22
- <Link
23
- href="/hello-near"
24
- className={styles.card}
25
- rel="noopener noreferrer"
26
- >
27
- <h2>
28
- Near Integration <span>-&gt;</span>
29
- </h2>
30
- <p>Discover how simple it is to interact with a Near smart contract.</p>
31
- </Link>
32
- );
33
- };
34
-
35
- export const HelloComponentsCard = () => {
36
- return (
37
- <Link
38
- href="/hello-components"
39
- className={styles.card}
40
- rel="noopener noreferrer"
41
- >
42
- <h2>
43
- Web3 Components <span>-&gt;</span>
44
- </h2>
45
- <p>See how Web3 components can help you to create multi-chain apps.</p>
46
- </Link>
20
+ <Link
21
+ href="/hello-near"
22
+ className={styles.card}
23
+ rel="noopener noreferrer"
24
+ >
25
+ <h2>
26
+ Near Integration <span>-&gt;</span>
27
+ </h2>
28
+ <p>Discover how simple it is to interact with a Near smart contract.</p>
29
+ </Link>
30
+ </div>
47
31
  );
48
32
  };
@@ -1,12 +1,12 @@
1
1
  import Image from 'next/image';
2
2
  import Link from 'next/link';
3
- import { useEffect, useState } from 'react';
3
+ import { useEffect, useState, useContext } from 'react';
4
4
 
5
+ import { NearContext } from '@/context';
5
6
  import NearLogo from '/public/near-logo.svg';
6
- import { useStore } from '@/app/layout';
7
7
 
8
8
  export const Navigation = () => {
9
- const { signedAccountId, wallet } = useStore();
9
+ const { signedAccountId, wallet } = useContext(NearContext);
10
10
  const [action, setAction] = useState(() => { });
11
11
  const [label, setLabel] = useState('Loading...');
12
12
 
@@ -3,21 +3,5 @@ const contractPerNetwork = {
3
3
  testnet: 'hello.near-examples.testnet',
4
4
  };
5
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
6
  export const NetworkId = 'testnet';
22
- export const HelloNearContract = contractPerNetwork[NetworkId];
23
- export const Components = componentsPerNetwork[NetworkId];
7
+ export const HelloNearContract = contractPerNetwork[NetworkId];
@@ -0,0 +1,13 @@
1
+ import { createContext } from 'react';
2
+
3
+ /**
4
+ * @typedef NearContext
5
+ * @property {import('./wallets/near').Wallet} wallet Current wallet
6
+ * @property {string} signedAccountId The AccountId of the signed user
7
+ */
8
+
9
+ /** @type {import ('react').Context<NearContext>} */
10
+ export const NearContext = createContext({
11
+ wallet: undefined,
12
+ signedAccountId: ''
13
+ });
@@ -1,4 +1,3 @@
1
-
2
1
  // near api js
3
2
  import { providers } from 'near-api-js';
4
3
 
@@ -16,8 +15,9 @@ const NO_DEPOSIT = '0';
16
15
  export class Wallet {
17
16
  /**
18
17
  * @constructor
19
- * @param {string} networkId - the network id to connect to
20
- * @param {string} createAccessKeyFor - the contract to create an access key for
18
+ * @param {Object} options - the options for the wallet
19
+ * @param {string} options.networkId - the network id to connect to
20
+ * @param {string} options.createAccessKeyFor - the contract to create an access key for
21
21
  * @example
22
22
  * const wallet = new Wallet({ networkId: 'testnet', createAccessKeyFor: 'contractId' });
23
23
  * wallet.startUp((signedAccountId) => console.log(signedAccountId));
@@ -73,15 +73,15 @@ export class Wallet {
73
73
 
74
74
  /**
75
75
  * Makes a read-only call to a contract
76
- * @param {string} contractId - the contract's account id
77
- * @param {string} method - the method to call
78
- * @param {Object} args - the arguments to pass to the method
76
+ * @param {Object} options - the options for the call
77
+ * @param {string} options.contractId - the contract's account id
78
+ * @param {string} options.method - the method to call
79
+ * @param {Object} options.args - the arguments to pass to the method
79
80
  * @returns {Promise<JSON.value>} - the result of the method call
80
81
  */
81
82
  viewMethod = async ({ contractId, method, args = {} }) => {
82
- const walletSelector = await this.selector;
83
- const { network } = walletSelector.options;
84
- const provider = new providers.JsonRpcProvider({ url: network.nodeUrl });
83
+ const url = `https://rpc.${this.networkId}.near.org`;
84
+ const provider = new providers.JsonRpcProvider({ url });
85
85
 
86
86
  let res = await provider.query({
87
87
  request_type: 'call_function',
@@ -96,11 +96,12 @@ export class Wallet {
96
96
 
97
97
  /**
98
98
  * Makes a call to a contract
99
- * @param {string} contractId - the contract's account id
100
- * @param {string} method - the method to call
101
- * @param {Object} args - the arguments to pass to the method
102
- * @param {string} gas - the amount of gas to use
103
- * @param {string} deposit - the amount of yoctoNEAR to deposit
99
+ * @param {Object} options - the options for the call
100
+ * @param {string} options.contractId - the contract's account id
101
+ * @param {string} options.method - the method to call
102
+ * @param {Object} options.args - the arguments to pass to the method
103
+ * @param {string} options.gas - the amount of gas to use
104
+ * @param {string} options.deposit - the amount of yoctoNEAR to deposit
104
105
  * @returns {Promise<Transaction>} - the resulting transaction
105
106
  */
106
107
  callMethod = async ({ contractId, method, args = {}, gas = THIRTY_TGAS, deposit = NO_DEPOSIT }) => {
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "next/core-web-vitals"
3
+ }
@@ -16,29 +16,17 @@
16
16
  "@near-wallet-selector/here-wallet": "^8.9.7",
17
17
  "@near-wallet-selector/modal-ui": "^8.9.7",
18
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
- "ieee754": "^1.2.1",
19
+ "bootstrap": "^5",
26
20
  "near-api-js": "^3.0.4",
27
- "near-social-vm": "github:gagdiez/VM" ,
28
- "next": "14.2.0",
29
- "pino-pretty": "^11.0.0",
30
- "react": "^18.2.0",
31
- "react-bootstrap": "^2.10.2",
32
- "react-bootstrap-icons": "^1.11.4",
33
- "react-dom": "^18.2.0",
34
- "react-singleton-hook": "^4.0.1",
35
- "zustand": "^4.5.2"
21
+ "next": "14.2.3",
22
+ "react": "^18",
23
+ "react-dom": "^18"
36
24
  },
37
25
  "overrides": {
38
26
  "near-api-js": "^3.0.4"
39
27
  },
40
28
  "devDependencies": {
41
- "eslint": "^8.57.0",
42
- "eslint-config-next": "14.2.2"
29
+ "eslint": "^8",
30
+ "eslint-config-next": "14.2.3"
43
31
  }
44
32
  }
@@ -1,48 +1,32 @@
1
1
  import Link from 'next/link';
2
2
 
3
- import styles from '../styles/app.module.css';
3
+ import styles from '@/styles/app.module.css';
4
4
 
5
- export const DocsCard = () => {
5
+ export const Cards = () => {
6
6
  return (
7
- <Link
8
- href="https://docs.near.org/build/web3-apps/quickstart"
9
- className={styles.card}
10
- target='_blank'
11
- rel="noopener noreferrer"
12
- >
13
- <h2>
14
- Near Docs <span>-&gt;</span>
15
- </h2>
16
- <p>Learn how this application works, and what you can build on Near.</p>
17
- </Link>);
18
- };
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>-&gt;</span>
16
+ </h2>
17
+ <p>Learn how this application works, and what you can build on Near.</p>
18
+ </Link>
19
19
 
20
- export const HelloNearCard = () => {
21
- return (
22
- <Link
23
- href="/hello-near"
24
- className={styles.card}
25
- rel="noopener noreferrer"
26
- >
27
- <h2>
28
- Near Integration <span>-&gt;</span>
29
- </h2>
30
- <p>Discover how simple it is to interact with a Near smart contract.</p>
31
- </Link>
32
- );
33
- };
34
-
35
- export const HelloComponentsCard = () => {
36
- return (
37
- <Link
38
- href="/hello-components"
39
- className={styles.card}
40
- rel="noopener noreferrer"
41
- >
42
- <h2>
43
- Web3 Components <span>-&gt;</span>
44
- </h2>
45
- <p>See how Web3 components can help you to create multi-chain apps.</p>
46
- </Link>
20
+ <Link
21
+ href="/hello-near"
22
+ className={styles.card}
23
+ rel="noopener noreferrer"
24
+ >
25
+ <h2>
26
+ Near Integration <span>-&gt;</span>
27
+ </h2>
28
+ <p>Discover how simple it is to interact with a Near smart contract.</p>
29
+ </Link>
30
+ </div>
47
31
  );
48
32
  };
@@ -1,12 +1,12 @@
1
1
  import Image from 'next/image';
2
2
  import Link from 'next/link';
3
- import { useEffect, useState } from 'react';
3
+ import { useEffect, useState, useContext } from 'react';
4
4
 
5
+ import { NearContext } from '@/context';
5
6
  import NearLogo from '/public/near-logo.svg';
6
- import { useStore } from '@/layout';
7
7
 
8
8
  export const Navigation = () => {
9
- const { signedAccountId, wallet } = useStore();
9
+ const { signedAccountId, wallet } = useContext(NearContext);
10
10
  const [action, setAction] = useState(() => { });
11
11
  const [label, setLabel] = useState('Loading...');
12
12
 
@@ -3,21 +3,5 @@ const contractPerNetwork = {
3
3
  testnet: 'hello.near-examples.testnet',
4
4
  };
5
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
6
  export const NetworkId = 'testnet';
22
- export const HelloNearContract = contractPerNetwork[NetworkId];
23
- export const Components = componentsPerNetwork[NetworkId];
7
+ export const HelloNearContract = contractPerNetwork[NetworkId];
@@ -0,0 +1,13 @@
1
+ import { createContext } from 'react';
2
+
3
+ /**
4
+ * @typedef NearContext
5
+ * @property {import('./wallets/near').Wallet} wallet Current wallet
6
+ * @property {string} signedAccountId The AccountId of the signed user
7
+ */
8
+
9
+ /** @type {import ('react').Context<NearContext>} */
10
+ export const NearContext = createContext({
11
+ wallet: undefined,
12
+ signedAccountId: ''
13
+ });
@@ -1,10 +1,23 @@
1
- import RootLayout from '@/layout';
1
+ import { useEffect, useState } from 'react';
2
+
2
3
  import '@/styles/globals.css';
4
+ import { NearContext } from '@/context';
5
+ import { Navigation } from '@/components/navigation';
6
+
7
+ import { Wallet } from '@/wallets/near';
8
+ import { NetworkId, HelloNearContract } from '@/config';
9
+
10
+ const wallet = new Wallet({ createAccessKeyFor: HelloNearContract, networkId: NetworkId });
3
11
 
4
12
  export default function MyApp({ Component, pageProps }) {
13
+ const [signedAccountId, setSignedAccountId] = useState('');
14
+
15
+ useEffect(() => { wallet.startUp(setSignedAccountId) }, []);
16
+
5
17
  return (
6
- <RootLayout>
18
+ <NearContext.Provider value={{ wallet, signedAccountId }}>
19
+ <Navigation />
7
20
  <Component {...pageProps} />
8
- </RootLayout>
21
+ </NearContext.Provider>
9
22
  );
10
- }
23
+ }
@@ -1,15 +1,15 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useState, useEffect, useContext } from 'react';
2
2
 
3
- import { useStore } from '@/layout';
3
+ import { NearContext } from '@/context';
4
4
  import styles from '@/styles/app.module.css';
5
5
  import { HelloNearContract } from '../../config';
6
- import { DocsCard, HelloComponentsCard } from '@/components/cards';
6
+ import { Cards } from '@/components/cards';
7
7
 
8
8
  // Contract that the app will interact with
9
9
  const CONTRACT = HelloNearContract;
10
10
 
11
11
  export default function HelloNear() {
12
- const { signedAccountId, wallet } = useStore();
12
+ const { signedAccountId, wallet } = useContext(NearContext);
13
13
 
14
14
  const [greeting, setGreeting] = useState('loading...');
15
15
  const [newGreeting, setNewGreeting] = useState('loading...');
@@ -70,11 +70,7 @@ export default function HelloNear() {
70
70
  <p className="m-0"> Please login to change the greeting </p>
71
71
  </div>
72
72
  </div>
73
-
74
- <div className={styles.grid}>
75
- <DocsCard />
76
- <HelloComponentsCard />
77
- </div>
73
+ <Cards />
78
74
  </main>
79
75
  );
80
76
  }
@@ -3,7 +3,7 @@ import Image from 'next/image';
3
3
  import NearLogo from '/public/near.svg';
4
4
  import NextLogo from '/public/next.svg';
5
5
  import styles from '@/styles/app.module.css';
6
- import { DocsCard, HelloComponentsCard, HelloNearCard } from '@/components/cards';
6
+ import { Cards } from '@/components/cards';
7
7
 
8
8
  export default function Home() {
9
9
  return (
@@ -31,9 +31,7 @@ export default function Home() {
31
31
  </div>
32
32
 
33
33
  <div className={styles.grid}>
34
- <HelloComponentsCard />
35
- <HelloNearCard />
36
- <DocsCard />
34
+ <Cards />
37
35
  </div>
38
36
  </main>
39
37
  );
@@ -1,5 +1,4 @@
1
1
  @import 'bootstrap';
2
- @import 'bootstrap-icons';
3
2
 
4
3
  :root {
5
4
  --max-width: 1100px;
@@ -1,4 +1,3 @@
1
-
2
1
  // near api js
3
2
  import { providers } from 'near-api-js';
4
3
 
@@ -16,8 +15,9 @@ const NO_DEPOSIT = '0';
16
15
  export class Wallet {
17
16
  /**
18
17
  * @constructor
19
- * @param {string} networkId - the network id to connect to
20
- * @param {string} createAccessKeyFor - the contract to create an access key for
18
+ * @param {Object} options - the options for the wallet
19
+ * @param {string} options.networkId - the network id to connect to
20
+ * @param {string} options.createAccessKeyFor - the contract to create an access key for
21
21
  * @example
22
22
  * const wallet = new Wallet({ networkId: 'testnet', createAccessKeyFor: 'contractId' });
23
23
  * wallet.startUp((signedAccountId) => console.log(signedAccountId));
@@ -73,15 +73,15 @@ export class Wallet {
73
73
 
74
74
  /**
75
75
  * Makes a read-only call to a contract
76
- * @param {string} contractId - the contract's account id
77
- * @param {string} method - the method to call
78
- * @param {Object} args - the arguments to pass to the method
76
+ * @param {Object} options - the options for the call
77
+ * @param {string} options.contractId - the contract's account id
78
+ * @param {string} options.method - the method to call
79
+ * @param {Object} options.args - the arguments to pass to the method
79
80
  * @returns {Promise<JSON.value>} - the result of the method call
80
81
  */
81
82
  viewMethod = async ({ contractId, method, args = {} }) => {
82
- const walletSelector = await this.selector;
83
- const { network } = walletSelector.options;
84
- const provider = new providers.JsonRpcProvider({ url: network.nodeUrl });
83
+ const url = `https://rpc.${this.networkId}.near.org`;
84
+ const provider = new providers.JsonRpcProvider({ url });
85
85
 
86
86
  let res = await provider.query({
87
87
  request_type: 'call_function',
@@ -96,11 +96,12 @@ export class Wallet {
96
96
 
97
97
  /**
98
98
  * Makes a call to a contract
99
- * @param {string} contractId - the contract's account id
100
- * @param {string} method - the method to call
101
- * @param {Object} args - the arguments to pass to the method
102
- * @param {string} gas - the amount of gas to use
103
- * @param {string} deposit - the amount of yoctoNEAR to deposit
99
+ * @param {Object} options - the options for the call
100
+ * @param {string} options.contractId - the contract's account id
101
+ * @param {string} options.method - the method to call
102
+ * @param {Object} options.args - the arguments to pass to the method
103
+ * @param {string} options.gas - the amount of gas to use
104
+ * @param {string} options.deposit - the amount of yoctoNEAR to deposit
104
105
  * @returns {Promise<Transaction>} - the resulting transaction
105
106
  */
106
107
  callMethod = async ({ contractId, method, args = {}, gas = THIRTY_TGAS, deposit = NO_DEPOSIT }) => {
@@ -1,33 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { create as createStore } from 'zustand';
3
-
4
- import { Wallet } from '@/wallets/near-wallet';
5
- import { Navigation } from '@/components/navigation';
6
- import { NetworkId, HelloNearContract } from '@/config';
7
-
8
- // Store to share wallet and signed account
9
- export const useStore = createStore((set) => ({
10
- wallet: undefined,
11
- signedAccountId: '',
12
- setWallet: (wallet) => set({ wallet }),
13
- setSignedAccountId: (signedAccountId) => set({ signedAccountId })
14
- }));
15
-
16
- export default function RootLayout({ children }) {
17
-
18
- const { setWallet, setSignedAccountId } = useStore();
19
-
20
- useEffect(() => {
21
- // create wallet instance
22
- const wallet = new Wallet({ createAccessKeyFor: HelloNearContract, networkId: NetworkId });
23
- wallet.startUp(setSignedAccountId);
24
- setWallet(wallet);
25
- }, []);
26
-
27
- return (
28
- <>
29
- <Navigation />
30
- {children}
31
- </>
32
- );
33
- }
@@ -1,17 +0,0 @@
1
- import Document, { Html, Head, Main, NextScript } from 'next/document';
2
-
3
- class MyDocument extends Document {
4
- render() {
5
- return (
6
- <Html lang="en">
7
- <Head />
8
- <body>
9
- <Main />
10
- <NextScript />
11
- </body>
12
- </Html>
13
- );
14
- }
15
- }
16
-
17
- export default MyDocument;