create-near-app 7.0.3 → 8.1.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 (64) hide show
  1. package/dist/app.js +1 -2
  2. package/dist/make.js +3 -7
  3. package/dist/messages.js +3 -2
  4. package/dist/tracking.js +32 -15
  5. package/dist/types.js +1 -1
  6. package/dist/user-input.js +10 -20
  7. package/package.json +3 -4
  8. package/templates/contracts/rs/.github/workflows/deploy-production.yml +27 -0
  9. package/templates/contracts/rs/.github/workflows/deploy-staging.yml +56 -0
  10. package/templates/contracts/rs/.github/workflows/test.yml +32 -0
  11. package/templates/contracts/rs/.github/workflows/undeploy-staging.yml +25 -0
  12. package/templates/contracts/rs/Cargo.lock +973 -3244
  13. package/templates/contracts/rs/Cargo.toml +23 -6
  14. package/templates/contracts/rs/README.md +5 -7
  15. package/templates/contracts/rs/src/lib.rs +1 -1
  16. package/templates/contracts/rs/tests/test_basics.rs +11 -14
  17. package/templates/contracts/ts/package.json +1 -1
  18. package/templates/frontend/next-app/package.json +17 -14
  19. package/templates/frontend/next-app/src/app/hello-near/page.js +1 -1
  20. package/templates/frontend/next-app/src/app/layout.js +3 -4
  21. package/templates/frontend/next-app/src/components/navigation.js +1 -1
  22. package/templates/frontend/next-app/src/config.js +18 -1
  23. package/templates/frontend/next-app/src/wallets/near.js +48 -11
  24. package/templates/frontend/next-app/src/wallets/web3modal.js +44 -0
  25. package/templates/frontend/next-page/package.json +17 -14
  26. package/templates/frontend/next-page/src/components/navigation.js +1 -1
  27. package/templates/frontend/next-page/src/config.js +18 -1
  28. package/templates/frontend/next-page/src/pages/_app.js +3 -4
  29. package/templates/frontend/next-page/src/pages/hello-near/index.js +1 -1
  30. package/templates/frontend/next-page/src/wallets/near.js +48 -11
  31. package/templates/frontend/next-page/src/wallets/web3modal.js +44 -0
  32. package/templates/frontend/vite-react/eslint.config.js +38 -0
  33. package/templates/frontend/vite-react/index.html +13 -0
  34. package/templates/frontend/vite-react/package.json +50 -0
  35. package/templates/frontend/vite-react/public/favicon.ico +0 -0
  36. package/templates/frontend/vite-react/src/App.jsx +36 -0
  37. package/templates/frontend/vite-react/src/assets/near-logo.svg +43 -0
  38. package/templates/frontend/vite-react/src/assets/near.svg +1 -0
  39. package/templates/frontend/vite-react/src/assets/react.svg +1 -0
  40. package/templates/frontend/{components/next-page/src/components/cards.js → vite-react/src/components/cards.jsx} +6 -22
  41. package/templates/frontend/vite-react/src/components/navigation.jsx +39 -0
  42. package/templates/frontend/vite-react/src/config.js +24 -0
  43. package/templates/frontend/vite-react/src/main.jsx +11 -0
  44. package/templates/frontend/vite-react/src/pages/hello_near.jsx +75 -0
  45. package/templates/frontend/vite-react/src/pages/home.jsx +31 -0
  46. package/templates/frontend/vite-react/src/styles/app.module.css +226 -0
  47. package/templates/frontend/vite-react/src/styles/globals.css +88 -0
  48. package/templates/frontend/vite-react/src/wallets/near.js +228 -0
  49. package/templates/frontend/vite-react/src/wallets/web3modal.js +42 -0
  50. package/templates/frontend/vite-react/vite.config.js +27 -0
  51. package/dist/package-json.js +0 -130
  52. package/templates/frontend/components/next-app/package.json +0 -42
  53. package/templates/frontend/components/next-app/src/app/hello-components/page.js +0 -46
  54. package/templates/frontend/components/next-app/src/components/cards.js +0 -43
  55. package/templates/frontend/components/next-app/src/components/vm.js +0 -31
  56. package/templates/frontend/components/next-app/src/config.js +0 -23
  57. package/templates/frontend/components/next-app/src/wallets/eth.ts +0 -289
  58. package/templates/frontend/components/next-page/package.json +0 -42
  59. package/templates/frontend/components/next-page/src/components/vm.js +0 -29
  60. package/templates/frontend/components/next-page/src/config.js +0 -23
  61. package/templates/frontend/components/next-page/src/pages/hello-components/index.js +0 -46
  62. package/templates/frontend/components/next-page/src/wallets/eth.ts +0 -289
  63. package/templates/frontend/next-app/src/context.js +0 -13
  64. package/templates/frontend/next-page/src/context.js +0 -13
