create-near-app 3.1.0 → 4.0.0-beta.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 (99) hide show
  1. package/README.md +11 -11
  2. package/dist/app.js +98 -0
  3. package/dist/checks.js +34 -0
  4. package/dist/make.js +131 -0
  5. package/dist/messages.js +46 -0
  6. package/dist/package-json.js +140 -0
  7. package/dist/tracking.js +34 -0
  8. package/dist/types.js +3 -0
  9. package/dist/user-input.js +113 -0
  10. package/index.js +1 -233
  11. package/package.json +53 -44
  12. package/{contracts → templates/contracts}/assemblyscript/README.md +4 -3
  13. package/templates/contracts/assemblyscript/as-pect.config.js +1 -0
  14. package/{contracts → templates/contracts}/assemblyscript/asconfig.json +0 -0
  15. package/{contracts → templates/contracts}/assemblyscript/assembly/__tests__/as-pect.d.ts +0 -0
  16. package/templates/contracts/assemblyscript/assembly/__tests__/main.spec.ts +11 -0
  17. package/{contracts → templates/contracts}/assemblyscript/assembly/as_types.d.ts +0 -0
  18. package/{contracts → templates/contracts}/assemblyscript/assembly/index.ts +5 -5
  19. package/{contracts → templates/contracts}/assemblyscript/assembly/tsconfig.json +0 -0
  20. package/templates/contracts/assemblyscript/package.json +14 -0
  21. package/templates/contracts/assemblyscript/yarn.lock +2952 -0
  22. package/templates/contracts/js/babel.config.json +7 -0
  23. package/templates/contracts/js/package.json +18 -0
  24. package/templates/contracts/js/src/contract.ts +31 -0
  25. package/templates/contracts/js/tsconfig.json +10 -0
  26. package/templates/contracts/js/yarn.lock +2534 -0
  27. package/{contracts → templates/contracts}/rust/.cargo/config +0 -0
  28. package/{contracts → templates/contracts}/rust/Cargo.toml +1 -1
  29. package/{contracts → templates/contracts}/rust/README.md +4 -6
  30. package/{contracts → templates/contracts}/rust/src/lib.rs +0 -0
  31. package/templates/frontend/react/frontend/App.js +66 -0
  32. package/templates/{react/frontend/assets/img → frontend/react/frontend/assets}/favicon.ico +0 -0
  33. package/templates/{vanilla/frontend/assets/css → frontend/react/frontend/assets}/global.css +64 -80
  34. package/templates/{react/frontend/assets/img → frontend/react/frontend/assets}/logo-black.svg +0 -0
  35. package/templates/{react/frontend/assets/img → frontend/react/frontend/assets}/logo-white.svg +0 -0
  36. package/templates/frontend/react/frontend/index.html +15 -0
  37. package/templates/frontend/react/frontend/index.js +15 -0
  38. package/templates/{react/frontend/assets/js/near/utils.js → frontend/react/frontend/near-api.js} +19 -19
  39. package/templates/frontend/react/frontend/near-config.js +61 -0
  40. package/templates/frontend/react/frontend/package.json +44 -0
  41. package/templates/frontend/react/frontend/ui-components.js +60 -0
  42. package/templates/frontend/react/frontend/yarn.lock +4550 -0
  43. package/templates/{vanilla/frontend/assets/img → frontend/vanilla/frontend/assets}/favicon.ico +0 -0
  44. package/templates/{react/frontend/assets/css → frontend/vanilla/frontend/assets}/global.css +64 -80
  45. package/templates/{vanilla/frontend/assets/img → frontend/vanilla/frontend/assets}/logo-black.svg +0 -0
  46. package/templates/{vanilla/frontend/assets/img → frontend/vanilla/frontend/assets}/logo-white.svg +0 -0
  47. package/templates/frontend/vanilla/frontend/index.html +86 -0
  48. package/templates/frontend/vanilla/frontend/index.js +78 -0
  49. package/templates/{vanilla/frontend/assets/js/near/utils.js → frontend/vanilla/frontend/near-api.js} +18 -18
  50. package/templates/frontend/vanilla/frontend/near-config.js +62 -0
  51. package/templates/frontend/vanilla/frontend/package.json +18 -0
  52. package/templates/frontend/vanilla/frontend/yarn.lock +2328 -0
  53. package/{integration-tests/js → templates/integration-tests/classic-tests}/ava.config.cjs +9 -9
  54. package/templates/integration-tests/classic-tests/package.json +17 -0
  55. package/templates/integration-tests/classic-tests/src/config.ts +34 -0
  56. package/templates/integration-tests/classic-tests/src/main.ava.ts +32 -0
  57. package/templates/integration-tests/classic-tests/yarn.lock +1323 -0
  58. package/{integration-tests → templates/integration-tests/workspaces-tests}/rs/Cargo.toml +0 -0
  59. package/{integration-tests → templates/integration-tests/workspaces-tests}/rs/src/tests.rs +5 -3
  60. package/{integration-tests → templates/integration-tests/workspaces-tests}/ts/ava.config.cjs +9 -9
  61. package/templates/integration-tests/workspaces-tests/ts/package.json +17 -0
  62. package/templates/integration-tests/workspaces-tests/ts/src/main.ava.ts +45 -0
  63. package/templates/integration-tests/workspaces-tests/ts/yarn.lock +1653 -0
  64. package/templates/{none → shared}/.gitpod.yml +0 -0
  65. package/templates/{vanilla → shared}/README.md +30 -31
  66. package/templates/{react → shared}/near.gitignore +1 -1
  67. package/contracts/assemblyscript/as-pect.config.js +0 -1
  68. package/contracts/assemblyscript/assembly/__tests__/main.spec.ts +0 -11
  69. package/contracts/assemblyscript/package.json +0 -13
  70. package/integration-tests/js/package.json +0 -16
  71. package/integration-tests/js/src/config.ts +0 -31
  72. package/integration-tests/js/src/main.ava.ts +0 -32
  73. package/integration-tests/ts/package.json +0 -16
  74. package/integration-tests/ts/src/main.ava.ts +0 -44
  75. package/templates/none/.gitattributes +0 -2
  76. package/templates/none/README.md +0 -101
  77. package/templates/none/near.gitignore +0 -27
  78. package/templates/none/neardev/shared-test/test.near.json +0 -1
  79. package/templates/none/package.json +0 -33
  80. package/templates/react/.gitpod.yml +0 -6
  81. package/templates/react/README.md +0 -102
  82. package/templates/react/ava.config.cjs +0 -9
  83. package/templates/react/frontend/App.js +0 -202
  84. package/templates/react/frontend/__mocks__/fileMock.js +0 -3
  85. package/templates/react/frontend/assets/js/near/config.js +0 -63
  86. package/templates/react/frontend/index.html +0 -25
  87. package/templates/react/frontend/index.js +0 -14
  88. package/templates/react/neardev/shared-test/test.near.json +0 -1
  89. package/templates/react/package.json +0 -55
  90. package/templates/vanilla/.gitattributes +0 -2
  91. package/templates/vanilla/.gitpod.yml +0 -6
  92. package/templates/vanilla/frontend/assets/js/index.js +0 -74
  93. package/templates/vanilla/frontend/assets/js/near/config.js +0 -63
  94. package/templates/vanilla/frontend/index.html +0 -103
  95. package/templates/vanilla/near.gitignore +0 -27
  96. package/templates/vanilla/neardev/shared-test/test.near.json +0 -1
  97. package/templates/vanilla/package.json +0 -34
  98. package/utils/rust-setup.js +0 -113
  99. package/utils/tracking.js +0 -29
