create-leo-app 0.9.11 → 0.9.12
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/package.json +2 -1
- package/template-build-and-execute-authorization-ts/package.json +1 -1
- package/template-extension/package.json +1 -1
- package/template-nextjs-ts/package.json +1 -1
- package/template-node/package.json +1 -1
- package/template-node-ts/package.json +1 -1
- package/template-offline-public-transaction-ts/package.json +1 -1
- package/template-private-transaction-ts/README.md +17 -0
- package/template-private-transaction-ts/_gitignore +24 -0
- package/template-private-transaction-ts/dist/index.js +39 -0
- package/template-private-transaction-ts/dist/index.js.map +1 -0
- package/template-private-transaction-ts/package.json +19 -0
- package/template-private-transaction-ts/rollup.config.js +19 -0
- package/template-private-transaction-ts/src/index.ts +43 -0
- package/template-private-transaction-ts/tsconfig.json +15 -0
- package/template-react-leo/package.json +1 -1
- package/template-react-managed-worker/package.json +1 -1
- package/template-react-ts/package.json +1 -1
- package/template-vanilla/package.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-leo-app",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"collaborators": [
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"template-build-and-execute-authorization-ts",
|
|
16
16
|
"template-node",
|
|
17
17
|
"template-offline-public-transaction-ts",
|
|
18
|
+
"template-private-transaction-ts",
|
|
18
19
|
"template-react-leo",
|
|
19
20
|
"template-react-managed-worker",
|
|
20
21
|
"template-react-ts",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Node.js Private Transfer Example
|
|
2
|
+
|
|
3
|
+
This example shows how to build a transfer_private transaction using the ProgramManager.
|
|
4
|
+
|
|
5
|
+
This example can be run with the following
|
|
6
|
+
|
|
7
|
+
#### Yarn
|
|
8
|
+
```bash
|
|
9
|
+
yarn dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
#### NPM
|
|
13
|
+
```bash
|
|
14
|
+
npm run dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Recommend Node.js 20+ for best performance.
|
|
@@ -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,39 @@
|
|
|
1
|
+
import { initThreadPool, Account, ProgramManager, AleoKeyProvider } from '@provablehq/sdk/testnet.js';
|
|
2
|
+
import { CREDITS_PROGRAM_KEYS } from '@provablehq/sdk/mainnet.js';
|
|
3
|
+
|
|
4
|
+
// Initialize the threadpool to speed up proving.
|
|
5
|
+
await initThreadPool();
|
|
6
|
+
// Specify the record to send.
|
|
7
|
+
const sendRecord = "{\n owner: aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3.private,\n microcredits: 500000u64.private,\n _nonce: 2128807984625485873765840993868794284062894954530194503954279385341936659546group.public,\n _version: 1u8.public\n}";
|
|
8
|
+
// Specify the fee record to use for the transaction.
|
|
9
|
+
const feeRecord = "{\n owner: aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3.private,\n microcredits: 50000u64.private,\n _nonce: 8327477210335641151082470829879168522735279120730137538049818239556464339772group.public,\n _version: 1u8.public\n}";
|
|
10
|
+
// Import the account.
|
|
11
|
+
const accountCiphertext = "ciphertext1qvq283j7ujnhz59d4rnu772rfmvf94039x9ekhk2lzuutteqzlghsr3g9824qgw97a79mmdymqdt0ulqdkahq39vnerw2tl7thvvnnunq386jzjnw29e0ghnq7unphgdzw637q3fgvvlkrcywsc5jukkdhss5qq3njp";
|
|
12
|
+
const account = Account.fromCiphertext(accountCiphertext, "provablealeo1");
|
|
13
|
+
// Specify the recipient.
|
|
14
|
+
const recipient = "aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3";
|
|
15
|
+
// Create a program manager with the account desired.
|
|
16
|
+
const programManager = new ProgramManager();
|
|
17
|
+
programManager.setAccount(account);
|
|
18
|
+
// Create a key provider in order to re-use the same key for each execution
|
|
19
|
+
const keyProvider = new AleoKeyProvider();
|
|
20
|
+
keyProvider.useCache(true);
|
|
21
|
+
// Initialize the keyProvider cache with all necessary keys.
|
|
22
|
+
await Promise.all([keyProvider.transferKeys("private"), keyProvider.feePrivateKeys()]);
|
|
23
|
+
programManager.setKeyProvider(keyProvider);
|
|
24
|
+
programManager.setInclusionProver();
|
|
25
|
+
const start = Date.now();
|
|
26
|
+
console.log("Starting transfer_private execution");
|
|
27
|
+
// Construct the transfer_private transaction.
|
|
28
|
+
const transfer_private_tx = await programManager.buildExecutionTransaction({
|
|
29
|
+
programName: "credits.aleo",
|
|
30
|
+
functionName: "transfer_private",
|
|
31
|
+
priorityFee: 0,
|
|
32
|
+
privateFee: true,
|
|
33
|
+
inputs: [sendRecord, recipient, "500000u64"],
|
|
34
|
+
feeRecord,
|
|
35
|
+
keySearchParams: { "cacheKey": CREDITS_PROGRAM_KEYS.getKey("transfer_private").locator }
|
|
36
|
+
});
|
|
37
|
+
console.log(`transfer_private Execute finished in ${Date.now() - start}ms`);
|
|
38
|
+
console.log(`Private execution ${transfer_private_tx}`);
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-ts-transfer-private-starter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rimraf dist/js && rollup --config",
|
|
8
|
+
"dev": "npm run build && node dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@provablehq/sdk": "^0.9.12"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"rimraf": "^6.0.1",
|
|
15
|
+
"rollup": "^4.32.0",
|
|
16
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
17
|
+
"typescript": "^5.7.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import typescript from "rollup-plugin-typescript2";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
input: {
|
|
5
|
+
index: "./src/index.ts",
|
|
6
|
+
},
|
|
7
|
+
output: {
|
|
8
|
+
dir: `dist`,
|
|
9
|
+
format: "es",
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
},
|
|
12
|
+
external: ['@provablehq/sdk'],
|
|
13
|
+
plugins: [
|
|
14
|
+
typescript({
|
|
15
|
+
tsconfig: "tsconfig.json",
|
|
16
|
+
clean: true,
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {Account, initThreadPool, ProgramManager, AleoKeyProvider} from "@provablehq/sdk/testnet.js";
|
|
2
|
+
import { CREDITS_PROGRAM_KEYS } from "@provablehq/sdk/mainnet.js";
|
|
3
|
+
|
|
4
|
+
// Initialize the threadpool to speed up proving.
|
|
5
|
+
await initThreadPool();
|
|
6
|
+
|
|
7
|
+
// Specify the record to send.
|
|
8
|
+
const sendRecord = "{\n owner: aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3.private,\n microcredits: 500000u64.private,\n _nonce: 2128807984625485873765840993868794284062894954530194503954279385341936659546group.public,\n _version: 1u8.public\n}";
|
|
9
|
+
// Specify the fee record to use for the transaction.
|
|
10
|
+
const feeRecord = "{\n owner: aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3.private,\n microcredits: 50000u64.private,\n _nonce: 8327477210335641151082470829879168522735279120730137538049818239556464339772group.public,\n _version: 1u8.public\n}";
|
|
11
|
+
// Import the account.
|
|
12
|
+
const accountCiphertext = "ciphertext1qvq283j7ujnhz59d4rnu772rfmvf94039x9ekhk2lzuutteqzlghsr3g9824qgw97a79mmdymqdt0ulqdkahq39vnerw2tl7thvvnnunq386jzjnw29e0ghnq7unphgdzw637q3fgvvlkrcywsc5jukkdhss5qq3njp";
|
|
13
|
+
const account = Account.fromCiphertext(accountCiphertext, "provablealeo1");
|
|
14
|
+
// Specify the recipient.
|
|
15
|
+
const recipient = "aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3";
|
|
16
|
+
|
|
17
|
+
// Create a program manager with the account desired.
|
|
18
|
+
const programManager = new ProgramManager();
|
|
19
|
+
programManager.setAccount(account);
|
|
20
|
+
|
|
21
|
+
// Create a key provider in order to re-use the same key for each execution
|
|
22
|
+
const keyProvider = new AleoKeyProvider();
|
|
23
|
+
keyProvider.useCache(true);
|
|
24
|
+
|
|
25
|
+
// Initialize the keyProvider cache with all necessary keys.
|
|
26
|
+
await Promise.all([keyProvider.transferKeys("private"), keyProvider.feePrivateKeys()]);
|
|
27
|
+
programManager.setKeyProvider(keyProvider);
|
|
28
|
+
programManager.setInclusionProver();
|
|
29
|
+
|
|
30
|
+
const start = Date.now();
|
|
31
|
+
console.log("Starting transfer_private execution");
|
|
32
|
+
// Construct the transfer_private transaction.
|
|
33
|
+
const transfer_private_tx = await programManager.buildExecutionTransaction({
|
|
34
|
+
programName: "credits.aleo",
|
|
35
|
+
functionName: "transfer_private",
|
|
36
|
+
priorityFee: 0,
|
|
37
|
+
privateFee: true,
|
|
38
|
+
inputs: [sendRecord, recipient, "500000u64"],
|
|
39
|
+
feeRecord,
|
|
40
|
+
keySearchParams: { "cacheKey" : CREDITS_PROGRAM_KEYS.getKey("transfer_private").locator}
|
|
41
|
+
});
|
|
42
|
+
console.log(`transfer_private Execute finished in ${Date.now() - start}ms`);
|
|
43
|
+
console.log(`Private execution ${transfer_private_tx}`);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Basic Options */
|
|
4
|
+
"target": "es2017",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
|
|
7
|
+
/* Module Resolution Options */
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
|
|
11
|
+
/* Advanced Options */
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true
|
|
14
|
+
}
|
|
15
|
+
}
|