create-near-app 1.3.6 → 3.0.0-pre.7.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 (146) hide show
  1. package/README.md +3 -3
  2. package/{common/contracts → contracts}/assemblyscript/README.md +2 -3
  3. package/{common/contracts → contracts}/assemblyscript/as-pect.config.js +0 -0
  4. package/{common/contracts → contracts}/assemblyscript/asconfig.json +0 -0
  5. package/{common/contracts → contracts}/assemblyscript/assembly/__tests__/as-pect.d.ts +0 -0
  6. package/contracts/assemblyscript/assembly/__tests__/main.spec.ts +11 -0
  7. package/{common/contracts → contracts}/assemblyscript/assembly/as_types.d.ts +0 -0
  8. package/contracts/assemblyscript/assembly/index.ts +23 -0
  9. package/{common/contracts → contracts}/assemblyscript/assembly/tsconfig.json +0 -0
  10. package/{common/contracts → contracts}/assemblyscript/package.json +2 -6
  11. package/{common/contracts → contracts}/rust/.cargo/config +0 -0
  12. package/{common/contracts → contracts}/rust/Cargo.toml +4 -5
  13. package/{common/contracts → contracts}/rust/README.md +2 -3
  14. package/contracts/rust/src/lib.rs +72 -0
  15. package/index.js +74 -77
  16. package/integration-tests/rs/Cargo.toml +22 -0
  17. package/integration-tests/rs/src/tests.rs +66 -0
  18. package/integration-tests/ts/ava.config.cjs +9 -0
  19. package/integration-tests/ts/package.json +16 -0
  20. package/integration-tests/ts/src/main.ava.ts +44 -0
  21. package/package.json +24 -23
  22. package/templates/react/README.md +2 -2
  23. package/templates/react/ava.config.cjs +9 -0
  24. package/templates/react/{src → frontend}/App.js +35 -30
  25. package/templates/react/{src → frontend}/__mocks__/fileMock.js +0 -0
  26. package/{common/frontend → templates/react/frontend/assets/css}/global.css +4 -3
  27. package/{common/frontend/assets → templates/react/frontend/assets/img}/favicon.ico +0 -0
  28. package/{common/frontend/assets → templates/react/frontend/assets/img}/logo-black.svg +0 -0
  29. package/{common/frontend/assets → templates/react/frontend/assets/img}/logo-white.svg +0 -0
  30. package/templates/react/{src → frontend/assets/js/near}/config.js +1 -1
  31. package/templates/{vue/src → react/frontend/assets/js/near}/utils.js +14 -4
  32. package/templates/react/{src → frontend}/index.html +3 -3
  33. package/templates/react/frontend/index.js +14 -0
  34. package/templates/react/near.gitignore +6 -3
  35. package/templates/react/package.json +29 -43
  36. package/templates/vanilla/README.md +2 -2
  37. package/templates/vanilla/frontend/assets/css/global.css +189 -0
  38. package/templates/vanilla/frontend/assets/img/favicon.ico +0 -0
  39. package/templates/vanilla/frontend/assets/img/logo-black.svg +1 -0
  40. package/templates/vanilla/frontend/assets/img/logo-white.svg +1 -0
  41. package/templates/vanilla/frontend/assets/js/index.js +74 -0
  42. package/templates/vanilla/{src → frontend/assets/js/near}/config.js +1 -1
  43. package/templates/{angular/src → vanilla/frontend/assets/js/near}/utils.js +14 -4
  44. package/templates/vanilla/{src → frontend}/index.html +25 -30
  45. package/templates/vanilla/near.gitignore +1 -1
  46. package/templates/vanilla/package.json +25 -31
  47. package/utils/rust-setup.js +102 -0
  48. package/utils/tracking.js +29 -0
  49. package/LICENSE-APACHE +0 -176
  50. package/common/.npmignore +0 -2
  51. package/common/contracts/.gitignore +0 -1
  52. package/common/contracts/assemblyscript/.gitignore +0 -4
  53. package/common/contracts/assemblyscript/assembly/__tests__/main.spec.ts +0 -9
  54. package/common/contracts/assemblyscript/assembly/index.ts +0 -40
  55. package/common/contracts/assemblyscript/compile.js +0 -51
  56. package/common/contracts/rust/.gitignore +0 -1
  57. package/common/contracts/rust/Cargo.lock +0 -472
  58. package/common/contracts/rust/compile.js +0 -55
  59. package/common/contracts/rust/res/.gitkeep +0 -0
  60. package/common/contracts/rust/src/lib.rs +0 -115
  61. package/common/contracts/rust/target/.gitkeep +0 -0
  62. package/templates/.npmignore +0 -3
  63. package/templates/angular/.gitignore +0 -26
  64. package/templates/angular/.gitpod.yml +0 -6
  65. package/templates/angular/README.md +0 -102
  66. package/templates/angular/angular.json +0 -126
  67. package/templates/angular/contract +0 -1
  68. package/templates/angular/extra-webpack.config.ts +0 -7
  69. package/templates/angular/karma.conf.js +0 -40
  70. package/templates/angular/near.gitignore +0 -46
  71. package/templates/angular/neardev/.gitignore +0 -2
  72. package/templates/angular/neardev/shared-test/test.near.json +0 -1
  73. package/templates/angular/neardev/shared-test-staging/test.near.json +0 -1
  74. package/templates/angular/package.json +0 -63
  75. package/templates/angular/set-contract-name.js +0 -16
  76. package/templates/angular/src/app/app.component.html +0 -87
  77. package/templates/angular/src/app/app.component.spec.ts +0 -107
  78. package/templates/angular/src/app/app.component.ts +0 -88
  79. package/templates/angular/src/app/app.module.ts +0 -21
  80. package/templates/angular/src/app/components/notification/notification.component.html +0 -12
  81. package/templates/angular/src/app/components/notification/notification.component.spec.ts +0 -25
  82. package/templates/angular/src/app/components/notification/notification.component.ts +0 -23
  83. package/templates/angular/src/app/services/window.service.ts +0 -47
  84. package/templates/angular/src/assets +0 -1
  85. package/templates/angular/src/config.d.ts +0 -13
  86. package/templates/angular/src/config.js +0 -62
  87. package/templates/angular/src/contract-name.js +0 -1
  88. package/templates/angular/src/environments/environment.prod.ts +0 -3
  89. package/templates/angular/src/environments/environment.ts +0 -16
  90. package/templates/angular/src/global.css +0 -1
  91. package/templates/angular/src/index.html +0 -15
  92. package/templates/angular/src/main.ts +0 -15
  93. package/templates/angular/src/polyfills.ts +0 -64
  94. package/templates/angular/src/styles.scss +0 -1
  95. package/templates/angular/src/test.ts +0 -25
  96. package/templates/angular/src/utils.d.ts +0 -3
  97. package/templates/angular/src/window.d.ts +0 -15
  98. package/templates/angular/tsconfig.app.json +0 -15
  99. package/templates/angular/tsconfig.json +0 -21
  100. package/templates/angular/tsconfig.spec.json +0 -18
  101. package/templates/angular/tslint.json +0 -149
  102. package/templates/react/.gitignore +0 -28
  103. package/templates/react/babel.config.js +0 -3
  104. package/templates/react/contract +0 -1
  105. package/templates/react/neardev/.gitignore +0 -2
  106. package/templates/react/neardev/shared-test-staging/test.near.json +0 -1
  107. package/templates/react/src/assets +0 -1
  108. package/templates/react/src/global.css +0 -1
  109. package/templates/react/src/index.js +0 -13
  110. package/templates/react/src/jest.init.js +0 -1
  111. package/templates/react/src/main.test.js +0 -28
  112. package/templates/react/src/utils.js +0 -39
  113. package/templates/react/src/wallet/login/index.html +0 -28
  114. package/templates/vanilla/.gitignore +0 -26
  115. package/templates/vanilla/contract +0 -1
  116. package/templates/vanilla/neardev/.gitignore +0 -2
  117. package/templates/vanilla/neardev/shared-test-staging/test.near.json +0 -1
  118. package/templates/vanilla/src/assets +0 -1
  119. package/templates/vanilla/src/global.css +0 -1
  120. package/templates/vanilla/src/index.js +0 -113
  121. package/templates/vanilla/src/main.test.js +0 -15
  122. package/templates/vanilla/src/utils.js +0 -39
  123. package/templates/vanilla/src/wallet/login/index.html +0 -28
  124. package/templates/vue/.gitignore +0 -26
  125. package/templates/vue/.gitpod.yml +0 -6
  126. package/templates/vue/README.md +0 -101
  127. package/templates/vue/babel.config.js +0 -5
  128. package/templates/vue/contract +0 -1
  129. package/templates/vue/copy-dev-account.js +0 -7
  130. package/templates/vue/jest.config.js +0 -7
  131. package/templates/vue/near.gitignore +0 -46
  132. package/templates/vue/neardev/shared-test/test.near.json +0 -1
  133. package/templates/vue/neardev/shared-test-staging/test.near.json +0 -1
  134. package/templates/vue/package.json +0 -86
  135. package/templates/vue/src/App.vue +0 -37
  136. package/templates/vue/src/assets +0 -1
  137. package/templates/vue/src/components/Notification.vue +0 -38
  138. package/templates/vue/src/components/SignedIn.vue +0 -179
  139. package/templates/vue/src/components/SignedOut.vue +0 -34
  140. package/templates/vue/src/config.js +0 -63
  141. package/templates/vue/src/favicon.ico +0 -1
  142. package/templates/vue/src/global.css +0 -1
  143. package/templates/vue/src/main.js +0 -16
  144. package/templates/vue/tests/unit/Notification.spec.js +0 -26
  145. package/templates/vue/tests/unit/SignedIn.spec.js +0 -24
  146. package/templates/vue/tests/unit/SignedOut.spec.js +0 -17
