create-near-app 4.0.0-beta.3.0 → 4.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 (54) hide show
  1. package/README.md +2 -0
  2. package/dist/app.js +5 -14
  3. package/dist/make.js +19 -18
  4. package/dist/messages.js +33 -20
  5. package/dist/package-json.js +26 -18
  6. package/dist/tracking.js +2 -2
  7. package/dist/types.js +4 -0
  8. package/dist/user-input.js +34 -50
  9. package/package.json +2 -5
  10. package/templates/contracts/js/README.md +71 -15
  11. package/templates/contracts/js/build.sh +5 -0
  12. package/templates/contracts/js/deploy.sh +13 -0
  13. package/templates/contracts/js/package.json +3 -3
  14. package/templates/contracts/js/src/contract.ts +10 -23
  15. package/templates/contracts/rust/Cargo.toml +1 -1
  16. package/templates/contracts/rust/README.md +83 -16
  17. package/templates/contracts/rust/build.sh +6 -0
  18. package/templates/contracts/rust/deploy.sh +13 -0
  19. package/templates/frontend/react/{frontend/App.js → App.js} +12 -11
  20. package/templates/frontend/react/{frontend/assets → assets}/favicon.ico +0 -0
  21. package/templates/frontend/{vanilla/frontend → react}/assets/global.css +62 -4
  22. package/templates/frontend/react/{frontend/assets → assets}/logo-black.svg +0 -0
  23. package/templates/frontend/react/{frontend/assets → assets}/logo-white.svg +0 -0
  24. package/templates/frontend/react/{frontend/index.html → index.html} +0 -0
  25. package/templates/frontend/react/index.js +21 -0
  26. package/templates/frontend/react/{frontend/package.json → package.json} +13 -2
  27. package/templates/frontend/react/{frontend/ui-components.js → ui-components.js} +4 -5
  28. package/templates/frontend/shared/near-interface.js +15 -0
  29. package/templates/frontend/shared/near-wallet.js +109 -0
  30. package/templates/frontend/shared/start.sh +26 -0
  31. package/templates/frontend/vanilla/{frontend/assets → assets}/favicon.ico +0 -0
  32. package/templates/frontend/{react/frontend → vanilla}/assets/global.css +64 -4
  33. package/templates/frontend/vanilla/{frontend/assets → assets}/logo-black.svg +0 -0
  34. package/templates/frontend/vanilla/{frontend/assets → assets}/logo-white.svg +0 -0
  35. package/templates/frontend/vanilla/index.html +91 -0
  36. package/templates/frontend/vanilla/{frontend/index.js → index.js} +30 -42
  37. package/templates/frontend/vanilla/package.json +29 -0
  38. package/templates/integration-tests/{shared/js-tests → js-tests}/ava.config.cjs +0 -0
  39. package/templates/integration-tests/{shared/js-tests → js-tests}/package.json +1 -1
  40. package/templates/integration-tests/{shared/js-tests → js-tests}/src/main.ava.ts +1 -1
  41. package/templates/integration-tests/{shared/rust-tests → rust-tests}/Cargo.toml +0 -0
  42. package/templates/integration-tests/{shared/rust-tests → rust-tests}/src/tests.rs +0 -0
  43. package/templates/shared/README.md +3 -3
  44. package/templates/shared/{near.gitignore → template.gitignore} +0 -0
  45. package/dist/checks.js +0 -34
  46. package/templates/frontend/react/frontend/index.js +0 -15
  47. package/templates/frontend/react/frontend/near-api.js +0 -51
  48. package/templates/frontend/react/frontend/near-config.js +0 -61
  49. package/templates/frontend/vanilla/frontend/index.html +0 -86
  50. package/templates/frontend/vanilla/frontend/near-api.js +0 -51
  51. package/templates/frontend/vanilla/frontend/near-config.js +0 -62
  52. package/templates/frontend/vanilla/frontend/package.json +0 -18
  53. package/templates/integration-tests/overrides/js-contract/js-tests/src/main.ava.ts +0 -46
  54. package/templates/integration-tests/overrides/js-contract/rust-tests/src/tests.rs +0 -74
@@ -29,10 +29,7 @@ main {
29
29
  max-width: 26em;
30
30
  }
31
31
 
32
- main.please-wait {
33
- opacity: 0.5;
34
- cursor: wait;
35
- }
32
+ main.please-wait {}
36
33
 