File without changes
@@ -7,44 +7,47 @@ This app was initialized with [create-near-app]
7
7
  Quick Start
8
8
  ===========
9
9
 
10
- To run this project locally:
10
+ If you haven't installed dependencies during setup:
11
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`)
12
+ yarn deps-install
16
13
 
17
- Now you'll have a local development environment backed by the NEAR TestNet!
18
14
 
19
- Go ahead and play with the app and the code. As you make code changes, the app will automatically reload.
15
+ Build and deploy your contract to TestNet with a temporary dev account:
16
+
17
+ yarn deploy
18
+
19
+ Test your contract tests:
20
+
21
+ yarn test
22
+
23
+ If you have a frontend, run `yarn start`. This will run a dev server.
20
24
 
21
25
 
22
26
  Exploring The Code
23
27
  ==================
24
28
 
25
- 1. The "backend" code lives in the `/contract` folder. See the README there for
26
- more info.
29
+ 1. The smart-contract code lives in the `/contract` folder. See the README there for
30
+ more info. In blockchain apps the smart contract is the "backend" of your app.
27
31
  2. The frontend code lives in the `/frontend` folder. `/frontend/index.html` is a great
28
- place to start exploring. Note that it loads in `/frontend/assets/src/js/index.js`, where you
29
- can learn how the frontend connects to the NEAR blockchain.
30
- 3. Tests: there are different kinds of tests for the frontend and the smart
31
- contract. See `contract/README` for info about how it's tested. The frontend
32
- code gets tested with [jest]. You can run both of these at once with `npm
33
- run test`.
32
+ place to start exploring. Note that it loads in `/frontend/index.js`,
33
+ this is your entrypoint to learn how the frontend connects to the NEAR blockchain.
34
+ 3. Test your contract: `yarn test`, this will run the tests in `integration-tests` directory.
34
35
 
35
36
 
36
37
  Deploy
37
38
  ======
38
39
 
39
- 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.
40
+ Every smart contract in NEAR has its [own associated account][NEAR accounts].
41
+ When you run `yarn deploy`, your smart contract gets deployed to the live NEAR TestNet with a temporary dev account.
42
+ When you're ready to make it permanent, here's how:
40
43
 
41
44
 
42
45
  Step 0: Install near-cli (optional)
43
46
  -------------------------------------
44
47
 
45
- [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:
48
+ [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 `yarn install`, but for best ergonomics you may want to install it globally:
46
49
 
47
- npm install --global near-cli
50
+ yarn global add near-cli
48
51
 
49
52
  Or, if you'd rather use the locally-installed version, you can prefix all `near` commands with `npx`
50
53
 
@@ -64,26 +67,22 @@ Each account on NEAR can have at most one contract deployed to it. If you've alr
64
67
 
65
68
  near create-account near-blank-project.YOUR-NAME.testnet --masterAccount YOUR-NAME.testnet
66
69
 
70
+ Step 2: deploy the contract
71
+ ---------------------------
67
72
 
68
- Step 2: set contract name in code
69
- ---------------------------------
70
-
71
- Modify the line in `src/config.js` that sets the account name of the contract. Set it to the account id you used above.
72
-
73
- const CONTRACT_NAME = process.env.CONTRACT_NAME || 'near-blank-project.YOUR-NAME.testnet'
73
+ Use the CLI to deploy the contract to TestNet with your account ID.
74
+ Replace `PATH_TO_WASM_FILE` with the `wasm` that was generated in `contract` build directory.
74
75
 
76
+ near deploy --accountId near-blank-project.YOUR-NAME.testnet --wasmFile PATH_TO_WASM_FILE
75
77
 
76
- Step 3: deploy!
77
- ---------------
78
78
 
79
- One command:
79
+ Step 3: set contract name in your frontend code
80
+ -----------------------------------------------
80
81
 
81
- npm run deploy
82
+ Modify the line in `src/config.js` that sets the account name of the contract. Set it to the account id you used above.
82
83
 
83
- As you can see in `package.json`, this does two things:
84
+ const CONTRACT_NAME = process.env.CONTRACT_NAME || 'near-blank-project.YOUR-NAME.testnet'
84
85
 
85
- 1. builds & deploys smart contract to NEAR TestNet
86
- 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.
87
86
 
88
87
 
89
88
  Troubleshooting
@@ -10,7 +10,7 @@ node_modules
10
10
  /dist
11
11
 
12
12
  # keys
13
- /neardev
13
+ /templates/react/neardev
14
14
 
15
15
  # testing
16
16
  /coverage
@@ -1 +0,0 @@
1
- module.exports = require('near-sdk-as/imports')
@@ -1,11 +0,0 @@
1
- import { set_greeting, get_greeting } from '..'
2
-
3
- describe('Greeting ', () => {
4
- it('should get the default greeting', () => {
5
- expect(get_greeting()).toBe('Hello')
6
- })
7
- it('should change the greeting', () => {
8
- set_greeting('howdy')
9
- expect(get_greeting()).toBe('howdy')
10
- })
11
- })
@@ -1,13 +0,0 @@
1
- {
2
- "name": "greeter",
3
- "version": "1.0.0",
4
- "license": "UNLICENSED",
5
- "private": true,
6
- "scripts": {
7
- "build": "asb",
8
- "test": "asp --nologo"
9
- },
10
- "dependencies": {
11
- "near-sdk-as": "^3.2.3"
12
- }
13
- }
@@ -1,16 +0,0 @@
1
- {
2
- "name": "ava-testing",
3
- "version": "1.0.0",
4
- "license": "(MIT AND Apache-2.0)",
5
- "scripts": {
6
- "test": "ava --verbose"
7
- },
8
- "devDependencies": {
9
- "ava": "^4.2.0",
10
- "near-api-js": "^0.44.2",
11
- "typescript": "^4.7.2",
12
- "ts-node": "^10.8.0",
13
- "@types/bn.js": "^5.1.0"
14
- },
15
- "dependencies": {}
16
- }
@@ -1,31 +0,0 @@
1
-
2
- import { keyStores, KeyPair } from 'near-api-js'
3
- const fs = require('fs')
4
-
5
- const CONTRACT_NAME=fs.readFileSync('../neardev/dev-account', 'utf-8')
6
- const NETWORK_ID='testnet'
7
-
8
- // Create an InMemoryKeyStore
9
- const keyStore = new keyStores.InMemoryKeyStore()
10
-
11
- // Load credentials
12
- const credPath = `${process.env.HOME}/.near-credentials/${NETWORK_ID}/${CONTRACT_NAME}.json`
13
- let credentials = JSON.parse(fs.readFileSync(credPath))
14
-
15
- // Save key in the key store
16
- keyStore.setKey(
17
- NETWORK_ID,
18
- CONTRACT_NAME,
19
- KeyPair.fromString(credentials.private_key)
20
- )
21
-
22
- export const nearConfig = {
23
- networkId: NETWORK_ID,
24
- nodeUrl: 'https://rpc.testnet.near.org',
25
- contractName: CONTRACT_NAME,
26
- walletUrl: 'https://wallet.testnet.near.org',
27
- helperUrl: 'https://helper.testnet.near.org',
28
- explorerUrl: 'https://explorer.testnet.near.org',
29
- headers: {},
30
- deps: {keyStore}
31
- }
@@ -1,32 +0,0 @@
1
- import anyTest, { TestFn } from 'ava'
2
-
3
- import { Near, Account, Contract } from 'near-api-js'
4
- import { nearConfig } from './config'
5
-
6
- const test = anyTest as TestFn<{
7
- accounts: Record<string, any>;
8
- }>
9
-
10
- test.beforeEach(async (t) => {
11
- const near = await new Near(nearConfig)
12
- const user = await new Account(near.connection, nearConfig.contractName)
13
- const contract = await new Contract(
14
- user,
15
- nearConfig.contractName,
16
- { viewMethods: ['get_greeting'], changeMethods: ['set_greeting'] }
17
- )
18
- t.context.accounts = { contract }
19
- })
20
-
21
- test('returns the default greeting', async (t) => {
22
- const { contract } = t.context.accounts
23
- const message: string = await contract.get_greeting({})
24
- t.is(message, 'Hello')
25
- })
26
-
27
- test('changes the message', async (t) => {
28
- const { contract } = t.context.accounts
29
- await contract.set_greeting({args:{ message: 'Howdy' }})
30
- const message: string = await contract.get_greeting({})
31
- t.is(message, 'Howdy')
32
- })
@@ -1,16 +0,0 @@
1
- {
2
- "name": "ava-testing",
3
- "version": "1.0.0",
4
- "license": "(MIT AND Apache-2.0)",
5
- "scripts": {
6
- "test": "ava --verbose"
7
- },
8
- "devDependencies": {
9
- "ava": "^4.2.0",
10
- "near-workspaces": "^2.0.0",
11
- "typescript": "^4.7.2",
12
- "ts-node": "^10.8.0",
13
- "@types/bn.js": "^5.1.0"
14
- },
15
- "dependencies": {}
16
- }
@@ -1,44 +0,0 @@
1
- import { Worker, NEAR, NearAccount } from 'near-workspaces'
2
- import anyTest, { TestFn } from 'ava'
3
-
4
- const test = anyTest as TestFn<{
5
- worker: Worker;
6
- accounts: Record<string, NearAccount>;
7
- }>
8
-
9
- test.beforeEach(async (t) => {
10
- // Init the worker and start a Sandbox server
11
- const worker = await Worker.init()
12
-
13
- // deploy contract
14
- const root = worker.rootAccount
15
- const contract = await root.createAndDeploy(
16
- root.getSubAccount('greeter').accountId,
17
- './out/main.wasm',
18
- { initialBalance: NEAR.parse('30 N').toJSON() }
19
- )
20
-
21
- // Save state for test runs, it is unique for each test
22
- t.context.worker = worker
23
- t.context.accounts = { root, contract }
24
- })
25
-
26
- test.afterEach(async (t) => {
27
- // Stop Sandbox server
28
- await t.context.worker.tearDown().catch((error) => {
29
- console.log('Failed to stop the Sandbox:', error)
30
- })
31
- })
32
-
33
- test('returns the default greeting', async (t) => {
34
- const { contract } = t.context.accounts
35
- const message: string = await contract.view('get_greeting', {})
36
- t.is(message, 'Hello')
37
- })
38
-
39
- test('changes the message', async (t) => {
40
- const { root, contract } = t.context.accounts
41
- await root.call(contract, 'set_greeting', { message: 'Howdy' })
42
- const message: string = await contract.view('get_greeting', {})
43
- t.is(message, 'Howdy')
44
- })
@@ -1,2 +0,0 @@
1
- package-lock.json linguist-generated=true -diff
2
- yarn.lock linguist-generated=true -diff
@@ -1,101 +0,0 @@
1
- near-blank-project
2
- ==================
3
-
4
- This 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 `/frontend` folder. `/frontend/index.html` is a great
28
- place to start exploring. Note that it loads in `/frontend/assets/src/js/index.js`, where you
29
- can learn how the frontend connects to the NEAR blockchain.
30
- 3. Tests: there are different kinds of tests for the frontend and the smart
31
- contract. See `contract/README` for info about how it's tested. The frontend
32
- code gets tested with [jest]. You can run both of these at once with `npm
33
- run test`.
34
-
35
-
36
- Deploy
37
- ======
38
-
39
- 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.
40
-
41
-
42
- Step 0: Install near-cli (optional)
43
- -------------------------------------
44
-
45
- [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:
46
-
47
- npm install --global near-cli
48
-
49
- Or, if you'd rather use the locally-installed version, you can prefix all `near` commands with `npx`
50
-
51
- Ensure that it's installed with `near --version` (or `npx near --version`)
52
-
53
-
54
- Step 1: Create an account for the contract
55
- ------------------------------------------
56
-
57
- 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`:
58
-
59
- 1. Authorize NEAR CLI, following the commands it gives you:
60
-
61
- near login
62
-
63
- 2. Create a subaccount (replace `YOUR-NAME` below with your actual account name):
64
-
65
- near create-account near-blank-project.YOUR-NAME.testnet --masterAccount YOUR-NAME.testnet
66
-
67
-
68
- Step 2: set contract name in code
69
- ---------------------------------
70
-
71
- Modify the line in `src/config.js` that sets the account name of the contract. Set it to the account id you used above.
72
-
73
- const CONTRACT_NAME = process.env.CONTRACT_NAME || 'near-blank-project.YOUR-NAME.testnet'
74
-
75
-
76
- Step 3: deploy!
77
- ---------------
78
-
79
- One command:
80
-
81
- npm run deploy
82
-
83
- As you can see in `package.json`, this does two things:
84
-
85
- 1. builds & deploys smart contract to NEAR TestNet
86
- 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.
87
-
88
-
89
- Troubleshooting
90
- ===============
91
-
92
- 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.
93
-
94
-
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,27 +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
- # misc
19
- .DS_Store
20
- .env.local
21
- .env.development.local
22
- .env.test.local
23
- .env.production.local
24
-
25
- npm-debug.log*
26
- yarn-debug.log*
27
- yarn-error.log*
@@ -1 +0,0 @@
1
- {"account_id":"test.near","private_key":"ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw"}
@@ -1,33 +0,0 @@
1
- {
2
- "name": "greeter",
3
- "version": "1.0.0",
4
- "license": "(MIT AND Apache-2.0)",
5
- "scripts": {
6
- "build": "npm run build:contract",
7
- "build:contract": "cd contract && npm run build && cp ./build/release/greeter.wasm ../out/main.wasm",
8
- "deploy": "npm run build:contract && near dev-deploy",
9
- "start": "npm run deploy",
10
- "dev": "nodemon --watch contract -e ts --exec \"npm run start\"",
11
- "test": "npm run build:contract && npm run test:unit && npm run test:integration",
12
- "test:unit": "cd contract && npm i && npm run test",
13
- "test:integration": "npm run test:integration:ts && npm run test:integration:rs",
14
- "test:integration:ts": "cd integration-tests/ts && npm run test",
15
- "test:integration:rs": "cd integration-tests/rs && cargo run --example integration-tests"
16
- },
17
- "devDependencies": {
18
- "env-cmd": "^10.1.0",
19
- "near-cli": "^3.3.0",
20
- "nodemon": "~2.0.16",
21
- "parcel": "^2.6.0",
22
- "ava": "^4.2.0",
23
- "near-workspaces": "^2.0.0",
24
- "typescript": "^4.7.2",
25
- "process": "^0.11.10",
26
- "ts-node": "^10.8.0"
27
- },
28
- "dependencies": {
29
- "near-api-js": "^0.44.2",
30
- "near-sdk-as": "^3.2.3",
31
- "regenerator-runtime": "~0.13.9"
32
- }
33
- }
@@ -1,6 +0,0 @@
1
- tasks:
2
- - init: yarn
3
- command: yarn dev
4
- ports:
5
- - port: 1234
6
- onOpen: open-browser
@@ -1,102 +0,0 @@
1
- near-blank-project
2
- ==================
3
-
4
- This [React] 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 `/frontend` folder. `/frontend/index.html` is a great
28
- place to start exploring. Note that it loads in `/frontend/assets/js/index.js`, where you
29
- can learn how the frontend connects to the NEAR blockchain.
30
- 3. Tests: there are different kinds of tests for the frontend and the smart
31
- contract. See `contract/README` for info about how it's tested. The frontend
32
- code gets tested with [jest]. You can run both of these at once with `npm
33
- run test`.
34
-
35
-
36
- Deploy
37
- ======
38
-
39
- 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.
40
-
41
-
42
- Step 0: Install near-cli (optional)
43
- -------------------------------------
44
-
45
- [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:
46
-
47
- npm install --global near-cli
48
-
49
- Or, if you'd rather use the locally-installed version, you can prefix all `near` commands with `npx`
50
-
51
- Ensure that it's installed with `near --version` (or `npx near --version`)
52
-
53
-
54
- Step 1: Create an account for the contract
55
- ------------------------------------------
56
-
57
- 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`:
58
-
59
- 1. Authorize NEAR CLI, following the commands it gives you:
60
-
61
- near login
62
-
63
- 2. Create a subaccount (replace `YOUR-NAME` below with your actual account name):
64
-
65
- near create-account near-blank-project.YOUR-NAME.testnet --masterAccount YOUR-NAME.testnet
66
-
67
-
68
- Step 2: set contract name in code
69
- ---------------------------------
70
-
71
- Modify the line in `src/config.js` that sets the account name of the contract. Set it to the account id you used above.
72
-
73
- const CONTRACT_NAME = process.env.CONTRACT_NAME || 'near-blank-project.YOUR-NAME.testnet'
74
-
75
-
76
- Step 3: deploy!
77
- ---------------
78
-
79
- One command:
80
-
81
- npm run deploy
82
-
83
- As you can see in `package.json`, this does two things:
84
-
85
- 1. builds & deploys smart contract to NEAR TestNet
86
- 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.
87
-
88
-
89
- Troubleshooting
90
- ===============
91
-
92
- 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.
93
-
94
-
95
- [React]: https://reactjs.org/
96
- [create-near-app]: https://github.com/near/create-near-app
97
- [Node.js]: https://nodejs.org/en/download/package-manager/
98
- [jest]: https://jestjs.io/
99
- [NEAR accounts]: https://docs.near.org/docs/concepts/account
100
- [NEAR Wallet]: https://wallet.testnet.near.org/
101
- [near-cli]: https://github.com/near/near-cli
102
- [gh-pages]: https://github.com/tschaub/gh-pages
@@ -1,9 +0,0 @@
1
- require("util").inspect.defaultOptions.depth = 5; // Increase AVA's printing depth
2
-
3
- module.exports = {
4
- timeout: "300000",
5
- files: ["**/*.ava.ts"],
6
- failWithoutAssertions: false,
7
- extensions: ["ts"],
8
- require: ["ts-node/register"],
9
- };