create-near-app 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{common/contracts → contracts}/assemblyscript/README.md +1 -2
- package/{common/contracts → contracts}/assemblyscript/as-pect.config.js +0 -0
- package/{common/contracts → contracts}/assemblyscript/asconfig.json +0 -0
- package/{common/contracts → contracts}/assemblyscript/assembly/__tests__/as-pect.d.ts +0 -0
- package/contracts/assemblyscript/assembly/__tests__/main.spec.ts +11 -0
- package/{common/contracts → contracts}/assemblyscript/assembly/as_types.d.ts +0 -0
- package/contracts/assemblyscript/assembly/index.ts +23 -0
- package/{common/contracts → contracts}/assemblyscript/assembly/tsconfig.json +0 -0
- package/{common/contracts → contracts}/assemblyscript/package.json +2 -6
- package/{common/contracts → contracts}/rust/.cargo/config +0 -0
- package/{common/contracts → contracts}/rust/Cargo.toml +4 -5
- package/{common/contracts → contracts}/rust/README.md +1 -2
- package/contracts/rust/src/lib.rs +72 -0
- package/index.js +51 -71
- package/integration-tests/rs/Cargo.toml +22 -0
- package/integration-tests/rs/src/tests.rs +66 -0
- package/integration-tests/ts/ava.config.cjs +9 -0
- package/integration-tests/ts/package.json +16 -0
- package/integration-tests/ts/src/main.ava.ts +44 -0
- package/package.json +23 -24
- package/templates/react/README.md +2 -2
- package/templates/react/ava.config.cjs +9 -0
- package/templates/react/{src → frontend}/App.js +34 -29
- package/templates/react/{src → frontend}/__mocks__/fileMock.js +0 -0
- package/{common/frontend → templates/react/frontend/assets/css}/global.css +4 -3
- package/{common/frontend/assets → templates/react/frontend/assets/img}/favicon.ico +0 -0
- package/{common/frontend/assets → templates/react/frontend/assets/img}/logo-black.svg +0 -0
- package/{common/frontend/assets → templates/react/frontend/assets/img}/logo-white.svg +0 -0
- package/templates/react/{src → frontend/assets/js/near}/config.js +1 -1
- package/templates/{vue/src → react/frontend/assets/js/near}/utils.js +14 -4
- package/templates/react/{src → frontend}/index.html +3 -3
- package/templates/react/frontend/index.js +14 -0
- package/templates/react/near.gitignore +1 -1
- package/templates/react/package.json +29 -43
- package/templates/vanilla/README.md +2 -2
- package/templates/vanilla/frontend/assets/css/global.css +189 -0
- package/templates/vanilla/frontend/assets/img/favicon.ico +0 -0
- package/templates/vanilla/frontend/assets/img/logo-black.svg +1 -0
- package/templates/vanilla/frontend/assets/img/logo-white.svg +1 -0
- package/templates/vanilla/frontend/assets/js/index.js +74 -0
- package/templates/vanilla/{src → frontend/assets/js/near}/config.js +1 -1
- package/templates/{angular/src → vanilla/frontend/assets/js/near}/utils.js +14 -4
- package/templates/vanilla/{src → frontend}/index.html +22 -27
- package/templates/vanilla/near.gitignore +1 -1
- package/templates/vanilla/package.json +25 -31
- package/utils/rust-setup.js +1 -20
- package/utils/tracking.js +1 -2
- package/common/contracts/assemblyscript/assembly/__tests__/main.spec.ts +0 -9
- package/common/contracts/assemblyscript/assembly/index.ts +0 -40
- package/common/contracts/assemblyscript/compile.js +0 -50
- package/common/contracts/rust/Cargo.lock +0 -638
- package/common/contracts/rust/compile.js +0 -53
- package/common/contracts/rust/res/.gitkeep +0 -0
- package/common/contracts/rust/src/lib.rs +0 -121
- package/templates/angular/.gitpod.yml +0 -6
- package/templates/angular/README.md +0 -102
- package/templates/angular/angular.json +0 -126
- package/templates/angular/extra-webpack.config.ts +0 -7
- package/templates/angular/karma.conf.js +0 -40
- package/templates/angular/near.gitignore +0 -46
- package/templates/angular/neardev/shared-test/test.near.json +0 -1
- package/templates/angular/neardev/shared-test-staging/test.near.json +0 -1
- package/templates/angular/package.json +0 -63
- package/templates/angular/set-contract-name.js +0 -16
- package/templates/angular/src/app/app.component.html +0 -87
- package/templates/angular/src/app/app.component.spec.ts +0 -107
- package/templates/angular/src/app/app.component.ts +0 -88
- package/templates/angular/src/app/app.module.ts +0 -21
- package/templates/angular/src/app/components/notification/notification.component.html +0 -12
- package/templates/angular/src/app/components/notification/notification.component.spec.ts +0 -25
- package/templates/angular/src/app/components/notification/notification.component.ts +0 -23
- package/templates/angular/src/app/services/window.service.ts +0 -43
- package/templates/angular/src/config.d.ts +0 -13
- package/templates/angular/src/config.js +0 -62
- package/templates/angular/src/contract-name.js +0 -1
- package/templates/angular/src/environments/environment.prod.ts +0 -3
- package/templates/angular/src/environments/environment.ts +0 -16
- package/templates/angular/src/index.html +0 -15
- package/templates/angular/src/main.ts +0 -15
- package/templates/angular/src/polyfills.ts +0 -64
- package/templates/angular/src/styles.scss +0 -1
- package/templates/angular/src/test.ts +0 -25
- package/templates/angular/src/utils.d.ts +0 -3
- package/templates/angular/src/window.d.ts +0 -15
- package/templates/angular/tsconfig.app.json +0 -15
- package/templates/angular/tsconfig.json +0 -21
- package/templates/angular/tsconfig.spec.json +0 -18
- package/templates/angular/tslint.json +0 -149
- package/templates/react/babel.config.js +0 -3
- package/templates/react/neardev/shared-test-staging/test.near.json +0 -1
- package/templates/react/src/index.js +0 -13
- package/templates/react/src/jest.init.js +0 -1
- package/templates/react/src/main.test.js +0 -28
- package/templates/react/src/utils.js +0 -39
- package/templates/react/src/wallet/login/index.html +0 -28
- package/templates/vanilla/neardev/shared-test-staging/test.near.json +0 -1
- package/templates/vanilla/src/index.js +0 -113
- package/templates/vanilla/src/main.test.js +0 -15
- package/templates/vanilla/src/utils.js +0 -39
- package/templates/vanilla/src/wallet/login/index.html +0 -28
- package/templates/vue/.gitpod.yml +0 -6
- package/templates/vue/README.md +0 -101
- package/templates/vue/babel.config.js +0 -5
- package/templates/vue/copy-dev-account.js +0 -7
- package/templates/vue/jest.config.js +0 -7
- package/templates/vue/near.gitignore +0 -46
- package/templates/vue/neardev/shared-test/test.near.json +0 -1
- package/templates/vue/neardev/shared-test-staging/test.near.json +0 -1
- package/templates/vue/package.json +0 -86
- package/templates/vue/src/App.vue +0 -37
- package/templates/vue/src/components/Notification.vue +0 -38
- package/templates/vue/src/components/SignedIn.vue +0 -179
- package/templates/vue/src/components/SignedOut.vue +0 -34
- package/templates/vue/src/config.js +0 -63
- package/templates/vue/src/main.js +0 -16
- package/templates/vue/tests/unit/Notification.spec.js +0 -26
- package/templates/vue/tests/unit/SignedIn.spec.js +0 -24
- package/templates/vue/tests/unit/SignedOut.spec.js +0 -17
|
@@ -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.12.1",
|
|
24
|
-
"near-api-js": "~0.41.0",
|
|
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.2.0",
|
|
33
|
-
"env-cmd": "~10.1.0",
|
|
34
|
-
"eslint": "~7.26.0",
|
|
35
|
-
"eslint-plugin-vue": "~7.9.0",
|
|
36
|
-
"gh-pages": "~3.1.0",
|
|
37
|
-
"near-cli": "~1.6.0",
|
|
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,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/develop/contracts/overview"
|
|
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,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
|
-
})
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils'
|
|
2
|
-
import SignedIn from 'components/SignedIn.vue'
|
|
3
|
-
import Notification from 'components/Notification.vue'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe('SignedIn.vue Test', () => {
|
|
7
|
-
it('compose component', () => {
|
|
8
|
-
// render the component
|
|
9
|
-
const wrapper = shallowMount(SignedIn, {})
|
|
10
|
-
|
|
11
|
-
// check that the text is rendered
|
|
12
|
-
expect(wrapper.text()).toMatch('This greeting is stored on the NEAR blockchain')
|
|
13
|
-
|
|
14
|
-
// check that the logout button is rendered
|
|
15
|
-
expect(wrapper.find('button').text()).toBe("Sign out")
|
|
16
|
-
|
|
17
|
-
// check that the save button is rendered
|
|
18
|
-
expect(wrapper.find('#save').text()).toBe("Save")
|
|
19
|
-
|
|
20
|
-
// check the notification component is present
|
|
21
|
-
expect(wrapper.findComponent(Notification).exists()).toBe(true)
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
})
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils'
|
|
2
|
-
import SignedOut from 'components/SignedOut.vue'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
describe('SignedOut.vue Test', () => {
|
|
6
|
-
it('compose main page', () => {
|
|
7
|
-
// render the component
|
|
8
|
-
const wrapper = shallowMount(SignedOut, {})
|
|
9
|
-
|
|
10
|
-
// check that the text is rendered
|
|
11
|
-
expect(wrapper.text()).toMatch('Welcome to NEAR')
|
|
12
|
-
|
|
13
|
-
// check that the login button rendered
|
|
14
|
-
expect(wrapper.find('button').text()).toBe("Sign in")
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
})
|