create-blocklet 0.3.5 → 0.3.6
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/README.md +14 -0
- package/index.js +7 -2
- package/lib/index.js +2 -1
- package/lib/server.js +17 -9
- package/package.json +6 -6
- package/templates/nextjs-dapp/package.json +5 -5
- package/templates/react-dapp/package.json +5 -5
- package/templates/react-dapp/src/app.css +5 -3
- package/templates/react-dapp/src/pages/home.js +1 -1
- package/templates/react-gun-dapp/.env +3 -0
- package/templates/react-gun-dapp/README.md +153 -0
- package/templates/react-gun-dapp/api/hooks/pre-start.js +33 -0
- package/templates/react-gun-dapp/api/index.js +65 -0
- package/templates/react-gun-dapp/api/libs/auth.js +22 -0
- package/templates/react-gun-dapp/api/libs/env.js +6 -0
- package/templates/react-gun-dapp/api/libs/logger.js +3 -0
- package/templates/react-gun-dapp/api/routes/index.js +6 -0
- package/templates/react-gun-dapp/blocklet.md +3 -0
- package/templates/react-gun-dapp/blocklet.yml +57 -0
- package/templates/react-gun-dapp/craco.config.js +30 -0
- package/templates/react-gun-dapp/package.json +81 -0
- package/templates/react-gun-dapp/public/index.html +35 -0
- package/templates/react-gun-dapp/src/app.css +41 -0
- package/templates/react-gun-dapp/src/app.js +32 -0
- package/templates/react-gun-dapp/src/index.js +5 -0
- package/templates/react-gun-dapp/src/libs/api.js +14 -0
- package/templates/react-gun-dapp/src/logo.svg +1 -0
- package/templates/react-gun-dapp/src/pages/about.js +26 -0
- package/templates/react-gun-dapp/src/pages/home.js +61 -0
- package/templates/react-static/src/app.css +5 -3
- package/templates/react-static/src/pages/home.js +4 -0
- package/templates/vue-dapp/package.json +6 -6
- package/templates/vue2-dapp/package.json +5 -5
package/README.md
CHANGED
|
@@ -36,6 +36,8 @@ Currently supported template presets include:
|
|
|
36
36
|
- `react`
|
|
37
37
|
- `vue3 + vite`
|
|
38
38
|
- `vue2 + @vue/cli`
|
|
39
|
+
- `next.js`
|
|
40
|
+
- `react + gunjs`
|
|
39
41
|
|
|
40
42
|
**static**
|
|
41
43
|
|
|
@@ -44,6 +46,9 @@ Currently supported template presets include:
|
|
|
44
46
|
- `vue2 + @vue/cli`
|
|
45
47
|
- `blocklet page`
|
|
46
48
|
|
|
49
|
+
**api**
|
|
50
|
+
- `express`
|
|
51
|
+
|
|
47
52
|
## Community Templates
|
|
48
53
|
|
|
49
54
|
create-blocklet is a tool to quickly start a blocklet from a basic template for popular frameworks. You can use a tool like [degit](https://github.com/Rich-Harris/degit) to scaffold your blocklet with github repository template.
|
|
@@ -61,3 +66,12 @@ If the blocklet uses `main` as the default branch, suffix the blocklet repo with
|
|
|
61
66
|
```bash
|
|
62
67
|
npx degit user/blocklet#main my-blocklet
|
|
63
68
|
```
|
|
69
|
+
|
|
70
|
+
## Development
|
|
71
|
+
Use `node /pathToCreateBlockletRepo/index.js` to create a blocklet, or you can use
|
|
72
|
+
``` bash
|
|
73
|
+
ln -s /pathToCreateBlockletRepo/index.js /usr/local/bin/cb
|
|
74
|
+
|
|
75
|
+
cb
|
|
76
|
+
```
|
|
77
|
+
to create a blocklet
|
package/index.js
CHANGED
|
@@ -46,6 +46,11 @@ const TYPES = [
|
|
|
46
46
|
display: 'next.js',
|
|
47
47
|
color: blue,
|
|
48
48
|
},
|
|
49
|
+
{
|
|
50
|
+
name: 'react-gun',
|
|
51
|
+
display: 'react + gunjs',
|
|
52
|
+
color: blue,
|
|
53
|
+
},
|
|
49
54
|
],
|
|
50
55
|
},
|
|
51
56
|
{
|
|
@@ -232,12 +237,13 @@ async function init() {
|
|
|
232
237
|
const templateDir = path.join(__dirname, `templates/${framework}-${type}`);
|
|
233
238
|
const name = packageName || targetDir;
|
|
234
239
|
|
|
240
|
+
// TODO: 需要把 common file copy 的逻辑移除,不同的 template 之间的差异越来越多,就会需要越来越多特殊处理的代码,违背了初衷,移除这部分逻辑可能是更好的选择
|
|
235
241
|
// copy common files
|
|
236
242
|
(() => {
|
|
237
243
|
const commonDir = path.join(__dirname, 'common');
|
|
238
244
|
const commonFiles = fs.readdirSync(commonDir);
|
|
239
245
|
for (const file of commonFiles) {
|
|
240
|
-
if (
|
|
246
|
+
if (!['react', 'react-gun'].includes(framework) && file === '_eslintrc.js') {
|
|
241
247
|
// eslint-disable-next-line no-continue
|
|
242
248
|
continue;
|
|
243
249
|
}
|
|
@@ -421,7 +427,6 @@ async function init() {
|
|
|
421
427
|
if (root !== cwd) console.log(blue(` cd ${bold(related)}`));
|
|
422
428
|
|
|
423
429
|
console.log(blue(` ${defaultAgent === 'yarn' ? 'yarn' : `${defaultAgent} install`}`));
|
|
424
|
-
console.log(blue(` ${defaultAgent === 'yarn' ? 'yarn dev' : `${defaultAgent} run dev`}`));
|
|
425
430
|
console.log(cyan('blocklet dev'));
|
|
426
431
|
console.log('\n', `Find more usage in ${green('README.md')}`, '\n');
|
|
427
432
|
}
|
package/lib/index.js
CHANGED
|
@@ -16,8 +16,9 @@ export async function getUser() {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const [npmAuthor, gitUser, serverUser] = await Promise.all([getAuthor(), getUserInfo(), getServerUserInfo()]);
|
|
19
|
-
|
|
19
|
+
const info = {
|
|
20
20
|
name: purifyString(serverUser.name) || purifyString(npmAuthor.name) || purifyString(gitUser.name) || '',
|
|
21
21
|
email: purifyString(serverUser.email) || purifyString(npmAuthor.email) || purifyString(gitUser.email) || '',
|
|
22
22
|
};
|
|
23
|
+
return info;
|
|
23
24
|
}
|
package/lib/server.js
CHANGED
|
@@ -3,6 +3,10 @@ import semver from 'semver';
|
|
|
3
3
|
|
|
4
4
|
$.verbose = false;
|
|
5
5
|
|
|
6
|
+
function trimServerOutputVersion(output = '') {
|
|
7
|
+
return output?.replace(/blocklet \S+ v\d+\.\d+\.\d\n+/g, '');
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
export async function checkServerInstalled() {
|
|
7
11
|
try {
|
|
8
12
|
await which('blocklet');
|
|
@@ -42,25 +46,29 @@ export async function checkSatisfiedVersion() {
|
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
export async function getServerDirectory() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
try {
|
|
50
|
+
const { stdout: output } = await $`blocklet server status`;
|
|
51
|
+
const [matchStr] = output.match(/Blocklet Server Data Directory:[\s\S]*?\n/gm) || [];
|
|
52
|
+
if (!matchStr) return null;
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
const directory = matchStr.replace(/Blocklet Server Data Directory:[\s]*([\S]+)\/\.abtnode\n/gm, '$1');
|
|
55
|
+
return directory;
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
export async function getUserInfo() {
|
|
54
62
|
try {
|
|
55
|
-
const { stdout:
|
|
63
|
+
const { stdout: name } = await $`blocklet config get name`;
|
|
56
64
|
const { stdout: email } = await $`blocklet config get email`;
|
|
57
65
|
return {
|
|
58
|
-
|
|
59
|
-
email: email?.trim(),
|
|
66
|
+
name: trimServerOutputVersion(name?.trim()),
|
|
67
|
+
email: trimServerOutputVersion(email?.trim()),
|
|
60
68
|
};
|
|
61
69
|
} catch {
|
|
62
70
|
return {
|
|
63
|
-
|
|
71
|
+
name: '',
|
|
64
72
|
email: '',
|
|
65
73
|
};
|
|
66
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-blocklet",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"exports": "./index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "git@github.com:blocklet/create-blocklet.git",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"test:run": "vitest run"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@arcblock/did": "^1.
|
|
33
|
-
"@ocap/mcrypto": "^1.
|
|
34
|
-
"@ocap/util": "^1.
|
|
32
|
+
"@arcblock/did": "^1.16.0",
|
|
33
|
+
"@ocap/mcrypto": "^1.16.0",
|
|
34
|
+
"@ocap/util": "^1.16.0",
|
|
35
35
|
"boxen": "^6.2.1",
|
|
36
36
|
"ejs": "^3.1.6",
|
|
37
37
|
"envfile": "^6.17.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"jdenticon": "^3.1.1",
|
|
41
41
|
"ora": "^6.1.0",
|
|
42
42
|
"prompts": "^2.4.2",
|
|
43
|
-
"semver": "^7.3.
|
|
43
|
+
"semver": "^7.3.6",
|
|
44
44
|
"terminal-link": "^3.0.0",
|
|
45
45
|
"zx": "^6.0.7"
|
|
46
46
|
},
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
58
58
|
"eslint-plugin-unicorn": "^34.0.1",
|
|
59
59
|
"prettier": "^2.3.2",
|
|
60
|
-
"vitest": "^0.
|
|
60
|
+
"vitest": "^0.9.0"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
]
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@arcblock/did-auth": "^1.
|
|
28
|
+
"@arcblock/did-auth": "^1.16.0",
|
|
29
29
|
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
30
|
-
"@blocklet/sdk": "^1.7.
|
|
31
|
-
"@ocap/client": "^1.
|
|
32
|
-
"@ocap/mcrypto": "^1.
|
|
33
|
-
"@ocap/wallet": "^1.
|
|
30
|
+
"@blocklet/sdk": "^1.7.6",
|
|
31
|
+
"@ocap/client": "^1.16.0",
|
|
32
|
+
"@ocap/mcrypto": "^1.16.0",
|
|
33
|
+
"@ocap/wallet": "^1.16.0",
|
|
34
34
|
"dotenv-flow": "^3.2.0",
|
|
35
35
|
"express": "^4.17.3",
|
|
36
36
|
"next": "12.1.0",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@arcblock/did-auth": "^1.
|
|
42
|
+
"@arcblock/did-auth": "^1.16.0",
|
|
43
43
|
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
44
|
-
"@blocklet/sdk": "^1.7.
|
|
44
|
+
"@blocklet/sdk": "^1.7.6",
|
|
45
45
|
"@craco/craco": "^6.4.3",
|
|
46
|
-
"@ocap/client": "^1.
|
|
47
|
-
"@ocap/mcrypto": "^1.
|
|
48
|
-
"@ocap/wallet": "^1.
|
|
46
|
+
"@ocap/client": "^1.16.0",
|
|
47
|
+
"@ocap/mcrypto": "^1.16.0",
|
|
48
|
+
"@ocap/wallet": "^1.16.0",
|
|
49
49
|
"axios": "^0.26.1",
|
|
50
50
|
"compression": "^1.7.4",
|
|
51
51
|
"cookie-parser": "^1.4.6",
|
|
@@ -8,19 +8,21 @@ body {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.app-logo {
|
|
11
|
-
height:
|
|
11
|
+
height: 10vmin;
|
|
12
12
|
pointer-events: none;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.app-header {
|
|
16
|
-
background-color: #282c34;
|
|
17
16
|
min-height: 100vh;
|
|
18
17
|
display: flex;
|
|
19
18
|
flex-direction: column;
|
|
20
19
|
align-items: center;
|
|
21
20
|
justify-content: center;
|
|
22
21
|
font-size: calc(10px + 2vmin);
|
|
23
|
-
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pre {
|
|
25
|
+
font-size: 0.75em;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
.app-link {
|
|
@@ -8,7 +8,7 @@ const Home = () => {
|
|
|
8
8
|
<header className="app-header">
|
|
9
9
|
<img src={logo} className="app-logo" alt="logo" />
|
|
10
10
|
<pre style={{ textAlign: 'left' }}>
|
|
11
|
-
<code>{JSON.stringify(window.blocklet, null, 2)}</code>
|
|
11
|
+
<code>window.blocklet = {JSON.stringify(window.blocklet, null, 2)}</code>
|
|
12
12
|
</pre>
|
|
13
13
|
<Link className="app-link" to="/about">
|
|
14
14
|
About
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Getting Started with Create Blocklet
|
|
2
|
+
|
|
3
|
+
This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
|
|
4
|
+
|
|
5
|
+
This blocklet is a dapp project, which means this is a full-stack application. It's contained both `server` and `client` code.
|
|
6
|
+
|
|
7
|
+
## File Structure
|
|
8
|
+
|
|
9
|
+
- public/ - static files
|
|
10
|
+
- favicon.ico - favicon
|
|
11
|
+
- favicon.svg - favicon
|
|
12
|
+
- index.html - main html file, template for react
|
|
13
|
+
- screenshots/ - Screenshots
|
|
14
|
+
- api/ - Api side code
|
|
15
|
+
- hooks/ - blocklet lifecycle hooks
|
|
16
|
+
- libs/ - Api side libraries
|
|
17
|
+
- middlewares/ - Api side middlewares
|
|
18
|
+
- routes/ - Api side routes
|
|
19
|
+
- index.js - Api side entry point
|
|
20
|
+
- src/ - Client side code (A standard react app structure)
|
|
21
|
+
- .env - Environment variables
|
|
22
|
+
- .env.local - Local environment variables
|
|
23
|
+
- .eslintrc.js - ESLint configuration
|
|
24
|
+
- .gitignore - Git ignore file
|
|
25
|
+
- .prettierrc - Prettier configuration
|
|
26
|
+
- blocklet.md - Blocklet README
|
|
27
|
+
- blocklet.yml - Blocklet configuration
|
|
28
|
+
- LICENSE - License file
|
|
29
|
+
- logo.png - Blocklet logo file
|
|
30
|
+
- Makefile - Makefile
|
|
31
|
+
- package.json - Npm package file
|
|
32
|
+
- README.md - A guide for this blocklet
|
|
33
|
+
- version - Version file
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
38
|
+
|
|
39
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
40
|
+
`npm install -g @blocklet/cli`
|
|
41
|
+
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution)
|
|
42
|
+
|
|
43
|
+
2. Init blocklet server & start blocklet server
|
|
44
|
+
|
|
45
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
46
|
+
`blocklet server init --mode=debug`
|
|
47
|
+
`blocklet server start`
|
|
48
|
+
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node)
|
|
49
|
+
|
|
50
|
+
3. Go to the project directory `cd [name]`
|
|
51
|
+
4. Install dependencies: `npm install` or `yarn`
|
|
52
|
+
5. Start development server: `blocklet dev`
|
|
53
|
+
|
|
54
|
+
## Bundle
|
|
55
|
+
|
|
56
|
+
After developing a blocklet, you may need to bundle it. Use `npm run bundle` command.
|
|
57
|
+
|
|
58
|
+
## Deploy
|
|
59
|
+
|
|
60
|
+
- If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment).
|
|
61
|
+
> Or you can simply use `npm run deploy` command.
|
|
62
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
63
|
+
|
|
64
|
+
```shell
|
|
65
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
> Make sure the blocklet is bundled before deployment.
|
|
69
|
+
|
|
70
|
+
## Upload to blocklet store
|
|
71
|
+
|
|
72
|
+
- If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
|
|
73
|
+
|
|
74
|
+
Bump version at first.
|
|
75
|
+
|
|
76
|
+
```shell
|
|
77
|
+
make bump-version
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then config blocklet store url.
|
|
81
|
+
You can use those store url in below.
|
|
82
|
+
|
|
83
|
+
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
84
|
+
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
85
|
+
3. A blocklet store started by yourself.
|
|
86
|
+
> Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
blocklet config set store {store url}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Get a `accessToken` by using this command.
|
|
93
|
+
|
|
94
|
+
> Why we need a `accessToken`?
|
|
95
|
+
> A `accessToken` is genrate by blocklet store, which help us upload our blocklet to any store.
|
|
96
|
+
|
|
97
|
+
Set `accessToken` to blocklet config
|
|
98
|
+
|
|
99
|
+
```shell
|
|
100
|
+
blocklet config set accessToken {accessToken}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Upload a new version to a store.
|
|
104
|
+
|
|
105
|
+
> Make sure the blocklet is bundled before upload.
|
|
106
|
+
|
|
107
|
+
```shell
|
|
108
|
+
blocklet upload
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Or you can simply use `npm run upload` command.
|
|
112
|
+
|
|
113
|
+
- You also can upload a new version to a store by Github CI.
|
|
114
|
+
Bump version at first.
|
|
115
|
+
|
|
116
|
+
```shell
|
|
117
|
+
make bump-version
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Push your code to Github main/master branch, or make a pull request to the main/master branch.
|
|
121
|
+
The CI workflow will automatically upload a new version to a store.
|
|
122
|
+
|
|
123
|
+
## Q & A
|
|
124
|
+
|
|
125
|
+
1. Q: How to change a blocklet's name?
|
|
126
|
+
|
|
127
|
+
A: Change the `name` field in the `package.json` file, change the `name` field in the `blocklet.yml` file.
|
|
128
|
+
|
|
129
|
+
You can also change the `title` field and `description` field in the `blocklet.yml` file.
|
|
130
|
+
|
|
131
|
+
Run `blocklet meta` command, you will get a `did` config, copy the `did` value.
|
|
132
|
+
|
|
133
|
+
Replace this command `"bundle:client": "PUBLIC_URL='/.blocklet/proxy/{did}' npm run build",` in `package.json`
|
|
134
|
+
|
|
135
|
+
Replace `did` field in the `blocklet.yml`
|
|
136
|
+
|
|
137
|
+
2. Q: How to change a blocklet's logo?
|
|
138
|
+
|
|
139
|
+
Change the `logo.png` file root folder.
|
|
140
|
+
|
|
141
|
+
Or you can change the `logo` field in the `blocklet.yml` file.
|
|
142
|
+
|
|
143
|
+
> Make sure you have added the logo path to the `blocklet.yml` file `files` field.
|
|
144
|
+
|
|
145
|
+
## Learn More
|
|
146
|
+
|
|
147
|
+
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
|
|
148
|
+
- Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
The code is licensed under the Apache 2.0 license found in the
|
|
153
|
+
[LICENSE](LICENSE) file.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require('@blocklet/sdk/lib/error-handler');
|
|
2
|
+
require('dotenv-flow').config();
|
|
3
|
+
|
|
4
|
+
const Client = require('@ocap/client');
|
|
5
|
+
|
|
6
|
+
const env = require('../libs/env');
|
|
7
|
+
const logger = require('../libs/logger');
|
|
8
|
+
const { wallet } = require('../libs/auth');
|
|
9
|
+
const { name } = require('../../package.json');
|
|
10
|
+
|
|
11
|
+
const ensureAccountDeclared = async () => {
|
|
12
|
+
if (env.isComponent) return;
|
|
13
|
+
if (!env.chainHost) return;
|
|
14
|
+
|
|
15
|
+
const client = new Client(env.chainHost);
|
|
16
|
+
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
17
|
+
if (!state) {
|
|
18
|
+
const hash = await client.declare({ moniker: name, wallet });
|
|
19
|
+
logger.log(`app account declared on chain ${env.chainHost}`, hash);
|
|
20
|
+
} else {
|
|
21
|
+
logger.log(`app account already declared on chain ${env.chainHost}`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
(async () => {
|
|
26
|
+
try {
|
|
27
|
+
await ensureAccountDeclared();
|
|
28
|
+
process.exit(0);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
logger.error(`${name} pre-start error`, err.message);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require('dotenv-flow').config();
|
|
2
|
+
require('express-async-errors');
|
|
3
|
+
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const cors = require('cors');
|
|
6
|
+
const Gun = require('gun');
|
|
7
|
+
const express = require('express');
|
|
8
|
+
const compression = require('compression');
|
|
9
|
+
const cookieParser = require('cookie-parser');
|
|
10
|
+
const fallback = require('express-history-api-fallback');
|
|
11
|
+
|
|
12
|
+
const { name, version } = require('../package.json');
|
|
13
|
+
const logger = require('./libs/logger');
|
|
14
|
+
const env = require('./libs/env');
|
|
15
|
+
|
|
16
|
+
const app = express();
|
|
17
|
+
|
|
18
|
+
app.set('trust proxy', true);
|
|
19
|
+
app.use(cookieParser());
|
|
20
|
+
app.use(express.json({ limit: '1 mb' }));
|
|
21
|
+
app.use(express.urlencoded({ extended: true, limit: '1 mb' }));
|
|
22
|
+
|
|
23
|
+
app.use(Gun.serve);
|
|
24
|
+
|
|
25
|
+
const router = express.Router();
|
|
26
|
+
router.use('/api', require('./routes'));
|
|
27
|
+
|
|
28
|
+
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
29
|
+
const isProduction = process.env.NODE_ENV === 'production' || process.env.ABT_NODE_SERVICE_ENV === 'production';
|
|
30
|
+
|
|
31
|
+
if (isDevelopment) {
|
|
32
|
+
process.env.BLOCKLET_PORT = 3030;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (isProduction) {
|
|
36
|
+
app.use(cors());
|
|
37
|
+
app.use(compression());
|
|
38
|
+
|
|
39
|
+
const staticDir = path.resolve(__dirname, '../', 'build');
|
|
40
|
+
app.use(express.static(staticDir, { index: 'index.html' }));
|
|
41
|
+
app.use(router);
|
|
42
|
+
app.use(fallback('index.html', { root: staticDir }));
|
|
43
|
+
|
|
44
|
+
app.use((req, res) => {
|
|
45
|
+
res.status(404).send('404 NOT FOUND');
|
|
46
|
+
});
|
|
47
|
+
app.use((err, req, res) => {
|
|
48
|
+
logger.error(err.stack);
|
|
49
|
+
res.status(500).send('Something broke!');
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
app.use(router);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const port = parseInt(process.env.BLOCKLET_PORT, 10) || 3030;
|
|
56
|
+
|
|
57
|
+
const server = app.listen(port, (err) => {
|
|
58
|
+
if (err) throw err;
|
|
59
|
+
logger.info(`> ${name} v${version} ready on ${port}`);
|
|
60
|
+
logger.info('> gun server ready on /gun');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const gun = Gun({ web: server, file: path.join(env.dataDir, 'gun.json') });
|
|
64
|
+
|
|
65
|
+
module.exports = { gun, server, app };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
4
|
+
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
5
|
+
const WalletHandler = require('@blocklet/sdk/lib/wallet-handler');
|
|
6
|
+
|
|
7
|
+
const env = require('./env');
|
|
8
|
+
|
|
9
|
+
const wallet = getWallet();
|
|
10
|
+
const authenticator = new WalletAuthenticator();
|
|
11
|
+
const handlers = new WalletHandler({
|
|
12
|
+
authenticator,
|
|
13
|
+
tokenStorage: new AuthStorage({
|
|
14
|
+
dbPath: path.join(env.dataDir, 'auth.db'),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
authenticator,
|
|
20
|
+
handlers,
|
|
21
|
+
wallet,
|
|
22
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: template-react
|
|
2
|
+
title: Blocklet Template React
|
|
3
|
+
description: A Blocklet DAPP blocklet
|
|
4
|
+
keywords:
|
|
5
|
+
- blocklet
|
|
6
|
+
- react
|
|
7
|
+
group: dapp
|
|
8
|
+
did: ''
|
|
9
|
+
main: api/index.js
|
|
10
|
+
author:
|
|
11
|
+
name: Blocklet
|
|
12
|
+
email: blocklet@arcblock.io
|
|
13
|
+
repository:
|
|
14
|
+
type: git
|
|
15
|
+
url: 'git+https://github.com/blocklet/create-blocklet.git'
|
|
16
|
+
specVersion: 1.1.1
|
|
17
|
+
version: 0.1.0
|
|
18
|
+
logo: logo.png
|
|
19
|
+
files:
|
|
20
|
+
- build
|
|
21
|
+
- logo.png
|
|
22
|
+
- README.md
|
|
23
|
+
- blocklet.md
|
|
24
|
+
- screenshots
|
|
25
|
+
- api/hooks/pre-start.js
|
|
26
|
+
interfaces:
|
|
27
|
+
- type: web
|
|
28
|
+
name: publicUrl
|
|
29
|
+
path: /
|
|
30
|
+
prefix: '*'
|
|
31
|
+
port: BLOCKLET_PORT
|
|
32
|
+
protocol: http
|
|
33
|
+
community: ''
|
|
34
|
+
documentation: ''
|
|
35
|
+
homepage: ''
|
|
36
|
+
license: ''
|
|
37
|
+
payment:
|
|
38
|
+
price: []
|
|
39
|
+
share: []
|
|
40
|
+
timeout:
|
|
41
|
+
start: 60
|
|
42
|
+
requirements:
|
|
43
|
+
server: '>=1.6.29'
|
|
44
|
+
os: '*'
|
|
45
|
+
cpu: '*'
|
|
46
|
+
scripts:
|
|
47
|
+
preStart: node api/hooks/pre-start.js
|
|
48
|
+
dev: npm run start
|
|
49
|
+
environments:
|
|
50
|
+
- name: CHAIN_HOST
|
|
51
|
+
description: What's endpoint of the chain?
|
|
52
|
+
required: true
|
|
53
|
+
default: 'https://beta.abtnetwork.io/api/'
|
|
54
|
+
secure: false
|
|
55
|
+
capabilities: {}
|
|
56
|
+
screenshots: []
|
|
57
|
+
children: []
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const port = process.env.BLOCKLET_PORT || process.env.PORT || 8080;
|
|
2
|
+
const dappPort = process.env.APP_PORT || 3030;
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
devServer: {
|
|
6
|
+
port,
|
|
7
|
+
client: {
|
|
8
|
+
// If you want to development this blocklet without blocklet-server, you can delete next line, otherwise the hot reload will be failed.
|
|
9
|
+
webSocketURL: 'wss://0.0.0.0/ws',
|
|
10
|
+
},
|
|
11
|
+
proxy: [
|
|
12
|
+
{
|
|
13
|
+
context: ['/api'],
|
|
14
|
+
target: `http://127.0.0.1:${dappPort}`,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
context: ['/gun'],
|
|
18
|
+
target: `ws://127.0.0.1:${dappPort}`,
|
|
19
|
+
ws: true,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
webpack: {
|
|
24
|
+
configure: {
|
|
25
|
+
module: {
|
|
26
|
+
noParse: /gun\.js$/,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-gun",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "craco start",
|
|
6
|
+
"build": "craco build",
|
|
7
|
+
"eject": "react-scripts eject",
|
|
8
|
+
"lint": "eslint src api --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
9
|
+
"start": "npm-run-all --parallel start:*",
|
|
10
|
+
"start:client": "npm run dev",
|
|
11
|
+
"start:api": "NODE_ENV=development nodemon api/index.js -w api",
|
|
12
|
+
"clean": "rm -rf .blocklet",
|
|
13
|
+
"bundle": "npm run bundle:client && npm run bundle:api",
|
|
14
|
+
"bundle:client": "PUBLIC_URL='/.blocklet/proxy/<%= did %>' npm run build",
|
|
15
|
+
"bundle:api": "npm run clean && blocklet bundle --zip --create-release",
|
|
16
|
+
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
17
|
+
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
18
|
+
"prepare": "husky install"
|
|
19
|
+
},
|
|
20
|
+
"lint-staged": {
|
|
21
|
+
"*.{mjs,js,jsx,ts,tsx}": [
|
|
22
|
+
"prettier --write",
|
|
23
|
+
"eslint"
|
|
24
|
+
],
|
|
25
|
+
"*.{css,less,scss,json,graphql}": [
|
|
26
|
+
"prettier --write"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"browserslist": {
|
|
30
|
+
"production": [
|
|
31
|
+
">0.2%",
|
|
32
|
+
"not dead",
|
|
33
|
+
"not op_mini all"
|
|
34
|
+
],
|
|
35
|
+
"development": [
|
|
36
|
+
"last 1 chrome version",
|
|
37
|
+
"last 1 firefox version",
|
|
38
|
+
"last 1 safari version"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@arcblock/did-auth": "^1.16.0",
|
|
43
|
+
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
44
|
+
"@blocklet/sdk": "^1.7.6",
|
|
45
|
+
"@craco/craco": "^6.4.3",
|
|
46
|
+
"@ocap/client": "^1.16.0",
|
|
47
|
+
"@ocap/mcrypto": "^1.16.0",
|
|
48
|
+
"@ocap/wallet": "^1.16.0",
|
|
49
|
+
"axios": "^0.26.1",
|
|
50
|
+
"compression": "^1.7.4",
|
|
51
|
+
"cookie-parser": "^1.4.6",
|
|
52
|
+
"cors": "^2.8.5",
|
|
53
|
+
"dotenv-flow": "^3.2.0",
|
|
54
|
+
"express": "^4.17.3",
|
|
55
|
+
"express-async-errors": "^3.1.1",
|
|
56
|
+
"express-history-api-fallback": "^2.2.1",
|
|
57
|
+
"gun": "^0.2020.1236",
|
|
58
|
+
"react": "^17.0.2",
|
|
59
|
+
"react-dom": "^17.0.2",
|
|
60
|
+
"react-router-dom": "^6.2.2",
|
|
61
|
+
"react-scripts": "5.0.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@arcblock/eslint-config": "^0.1.8",
|
|
65
|
+
"babel-eslint": "^10.1.0",
|
|
66
|
+
"eslint": "^7.32.0",
|
|
67
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
68
|
+
"eslint-config-prettier": "^8.3.0",
|
|
69
|
+
"eslint-plugin-import": "^2.23.4",
|
|
70
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
71
|
+
"eslint-plugin-prettier": "^3.4.1",
|
|
72
|
+
"eslint-plugin-react": "^7.24.0",
|
|
73
|
+
"eslint-plugin-react-hooks": "^4.2.0",
|
|
74
|
+
"eslint-plugin-unicorn": "^34.0.1",
|
|
75
|
+
"husky": "^7.0.4",
|
|
76
|
+
"lint-staged": "^12.3.7",
|
|
77
|
+
"nodemon": "^2.0.15",
|
|
78
|
+
"npm-run-all": "^4.1.5",
|
|
79
|
+
"prettier": "^2.6.0"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
7
|
+
<meta name="theme-color" content="#4F6AF5" />
|
|
8
|
+
<meta name="description" content="Web site created using create-blocklet" />
|
|
9
|
+
<script src="__meta__.js"></script>
|
|
10
|
+
<!--
|
|
11
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
|
12
|
+
It will be replaced with the URL of the `public` folder during the build.
|
|
13
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
|
14
|
+
|
|
15
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
16
|
+
work correctly both with client-side routing and a non-root public URL.
|
|
17
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
|
18
|
+
-->
|
|
19
|
+
<title>%REACT_APP_TITLE%</title>
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
23
|
+
<div id="root"></div>
|
|
24
|
+
<!--
|
|
25
|
+
This HTML file is a template.
|
|
26
|
+
If you open it directly in the browser, you will see an empty page.
|
|
27
|
+
|
|
28
|
+
You can add webfonts, meta tags, or analytics to this file.
|
|
29
|
+
The build step will place the bundled scripts into the <body> tag.
|
|
30
|
+
|
|
31
|
+
To begin the development, run `npm start` or `yarn start`.
|
|
32
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
|
33
|
+
-->
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
html,
|
|
2
|
+
body {
|
|
3
|
+
padding: 0;
|
|
4
|
+
margin: 0;
|
|
5
|
+
}
|
|
6
|
+
.app {
|
|
7
|
+
text-align: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.app-logo {
|
|
11
|
+
height: 10vmin;
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.app-header {
|
|
16
|
+
min-height: 100vh;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
font-size: calc(10px + 2vmin);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pre {
|
|
25
|
+
font-size: 0.75em;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.app-link {
|
|
29
|
+
color: #4f6af5;
|
|
30
|
+
margin-right: 32px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.input-wrapper {
|
|
34
|
+
margin: 32px 0;
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.input {
|
|
39
|
+
width: 480px;
|
|
40
|
+
height: 240px;
|
|
41
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import './app.css';
|
|
5
|
+
import Home from './pages/home';
|
|
6
|
+
import About from './pages/about';
|
|
7
|
+
|
|
8
|
+
function App() {
|
|
9
|
+
return (
|
|
10
|
+
<div className="app">
|
|
11
|
+
<Routes>
|
|
12
|
+
<Route exact path="/" element={<Home />} />
|
|
13
|
+
<Route path="/about" element={<About />} />
|
|
14
|
+
<Route path="/home" element={<Home />} />
|
|
15
|
+
<Route path="*" element={<Navigate to="/" />} />
|
|
16
|
+
</Routes>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const WrappedApp = App;
|
|
22
|
+
|
|
23
|
+
export default () => {
|
|
24
|
+
// While the blocklet is deploy to a sub path, this will be work properly.
|
|
25
|
+
const basename = window?.blocklet?.prefix || '/';
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Router basename={basename}>
|
|
29
|
+
<WrappedApp />
|
|
30
|
+
</Router>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
axios.interceptors.request.use(
|
|
4
|
+
(config) => {
|
|
5
|
+
const prefix = window.blocklet ? window.blocklet.prefix : '/';
|
|
6
|
+
config.baseURL = prefix || '';
|
|
7
|
+
config.timeout = 200000;
|
|
8
|
+
|
|
9
|
+
return config;
|
|
10
|
+
},
|
|
11
|
+
(error) => Promise.reject(error)
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export default axios;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="450" height="520" viewBox="0 0 45 52"><g fill="none" fill-rule="evenodd" stroke="#4F6AF5"><path d="M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25m-43.301 0l43.301-25"></path><path d="M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"></path></g></svg>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import logo from '../logo.svg';
|
|
5
|
+
|
|
6
|
+
const About = () => {
|
|
7
|
+
return (
|
|
8
|
+
<header className="app-header">
|
|
9
|
+
<img src={logo} className="app-logo" alt="logo" />
|
|
10
|
+
<pre style={{ textAlign: 'left' }}>
|
|
11
|
+
<code>window.blocklet = {JSON.stringify(window.blocklet, null, 2)}</code>
|
|
12
|
+
</pre>
|
|
13
|
+
<Link className="app-link" to="/home">
|
|
14
|
+
Home
|
|
15
|
+
</Link>
|
|
16
|
+
<a className="app-link" href="https://docs.arcblock.io/abtnode/" target="_blank" rel="noopener noreferrer">
|
|
17
|
+
Learn Blocklet
|
|
18
|
+
</a>
|
|
19
|
+
<a className="app-link" href="https://gun.eco" target="_blank" rel="noopener noreferrer">
|
|
20
|
+
Learn GunJS
|
|
21
|
+
</a>
|
|
22
|
+
</header>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default About;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import Gun from 'gun';
|
|
4
|
+
|
|
5
|
+
import { Link } from 'react-router-dom';
|
|
6
|
+
|
|
7
|
+
const gun = Gun({
|
|
8
|
+
peers: [`${window.location.origin}/gun`], // Put the relay nodes that you want here
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export default function Home() {
|
|
12
|
+
const [txt, setTxt] = useState();
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
gun.get('text').once((node) => {
|
|
16
|
+
// Retrieve the text value on startup
|
|
17
|
+
console.log(node);
|
|
18
|
+
if (node === undefined) {
|
|
19
|
+
gun.get('text').put({ text: 'Write the text here' });
|
|
20
|
+
} else {
|
|
21
|
+
console.log('Found Node');
|
|
22
|
+
setTxt(node.text);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
gun.get('text').on((node) => {
|
|
27
|
+
// Is called whenever text is updated
|
|
28
|
+
console.log('Receiving Update');
|
|
29
|
+
console.log(node);
|
|
30
|
+
setTxt(node.text);
|
|
31
|
+
});
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
const updateText = (event) => {
|
|
35
|
+
console.log('Updating Text');
|
|
36
|
+
console.log(event.target.value);
|
|
37
|
+
gun.get('text').put({ text: event.target.value }); // Edit the value in our db
|
|
38
|
+
setTxt(event.target.value);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className="App">
|
|
43
|
+
<h1 className="page-title">Sample App build with React & GunJS</h1>
|
|
44
|
+
<div className="input-wrapper">
|
|
45
|
+
<textarea className="input" value={txt} onChange={updateText} />
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div className="link-wrapper">
|
|
49
|
+
<Link className="app-link" to="/home">
|
|
50
|
+
Home
|
|
51
|
+
</Link>
|
|
52
|
+
<a className="app-link" href="https://docs.arcblock.io/abtnode/" target="_blank" rel="noopener noreferrer">
|
|
53
|
+
Learn Blocklet
|
|
54
|
+
</a>
|
|
55
|
+
<a className="app-link" href="https://gun.eco" target="_blank" rel="noopener noreferrer">
|
|
56
|
+
Learn GunJS
|
|
57
|
+
</a>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -8,19 +8,21 @@ body {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.app-logo {
|
|
11
|
-
height:
|
|
11
|
+
height: 10vmin;
|
|
12
12
|
pointer-events: none;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.app-header {
|
|
16
|
-
background-color: #282c34;
|
|
17
16
|
min-height: 100vh;
|
|
18
17
|
display: flex;
|
|
19
18
|
flex-direction: column;
|
|
20
19
|
align-items: center;
|
|
21
20
|
justify-content: center;
|
|
22
21
|
font-size: calc(10px + 2vmin);
|
|
23
|
-
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pre {
|
|
25
|
+
font-size: 0.75em;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
.app-link {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Link } from 'react-router-dom';
|
|
3
|
+
|
|
3
4
|
import logo from '../logo.svg';
|
|
4
5
|
|
|
5
6
|
const Home = () => {
|
|
6
7
|
return (
|
|
7
8
|
<header className="app-header">
|
|
8
9
|
<img src={logo} className="app-logo" alt="logo" />
|
|
10
|
+
<pre style={{ textAlign: 'left' }}>
|
|
11
|
+
<code>window.blocklet = {JSON.stringify(window.blocklet, null, 2)}</code>
|
|
12
|
+
</pre>
|
|
9
13
|
<Link className="app-link" to="/about">
|
|
10
14
|
About
|
|
11
15
|
</Link>
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"prepare": "husky install"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@arcblock/did-auth": "^1.
|
|
21
|
+
"@arcblock/did-auth": "^1.16.0",
|
|
22
22
|
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
23
|
-
"@blocklet/sdk": "^1.7.
|
|
24
|
-
"@ocap/client": "^1.
|
|
25
|
-
"@ocap/mcrypto": "^1.
|
|
26
|
-
"@ocap/wallet": "^1.
|
|
23
|
+
"@blocklet/sdk": "^1.7.6",
|
|
24
|
+
"@ocap/client": "^1.16.0",
|
|
25
|
+
"@ocap/mcrypto": "^1.16.0",
|
|
26
|
+
"@ocap/wallet": "^1.16.0",
|
|
27
27
|
"axios": "^0.26.1",
|
|
28
28
|
"compression": "^1.7.4",
|
|
29
29
|
"cookie-parser": "^1.4.6",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"npm-run-all": "^4.1.5",
|
|
48
48
|
"prettier": "^2.6.0",
|
|
49
49
|
"vite": "^2.8.6",
|
|
50
|
-
"vite-plugin-blocklet": "^0.1.
|
|
50
|
+
"vite-plugin-blocklet": "^0.1.2"
|
|
51
51
|
},
|
|
52
52
|
"lint-staged": {
|
|
53
53
|
"*.{mjs,js,vue}": [
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"prepare": "husky install"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@arcblock/did-auth": "^1.
|
|
21
|
+
"@arcblock/did-auth": "^1.16.0",
|
|
22
22
|
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
23
|
-
"@blocklet/sdk": "^1.7.
|
|
24
|
-
"@ocap/client": "^1.
|
|
25
|
-
"@ocap/mcrypto": "^1.
|
|
26
|
-
"@ocap/wallet": "^1.
|
|
23
|
+
"@blocklet/sdk": "^1.7.6",
|
|
24
|
+
"@ocap/client": "^1.16.0",
|
|
25
|
+
"@ocap/mcrypto": "^1.16.0",
|
|
26
|
+
"@ocap/wallet": "^1.16.0",
|
|
27
27
|
"axios": "^0.26.1",
|
|
28
28
|
"compression": "^1.7.4",
|
|
29
29
|
"cookie-parser": "^1.4.6",
|