create-leo-app 0.0.13
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 +36 -0
- package/dist/index.mjs +52 -0
- package/index.js +3 -0
- package/package.json +34 -0
- package/template-extension/.gitignore +2 -0
- package/template-extension/README.md +4 -0
- package/template-extension/package.json +15 -0
- package/template-extension/rollup.config.js +21 -0
- package/template-extension/src/offscreen.js +1 -0
- package/template-extension/src/service_worker.js +20 -0
- package/template-extension/src/worker.js +34 -0
- package/template-extension/static/manifest.json +16 -0
- package/template-extension/static/offscreen.html +9 -0
- package/template-nextjs-ts/README.md +19 -0
- package/template-nextjs-ts/_gitignore +35 -0
- package/template-nextjs-ts/next-env.d.ts +5 -0
- package/template-nextjs-ts/next.config.js +32 -0
- package/template-nextjs-ts/package.json +24 -0
- package/template-nextjs-ts/public/aleo.svg +8 -0
- package/template-nextjs-ts/public/next.svg +1 -0
- package/template-nextjs-ts/src/app/favicon.ico +0 -0
- package/template-nextjs-ts/src/app/globals.css +126 -0
- package/template-nextjs-ts/src/app/layout.tsx +22 -0
- package/template-nextjs-ts/src/app/page.module.css +160 -0
- package/template-nextjs-ts/src/app/page.tsx +94 -0
- package/template-nextjs-ts/src/app/worker.ts +47 -0
- package/template-nextjs-ts/tsconfig.json +27 -0
- package/template-node/README.md +5 -0
- package/template-node/_gitignore +24 -0
- package/template-node/index.js +59 -0
- package/template-node/package.json +12 -0
- package/template-node-ts/README.md +5 -0
- package/template-node-ts/_gitignore +24 -0
- package/template-node-ts/package.json +19 -0
- package/template-node-ts/rollup.config.js +19 -0
- package/template-node-ts/src/index.ts +66 -0
- package/template-node-ts/tsconfig.json +15 -0
- package/template-offline-public-transaction-ts/README.md +52 -0
- package/template-offline-public-transaction-ts/_gitignore +24 -0
- package/template-offline-public-transaction-ts/package.json +19 -0
- package/template-offline-public-transaction-ts/rollup.config.js +19 -0
- package/template-offline-public-transaction-ts/src/helpers.ts +70 -0
- package/template-offline-public-transaction-ts/src/index.ts +171 -0
- package/template-offline-public-transaction-ts/tsconfig.json +15 -0
- package/template-react-leo/.babelrc +6 -0
- package/template-react-leo/.eslintrc.cjs +20 -0
- package/template-react-leo/README.md +90 -0
- package/template-react-leo/_gitignore +24 -0
- package/template-react-leo/_headers +3 -0
- package/template-react-leo/helloworld/.env.example +2 -0
- package/template-react-leo/helloworld/.gitignore +5 -0
- package/template-react-leo/helloworld/README.md +13 -0
- package/template-react-leo/helloworld/build/main.aleo +7 -0
- package/template-react-leo/helloworld/build/program.json +6 -0
- package/template-react-leo/helloworld/inputs/helloworld.in +4 -0
- package/template-react-leo/helloworld/program.json +6 -0
- package/template-react-leo/helloworld/src/main.leo +7 -0
- package/template-react-leo/index.html +88 -0
- package/template-react-leo/install.sh +30 -0
- package/template-react-leo/package.json +44 -0
- package/template-react-leo/public/favicon.ico +0 -0
- package/template-react-leo/src/App.css +42 -0
- package/template-react-leo/src/App.jsx +103 -0
- package/template-react-leo/src/assets/aleo.svg +5 -0
- package/template-react-leo/src/assets/react.svg +1 -0
- package/template-react-leo/src/index.css +69 -0
- package/template-react-leo/src/main.jsx +10 -0
- package/template-react-leo/src/workers/AleoWorker.js +20 -0
- package/template-react-leo/src/workers/worker.js +72 -0
- package/template-react-leo/vite.config.js +16 -0
- package/template-react-leo/webpack.config.js +102 -0
- package/template-react-managed-worker/.babelrc +6 -0
- package/template-react-managed-worker/.eslintrc.cjs +20 -0
- package/template-react-managed-worker/README.md +8 -0
- package/template-react-managed-worker/_gitignore +24 -0
- package/template-react-managed-worker/index.html +88 -0
- package/template-react-managed-worker/package.json +41 -0
- package/template-react-managed-worker/public/favicon.ico +0 -0
- package/template-react-managed-worker/src/App.css +42 -0
- package/template-react-managed-worker/src/App.jsx +78 -0
- package/template-react-managed-worker/src/assets/aleo.png +0 -0
- package/template-react-managed-worker/src/assets/react.svg +1 -0
- package/template-react-managed-worker/src/index.css +69 -0
- package/template-react-managed-worker/src/main.jsx +10 -0
- package/template-react-managed-worker/vite.config.js +20 -0
- package/template-react-managed-worker/webpack.config.js +90 -0
- package/template-react-ts/.babelrc +7 -0
- package/template-react-ts/.eslintrc.cjs +20 -0
- package/template-react-ts/README.md +90 -0
- package/template-react-ts/_gitignore +24 -0
- package/template-react-ts/_headers +3 -0
- package/template-react-ts/helloworld/.env.example +2 -0
- package/template-react-ts/helloworld/.gitignore +5 -0
- package/template-react-ts/helloworld/README.md +13 -0
- package/template-react-ts/helloworld/build/main.aleo +7 -0
- package/template-react-ts/helloworld/build/program.json +6 -0
- package/template-react-ts/helloworld/inputs/helloworld.in +4 -0
- package/template-react-ts/helloworld/program.json +6 -0
- package/template-react-ts/helloworld/src/main.leo +7 -0
- package/template-react-ts/index.html +88 -0
- package/template-react-ts/install.sh +30 -0
- package/template-react-ts/package.json +49 -0
- package/template-react-ts/public/favicon.ico +0 -0
- package/template-react-ts/src/App.css +42 -0
- package/template-react-ts/src/App.tsx +103 -0
- package/template-react-ts/src/assets/aleo.svg +5 -0
- package/template-react-ts/src/assets/react.svg +1 -0
- package/template-react-ts/src/custom.d.ts +16 -0
- package/template-react-ts/src/index.css +69 -0
- package/template-react-ts/src/main.tsx +10 -0
- package/template-react-ts/src/workers/AleoWorker.ts +21 -0
- package/template-react-ts/src/workers/worker.ts +73 -0
- package/template-react-ts/tsconfig.json +16 -0
- package/template-react-ts/vite.config.ts +16 -0
- package/template-react-ts/webpack.config.ts +112 -0
- package/template-vanilla/_gitignore +24 -0
- package/template-vanilla/_headers +3 -0
- package/template-vanilla/index.html +13 -0
- package/template-vanilla/javascript.svg +1 -0
- package/template-vanilla/main.js +48 -0
- package/template-vanilla/package.json +16 -0
- package/template-vanilla/public/aleo.svg +76 -0
- package/template-vanilla/public/vite.svg +1 -0
- package/template-vanilla/style.css +97 -0
- package/template-vanilla/vite.config.js +12 -0
- package/template-vanilla/worker.js +95 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#root {
|
|
2
|
+
max-width: 1280px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
padding: 2rem;
|
|
5
|
+
text-align: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.logo {
|
|
9
|
+
height: 6em;
|
|
10
|
+
padding: 1.5em;
|
|
11
|
+
will-change: filter;
|
|
12
|
+
transition: filter 300ms;
|
|
13
|
+
}
|
|
14
|
+
.logo:hover {
|
|
15
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
16
|
+
}
|
|
17
|
+
.logo.react:hover {
|
|
18
|
+
filter: drop-shadow(0 0 2em #61dafbaa);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@keyframes logo-spin {
|
|
22
|
+
from {
|
|
23
|
+
transform: rotate(0deg);
|
|
24
|
+
}
|
|
25
|
+
to {
|
|
26
|
+
transform: rotate(360deg);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
31
|
+
a:nth-of-type(2) .logo {
|
|
32
|
+
animation: logo-spin infinite 20s linear;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.card {
|
|
37
|
+
padding: 2em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.read-the-docs {
|
|
41
|
+
color: #888;
|
|
42
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import reactLogo from "./assets/react.svg";
|
|
3
|
+
import aleoLogo from "./assets/aleo.png";
|
|
4
|
+
import "./App.css";
|
|
5
|
+
import { createAleoWorker } from "@provablehq/sdk";
|
|
6
|
+
|
|
7
|
+
const aleoWorker = createAleoWorker();
|
|
8
|
+
|
|
9
|
+
function App() {
|
|
10
|
+
const [count, setCount] = useState(0);
|
|
11
|
+
const [account, setAccount] = useState(null);
|
|
12
|
+
const [loading, setLoading] = useState(false);
|
|
13
|
+
|
|
14
|
+
const generateAccount = async () => {
|
|
15
|
+
const privateKey = await aleoWorker.getPrivateKey();
|
|
16
|
+
setAccount(privateKey);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
async function execute() {
|
|
20
|
+
const hello_hello_program =
|
|
21
|
+
"program hello_hello.aleo;\n" +
|
|
22
|
+
"\n" +
|
|
23
|
+
"function hello:\n" +
|
|
24
|
+
" input r0 as u32.public;\n" +
|
|
25
|
+
" input r1 as u32.private;\n" +
|
|
26
|
+
" add r0 r1 into r2;\n" +
|
|
27
|
+
" output r2 as u32.private;\n";
|
|
28
|
+
|
|
29
|
+
setLoading(true);
|
|
30
|
+
const result = await aleoWorker.run(hello_hello_program,"hello", ["5u32", "5u32"], "APrivateKey1zkp778oUFSck3PZA5xppgp4trFwkkD6xnUXtxcBCfsq4URJ")
|
|
31
|
+
setLoading(false);
|
|
32
|
+
|
|
33
|
+
alert(JSON.stringify(result));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<div>
|
|
39
|
+
<a href="https://aleo.org" target="_blank">
|
|
40
|
+
<img src={aleoLogo} className="logo" alt="Aleo logo" />
|
|
41
|
+
</a>
|
|
42
|
+
<a href="https://react.dev" target="_blank">
|
|
43
|
+
<img src={reactLogo} className="logo react" alt="React logo" />
|
|
44
|
+
</a>
|
|
45
|
+
</div>
|
|
46
|
+
<h1>Aleo + React</h1>
|
|
47
|
+
<div className="card">
|
|
48
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
49
|
+
count is {count}
|
|
50
|
+
</button>
|
|
51
|
+
<p>
|
|
52
|
+
<button onClick={generateAccount}>
|
|
53
|
+
{
|
|
54
|
+
(account
|
|
55
|
+
? `Account private key is ${JSON.stringify(account)}`
|
|
56
|
+
: `Click to generate account`)
|
|
57
|
+
}
|
|
58
|
+
</button>
|
|
59
|
+
</p>
|
|
60
|
+
<p>
|
|
61
|
+
<button disabled={!account || loading} onClick={execute}>
|
|
62
|
+
{loading
|
|
63
|
+
? `Executing...check console for details...`
|
|
64
|
+
: `Execute hello_hello.aleo`}
|
|
65
|
+
</button>
|
|
66
|
+
</p>
|
|
67
|
+
<p>
|
|
68
|
+
Edit <code>src/App.jsx</code> and save to test HMR
|
|
69
|
+
</p>
|
|
70
|
+
</div>
|
|
71
|
+
<p className="read-the-docs">
|
|
72
|
+
Click on the Aleo and React logos to learn more
|
|
73
|
+
</p>
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default App;
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
font-weight: 400;
|
|
5
|
+
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
background-color: #242424;
|
|
9
|
+
|
|
10
|
+
font-synthesis: none;
|
|
11
|
+
text-rendering: optimizeLegibility;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
-webkit-text-size-adjust: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
a {
|
|
18
|
+
font-weight: 500;
|
|
19
|
+
color: #646cff;
|
|
20
|
+
text-decoration: inherit;
|
|
21
|
+
}
|
|
22
|
+
a:hover {
|
|
23
|
+
color: #535bf2;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
body {
|
|
27
|
+
margin: 0;
|
|
28
|
+
display: flex;
|
|
29
|
+
place-items: center;
|
|
30
|
+
min-width: 320px;
|
|
31
|
+
min-height: 100vh;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 3.2em;
|
|
36
|
+
line-height: 1.1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
button {
|
|
40
|
+
border-radius: 8px;
|
|
41
|
+
border: 1px solid transparent;
|
|
42
|
+
padding: 0.6em 1.2em;
|
|
43
|
+
font-size: 1em;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
font-family: inherit;
|
|
46
|
+
background-color: #1a1a1a;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
transition: border-color 0.25s;
|
|
49
|
+
}
|
|
50
|
+
button:hover {
|
|
51
|
+
border-color: #646cff;
|
|
52
|
+
}
|
|
53
|
+
button:focus,
|
|
54
|
+
button:focus-visible {
|
|
55
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@media (prefers-color-scheme: light) {
|
|
59
|
+
:root {
|
|
60
|
+
color: #213547;
|
|
61
|
+
background-color: #ffffff;
|
|
62
|
+
}
|
|
63
|
+
a:hover {
|
|
64
|
+
color: #747bff;
|
|
65
|
+
}
|
|
66
|
+
button {
|
|
67
|
+
background-color: #f9f9f9;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig, searchForWorkspaceRoot } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
|
|
4
|
+
// https://vitejs.dev/config/
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react()],
|
|
7
|
+
optimizeDeps: {
|
|
8
|
+
exclude: ["@provablehq/wasm", "@provablehq/sdk"],
|
|
9
|
+
},
|
|
10
|
+
server: {
|
|
11
|
+
// Needed if you are linking local packages for development
|
|
12
|
+
fs: {
|
|
13
|
+
allow: [searchForWorkspaceRoot(process.cwd()), "../../sdk"],
|
|
14
|
+
},
|
|
15
|
+
headers: {
|
|
16
|
+
"Cross-Origin-Opener-Policy": "same-origin",
|
|
17
|
+
"Cross-Origin-Embedder-Policy": "require-corp",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import CopyPlugin from "copy-webpack-plugin";
|
|
2
|
+
|
|
3
|
+
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
4
|
+
|
|
5
|
+
import path from "path";
|
|
6
|
+
|
|
7
|
+
const appConfig = {
|
|
8
|
+
mode: "production",
|
|
9
|
+
entry: {
|
|
10
|
+
index: "./src/main.jsx",
|
|
11
|
+
},
|
|
12
|
+
output: {
|
|
13
|
+
path: path.resolve("dist"),
|
|
14
|
+
filename: "[name].bundle.js",
|
|
15
|
+
},
|
|
16
|
+
resolve: {
|
|
17
|
+
extensions: [".js", ".wasm", ".jsx"],
|
|
18
|
+
},
|
|
19
|
+
devServer: {
|
|
20
|
+
port: 3000,
|
|
21
|
+
headers: {
|
|
22
|
+
"Cross-Origin-Opener-Policy": "same-origin",
|
|
23
|
+
"Cross-Origin-Embedder-Policy": "require-corp",
|
|
24
|
+
},
|
|
25
|
+
client: {
|
|
26
|
+
overlay: false,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
module: {
|
|
30
|
+
rules: [
|
|
31
|
+
{
|
|
32
|
+
test: /\.(js|jsx)$/,
|
|
33
|
+
exclude: /nodeModules/,
|
|
34
|
+
use: {
|
|
35
|
+
loader: "babel-loader",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
test: /\.css$/,
|
|
40
|
+
use: ["style-loader", "css-loader"],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
test: /\.(png|jpe?g|gif)$/i,
|
|
44
|
+
use: [
|
|
45
|
+
{
|
|
46
|
+
loader: "file-loader",
|
|
47
|
+
options: {
|
|
48
|
+
name: "[path][name].[ext]",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
test: /\.svg$/,
|
|
55
|
+
use: [
|
|
56
|
+
{
|
|
57
|
+
loader: "svg-url-loader",
|
|
58
|
+
options: {
|
|
59
|
+
limit: 8192,
|
|
60
|
+
noquotes: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
plugins: [
|
|
68
|
+
new CopyPlugin({
|
|
69
|
+
patterns: [{ from: "public", to: "public" }],
|
|
70
|
+
}),
|
|
71
|
+
new HtmlWebpackPlugin({
|
|
72
|
+
template: "./index.html",
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
75
|
+
performance: {
|
|
76
|
+
hints: false,
|
|
77
|
+
maxAssetSize: 13 * 1024 * 1024, // 12 MiB
|
|
78
|
+
maxEntrypointSize: 13 * 1024 * 1024, // 12 MiB
|
|
79
|
+
},
|
|
80
|
+
stats: {
|
|
81
|
+
warnings: false,
|
|
82
|
+
},
|
|
83
|
+
experiments: {
|
|
84
|
+
asyncWebAssembly: true,
|
|
85
|
+
topLevelAwait: true,
|
|
86
|
+
},
|
|
87
|
+
devtool: "source-map",
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default [appConfig];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: { browser: true, es2020: true },
|
|
4
|
+
extends: [
|
|
5
|
+
'eslint:recommended',
|
|
6
|
+
'plugin:react/recommended',
|
|
7
|
+
'plugin:react/jsx-runtime',
|
|
8
|
+
'plugin:react-hooks/recommended',
|
|
9
|
+
],
|
|
10
|
+
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
11
|
+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
|
|
12
|
+
settings: { react: { version: '18.2' } },
|
|
13
|
+
plugins: ['react-refresh'],
|
|
14
|
+
rules: {
|
|
15
|
+
'react-refresh/only-export-components': [
|
|
16
|
+
'warn',
|
|
17
|
+
{ allowConstantExport: true },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# React + Aleo + Leo
|
|
2
|
+
|
|
3
|
+
[](https://stackblitz.com/fork/github/ProvableHQ/sdk/tree/testnet3/create-leo-app/template-react)
|
|
4
|
+
|
|
5
|
+
This template provides a minimal setup to get React and Aleo working in Vite
|
|
6
|
+
with HMR and some ESLint rules.
|
|
7
|
+
|
|
8
|
+
This template includes a Leo program that is loaded by the web app located in
|
|
9
|
+
the `helloworld` directory.
|
|
10
|
+
|
|
11
|
+
Note: Webpack is currently used for production builds due to a
|
|
12
|
+
[bug](https://github.com/vitejs/vite/issues/13367) with Vite related to nested
|
|
13
|
+
workers.
|
|
14
|
+
|
|
15
|
+
### Start in development mode
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm run dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Your app should be running on http://localhost:5173/
|
|
22
|
+
|
|
23
|
+
### Build Leo program
|
|
24
|
+
|
|
25
|
+
1. Copy the `helloworld/.env.example` to `helloworld/.env` (this will be ignored
|
|
26
|
+
by Git):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cd helloworld
|
|
30
|
+
cp .env.example .env
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
2. Replace `PRIVATE_KEY=user1PrivateKey` in the `.env` with your own key (you
|
|
34
|
+
can use an existing one or generate your own at https://provable.tools/account)
|
|
35
|
+
|
|
36
|
+
3. Follow instructions to install Leo here: https://github.com/ProvableHQ/leo
|
|
37
|
+
|
|
38
|
+
4. You can edit `helloworld/src/main.leo` and run `leo run` to compile and update the
|
|
39
|
+
Aleo instructions under `build` which are loaded by the web app.
|
|
40
|
+
|
|
41
|
+
## Deploy program from web app
|
|
42
|
+
|
|
43
|
+
> [!WARNING]
|
|
44
|
+
> This is for demonstration purposes or local testing only, in production applications you
|
|
45
|
+
> should avoid building a public facing web app with private key information
|
|
46
|
+
|
|
47
|
+
Information on generating a private key, seeding a wallet with funds, and finding a spendable record can be found here
|
|
48
|
+
if you are unfamiliar: https://developer.aleo.org/testnet/getting_started/deploy_execute_demo
|
|
49
|
+
|
|
50
|
+
Aleo programs deployed require unique names, make sure to edit the program's name to something unique in `helloworld/src/main.leo`, `helloworld/program.json`, rename `helloworld/inputs/helloworld.in` and rebuild.
|
|
51
|
+
|
|
52
|
+
1. In the `worker.js` file modify the privateKey to be an account with available
|
|
53
|
+
funds
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
// Use existing account with funds
|
|
57
|
+
const account = new Account({
|
|
58
|
+
privateKey: "user1PrivateKey",
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. (Optional) Provide a fee record manually (located in commented code within `worker.js`)
|
|
63
|
+
|
|
64
|
+
If you do not provide a manual fee record, the SDK will attempt to scan for a record starting at the latest block. A simple way to speed this up would be to make a public transaction to this account right before deploying.
|
|
65
|
+
|
|
66
|
+
3. Run the web app and hit the deploy button
|
|
67
|
+
|
|
68
|
+
## Production deployment
|
|
69
|
+
|
|
70
|
+
### Build
|
|
71
|
+
|
|
72
|
+
`npm run build`
|
|
73
|
+
|
|
74
|
+
Upload `dist` folder to your host of choice.
|
|
75
|
+
|
|
76
|
+
### ⚠️ Header warnings
|
|
77
|
+
|
|
78
|
+
`DOMException: Failed to execute 'postMessage' on 'Worker': SharedArrayBuffer transfer requires self.crossOriginIsolated`
|
|
79
|
+
|
|
80
|
+
If you get a warning similar to this when deploying your application, you need
|
|
81
|
+
to make sure your web server is configured with the following headers:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
Cross-Origin-Opener-Policy: same-origin
|
|
85
|
+
Cross-Origin-Embedder-Policy: require-corp
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
We've included a `_headers` file that works with some web hosts (e.g. Netlify)
|
|
89
|
+
but depending on your host / server setup you may need to configure the headers
|
|
90
|
+
manually.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
4
|
+
npm-debug.log*
|
|
5
|
+
yarn-debug.log*
|
|
6
|
+
yarn-error.log*
|
|
7
|
+
pnpm-debug.log*
|
|
8
|
+
lerna-debug.log*
|
|
9
|
+
|
|
10
|
+
node_modules
|
|
11
|
+
dist
|
|
12
|
+
dist-ssr
|
|
13
|
+
*.local
|
|
14
|
+
|
|
15
|
+
# Editor directories and files
|
|
16
|
+
.vscode/*
|
|
17
|
+
!.vscode/extensions.json
|
|
18
|
+
.idea
|
|
19
|
+
.DS_Store
|
|
20
|
+
*.suo
|
|
21
|
+
*.ntvs*
|
|
22
|
+
*.njsproj
|
|
23
|
+
*.sln
|
|
24
|
+
*.sw?
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="public/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Aleo + React</title>
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
background: #000000;
|
|
11
|
+
}
|
|
12
|
+
.spinner {
|
|
13
|
+
margin: 150px auto 50px auto;
|
|
14
|
+
width: 40px;
|
|
15
|
+
height: 40px;
|
|
16
|
+
position: relative;
|
|
17
|
+
text-align: center;
|
|
18
|
+
|
|
19
|
+
-webkit-animation: sk-rotate 2s infinite linear;
|
|
20
|
+
animation: sk-rotate 2s infinite linear;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.dot1,
|
|
24
|
+
.dot2 {
|
|
25
|
+
width: 60%;
|
|
26
|
+
height: 60%;
|
|
27
|
+
display: inline-block;
|
|
28
|
+
position: absolute;
|
|
29
|
+
top: 0;
|
|
30
|
+
background-color: #00C0F9;
|
|
31
|
+
border-radius: 100%;
|
|
32
|
+
|
|
33
|
+
-webkit-animation: sk-bounce 2s infinite ease-in-out;
|
|
34
|
+
animation: sk-bounce 2s infinite ease-in-out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.dot2 {
|
|
38
|
+
top: auto;
|
|
39
|
+
bottom: 0;
|
|
40
|
+
-webkit-animation-delay: -1s;
|
|
41
|
+
animation-delay: -1s;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@-webkit-keyframes sk-rotate {
|
|
45
|
+
100% {
|
|
46
|
+
-webkit-transform: rotate(360deg);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
@keyframes sk-rotate {
|
|
50
|
+
100% {
|
|
51
|
+
transform: rotate(360deg);
|
|
52
|
+
-webkit-transform: rotate(360deg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@-webkit-keyframes sk-bounce {
|
|
57
|
+
0%,
|
|
58
|
+
100% {
|
|
59
|
+
-webkit-transform: scale(0);
|
|
60
|
+
}
|
|
61
|
+
50% {
|
|
62
|
+
-webkit-transform: scale(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@keyframes sk-bounce {
|
|
67
|
+
0%,
|
|
68
|
+
100% {
|
|
69
|
+
transform: scale(0);
|
|
70
|
+
-webkit-transform: scale(0);
|
|
71
|
+
}
|
|
72
|
+
50% {
|
|
73
|
+
transform: scale(1);
|
|
74
|
+
-webkit-transform: scale(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
78
|
+
</head>
|
|
79
|
+
<body>
|
|
80
|
+
<div id="root">
|
|
81
|
+
<div class="spinner">
|
|
82
|
+
<div class="dot1"></div>
|
|
83
|
+
<div class="dot2"></div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
87
|
+
</body>
|
|
88
|
+
</html>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# script exists immediately if command fails
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
# check for dependencies
|
|
7
|
+
command -v git >/dev/null 2>&1 || { echo >&2 "git is required but it's not installed. Aborting."; exit 1; }
|
|
8
|
+
command -v cargo >/dev/null 2>&1 || { echo >&2 "cargo is required but it's not installed. Aborting."; exit 1; }
|
|
9
|
+
|
|
10
|
+
INSTALL_DIR="${INSTALL_DIR:-$HOME/.leo}"
|
|
11
|
+
|
|
12
|
+
# ask for confirmation
|
|
13
|
+
read -p "This script will install Leo into $INSTALL_DIR. Do you want to continue? (y/N) " choice
|
|
14
|
+
case "$choice" in
|
|
15
|
+
y|Y ) echo "Continuing installation...";;
|
|
16
|
+
* ) echo "Aborting."; exit;;
|
|
17
|
+
esac
|
|
18
|
+
|
|
19
|
+
# clone or update the repo
|
|
20
|
+
if [ -d "$INSTALL_DIR" ]; then
|
|
21
|
+
echo "Directory $INSTALL_DIR exists. Updating repository..."
|
|
22
|
+
git -C "$INSTALL_DIR" pull
|
|
23
|
+
else
|
|
24
|
+
echo "Cloning repository into $INSTALL_DIR..."
|
|
25
|
+
git clone https://github.com/ProvableHQ/leo "$INSTALL_DIR"
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# build and install
|
|
29
|
+
echo "Building and installing from source..."
|
|
30
|
+
cargo install --path "$INSTALL_DIR"
|