@@ -0,0 +1,88 @@
1
+ @import 'bootstrap';
2
+ @import 'bootstrap-icons';
3
+
4
+ :root {
5
+ --max-width: 1100px;
6
+ --border-radius: 12px;
7
+
8
+ --foreground-rgb: 0, 0, 0;
9
+ --background-start-rgb: 214, 219, 220;
10
+ --background-end-rgb: 255, 255, 255;
11
+
12
+ --primary-glow: conic-gradient(
13
+ from 180deg at 50% 50%,
14
+ #16abff33 0deg,
15
+ #0885ff33 55deg,
16
+ #54d6ff33 120deg,
17
+ #0071ff33 160deg,
18
+ transparent 360deg
19
+ );
20
+ --secondary-glow: radial-gradient(rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
21
+
22
+ --tile-start-rgb: 239, 245, 249;
23
+ --tile-end-rgb: 228, 232, 233;
24
+ --tile-border: conic-gradient(#00000080, #00000040, #00000030, #00000020, #00000010, #00000010, #00000080);
25
+
26
+ --callout-rgb: 238, 240, 241;
27
+ --callout-border-rgb: 172, 175, 176;
28
+ --card-rgb: 180, 185, 188;
29
+ --card-border-rgb: 131, 134, 135;
30
+ }
31
+
32
+ @media (prefers-color-scheme: dark) {
33
+ :root {
34
+ --foreground-rgb: 255, 255, 255;
35
+ --background-start-rgb: 0, 0, 0;
36
+ --background-end-rgb: 0, 0, 0;
37
+
38
+ --primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0));
39
+ --secondary-glow: linear-gradient(to bottom right, rgba(1, 65, 255, 0), rgba(1, 65, 255, 0), rgba(1, 65, 255, 0.3));
40
+
41
+ --tile-start-rgb: 2, 13, 46;
42
+ --tile-end-rgb: 2, 5, 19;
43
+ --tile-border: conic-gradient(#ffffff80, #ffffff40, #ffffff30, #ffffff20, #ffffff10, #ffffff10, #ffffff80);
44
+
45
+ --callout-rgb: 20, 20, 20;
46
+ --callout-border-rgb: 108, 108, 108;
47
+ --card-rgb: 100, 100, 100;
48
+ --card-border-rgb: 200, 200, 200;
49
+ }
50
+ }
51
+
52
+ * {
53
+ box-sizing: border-box;
54
+ padding: 0;
55
+ margin: 0;
56
+ }
57
+
58
+ html,
59
+ body {
60
+ max-width: 100vw;
61
+ overflow-x: hidden;
62
+ }
63
+
64
+ body {
65
+ color: rgb(var(--foreground-rgb));
66
+ background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb))) rgb(var(--background-start-rgb));
67
+ font-family:
68
+ -apple-system,
69
+ BlinkMacSystemFont,
70
+ Segoe UI,
71
+ Roboto,
72
+ Noto Sans,
73
+ Ubuntu,
74
+ Droid Sans,
75
+ Helvetica Neue,
76
+ sans-serif;
77
+ }
78
+
79
+ a {
80
+ color: inherit;
81
+ text-decoration: none;
82
+ }
83
+
84
+ @media (prefers-color-scheme: dark) {
85
+ html {
86
+ color-scheme: dark;
87
+ }
88
+ }
@@ -0,0 +1,228 @@
1
+ // wallet selector
2
+ import '@near-wallet-selector/modal-ui/styles.css';
3
+
4
+ import { setupBitteWallet } from '@near-wallet-selector/bitte-wallet';
5
+ import { setupWalletSelector } from '@near-wallet-selector/core';
6
+ import { setupEthereumWallets } from '@near-wallet-selector/ethereum-wallets';
7
+ import { setupLedger } from '@near-wallet-selector/ledger';
8
+ import { setupMeteorWallet } from '@near-wallet-selector/meteor-wallet';
9
+ import { setupModal } from '@near-wallet-selector/modal-ui';
10
+ import { setupMyNearWallet } from '@near-wallet-selector/my-near-wallet';
11
+ import { setupSender } from '@near-wallet-selector/sender';
12
+ import { setupHereWallet } from '@near-wallet-selector/here-wallet';
13
+ import { setupNearMobileWallet } from '@near-wallet-selector/near-mobile-wallet';
14
+ import { setupWelldoneWallet } from '@near-wallet-selector/welldone-wallet';
15
+ import { Buffer } from 'buffer';
16
+
17
+
18
+ // near api js
19
+ import { providers, utils } from 'near-api-js';
20
+ import { createContext } from 'react';
21
+
22
+ // ethereum wallets
23
+ import { wagmiConfig, web3Modal } from '@/wallets/web3modal';
24
+
25
+ const THIRTY_TGAS = '30000000000000';
26
+ const NO_DEPOSIT = '0';
27
+
28
+ export class Wallet {
29
+ /**
30
+ * @constructor
31
+ * @param {Object} options - the options for the wallet
32
+ * @param {string} options.networkId - the network id to connect to
33
+ * @param {string} options.createAccessKeyFor - the contract to create an access key for
34
+ * @example
35
+ * const wallet = new Wallet({ networkId: 'testnet', createAccessKeyFor: 'contractId' });
36
+ * wallet.startUp((signedAccountId) => console.log(signedAccountId));
37
+ */
38
+ constructor({ networkId = 'testnet', createAccessKeyFor = undefined }) {
39
+ this.createAccessKeyFor = createAccessKeyFor;
40
+ this.networkId = networkId;
41
+ }
42
+
43
+ /**
44
+ * To be called when the website loads
45
+ * @param {Function} accountChangeHook - a function that is called when the user signs in or out#
46
+ * @returns {Promise<string>} - the accountId of the signed-in user
47
+ */
48
+ startUp = async (accountChangeHook) => {
49
+ this.selector = setupWalletSelector({
50
+ network: this.networkId,
51
+ modules: [
52
+ setupMeteorWallet(),
53
+ setupEthereumWallets({ wagmiConfig, web3Modal, alwaysOnboardDuringSignIn: true }),
54
+ setupLedger(),
55
+ setupBitteWallet(),
56
+ setupHereWallet(),
57
+ setupSender(),
58
+ setupNearMobileWallet(),
59
+ setupWelldoneWallet(),
60
+ setupMyNearWallet(),
61
+ ],
62
+ });
63
+
64
+ const walletSelector = await this.selector;
65
+ const isSignedIn = walletSelector.isSignedIn();
66
+ const accountId = isSignedIn ? walletSelector.store.getState().accounts[0].accountId : '';
67
+
68
+ walletSelector.store.observable.subscribe(async (state) => {
69
+ const signedAccount = state?.accounts.find((account) => account.active)?.accountId;
70
+ accountChangeHook(signedAccount || '');
71
+ });
72
+
73
+ return accountId;
74
+ };
75
+
76
+ /**
77
+ * Displays a modal to login the user
78
+ */
79
+ signIn = async () => {
80
+ const modal = setupModal(await this.selector, { contractId: this.createAccessKeyFor });
81
+ modal.show();
82
+ };
83
+
84
+ /**
85
+ * Logout the user
86
+ */
87
+ signOut = async () => {
88
+ const selectedWallet = await (await this.selector).wallet();
89
+ selectedWallet.signOut();
90
+ };
91
+
92
+ /**
93
+ * Makes a read-only call to a contract
94
+ * @param {Object} options - the options for the call
95
+ * @param {string} options.contractId - the contract's account id
96
+ * @param {string} options.method - the method to call
97
+ * @param {Object} options.args - the arguments to pass to the method
98
+ * @returns {Promise<JSON.value>} - the result of the method call
99
+ */
100
+ viewMethod = async ({ contractId, method, args = {} }) => {
101
+ const url = `https://rpc.${this.networkId}.near.org`;
102
+ const provider = new providers.JsonRpcProvider({ url });
103
+
104
+ const res = await provider.query({
105
+ request_type: 'call_function',
106
+ account_id: contractId,
107
+ method_name: method,
108
+ args_base64: Buffer.from(JSON.stringify(args)).toString('base64'),
109
+ finality: 'optimistic',
110
+ });
111
+ return JSON.parse(Buffer.from(res.result).toString());
112
+ };
113
+
114
+ /**
115
+ * Makes a call to a contract
116
+ * @param {Object} options - the options for the call
117
+ * @param {string} options.contractId - the contract's account id
118
+ * @param {string} options.method - the method to call
119
+ * @param {Object} options.args - the arguments to pass to the method
120
+ * @param {string} options.gas - the amount of gas to use
121
+ * @param {string} options.deposit - the amount of yoctoNEAR to deposit
122
+ * @returns {Promise<Transaction>} - the resulting transaction
123
+ */
124
+ callMethod = async ({ contractId, method, args = {}, gas = THIRTY_TGAS, deposit = NO_DEPOSIT }) => {
125
+ // Sign a transaction with the "FunctionCall" action
126
+ const selectedWallet = await (await this.selector).wallet();
127
+ const outcome = await selectedWallet.signAndSendTransaction({
128
+ receiverId: contractId,
129
+ actions: [
130
+ {
131
+ type: 'FunctionCall',
132
+ params: {
133
+ methodName: method,
134
+ args,
135
+ gas,
136
+ deposit,
137
+ },
138
+ },
139
+ ],
140
+ });
141
+
142
+ return providers.getTransactionLastResult(outcome);
143
+ };
144
+
145
+ /**
146
+ * Makes a call to a contract
147
+ * @param {string} txhash - the transaction hash
148
+ * @returns {Promise<JSON.value>} - the result of the transaction
149
+ */
150
+ getTransactionResult = async (txhash) => {
151
+ const walletSelector = await this.selector;
152
+ const { network } = walletSelector.options;
153
+ const provider = new providers.JsonRpcProvider({ url: network.nodeUrl });
154
+
155
+ // Retrieve transaction result from the network
156
+ const transaction = await provider.txStatus(txhash, 'unnused');
157
+ return providers.getTransactionLastResult(transaction);
158
+ };
159
+
160
+ /**
161
+ * Gets the balance of an account
162
+ * @param {string} accountId - the account id to get the balance of
163
+ * @param {boolean} format - whether to format the balance
164
+ * @returns {Promise<number>} - the balance of the account
165
+ *
166
+ */
167
+ getBalance = async (accountId, format = false) => {
168
+ const walletSelector = await this.selector;
169
+ const { network } = walletSelector.options;
170
+ const provider = new providers.JsonRpcProvider({ url: network.nodeUrl });
171
+
172
+ // Retrieve account state from the network
173
+ const account = await provider.query({
174
+ request_type: 'view_account',
175
+ account_id: accountId,
176
+ finality: 'final',
177
+ });
178
+
179
+ // Format the amount if needed
180
+ if (format) {
181
+ return account.amount ? utils.format.formatNearAmount(account.amount) : '0';
182
+ } else {
183
+ return account.amount || '0';
184
+ }
185
+ };
186
+
187
+ /**
188
+ * Signs and sends transactions
189
+ * @param {Object[]} transactions - the transactions to sign and send
190
+ * @returns {Promise<Transaction[]>} - the resulting transactions
191
+ *
192
+ */
193
+ signAndSendTransactions = async ({ transactions }) => {
194
+ const selectedWallet = await (await this.selector).wallet();
195
+ return selectedWallet.signAndSendTransactions({ transactions });
196
+ };
197
+
198
+ /**
199
+ *
200
+ * @param {string} accountId
201
+ * @returns {Promise<Object[]>} - the access keys for the
202
+ */
203
+ getAccessKeys = async (accountId) => {
204
+ const walletSelector = await this.selector;
205
+ const { network } = walletSelector.options;
206
+ const provider = new providers.JsonRpcProvider({ url: network.nodeUrl });
207
+
208
+ // Retrieve account state from the network
209
+ const keys = await provider.query({
210
+ request_type: 'view_access_key_list',
211
+ account_id: accountId,
212
+ finality: 'final',
213
+ });
214
+ return keys.keys;
215
+ };
216
+ }
217
+
218
+ /**
219
+ * @typedef NearContext
220
+ * @property {import('./wallets/near').Wallet} wallet Current wallet
221
+ * @property {string} signedAccountId The AccountId of the signed user
222
+ */
223
+
224
+ /** @type {import ('react').Context<NearContext>} */
225
+ export const NearContext = createContext({
226
+ wallet: undefined,
227
+ signedAccountId: '',
228
+ });
@@ -0,0 +1,42 @@
1
+ import { injected,walletConnect } from '@wagmi/connectors';
2
+ import { createConfig,http, reconnect } from '@wagmi/core';
3
+ import { createWeb3Modal } from '@web3modal/wagmi';
4
+
5
+ import { EVMWalletChain,NetworkId } from '@/config';
6
+
7
+ // Config
8
+ const near = {
9
+ id: EVMWalletChain.chainId,
10
+ name: EVMWalletChain.name,
11
+ nativeCurrency: {
12
+ decimals: 18,
13
+ name: 'NEAR',
14
+ symbol: 'NEAR',
15
+ },
16
+ rpcUrls: {
17
+ default: { http: [EVMWalletChain.rpc] },
18
+ public: { http: [EVMWalletChain.rpc] },
19
+ },
20
+ blockExplorers: {
21
+ default: {
22
+ name: 'NEAR Explorer',
23
+ url: EVMWalletChain.explorer,
24
+ },
25
+ },
26
+ testnet: NetworkId === 'testnet',
27
+ };
28
+
29
+ // Get your projectId at https://cloud.reown.com
30
+ const projectId = '5bb0fe33763b3bea40b8d69e4269b4ae';
31
+
32
+ export const wagmiConfig = createConfig({
33
+ chains: [near],
34
+ transports: { [near.id]: http() },
35
+ connectors: [walletConnect({ projectId, showQrModal: false }), injected({ shimDisconnect: true })],
36
+ });
37
+
38
+ // Preserve login state on page reload
39
+ reconnect(wagmiConfig);
40
+
41
+ // Modal for login
42
+ export const web3Modal = createWeb3Modal({ wagmiConfig, projectId });
@@ -0,0 +1,27 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import eslint from 'vite-plugin-eslint';
4
+ import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
5
+
6
+ // https://vite.dev/config/
7
+ export default defineConfig({
8
+ plugins: [react(), eslint()],
9
+ resolve: {
10
+ alias: {
11
+ '@': '/src',
12
+ buffer: 'buffer',
13
+ },
14
+ },
15
+ optimizeDeps: {
16
+ esbuildOptions: {
17
+ define: {
18
+ global: 'globalThis'
19
+ },
20
+ plugins: [
21
+ NodeGlobalsPolyfillPlugin({
22
+ buffer: true
23
+ })
24
+ ]
25
+ }
26
+ }
27
+ })
@@ -1,130 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildPackagetson = void 0;
4
- function buildPackagetson({ contract, frontend, tests, projectName }) {
5
- const result = basePackage({
6
- contract, frontend, tests, projectName,
7
- });
8
- return result;
9
- }
10
- exports.buildPackagetson = buildPackagetson;
11
- function basePackage({ contract, frontend, tests, projectName }) {
12
- const hasFrontend = frontend !== 'none';
13
- return {
14
- 'name': projectName,
15
- 'version': '1.0.0',
16
- 'license': '(MIT AND Apache-2.0)',
17
- 'scripts': {
18
- ...startScript(hasFrontend),
19
- ...deployScript(contract),
20
- ...buildScript(hasFrontend),
21
- ...buildContractScript(contract),
22
- 'test': 'npm run test:unit && npm run test:integration',
23
- ...unitTestScripts(contract),
24
- ...integrationTestScripts(contract, tests),
25
- ...npmInstallScript(contract, hasFrontend, tests),
26
- },
27
- 'devDependencies': {
28
- 'near-cli': '^3.3.0',
29
- },
30
- 'dependencies': {}
31
- };
32
- }
33
- const startScript = (hasFrontend) => hasFrontend ? {
34
- 'start': 'cd frontend && npm run dev'
35
- } : {};
36
- const buildScript = (hasFrontend) => hasFrontend ? {
37
- 'build': 'npm run build:contract && npm run build:web',
38
- 'build:web': 'cd frontend && npm run build',
39
- } : {
40
- 'build': 'npm run build:contract',
41
- };
42
- const buildContractScriptName = 'build:contract';
43
- const buildContractScript = (contract) => {
44
- switch (contract) {
45
- case 'ts':
46
- return {
47
- [buildContractScriptName]: 'cd contract && npm run build',
48
- };
49
- case 'rs':
50
- return {
51
- [buildContractScriptName]: 'cd contract && ./build.sh',
52
- };
53
- case 'none':
54
- return {
55
- [buildContractScriptName]: 'echo "No contract to build"',
56
- };
57
- }
58
- };
59
- const deployScript = (contract) => {
60
- switch (contract) {
61
- case 'ts':
62
- return {
63
- 'deploy': 'cd contract && npm run deploy',
64
- };
65
- case 'rs':
66
- return {
67
- 'deploy': 'cd contract && ./deploy.sh',
68
- };
69
- case 'none':
70
- return {
71
- 'deploy': 'echo "No contract to deploy"',
72
- };
73
- }
74
- };
75
- const unitTestScripts = (contract) => {
76
- switch (contract) {
77
- case 'ts':
78
- return { 'test:unit': 'cd contract && npm test' };
79
- case 'rs':
80
- return { 'test:unit': 'cd contract && cargo test' };
81
- case 'none':
82
- return { 'test:unit': 'echo "No contract to test"' };
83
- }
84
- };
85
- const integrationTestScripts = (contract, tests) => {
86
- if (contract === 'none') {
87
- return { 'test:integration': 'echo "No contract to test"' };
88
- }
89
- let wasm_path = '';
90
- switch (contract) {
91
- case 'ts':
92
- wasm_path = 'contract/build/hello_near.wasm';
93
- break;
94
- case 'rs':
95
- wasm_path = 'contract/target/wasm32-unknown-unknown/release/hello_near.wasm';
96
- break;
97
- }
98
- let run_test = '';
99
- switch (tests) {
100
- case 'ts':
101
- run_test = `npm test -- -- "./${wasm_path}"`;
102
- break;
103
- case 'rs':
104
- run_test = `cargo run --example integration-tests "../${wasm_path}"`;
105
- break;
106
- }
107
- return {
108
- 'test:integration': `npm run ${buildContractScriptName} && cd integration-tests && ${run_test}`,
109
- };
110
- };
111
- const npmInstallScript = (contract, hasFrontend, tests) => {
112
- const frontend_install = hasFrontend ? 'cd frontend && npm install && cd ..' : 'echo no frontend';
113
- const test_install = (contract !== 'none' && tests === 'ts') ? 'cd integration-tests && npm install && cd ..' : 'echo no ts test';
114
- let contract_install = '';
115
- switch (contract) {
116
- case 'ts':
117
- contract_install = 'cd contract && npm install';
118
- break;
119
- case 'rs':
120
- contract_install = 'echo rs contract';
121
- break;
122
- case 'none':
123
- contract_install = 'echo no contract';
124
- break;
125
- }
126
- return {
127
- 'postinstall': `${frontend_install} && ${test_install} && ${contract_install}`
128
- };
129
- };
130
- //# sourceMappingURL=package-json.js.map
@@ -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: &nbsp;
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">&nbsp;</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>-&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,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
- }