37
34
  h1 {
38
35
  background-image: url(./logo-black.svg);
@@ -90,6 +87,8 @@ ul.information {
90
87
  }
91
88
  .change input {
92
89
  flex: 1;
90
+ border-bottom-right-radius: 0;
91
+ border-top-right-radius: 0;
93
92
  }
94
93
  .change label {
95
94
  display: block;
@@ -97,6 +96,10 @@ ul.information {
97
96
  margin-right: 10px;
98
97
  padding-bottom: 0.5em;
99
98
  }
99
+ .change button {
100
+ border-bottom-left-radius: 0;
101
+ border-top-left-radius: 0;
102
+ }
100
103
 
101
104
  a,
102
105
  .link {
@@ -119,6 +122,15 @@ button, input {
119
122
  outline: none;
120
123
  }
121
124
 
125
+ main.please-wait .change button {
126
+ position: relative;
127
+ pointer-events: none;
128
+ background-color: white;
129
+ }
130
+ main.please-wait .change button span {
131
+ visibility: hidden;
132
+ }
133
+
122
134
  button {
123
135
  background-color: var(--secondary);
124
136
  border-radius: 5px;
@@ -171,3 +183,51 @@ li {
171
183
  box-shadow: 0 0 10em rgba(255, 255, 255, 0.02) inset;
172
184
  }
173
185
  }
186
+
187
+ main.please-wait .loader,
188
+ main.please-wait .loader:after{
189
+ display: inline-block;
190
+ }
191
+ .loader,
192
+ .loader:after {
193
+ display: none;
194
+ border-radius: 50%;
195
+ width: 20px;
196
+ height: 20px;
197
+ }
198
+ .loader {
199
+ font-size: 10px;
200
+ position: absolute;
201
+ top: calc(50% - 10px);
202
+ left: calc(50% - 10px);
203
+ text-indent: -9999em;
204
+ border-top: 3px solid var(--secondary);
205
+ border-right: 3px solid var(--secondary);
206
+ border-bottom: 3px solid var(--secondary);
207
+ border-left: 3px solid #ffffff;
208
+ -webkit-transform: translateZ(0);
209
+ -ms-transform: translateZ(0);
210
+ transform: translateZ(0);
211
+ -webkit-animation: load8 1.1s infinite linear;
212
+ animation: load8 1.1s infinite linear;
213
+ }
214
+ @-webkit-keyframes load8 {
215
+ 0% {
216
+ -webkit-transform: rotate(0deg);
217
+ transform: rotate(0deg);
218
+ }
219
+ 100% {
220
+ -webkit-transform: rotate(360deg);
221
+ transform: rotate(360deg);
222
+ }
223
+ }
224
+ @keyframes load8 {
225
+ 0% {
226
+ -webkit-transform: rotate(0deg);
227
+ transform: rotate(0deg);
228
+ }
229
+ 100% {
230
+ -webkit-transform: rotate(360deg);
231
+ transform: rotate(360deg);
232
+ }
233
+ }
@@ -0,0 +1,91 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <link rel="icon" href="assets/favicon.ico"/>
7
+ <link rel="apple-touch-icon" href="assets/favicon.ico"/>
8
+ <!-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous"> -->
9
+ <title>Welcome to NEAR</title>
10
+ <link rel="stylesheet" href="assets/global.css">
11
+ </head>
12
+ <body>
13
+ <main id="signed-out-flow" style="display: none">
14
+ <h1>
15
+ The contract says: <span class="greeting" data-behavior="greeting"></span>
16
+ </h1>
17
+ <h3>
18
+ Welcome to NEAR!
19
+ </h3>
20
+ <p>
21
+ Your contract is storing a greeting message in the NEAR blockchain. To
22
+ change it you need to sign in using the NEAR Wallet. It is very simple,
23
+ just use the button below.
24
+ </p>
25
+ <p>
26
+ Do not worry, this app runs in the test network ("testnet"). It works
27
+ just like the main network ("mainnet"), but using NEAR Tokens that are
28
+ only for testing!
29
+ </p>
30
+ <p style="text-align: center; margin-top: 2.5em">
31
+ <button id="sign-in-button">Sign in with NEAR Wallet</button>
32
+ </p>
33
+
34
+ </main>
35
+
36
+ <div id="signed-in-flow" style="display: none">
37
+ <button style="float: right" id="sign-out-button">
38
+ Sign out <span data-behavior="account-id"></span>
39
+ </button>
40
+ <main>
41
+ <h1>
42
+ The contract says: <span class="greeting" data-behavior="greeting"></span>
43
+ </h1>
44
+ <form class="change">
45
+ <label for="greeting">Change greeting:</label>
46
+ <div>
47
+ <input
48
+ autocomplete="off"
49
+ id="greeting"
50
+ data-behavior="greeting"
51
+ />
52
+ <button>
53
+ <span>Save</span>
54
+ <div class="loader"></div>
55
+ </button>
56
+ </div>
57
+ </form>
58
+ <p>
59
+ Look at that! A Hello World app! This greeting is stored on the NEAR blockchain. Check it out:
60
+ </p>
61
+ <ol>
62
+ <li>
63
+ Look in <code>index.js</code> and <code>near-api.js</code> – you'll see <code>get_greeting</code>
64
+ and <code>set_greeting</code> being called on <code>contract</code>.
65
+ What's this?
66
+ </li>
67
+ <li>
68
+ Ultimately, this <code>contract</code> code is defined in
69
+ <code>assembly/index.ts</code> – this is the source code for your
70
+ <a target="_blank" href="https://docs.near.org/docs/develop/contracts/overview">smart contract</a>.
71
+ </li>
72
+ <li>
73
+ When you run <code>npm run dev</code>, the code in
74
+ <code>assembly/index.ts</code> gets deployed to the NEAR testnet. You
75
+ can see how this happens by looking in <code>package.json</code> at the
76
+ <code>scripts</code> section to find the <code>dev</code> command.
77
+ </li>
78
+ </ol>
79
+ <hr>
80
+ <p>
81
+ To keep learning, check out
82
+ <a target="_blank" href="https://docs.near.org">the NEAR docs</a>
83
+ or look through some
84
+ <a target="_blank" href="https://examples.near.org">example apps</a>.
85
+ </p>
86
+ </main>
87
+ </div>
88
+
89
+ <script src="index.js" type="module"></script>
90
+ </body>
91
+ </html>
@@ -1,56 +1,48 @@
1
1
  import 'regenerator-runtime/runtime';
2
- import {
3
- initContract,
4
- signInWithNearWallet,
5
- signOutNearWallet,
6
- setGreetingOnContract,
7
- getGreetingFromContract,
8
- } from './near-api';
2
+ import { Contract } from './near-interface';
3
+ import { Wallet } from './near-wallet';
9
4
 
10
- document.querySelector('form').onsubmit = doUserAction;
11
- document.querySelector('#sign-in-button').onclick = signInWithNearWallet;
12
- document.querySelector('#sign-out-button').onclick = signOutNearWallet;
5
+ // create the Wallet and the Contract
6
+ const wallet = new Wallet({contractId: process.env.CONTRACT_NAME});
7
+ const contract = new Contract({wallet: wallet});
8
+
9
+ // Setup on page load
10
+ window.onload = async () => {
11
+ let isSignedIn = await wallet.startUp();
12
+
13
+ if(isSignedIn){
14
+ signedInFlow();
15
+ }else{
16
+ signedOutFlow();
17
+ }
13
18
 
14
- // ====== Initialize the API for NEAR ======
15
- window.nearInitPromise = initContract()
16
- .then(() => {
17
- if (window.walletConnection.isSignedIn()) {
18
- signedInFlow();
19
- } else {
20
- signedOutFlow();
21
- }
22
- })
23
- .catch(alert);
19
+ fetchGreeting();
20
+ };
21
+
22
+ // Button clicks
23
+ document.querySelector('form').onsubmit = doUserAction;
24
+ document.querySelector('#sign-in-button').onclick = () => { wallet.signIn(); };
25
+ document.querySelector('#sign-out-button').onclick = () => { wallet.signOut(); };
24
26
 
25
27
  // Take the new greeting and send it to the contract
26
28
  async function doUserAction(event) {
27
29
  event.preventDefault();
28
30
  const { greeting } = event.target.elements;
29
- document
30
- .querySelector('#signed-in-flow main')
31
+
32
+ document.querySelector('#signed-in-flow main')
31
33
  .classList.add('please-wait');
32
- try {
33
- // ===== Call smart-contract to save the value on then blockchain =====
34
- await setGreetingOnContract(greeting.value);
35
- } catch (e) {
36
- alert(
37
- 'Something went wrong! ' +
38
- 'Maybe you need to sign out and back in? ' +
39
- 'Check your browser console for more info.'
40
- );
41
- throw e;
42
- }
34
+
35
+ await contract.setGreeting(greeting.value);
43
36
 
44
37
  // ===== Fetch the data from the blockchain =====
45
38
  await fetchGreeting();
46
- document
47
- .querySelector('#signed-in-flow main')
39
+ document.querySelector('#signed-in-flow main')
48
40
  .classList.remove('please-wait');
49
41
  }
50
42
 
51
43
  // Get greeting from the contract on chain
52
44
  async function fetchGreeting() {
53
- const currentGreeting = await getGreetingFromContract();
45
+ const currentGreeting = await contract.getGreeting();
54
46
 
55
47
  document.querySelectorAll('[data-behavior=greeting]').forEach(el => {
56
48
  el.innerText = currentGreeting;
@@ -62,8 +54,6 @@ async function fetchGreeting() {
62
54
  function signedOutFlow() {
63
55
  document.querySelector('#signed-in-flow').style.display = 'none';
64
56
  document.querySelector('#signed-out-flow').style.display = 'block';
65
-
66
- fetchGreeting();
67
57
  }
68
58
 
69
59
  // Displaying the signed in flow container and fill in account-specific data
@@ -71,8 +61,6 @@ function signedInFlow() {
71
61
  document.querySelector('#signed-out-flow').style.display = 'none';
72
62
  document.querySelector('#signed-in-flow').style.display = 'block';
73
63
  document.querySelectorAll('[data-behavior=account-id]').forEach(el => {
74
- el.innerText = window.accountId;
64
+ el.innerText = wallet.accountId;
75
65
  });
76
-
77
- fetchGreeting();
78
- }
66
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "my-near-app",
3
+ "version": "1.0.0",
4
+ "license": "(MIT AND Apache-2.0)",
5
+ "scripts": {
6
+ "start": "./start.sh",
7
+ "build": "parcel build index.html --public-url ./"
8
+ },
9
+ "devDependencies": {
10
+ "nodemon": "^2.0.16",
11
+ "parcel": "^2.6.0",
12
+ "process": "^0.11.10",
13
+ "env-cmd": "^10.1.0"
14
+ },
15
+ "dependencies": {
16
+ "@near-wallet-selector/core": "^6.0.0",
17
+ "@near-wallet-selector/ledger": "^6.0.0",
18
+ "@near-wallet-selector/math-wallet": "^6.0.0",
19
+ "@near-wallet-selector/meteor-wallet": "^6.0.0",
20
+ "@near-wallet-selector/modal-ui": "^6.0.0",
21
+ "@near-wallet-selector/my-near-wallet": "^6.0.0",
22
+ "@near-wallet-selector/near-wallet": "^6.0.0",
23
+ "@near-wallet-selector/nightly": "^6.0.0",
24
+ "@near-wallet-selector/nightly-connect": "^6.0.0",
25
+ "@near-wallet-selector/sender": "^6.0.0",
26
+ "@near-wallet-selector/wallet-connect": "^6.0.0",
27
+ "near-api-js": "^0.44.2"
28
+ }
29
+ }
@@ -9,7 +9,7 @@
9
9
  "@types/bn.js": "^5.1.0",
10
10
  "@types/node": "^18.6.2",
11
11
  "ava": "^4.2.0",
12
- "near-workspaces": "^3.1.0",
12
+ "near-workspaces": "^3.2.1",
13
13
  "ts-node": "^10.8.0",
14
14
  "typescript": "^4.7.2"
15
15
  },
@@ -1,4 +1,4 @@
1
- import { Worker, NEAR, NearAccount } from 'near-workspaces';
1
+ import { Worker, NearAccount } from 'near-workspaces';
2
2
  import anyTest, { TestFn } from 'ava';
3
3
 
4
4
  const test = anyTest as TestFn<{
@@ -9,18 +9,18 @@ Quick Start
9
9
 
10
10
  If you haven't installed dependencies during setup:
11
11
 
12
- npm run deps-install
12
+ npm install
13
13
 
14
14
 
15
15
  Build and deploy your contract to TestNet with a temporary dev account:
16
16
 
17
17
  npm run deploy
18
18
 
19
- Test your contract tests:
19
+ Test your contract:
20
20
 
21
21
  npm test
22
22
 
23
- If you have a frontend, run `npm run start`. This will run a dev server.
23
+ If you have a frontend, run `npm start`. This will run a dev server.
24
24
 
25
25
 
26
26
  Exploring The Code
package/dist/checks.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.postMessage = exports.preMessage = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- function preMessage(settings) {
9
- switch (settings.contract) {
10
- case 'assemblyscript':
11
- return asPreMessage(settings);
12
- default:
13
- return true;
14
- }
15
- }
16
- exports.preMessage = preMessage;
17
- function postMessage(settings) {
18
- switch (settings.contract) {
19
- default:
20
- return true;
21
- }
22
- }
23
- exports.postMessage = postMessage;
24
- // AS preMessage
25
- const AS_NOT_SUPPORTED_MSG = (0, chalk_1.default) `
26
- {yellow Warning} NEAR-SDK-AS might {bold {red not be compatible}} with your system
27
- `;
28
- async function asPreMessage({ tests }) {
29
- if (tests === 'workspaces') {
30
- console.log(AS_NOT_SUPPORTED_MSG);
31
- return true;
32
- }
33
- }
34
- //# sourceMappingURL=checks.js.map
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { createRoot } from 'react-dom/client';
3
- import App from './App';
4
- import { initContract } from './near-api';
5
-
6
- const reactRoot = createRoot(document.querySelector('#root'));
7
-
8
- window.nearInitPromise = initContract()
9
- .then(() => {
10
- reactRoot.render(<App />);
11
- })
12
- .catch(e => {
13
- reactRoot.render(<div style={{color: 'red'}}>Error: <code>{e.message}</code></div>);
14
- console.error(e);
15
- });
@@ -1,51 +0,0 @@
1
- import { connect, Contract, keyStores, WalletConnection } from 'near-api-js';
2
- import { getConfig } from './near-config';
3
-
4
- const nearConfig = getConfig(process.env.NODE_ENV || 'development');
5
-
6
- // Initialize contract & set global variables
7
- export async function initContract() {
8
- // Initialize connection to the NEAR testnet
9
- const near = await connect(Object.assign({ deps: { keyStore: new keyStores.BrowserLocalStorageKeyStore() } }, nearConfig));
10
-
11
- // Initializing Wallet based Account. It can work with NEAR testnet wallet that
12
- // is hosted at https://wallet.testnet.near.org
13
- window.walletConnection = new WalletConnection(near);
14
-
15
- // Getting the Account ID. If still unauthorized, it's just empty string
16
- window.accountId = window.walletConnection.getAccountId();
17
-
18
- // Initializing our contract APIs by contract name and configuration
19
- window.contract = await new Contract(window.walletConnection.account(), nearConfig.contractName, {
20
- // View methods are read only. They don't modify the state, but usually return some value.
21
- viewMethods: ['get_greeting'],
22
- // Change methods can modify the state. But you don't receive the returned value when called.
23
- changeMethods: ['set_greeting'],
24
- });
25
- }
26
-
27
- export function signOutNearWallet() {
28
- window.walletConnection.signOut();
29
- // reload page
30
- window.location.replace(window.location.origin + window.location.pathname);
31
- }
32
-
33
- export function signInWithNearWallet() {
34
- // Allow the current app to make calls to the specified contract on the
35
- // user's behalf.
36
- // This works by creating a new access key for the user's account and storing
37
- // the private key in localStorage.
38
- window.walletConnection.requestSignIn(nearConfig.contractName);
39
- }
40
-
41
- export async function setGreetingOnContract(message) {
42
- let response = await window.contract.set_greeting({
43
- args: { message: message }
44
- });
45
- return response;
46
- }
47
-
48
- export async function getGreetingFromContract() {
49
- let greeting = await window.contract.get_greeting();
50
- return greeting;
51
- }
@@ -1,61 +0,0 @@
1
- const CONTRACT_NAME = process.env.CONTRACT_NAME;
2
-
3
- export function getConfig(env) {
4
- switch (env) {
5
-
6
- case 'production':
7
- case 'mainnet':
8
- return {
9
- networkId: 'mainnet',
10
- nodeUrl: 'https://rpc.mainnet.near.org',
11
- contractName: CONTRACT_NAME,
12
- walletUrl: 'https://wallet.near.org',
13
- helperUrl: 'https://helper.mainnet.near.org',
14
- explorerUrl: 'https://explorer.mainnet.near.org',
15
- };
16
- case 'development':
17
- case 'testnet':
18
- return {
19
- networkId: 'testnet',
20
- nodeUrl: 'https://rpc.testnet.near.org',
21
- contractName: CONTRACT_NAME,
22
- walletUrl: 'https://wallet.testnet.near.org',
23
- helperUrl: 'https://helper.testnet.near.org',
24
- explorerUrl: 'https://explorer.testnet.near.org',
25
- };
26
- case 'betanet':
27
- return {
28
- networkId: 'betanet',
29
- nodeUrl: 'https://rpc.betanet.near.org',
30
- contractName: CONTRACT_NAME,
31
- walletUrl: 'https://wallet.betanet.near.org',
32
- helperUrl: 'https://helper.betanet.near.org',
33
- explorerUrl: 'https://explorer.betanet.near.org',
34
- };
35
- case 'local':
36
- return {
37
- networkId: 'local',
38
- nodeUrl: 'http://localhost:3030',
39
- keyPath: `${process.env.HOME}/.near/validator_key.json`,
40
- walletUrl: 'http://localhost:4000/wallet',
41
- contractName: CONTRACT_NAME,
42
- };
43
- case 'test':
44
- case 'ci':
45
- return {
46
- networkId: 'shared-test',
47
- nodeUrl: 'https://rpc.ci-testnet.near.org',
48
- contractName: CONTRACT_NAME,
49
- masterAccount: 'test.near',
50
- };
51
- case 'ci-betanet':
52
- return {
53
- networkId: 'shared-test-staging',
54
- nodeUrl: 'https://rpc.ci-betanet.near.org',
55
- contractName: CONTRACT_NAME,
56
- masterAccount: 'test.near',
57
- };
58
- default:
59
- throw Error(`Unconfigured environment '${env}'. Can be configured in src/config.js.`);
60
- }
61
- }
@@ -1,86 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <link rel="icon" href="assets/favicon.ico"/>
7
- <link rel="apple-touch-icon" href="assets/favicon.ico"/>
8
- <title>Welcome to NEAR</title>
9
- <link rel="stylesheet" href="assets/global.css">
10
- </head>
11
- <body>
12
- <main id="signed-out-flow" style="display: none">
13
- <h1>
14
- The contract says: <span class="greeting" data-behavior="greeting"></span>
15
- </h1>
16
- <h3>
17
- Welcome to NEAR!
18
- </h3>
19
- <p>
20
- Your contract is storing a greeting message in the NEAR blockchain. To
21
- change it you need to sign in using the NEAR Wallet. It is very simple,
22
- just use the button below.
23
- </p>
24
- <p>
25
- Do not worry, this app runs in the test network ("testnet"). It works
26
- just like the main network ("mainnet"), but using NEAR Tokens that are
27
- only for testing!
28
- </p>
29
- <p style="text-align: center; margin-top: 2.5em">
30
- <button id="sign-in-button">Sign in with NEAR Wallet</button>
31
- </p>
32
- </main>
33
-
34
- <div id="signed-in-flow" style="display: none">
35
- <button style="float: right" id="sign-out-button">
36
- Sign out <span data-behavior="account-id"></span>
37
- </button>
38
- <main>
39
- <h1>
40
- The contract says: <span class="greeting" data-behavior="greeting"></span>
41
- </h1>
42
- <form class="change">
43
- <label for="greeting">Change greeting:</label>
44
- <div>
45
- <input
46
- autocomplete="off"
47
- id="greeting"
48
- data-behavior="greeting"
49
- />
50
- <button>Save</button>
51
- </div>
52
- </form>
53
- <p>
54
- Look at that! A Hello World app! This greeting is stored on the NEAR blockchain. Check it out:
55
- </p>
56
- <ol>
57
- <li>
58
- Look in <code>index.js</code> and <code>near-api.js</code> – you'll see <code>get_greeting</code>
59
- and <code>set_greeting</code> being called on <code>contract</code>.
60
- What's this?
61
- </li>
62
- <li>
63
- Ultimately, this <code>contract</code> code is defined in
64
- <code>assembly/index.ts</code> – this is the source code for your
65
- <a target="_blank" href="https://docs.near.org/docs/develop/contracts/overview">smart contract</a>.
66
- </li>
67
- <li>
68
- When you run <code>npm run dev</code>, the code in
69
- <code>assembly/index.ts</code> gets deployed to the NEAR testnet. You
70
- can see how this happens by looking in <code>package.json</code> at the
71
- <code>scripts</code> section to find the <code>dev</code> command.
72
- </li>
73
- </ol>
74
- <hr>
75
- <p>
76
- To keep learning, check out
77
- <a target="_blank" href="https://docs.near.org">the NEAR docs</a>
78
- or look through some
79
- <a target="_blank" href="https://examples.near.org">example apps</a>.
80
- </p>
81
- </main>
82
- </div>
83
-
84
- <script src="index.js" type="module"></script>
85
- </body>
86
- </html>