@@ -1,101 +0,0 @@
1
- near-blank-project
2
- ==================
3
-
4
- This [Vue] app was initialized with [create-near-app]
5
-
6
-
7
- Quick Start
8
- ===========
9
-
10
- To run this project locally:
11
-
12
- 1. Prerequisites: Make sure you've installed [Node.js] ≥ 12
13
- 2. Install dependencies: `npm install`
14
- 3. Run the local development server: `npm run dev` (see `package.json` for a
15
- full list of `scripts` you can run with `npm`)
16
-
17
- Now you'll have a local development environment backed by the NEAR TestNet!
18
-
19
- Go ahead and play with the app and the code. As you make code changes, the app will automatically reload.
20
-
21
-
22
- Exploring The Code
23
- ==================
24
-
25
- 1. The "backend" code lives in the `/contract` folder. See the README there for
26
- more info.
27
- 2. The frontend code lives in the `/src` folder. `/src/main.js` is a great
28
- place to start exploring.
29
- 3. Tests: there are different kinds of tests for the frontend and the smart
30
- contract. See `contract/README` for info about how it's tested. The frontend
31
- code gets tested with [jest]. You can run both of these at once with `npm
32
- run test`.
33
-
34
-
35
- Deploy
36
- ======
37
-
38
- Every smart contract in NEAR has its [own associated account][NEAR accounts]. When you run `npm run dev`, your smart contract gets deployed to the live NEAR TestNet with a throwaway account. When you're ready to make it permanent, here's how.
39
-
40
-
41
- Step 0: Install near-cli (optional)
42
- -------------------------------------
43
-
44
- [near-cli] is a command line interface (CLI) for interacting with the NEAR blockchain. It was installed to the local `node_modules` folder when you ran `npm install`, but for best ergonomics you may want to install it globally:
45
-
46
- npm install --global near-cli
47
-
48
- Or, if you'd rather use the locally-installed version, you can prefix all `near` commands with `npx`
49
-
50
- Ensure that it's installed with `near --version` (or `npx near --version`)
51
-
52
-
53
- Step 1: Create an account for the contract
54
- ------------------------------------------
55
-
56
- Each account on NEAR can have at most one contract deployed to it. If you've already created an account such as `your-name.testnet`, you can deploy your contract to `near-blank-project.your-name.testnet`. Assuming you've already created an account on [NEAR Wallet], here's how to create `near-blank-project.your-name.testnet`:
57
-
58
- 1. Authorize NEAR CLI, following the commands it gives you:
59
-
60
- near login
61
-
62
- 2. Create a subaccount (replace `YOUR-NAME` below with your actual account name):
63
-
64
- near create-account near-blank-project.YOUR-NAME.testnet --masterAccount YOUR-NAME.testnet
65
-
66
-
67
- Step 2: set contract name in code
68
- ---------------------------------
69
-
70
- Modify the line in `src/config.js` that sets the account name of the contract. Set it to the account id you used above.
71
-
72
- const CONTRACT_NAME = process.env.CONTRACT_NAME || 'near-blank-project.YOUR-NAME.testnet'
73
-
74
-
75
- Step 3: deploy!
76
- ---------------
77
-
78
- One command:
79
-
80
- npm run deploy
81
-
82
- As you can see in `package.json`, this does two things:
83
-
84
- 1. builds & deploys smart contract to NEAR TestNet
85
- 2. builds & deploys frontend code to GitHub using [gh-pages]. This will only work if the project already has a repository set up on GitHub. Feel free to modify the `deploy` script in `package.json` to deploy elsewhere.
86
-
87
-
88
- Troubleshooting
89
- ===============
90
-
91
- On Windows, if you're seeing an error containing `EPERM` it may be related to spaces in your path. Please see [this issue](https://github.com/zkat/npx/issues/209) for more details.
92
-
93
-
94
- [Vue]: https://vuejs.org/
95
- [create-near-app]: https://github.com/near/create-near-app
96
- [Node.js]: https://nodejs.org/en/download/package-manager/
97
- [jest]: https://jestjs.io/
98
- [NEAR accounts]: https://docs.near.org/docs/concepts/account
99
- [NEAR Wallet]: https://wallet.testnet.near.org/
100
- [near-cli]: https://github.com/near/near-cli
101
- [gh-pages]: https://github.com/tschaub/gh-pages
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- '@vue/cli-plugin-babel/preset'
4
- ]
5
- }
@@ -1 +0,0 @@
1
- ../../common/contracts/assemblyscript
@@ -1,7 +0,0 @@
1
- let fs=require('fs')
2
- // copy created contract name for vue-cli-service at ./.env
3
- const contractNameFilePath = './neardev/dev-account';
4
- const existingContractName = fs.readFileSync(contractNameFilePath, { encoding: "utf8" }).trim();
5
- const vueEnvFile = "./.env.development.local"
6
- fs.writeFileSync(vueEnvFile , "VUE_APP_CONTRACT_NAME=" + existingContractName)
7
- console.log(`copied ${contractNameFilePath} to ${vueEnvFile}`)
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- preset: '@vue/cli-plugin-unit-jest',
3
- modulePaths: [
4
- "node_modules",
5
- "src"
6
- ]
7
- }
@@ -1,46 +0,0 @@
1
- # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
- # Developer note: near.gitignore will be renamed to .gitignore upon project creation
3
- # dependencies
4
- /node_modules
5
- /.pnp
6
- .pnp.js
7
- /out
8
-
9
- #keys
10
- /neardev
11
-
12
- # testing
13
- /coverage
14
-
15
- # production
16
- /build
17
-
18
- # Log files
19
- npm-debug.log*
20
- yarn-debug.log*
21
- yarn-error.log*
22
- pnpm-debug.log*
23
-
24
- # misc
25
- .DS_Store
26
- .env.local
27
- .env.development.local
28
- .env.test.local
29
- .env.production.local
30
-
31
- /dist
32
- /.cache
33
- /.vs
34
-
35
- # local env files
36
- .env.local
37
- .env.*.local
38
-
39
- # Editor directories and files
40
- .idea
41
- .vscode
42
- *.suo
43
- *.ntvs*
44
- *.njsproj
45
- *.sln
46
- *.sw?
@@ -1 +0,0 @@
1
- {"account_id":"test.near","private_key":"ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw"}
@@ -1 +0,0 @@
1
- {"account_id":"test.near","private_key":"ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw"}
@@ -1,86 +0,0 @@
1
- {
2
- "name": "near-blank-project",
3
- "version": "0.0.1",
4
- "license": "UNLICENSED",
5
- "scripts": {
6
- "build": "npm run build:contract && npm run build:web",
7
- "build:contract": "node contract/compile.js",
8
- "build:contract:debug": "node contract/compile.js --debug",
9
- "build:web": "node copy-dev-account.js && vue-cli-service build",
10
- "dev:deploy:contract": "near dev-deploy",
11
- "deploy:contract": "near deploy",
12
- "deploy:pages": "gh-pages -d dist/",
13
- "deploy": "npm run build && npm run deploy:contract && npm run deploy:pages",
14
- "prestart": "npm run build:contract:debug && npm run dev:deploy:contract",
15
- "start": "echo The app is starting! It will automatically open in your browser when ready && npm run serve",
16
- "dev": "nodemon --watch contract -e ts --exec \"npm run start\"",
17
- "test:web": "vue-cli-service test:unit",
18
- "test": "npm run build:contract:debug && cd contract && npm run test && cd .. && vue-cli-service test:unit",
19
- "serve": "node copy-dev-account.js && vue-cli-service serve --open",
20
- "lint": "eslint . --ext .js --ext .vue --fix"
21
- },
22
- "dependencies": {
23
- "core-js": "~3.6.5",
24
- "near-api-js": "~0.36.3",
25
- "vue": "~2.6.11"
26
- },
27
- "devDependencies": {
28
- "@vue/cli-plugin-babel": "~4.5.8",
29
- "@vue/cli-plugin-eslint": "~4.5.8",
30
- "@vue/cli-plugin-unit-jest": "~4.5.4",
31
- "@vue/cli-service": "~4.5.8",
32
- "@vue/test-utils": "~1.1.1",
33
- "env-cmd": "~10.1.0",
34
- "eslint": "~7.20.0",
35
- "eslint-plugin-vue": "~7.6.0",
36
- "gh-pages": "~3.1.0",
37
- "near-cli": "~1.5.3",
38
- "nodemon": "~2.0.4",
39
- "shelljs": "~0.8.4",
40
- "vue-template-compiler": "~2.6.11"
41
- },
42
- "eslintConfig": {
43
- "ignorePatterns": [
44
- "src/config.js",
45
- "/tests/*.spec.js",
46
- "copy-dev-account.js"
47
- ],
48
- "env": {
49
- "browser": true,
50
- "es2020": true
51
- },
52
- "extends": [
53
- "eslint:recommended",
54
- "plugin:vue/essential"
55
- ],
56
- "parserOptions": {
57
- "ecmaVersion": 2017,
58
- "sourceType": "module"
59
- },
60
- "plugins": [
61
- "vue"
62
- ],
63
- "rules": {
64
- "indent": [
65
- 2,
66
- 2
67
- ],
68
- "quotes": [
69
- "off",
70
- "double"
71
- ],
72
- "vue/html-indent": [
73
- "error",
74
- 2,
75
- {
76
- "alignAttributesVertically": true
77
- }
78
- ]
79
- }
80
- },
81
- "browserslist": [
82
- "> 1%",
83
- "last 2 versions",
84
- "not dead"
85
- ]
86
- }
@@ -1,37 +0,0 @@
1
- <template>
2
- <div id="root">
3
- <SignedOut v-show="!isSignedIn" />
4
- <SignedIn v-show="isSignedIn" />
5
- </div>
6
- </template>
7
-
8
- <script>
9
- import "./global.css"
10
- import getConfig from "./config"
11
- import SignedOut from "./components/SignedOut.vue"
12
- import SignedIn from "./components/SignedIn.vue"
13
-
14
- const nearConfig = getConfig(process.env.NODE_ENV || "development")
15
- console.log(
16
- `networkId:${nearConfig.networkId} CONTRACT_NAME:${nearConfig.contractName}`
17
- )
18
- window.networkId = nearConfig.networkId
19
-
20
- export default {
21
- created() {
22
- document.title = "near-blank-project"
23
- },
24
- name: "App",
25
- components: {
26
- SignedOut,
27
- SignedIn,
28
- },
29
-
30
- computed: {
31
- isSignedIn() {
32
- return window.walletConnection.isSignedIn()
33
- },
34
- },
35
- }
36
- </script>
37
-
@@ -1 +0,0 @@
1
- ../../../common/frontend/assets
@@ -1,38 +0,0 @@
1
- <template>
2
- <div class="notification">
3
- <aside>
4
- <a target="_blank" rel="noreferrer" v-bind:href="urlPrefix + '/' + accountId">{{ accountId }}</a>
5
- <br />
6
- {{ msg }}
7
- <br />in contract:
8
- <a
9
- target="_blank"
10
- rel="noreferrer"
11
- v-bind:href="urlPrefix + '/' + contractId"
12
- >{{ contractId }}</a>
13
- <footer>
14
- <div>✔ Succeeded</div>
15
- <div>Just now</div>
16
- </footer>
17
- </aside>
18
- </div>
19
- </template>
20
-
21
- <script>
22
- export default {
23
- name: "Notification",
24
- props: {
25
- networkId: String,
26
- msg: String,
27
- contractId: String,
28
- },
29
- computed: {
30
- urlPrefix() {
31
- return "https://explorer." + this.networkId + ".near.org/accounts"
32
- },
33
- accountId() {
34
- return window.accountId
35
- }
36
- }
37
- }
38
- </script>
@@ -1,179 +0,0 @@
1
- <template>
2
- <div>
3
- <button class="link" style="float: right" v-on:click="logout">Sign out</button>
4
- <main>
5
- <h1>
6
- <label
7
- for="greeting"
8
- style="color: var(--secondary);border-bottom: 2px solid var(--secondary);"
9
- >{{ savedGreeting }}</label>
10
- {{ accountId }}
11
- </h1>
12
- <form v-on:submit.prevent="saveGreeting">
13
- <fieldset ref="fieldset">
14
- <label
15
- for="greeting"
16
- style="display:block; color:var(--gray);margin-bottom:0.5em;"
17
- >Change greeting</label>
18
- <div style="display:flex">
19
- <input v-model="newGreeting" autocomplete="off" id="greeting" style="flex:1" />
20
- <button id="save" style="border-radius:0 5px 5px 0">Save</button>
21
- </div>
22
- </fieldset>
23
- </form>
24
- <p>Look at that! A Hello World app! This greeting is stored on the NEAR blockchain. Check it out:</p>
25
- <ol>
26
- <li>
27
- Look in
28
- <code>src/App.vue</code> and
29
- <code>src/utils.js</code>
30
- - you'll see
31
- <code>getGreeting</code>
32
- and
33
- <code>setGreeting</code> being called on
34
- <code>contract</code>. What's this?
35
- </li>
36
- <li>
37
- Ultimately, this
38
- <code>contract</code> code is defined in
39
- <code>assembly/main.ts</code>
40
- - this is the source code for your
41
- <a
42
- target="_blank"
43
- rel="noreferrer"
44
- href="https://docs.near.org/docs/roles/developer/contracts/intro"
45
- >smart contract</a>.
46
- </li>
47
- <li>
48
- When you run
49
- <code>npm run dev</code> or
50
- <code>yarn dev</code>, the code in
51
- <code>assembly/main.ts</code>
52
- gets deployed to the NEAR testnet. You can see how this happens by looking in
53
- <code>package.json</code>
54
- at the
55
- <code>scripts</code> section to find the
56
- <code>dev</code> command.
57
- </li>
58
- </ol>
59
- <hr />
60
- <p>
61
- To keep learning, check out
62
- <a
63
- target="_blank"
64
- rel="noreferrer"
65
- href="https://docs.near.org"
66
- >the NEAR docs</a> or look through some
67
- <a
68
- target="_blank"
69
- rel="noreferrer"
70
- href="https://examples.near.org"
71
- >example apps</a>.
72
- </p>
73
- </main>
74
-
75
- <Notification
76
- v-show="notificationVisible"
77
- ref="notification"
78
- :networkId="networkId"
79
- :msg="'called method: setGreeting'"
80
- :contractId="contractId"
81
- :visible="false"
82
- />
83
- </div>
84
- </template>
85
-
86
- <script>
87
- import { logout } from "../utils"
88
-
89
- import Notification from "./Notification.vue"
90
-
91
- export default {
92
- name: "SignedIn",
93
-
94
- beforeMount() {
95
- if (this.isSignedIn) {
96
- this.retrieveSavedGreeting()
97
- }
98
- },
99
-
100
- components: {
101
- Notification,
102
- },
103
-
104
- data: function () {
105
- return {
106
- savedGreeting: "",
107
- newGreeting: "",
108
- notificationVisible: false,
109
- }
110
- },
111
-
112
- computed: {
113
- isSignedIn() {
114
- return window.walletConnection? window.walletConnection.isSignedIn(): false
115
- },
116
- accountId() {
117
- return window.accountId
118
- },
119
- contractId() {
120
- return window.contract? window.contract.contractId: null
121
- },
122
- networkId() {
123
- return window.networkId
124
- },
125
- },
126
-
127
- methods: {
128
- retrieveSavedGreeting() {
129
- //retrieve greeting
130
- window.contract
131
- .getGreeting({ accountId: window.accountId })
132
- .then((greetingFromContract) => {
133
- this.savedGreeting = greetingFromContract
134
- this.newGreeting = greetingFromContract
135
- })
136
- },
137
-
138
- saveGreeting: async function (event) {
139
- // fired on form submit button used to update the greeting
140
-
141
- // disable the form while the value gets updated on-chain
142
- this.$refs.fieldset.disabled = true
143
-
144
- try {
145
-
146
- // make an update call to the smart contract
147
- await window.contract.setGreeting({
148
- // pass the new greeting
149
- message: this.newGreeting,
150
- })
151
- } catch (e) {
152
- alert(
153
- "Something went wrong! " +
154
- "Maybe you need to sign out and back in? " +
155
- "Check your browser console for more info."
156
- )
157
- throw e //re-throw
158
- } finally {
159
- // re-enable the form, whether the call succeeded or failed
160
- this.$refs.fieldset.disabled = false
161
- }
162
-
163
- // update savedGreeting with persisted value
164
- this.savedGreeting = this.newGreeting
165
-
166
- this.notificationVisible = true //show new notification
167
-
168
- // remove Notification again after css animation completes
169
- // this allows it to be shown again next time the form is submitted
170
- setTimeout(() => {
171
- this.notificationVisible = false
172
- }, 11000)
173
-
174
- },
175
-
176
- logout: logout,
177
- },
178
- }
179
- </script>
@@ -1,34 +0,0 @@
1
- <template>
2
- <main>
3
- <h1>Welcome to NEAR!</h1>
4
- <p>
5
- To make use of the NEAR blockchain, you need to sign in. The button
6
- below will sign you in using NEAR Wallet.
7
- </p>
8
- <p>
9
- By default, when your app runs in "development" mode, it connects
10
- to a test network ("testnet") wallet. This works just like the main
11
- network ("mainnet") wallet, but the NEAR Tokens on testnet aren't
12
- convertible to other currencies - they're just for testing!
13
- </p>
14
- <p>Go ahead and click the button below to try it out:</p>
15
- <p style="text-align:center; margin-top:2.5em">
16
- <button v-on:click="login">Sign in</button>
17
- </p>
18
- </main>
19
- </template>
20
-
21
- <script>
22
- import { login } from "../utils"
23
-
24
- export default {
25
- name: "SignedOut",
26
-
27
- methods: {
28
- login() {
29
- console.log("calling utils.login")
30
- login()
31
- },
32
- },
33
- }
34
- </script>
@@ -1,63 +0,0 @@
1
- const CONTRACT_NAME = process.env.VUE_APP_CONTRACT_NAME ||'near-blank-project'
2
-
3
- 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
- }
62
-
63
- module.exports = getConfig
@@ -1 +0,0 @@
1
- ../../../common/frontend/assets/favicon.ico
@@ -1 +0,0 @@
1
- ../../../common/frontend/global.css
@@ -1,16 +0,0 @@
1
- import Vue from "vue"
2
- import App from "./App.vue"
3
-
4
- import { initContract } from "./utils"
5
-
6
- Vue.config.productionTip = false
7
-
8
- window.nearInitPromise = initContract()
9
- .then(() => {
10
-
11
- new Vue({
12
- render: h => h(App),
13
- }).$mount("#app")
14
-
15
- })
16
-
@@ -1,26 +0,0 @@
1
- import { shallowMount } from '@vue/test-utils'
2
- import Notification from 'components/Notification.vue'
3
-
4
-
5
- describe('Notification.vue Test', () => {
6
- it('renders message when component is created', () => {
7
- // render the component
8
- const wrapper = shallowMount(Notification, {
9
- propsData: {
10
- msg: 'Test Message'
11
- }
12
- })
13
-
14
- console.log(wrapper.text())
15
-
16
- //check msg prop
17
- expect(wrapper.props("msg")).toMatch('Test Message')
18
-
19
- // check that the message is rendered
20
- expect(wrapper.text()).toMatch('Test Message')
21
-
22
- // check that additional the text is rendered
23
- expect(wrapper.text()).toMatch('in contract')
24
-
25
- })
26
- })