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.
Files changed (118) hide show
  1. package/{common/contracts → contracts}/assemblyscript/README.md +1 -2
  2. package/{common/contracts → contracts}/assemblyscript/as-pect.config.js +0 -0
  3. package/{common/contracts → contracts}/assemblyscript/asconfig.json +0 -0
  4. package/{common/contracts → contracts}/assemblyscript/assembly/__tests__/as-pect.d.ts +0 -0
  5. package/contracts/assemblyscript/assembly/__tests__/main.spec.ts +11 -0
  6. package/{common/contracts → contracts}/assemblyscript/assembly/as_types.d.ts +0 -0
  7. package/contracts/assemblyscript/assembly/index.ts +23 -0
  8. package/{common/contracts → contracts}/assemblyscript/assembly/tsconfig.json +0 -0
  9. package/{common/contracts → contracts}/assemblyscript/package.json +2 -6
  10. package/{common/contracts → contracts}/rust/.cargo/config +0 -0
  11. package/{common/contracts → contracts}/rust/Cargo.toml +4 -5
  12. package/{common/contracts → contracts}/rust/README.md +1 -2
  13. package/contracts/rust/src/lib.rs +72 -0
  14. package/index.js +51 -71
  15. package/integration-tests/rs/Cargo.toml +22 -0
  16. package/integration-tests/rs/src/tests.rs +66 -0
  17. package/integration-tests/ts/ava.config.cjs +9 -0
  18. package/integration-tests/ts/package.json +16 -0
  19. package/integration-tests/ts/src/main.ava.ts +44 -0
  20. package/package.json +23 -24
  21. package/templates/react/README.md +2 -2
  22. package/templates/react/ava.config.cjs +9 -0
  23. package/templates/react/{src → frontend}/App.js +34 -29
  24. package/templates/react/{src → frontend}/__mocks__/fileMock.js +0 -0
  25. package/{common/frontend → templates/react/frontend/assets/css}/global.css +4 -3
  26. package/{common/frontend/assets → templates/react/frontend/assets/img}/favicon.ico +0 -0
  27. package/{common/frontend/assets → templates/react/frontend/assets/img}/logo-black.svg +0 -0
  28. package/{common/frontend/assets → templates/react/frontend/assets/img}/logo-white.svg +0 -0
  29. package/templates/react/{src → frontend/assets/js/near}/config.js +1 -1
  30. package/templates/{vue/src → react/frontend/assets/js/near}/utils.js +14 -4
  31. package/templates/react/{src → frontend}/index.html +3 -3
  32. package/templates/react/frontend/index.js +14 -0
  33. package/templates/react/near.gitignore +1 -1
  34. package/templates/react/package.json +29 -43
  35. package/templates/vanilla/README.md +2 -2
  36. package/templates/vanilla/frontend/assets/css/global.css +189 -0
  37. package/templates/vanilla/frontend/assets/img/favicon.ico +0 -0
  38. package/templates/vanilla/frontend/assets/img/logo-black.svg +1 -0
  39. package/templates/vanilla/frontend/assets/img/logo-white.svg +1 -0
  40. package/templates/vanilla/frontend/assets/js/index.js +74 -0
  41. package/templates/vanilla/{src → frontend/assets/js/near}/config.js +1 -1
  42. package/templates/{angular/src → vanilla/frontend/assets/js/near}/utils.js +14 -4
  43. package/templates/vanilla/{src → frontend}/index.html +22 -27
  44. package/templates/vanilla/near.gitignore +1 -1
  45. package/templates/vanilla/package.json +25 -31
  46. package/utils/rust-setup.js +1 -20
  47. package/utils/tracking.js +1 -2
  48. package/common/contracts/assemblyscript/assembly/__tests__/main.spec.ts +0 -9
  49. package/common/contracts/assemblyscript/assembly/index.ts +0 -40
  50. package/common/contracts/assemblyscript/compile.js +0 -50
  51. package/common/contracts/rust/Cargo.lock +0 -638
  52. package/common/contracts/rust/compile.js +0 -53
  53. package/common/contracts/rust/res/.gitkeep +0 -0
  54. package/common/contracts/rust/src/lib.rs +0 -121
  55. package/templates/angular/.gitpod.yml +0 -6
  56. package/templates/angular/README.md +0 -102
  57. package/templates/angular/angular.json +0 -126
  58. package/templates/angular/extra-webpack.config.ts +0 -7
  59. package/templates/angular/karma.conf.js +0 -40
  60. package/templates/angular/near.gitignore +0 -46
  61. package/templates/angular/neardev/shared-test/test.near.json +0 -1
  62. package/templates/angular/neardev/shared-test-staging/test.near.json +0 -1
  63. package/templates/angular/package.json +0 -63
  64. package/templates/angular/set-contract-name.js +0 -16
  65. package/templates/angular/src/app/app.component.html +0 -87
  66. package/templates/angular/src/app/app.component.spec.ts +0 -107
  67. package/templates/angular/src/app/app.component.ts +0 -88
  68. package/templates/angular/src/app/app.module.ts +0 -21
  69. package/templates/angular/src/app/components/notification/notification.component.html +0 -12
  70. package/templates/angular/src/app/components/notification/notification.component.spec.ts +0 -25
  71. package/templates/angular/src/app/components/notification/notification.component.ts +0 -23
  72. package/templates/angular/src/app/services/window.service.ts +0 -43
  73. package/templates/angular/src/config.d.ts +0 -13
  74. package/templates/angular/src/config.js +0 -62
  75. package/templates/angular/src/contract-name.js +0 -1
  76. package/templates/angular/src/environments/environment.prod.ts +0 -3
  77. package/templates/angular/src/environments/environment.ts +0 -16
  78. package/templates/angular/src/index.html +0 -15
  79. package/templates/angular/src/main.ts +0 -15
  80. package/templates/angular/src/polyfills.ts +0 -64
  81. package/templates/angular/src/styles.scss +0 -1
  82. package/templates/angular/src/test.ts +0 -25
  83. package/templates/angular/src/utils.d.ts +0 -3
  84. package/templates/angular/src/window.d.ts +0 -15
  85. package/templates/angular/tsconfig.app.json +0 -15
  86. package/templates/angular/tsconfig.json +0 -21
  87. package/templates/angular/tsconfig.spec.json +0 -18
  88. package/templates/angular/tslint.json +0 -149
  89. package/templates/react/babel.config.js +0 -3
  90. package/templates/react/neardev/shared-test-staging/test.near.json +0 -1
  91. package/templates/react/src/index.js +0 -13
  92. package/templates/react/src/jest.init.js +0 -1
  93. package/templates/react/src/main.test.js +0 -28
  94. package/templates/react/src/utils.js +0 -39
  95. package/templates/react/src/wallet/login/index.html +0 -28
  96. package/templates/vanilla/neardev/shared-test-staging/test.near.json +0 -1
  97. package/templates/vanilla/src/index.js +0 -113
  98. package/templates/vanilla/src/main.test.js +0 -15
  99. package/templates/vanilla/src/utils.js +0 -39
  100. package/templates/vanilla/src/wallet/login/index.html +0 -28
  101. package/templates/vue/.gitpod.yml +0 -6
  102. package/templates/vue/README.md +0 -101
  103. package/templates/vue/babel.config.js +0 -5
  104. package/templates/vue/copy-dev-account.js +0 -7
  105. package/templates/vue/jest.config.js +0 -7
  106. package/templates/vue/near.gitignore +0 -46
  107. package/templates/vue/neardev/shared-test/test.near.json +0 -1
  108. package/templates/vue/neardev/shared-test-staging/test.near.json +0 -1
  109. package/templates/vue/package.json +0 -86
  110. package/templates/vue/src/App.vue +0 -37
  111. package/templates/vue/src/components/Notification.vue +0 -38
  112. package/templates/vue/src/components/SignedIn.vue +0 -179
  113. package/templates/vue/src/components/SignedOut.vue +0 -34
  114. package/templates/vue/src/config.js +0 -63
  115. package/templates/vue/src/main.js +0 -16
  116. package/templates/vue/tests/unit/Notification.spec.js +0 -26
  117. package/templates/vue/tests/unit/SignedIn.spec.js +0 -24
  118. package/templates/vue/tests/unit/SignedOut.spec.js +0 -17
@@ -1,149 +0,0 @@
1
- {
2
- "extends": "tslint:recommended",
3
- "rules": {
4
- "align": {
5
- "options": [
6
- "parameters",
7
- "statements"
8
- ]
9
- },
10
- "array-type": false,
11
- "arrow-return-shorthand": true,
12
- "curly": true,
13
- "deprecation": {
14
- "severity": "warning"
15
- },
16
- "component-class-suffix": true,
17
- "contextual-lifecycle": true,
18
- "directive-class-suffix": true,
19
- "directive-selector": [
20
- true,
21
- "attribute",
22
- "app",
23
- "camelCase"
24
- ],
25
- "component-selector": [
26
- true,
27
- "element",
28
- "app",
29
- "kebab-case"
30
- ],
31
- "eofline": true,
32
- "import-blacklist": [
33
- true,
34
- "rxjs/Rx"
35
- ],
36
- "import-spacing": true,
37
- "indent": {
38
- "options": [
39
- "spaces",
40
- 2
41
- ]
42
- },
43
- "max-classes-per-file": false,
44
- "max-line-length": [
45
- true,
46
- 140
47
- ],
48
- "member-ordering": [
49
- true,
50
- {
51
- "order": [
52
- "static-field",
53
- "instance-field",
54
- "static-method",
55
- "instance-method"
56
- ]
57
- }
58
- ],
59
- "no-console": false,
60
- "no-empty": false,
61
- "no-inferrable-types": [
62
- true,
63
- "ignore-params"
64
- ],
65
- "no-non-null-assertion": true,
66
- "no-redundant-jsdoc": true,
67
- "no-switch-case-fall-through": true,
68
- "no-var-requires": false,
69
- "object-literal-key-quotes": [
70
- true,
71
- "as-needed"
72
- ],
73
- "quotemark": [
74
- true,
75
- "single"
76
- ],
77
- "semicolon": {
78
- "options": [
79
- "never"
80
- ]
81
- },
82
- "space-before-function-paren": {
83
- "options": {
84
- "anonymous": "never",
85
- "asyncArrow": "always",
86
- "constructor": "never",
87
- "method": "never",
88
- "named": "never"
89
- }
90
- },
91
- "typedef": [
92
- true,
93
- "call-signature"
94
- ],
95
- "typedef-whitespace": {
96
- "options": [
97
- {
98
- "call-signature": "nospace",
99
- "index-signature": "nospace",
100
- "parameter": "nospace",
101
- "property-declaration": "nospace",
102
- "variable-declaration": "nospace"
103
- },
104
- {
105
- "call-signature": "onespace",
106
- "index-signature": "onespace",
107
- "parameter": "onespace",
108
- "property-declaration": "onespace",
109
- "variable-declaration": "onespace"
110
- }
111
- ]
112
- },
113
- "variable-name": {
114
- "options": [
115
- "ban-keywords",
116
- "check-format",
117
- "allow-pascal-case"
118
- ]
119
- },
120
- "whitespace": {
121
- "options": [
122
- "check-branch",
123
- "check-decl",
124
- "check-operator",
125
- "check-separator",
126
- "check-type",
127
- "check-typecast",
128
- "check-module",
129
- "check-rest-spread",
130
- "check-preblock"
131
- ]
132
- },
133
- "no-conflicting-lifecycle": true,
134
- "no-host-metadata-property": true,
135
- "no-input-rename": true,
136
- "no-inputs-metadata-property": true,
137
- "no-output-native": true,
138
- "no-output-on-prefix": true,
139
- "no-output-rename": true,
140
- "no-outputs-metadata-property": true,
141
- "template-banana-in-box": true,
142
- "template-no-negated-async": true,
143
- "use-lifecycle-interface": true,
144
- "use-pipe-transform-interface": true
145
- },
146
- "rulesDirectory": [
147
- "codelyzer"
148
- ]
149
- }
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- presets: ['@babel/preset-env', '@babel/preset-react'],
3
- }
@@ -1 +0,0 @@
1
- {"account_id":"test.near","private_key":"ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw"}
@@ -1,13 +0,0 @@
1
- import React from 'react'
2
- import ReactDOM from 'react-dom'
3
- import App from './App'
4
- import { initContract } from './utils'
5
-
6
- window.nearInitPromise = initContract()
7
- .then(() => {
8
- ReactDOM.render(
9
- <App />,
10
- document.querySelector('#root')
11
- )
12
- })
13
- .catch(console.error)
@@ -1 +0,0 @@
1
- import 'regenerator-runtime/runtime'
@@ -1,28 +0,0 @@
1
- beforeAll(async function () {
2
- // NOTE: nearlib and nearConfig are made available by near-cli/test_environment
3
- const near = await nearlib.connect(nearConfig)
4
- window.accountId = nearConfig.contractName
5
- window.contract = await near.loadContract(nearConfig.contractName, {
6
- viewMethods: ['getGreeting'],
7
- changeMethods: [],
8
- sender: window.accountId
9
- })
10
-
11
- window.walletConnection = {
12
- requestSignIn() {
13
- },
14
- signOut() {
15
- },
16
- isSignedIn() {
17
- return true
18
- },
19
- getAccountId() {
20
- return window.accountId
21
- }
22
- }
23
- })
24
-
25
- test('getGreeting', async () => {
26
- const message = await window.contract.getGreeting({ accountId: window.accountId })
27
- expect(message).toEqual('Hello')
28
- })
@@ -1,39 +0,0 @@
1
- import { connect, Contract, keyStores, WalletConnection } from 'near-api-js'
2
- import getConfig from './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: ['getGreeting'],
22
- // Change methods can modify the state. But you don't receive the returned value when called.
23
- changeMethods: ['setGreeting'],
24
- })
25
- }
26
-
27
- export function logout() {
28
- window.walletConnection.signOut()
29
- // reload page
30
- window.location.replace(window.location.origin + window.location.pathname)
31
- }
32
-
33
- export function login() {
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
- }
@@ -1,28 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
6
- </head>
7
- <body style="background: #fff; margin-top: 3em">
8
- <div>For local account login, Please run the following command in NEAR CLI, then enter account id here.
9
- </div>
10
- <div>
11
- <code id="shell-command"></code>
12
- </div>
13
- <input type="text" id="accountId" name="accountId" placeholder="Account id"></input>
14
- <button type="button" onClick="done()">done</button>
15
- <script>
16
- const currentUrl = new URL(window.location.href);
17
- const message = `NODE_ENV=local near create_account {newAccountId} --masterAccount {masterAccountId} --publicKey ${currentUrl.searchParams.get('public_key')} --initialAmount 10000000000000000000`;
18
- document.getElementById('shell-command').innerText = message;
19
-
20
- function done() {
21
- const successUrl = new URL(currentUrl.searchParams.get('success_url'));
22
- successUrl.searchParams.set('account_id', document.getElementById('accountId').value);
23
- successUrl.searchParams.set('public_key', currentUrl.searchParams.get('public_key'));
24
- window.location.assign(successUrl.toString());
25
- }
26
- </script>
27
- </body>
28
- </html>
@@ -1 +0,0 @@
1
- {"account_id":"test.near","private_key":"ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw"}
@@ -1,113 +0,0 @@
1
- import 'regenerator-runtime/runtime'
2
-
3
- import { initContract, login, logout } from './utils'
4
-
5
- import getConfig from './config'
6
- const { networkId } = getConfig(process.env.NODE_ENV || 'development')
7
-
8
- // global variable used throughout
9
- let currentGreeting
10
-
11
- const submitButton = document.querySelector('form button')
12
-
13
- document.querySelector('form').onsubmit = async (event) => {
14
- event.preventDefault()
15
-
16
- // get elements from the form using their id attribute
17
- const { fieldset, greeting } = event.target.elements
18
-
19
- // disable the form while the value gets updated on-chain
20
- fieldset.disabled = true
21
-
22
- try {
23
- // make an update call to the smart contract
24
- await window.contract.setGreeting({
25
- // pass the value that the user entered in the greeting field
26
- message: greeting.value
27
- })
28
- } catch (e) {
29
- alert(
30
- 'Something went wrong! ' +
31
- 'Maybe you need to sign out and back in? ' +
32
- 'Check your browser console for more info.'
33
- )
34
- throw e
35
- } finally {
36
- // re-enable the form, whether the call succeeded or failed
37
- fieldset.disabled = false
38
- }
39
-
40
- // disable the save button, since it now matches the persisted value
41
- submitButton.disabled = true
42
-
43
- // update the greeting in the UI
44
- await fetchGreeting()
45
-
46
- // show notification
47
- document.querySelector('[data-behavior=notification]').style.display = 'block'
48
-
49
- // remove notification again after css animation completes
50
- // this allows it to be shown again next time the form is submitted
51
- setTimeout(() => {
52
- document.querySelector('[data-behavior=notification]').style.display = 'none'
53
- }, 11000)
54
- }
55
-
56
- document.querySelector('input#greeting').oninput = (event) => {
57
- if (event.target.value !== currentGreeting) {
58
- submitButton.disabled = false
59
- } else {
60
- submitButton.disabled = true
61
- }
62
- }
63
-
64
- document.querySelector('#sign-in-button').onclick = login
65
- document.querySelector('#sign-out-button').onclick = logout
66
-
67
- // Display the signed-out-flow container
68
- function signedOutFlow() {
69
- document.querySelector('#signed-out-flow').style.display = 'block'
70
- }
71
-
72
- // Displaying the signed in flow container and fill in account-specific data
73
- function signedInFlow() {
74
- document.querySelector('#signed-in-flow').style.display = 'block'
75
-
76
- document.querySelectorAll('[data-behavior=account-id]').forEach(el => {
77
- el.innerText = window.accountId
78
- })
79
-
80
- // populate links in the notification box
81
- const accountLink = document.querySelector('[data-behavior=notification] a:nth-of-type(1)')
82
- accountLink.href = accountLink.href + window.accountId
83
- accountLink.innerText = '@' + window.accountId
84
- const contractLink = document.querySelector('[data-behavior=notification] a:nth-of-type(2)')
85
- contractLink.href = contractLink.href + window.contract.contractId
86
- contractLink.innerText = '@' + window.contract.contractId
87
-
88
- // update with selected networkId
89
- accountLink.href = accountLink.href.replace('testnet', networkId)
90
- contractLink.href = contractLink.href.replace('testnet', networkId)
91
-
92
- fetchGreeting()
93
- }
94
-
95
- // update global currentGreeting variable; update DOM with it
96
- async function fetchGreeting() {
97
- currentGreeting = await contract.getGreeting({ accountId: window.accountId })
98
- document.querySelectorAll('[data-behavior=greeting]').forEach(el => {
99
- // set divs, spans, etc
100
- el.innerText = currentGreeting
101
-
102
- // set input elements
103
- el.value = currentGreeting
104
- })
105
- }
106
-
107
- // `nearInitPromise` gets called on page load
108
- window.nearInitPromise = initContract()
109
- .then(() => {
110
- if (window.walletConnection.isSignedIn()) signedInFlow()
111
- else signedOutFlow()
112
- })
113
- .catch(console.error)
@@ -1,15 +0,0 @@
1
- beforeAll(async function () {
2
- // NOTE: nearlib and nearConfig are made available by near-cli/test_environment
3
- const near = await nearlib.connect(nearConfig)
4
- window.accountId = nearConfig.contractName
5
- window.contract = await near.loadContract(nearConfig.contractName, {
6
- viewMethods: ['getGreeting'],
7
- changeMethods: [],
8
- sender: window.accountId
9
- })
10
- })
11
-
12
- test('getGreeting', async () => {
13
- const message = await window.contract.getGreeting({ accountId: window.accountId })
14
- expect(message).toEqual('Hello')
15
- })
@@ -1,39 +0,0 @@
1
- import { connect, Contract, keyStores, WalletConnection } from 'near-api-js'
2
- import getConfig from './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: ['getGreeting'],
22
- // Change methods can modify the state. But you don't receive the returned value when called.
23
- changeMethods: ['setGreeting'],
24
- })
25
- }
26
-
27
- export function logout() {
28
- window.walletConnection.signOut()
29
- // reload page
30
- window.location.replace(window.location.origin + window.location.pathname)
31
- }
32
-
33
- export function login() {
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
- }
@@ -1,28 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
6
- </head>
7
- <body style="background: #fff; margin-top: 3em">
8
- <div>Please run the following command in NEAR CLI, then enter account id here. masterAccountId default: test.near
9
- </div>
10
- <div>
11
- <code id="shell-command"></code>
12
- </div>
13
- <input type="text" id="accountId" name="accountId" placeholder="Account id"></input>
14
- <button type="button" onClick="done()">done</button>
15
- <script>
16
- const currentUrl = new URL(window.location.href);
17
- const message = `NODE_ENV=local near create_account {newAccountId} --masterAccount {masterAccountId} --publicKey ${currentUrl.searchParams.get('public_key')} --initialAmount 10000000000000000000`;
18
- document.getElementById('shell-command').innerText = message;
19
-
20
- function done() {
21
- const successUrl = new URL(currentUrl.searchParams.get('success_url'));
22
- successUrl.searchParams.set('account_id', document.getElementById('accountId').value);
23
- successUrl.searchParams.set('public_key', currentUrl.searchParams.get('public_key'));
24
- window.location.assign(successUrl.toString());
25
- }
26
- </script>
27
- </body>
28
- </html>
@@ -1,6 +0,0 @@
1
- tasks:
2
- - init: yarn
3
- command: yarn dev
4
- ports:
5
- - port: 8080
6
- onOpen: open-browser
@@ -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,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"}