@halot/cli 1.0.2 → 1.0.4
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 +6 -12
- package/dist/features/provider/provider-init.command.js +27 -7
- package/dist/features/requester/requester-init.command.js +25 -6
- package/dist/features/service/service-init.command.js +16 -1
- package/dist/features/verifier/verifier-init.command.js +36 -8
- package/dist/index.js +28 -3
- package/dist/shared/ui/console.js +61 -0
- package/dist/shared/wallet/authority.util.js +18 -7
- package/dist/shared/wallet/init-cluster.util.js +18 -0
- package/dist/shared/wallet/wallet.manager.js +9 -15
- package/dist/shared/workspace/workspace.service.js +8 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,6 +27,8 @@ npx @halot/cli --help
|
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
halot provider init
|
|
30
|
+
halot provider init --testnet
|
|
31
|
+
halot provider init --mainnet
|
|
30
32
|
```
|
|
31
33
|
|
|
32
34
|
This creates:
|
|
@@ -42,19 +44,15 @@ This creates:
|
|
|
42
44
|
"0g:testnet": {
|
|
43
45
|
"privateKey": "0x..."
|
|
44
46
|
},
|
|
45
|
-
"0g:mainnet": {
|
|
46
|
-
"privateKey": "0x..."
|
|
47
|
-
},
|
|
48
47
|
"stellar:testnet": {
|
|
49
48
|
"privateKey": "S..."
|
|
50
|
-
},
|
|
51
|
-
"stellar:mainnet": {
|
|
52
|
-
"privateKey": "S..."
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
```
|
|
57
53
|
|
|
54
|
+
The default is `--testnet`. `--mainnet` generates the equivalent `0g:mainnet` and `stellar:mainnet` scoped workspace without adding testnet entries.
|
|
55
|
+
|
|
58
56
|
`halot.provider.json` stores provider identity, the selected Halot actor authority, and settlement wallets:
|
|
59
57
|
|
|
60
58
|
```json
|
|
@@ -77,9 +75,7 @@ This creates:
|
|
|
77
75
|
},
|
|
78
76
|
"settlementWallets": {
|
|
79
77
|
"0g:testnet": "0x...",
|
|
80
|
-
"
|
|
81
|
-
"stellar:testnet": "G...",
|
|
82
|
-
"stellar:mainnet": "G..."
|
|
78
|
+
"stellar:testnet": "G..."
|
|
83
79
|
}
|
|
84
80
|
}
|
|
85
81
|
```
|
|
@@ -275,9 +271,7 @@ This creates:
|
|
|
275
271
|
},
|
|
276
272
|
"settlementWallets": {
|
|
277
273
|
"0g:testnet": "0x...",
|
|
278
|
-
"
|
|
279
|
-
"stellar:testnet": "G...",
|
|
280
|
-
"stellar:mainnet": "G..."
|
|
274
|
+
"stellar:testnet": "G..."
|
|
281
275
|
},
|
|
282
276
|
"stake": {
|
|
283
277
|
"amount": "1000",
|
|
@@ -3,11 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.runProviderInitCommand = runProviderInitCommand;
|
|
4
4
|
const wallet_manager_1 = require("@halot/cli/shared/wallet/wallet.manager");
|
|
5
5
|
const authority_util_1 = require("@halot/cli/shared/wallet/authority.util");
|
|
6
|
+
const init_cluster_util_1 = require("@halot/cli/shared/wallet/init-cluster.util");
|
|
6
7
|
const workspace_service_1 = require("@halot/cli/shared/workspace/workspace.service");
|
|
7
|
-
|
|
8
|
+
const console_1 = require("@halot/cli/shared/ui/console");
|
|
9
|
+
async function runProviderInitCommand(options = {}) {
|
|
10
|
+
const cluster = (0, init_cluster_util_1.resolveInitCluster)(options);
|
|
11
|
+
const authorities = (0, init_cluster_util_1.describeClusterAuthorities)(cluster);
|
|
8
12
|
const workspace = new workspace_service_1.WorkspaceService();
|
|
9
13
|
const walletManager = new wallet_manager_1.WalletManager(workspace);
|
|
10
|
-
const wallets = walletManager.createWallets();
|
|
14
|
+
const wallets = walletManager.createWallets(cluster);
|
|
15
|
+
const zeroGAddress = (0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.zeroG);
|
|
16
|
+
const stellarAddress = (0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.stellar);
|
|
11
17
|
workspace.writeProviderConfig({
|
|
12
18
|
providerId: '',
|
|
13
19
|
displayName: 'My Provider',
|
|
@@ -17,17 +23,31 @@ async function runProviderInitCommand() {
|
|
|
17
23
|
erc8004TokenId: '',
|
|
18
24
|
agentRegistry: '',
|
|
19
25
|
agentUri: '',
|
|
20
|
-
ownerAddress:
|
|
26
|
+
ownerAddress: zeroGAddress,
|
|
21
27
|
domain: 'myprovider.0g',
|
|
22
28
|
domainType: 'space-id',
|
|
23
29
|
},
|
|
24
30
|
authority: {
|
|
25
31
|
path: './wallets.json',
|
|
26
|
-
actor:
|
|
32
|
+
actor: authorities.zeroG,
|
|
27
33
|
},
|
|
28
34
|
settlementWallets: (0, authority_util_1.createDefaultSettlementWallets)(wallets),
|
|
29
35
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
(0, console_1.printInitSummary)({
|
|
37
|
+
title: 'Provider workspace initialized',
|
|
38
|
+
subtitle: `Cluster: ${cluster}`,
|
|
39
|
+
rows: [
|
|
40
|
+
{ label: 'Actor', value: authorities.zeroG },
|
|
41
|
+
{ label: 'Owner', value: zeroGAddress },
|
|
42
|
+
{ label: 'Settlement', value: `${authorities.zeroG}, ${authorities.stellar}` },
|
|
43
|
+
{ label: 'Stellar', value: stellarAddress },
|
|
44
|
+
],
|
|
45
|
+
files: ['wallets.json', 'halot.provider.json', '.gitignore'],
|
|
46
|
+
warnings: ['wallets.json contains private keys. Do not commit it.'],
|
|
47
|
+
nextSteps: [
|
|
48
|
+
'Edit halot.provider.json',
|
|
49
|
+
`Run ${(0, console_1.command)('halot provider register')}`,
|
|
50
|
+
`Run ${(0, console_1.command)('halot service init --name "GPT-5.4 Text" --category text')}`,
|
|
51
|
+
],
|
|
52
|
+
});
|
|
33
53
|
}
|
|
@@ -3,20 +3,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.runRequesterInitCommand = runRequesterInitCommand;
|
|
4
4
|
const wallet_manager_1 = require("@halot/cli/shared/wallet/wallet.manager");
|
|
5
5
|
const authority_util_1 = require("@halot/cli/shared/wallet/authority.util");
|
|
6
|
+
const init_cluster_util_1 = require("@halot/cli/shared/wallet/init-cluster.util");
|
|
6
7
|
const workspace_service_1 = require("@halot/cli/shared/workspace/workspace.service");
|
|
7
|
-
|
|
8
|
+
const console_1 = require("@halot/cli/shared/ui/console");
|
|
9
|
+
async function runRequesterInitCommand(options = {}) {
|
|
10
|
+
const cluster = (0, init_cluster_util_1.resolveInitCluster)(options);
|
|
11
|
+
const authorities = (0, init_cluster_util_1.describeClusterAuthorities)(cluster);
|
|
8
12
|
const workspace = new workspace_service_1.WorkspaceService();
|
|
9
13
|
const walletManager = new wallet_manager_1.WalletManager(workspace);
|
|
10
|
-
const wallets = walletManager.createWallets();
|
|
14
|
+
const wallets = walletManager.createWallets(cluster);
|
|
15
|
+
const zeroGAddress = (0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.zeroG);
|
|
16
|
+
const stellarAddress = (0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.stellar);
|
|
11
17
|
workspace.writeRequesterConfig({
|
|
12
18
|
requesterId: '',
|
|
13
19
|
displayName: 'Halot Requester',
|
|
14
20
|
authority: {
|
|
15
21
|
path: './wallets.json',
|
|
16
|
-
actor:
|
|
22
|
+
actor: authorities.zeroG,
|
|
17
23
|
},
|
|
18
24
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
(0, console_1.printInitSummary)({
|
|
26
|
+
title: 'Requester workspace initialized',
|
|
27
|
+
subtitle: `Cluster: ${cluster}`,
|
|
28
|
+
rows: [
|
|
29
|
+
{ label: 'Actor', value: authorities.zeroG },
|
|
30
|
+
{ label: '0G', value: zeroGAddress },
|
|
31
|
+
{ label: 'Stellar', value: stellarAddress },
|
|
32
|
+
],
|
|
33
|
+
files: ['wallets.json', 'halot.requester.json', '.gitignore'],
|
|
34
|
+
warnings: ['wallets.json contains private keys. Do not commit it.'],
|
|
35
|
+
nextSteps: [
|
|
36
|
+
`Run ${(0, console_1.command)('halot browse')}`,
|
|
37
|
+
`Run ${(0, console_1.command)('halot quote --service <serviceId> --input \'{"query":"hello"}\'')}`,
|
|
38
|
+
`Run ${(0, console_1.command)('halot job create --service <serviceId> --input \'{"query":"hello"}\'')}`,
|
|
39
|
+
],
|
|
40
|
+
});
|
|
22
41
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runServiceInitCommand = runServiceInitCommand;
|
|
4
4
|
const sdk_1 = require("@halot/sdk");
|
|
5
|
+
const console_1 = require("@halot/cli/shared/ui/console");
|
|
5
6
|
const workspace_service_1 = require("@halot/cli/shared/workspace/workspace.service");
|
|
6
7
|
async function runServiceInitCommand(options) {
|
|
7
8
|
const workspace = new workspace_service_1.WorkspaceService();
|
|
@@ -67,7 +68,21 @@ async function runServiceInitCommand(options) {
|
|
|
67
68
|
},
|
|
68
69
|
};
|
|
69
70
|
workspace.writeService(fileName, service);
|
|
70
|
-
|
|
71
|
+
(0, console_1.printInitSummary)({
|
|
72
|
+
title: 'Service draft initialized',
|
|
73
|
+
rows: [
|
|
74
|
+
{ label: 'Service', value: name },
|
|
75
|
+
{ label: 'Category', value: category },
|
|
76
|
+
{ label: 'Trust', value: trustLevel },
|
|
77
|
+
{ label: 'Draft', value: `services/${fileName}` },
|
|
78
|
+
],
|
|
79
|
+
files: [`services/${fileName}`],
|
|
80
|
+
nextSteps: [
|
|
81
|
+
`Edit services/${fileName}`,
|
|
82
|
+
`Run ${(0, console_1.command)(`halot service register --file ${fileName}`)}`,
|
|
83
|
+
'Use the returned serviceId in SDK middleware or worker configuration',
|
|
84
|
+
],
|
|
85
|
+
});
|
|
71
86
|
}
|
|
72
87
|
function parseServiceCategory(value) {
|
|
73
88
|
if (!value) {
|
|
@@ -3,11 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.runVerifierInitCommand = runVerifierInitCommand;
|
|
4
4
|
const wallet_manager_1 = require("@halot/cli/shared/wallet/wallet.manager");
|
|
5
5
|
const authority_util_1 = require("@halot/cli/shared/wallet/authority.util");
|
|
6
|
+
const init_cluster_util_1 = require("@halot/cli/shared/wallet/init-cluster.util");
|
|
6
7
|
const workspace_service_1 = require("@halot/cli/shared/workspace/workspace.service");
|
|
7
|
-
|
|
8
|
+
const console_1 = require("@halot/cli/shared/ui/console");
|
|
9
|
+
async function runVerifierInitCommand(options = {}) {
|
|
10
|
+
const cluster = (0, init_cluster_util_1.resolveInitCluster)(options);
|
|
11
|
+
const authorities = (0, init_cluster_util_1.describeClusterAuthorities)(cluster);
|
|
8
12
|
const workspace = new workspace_service_1.WorkspaceService();
|
|
9
13
|
const walletManager = new wallet_manager_1.WalletManager(workspace);
|
|
10
|
-
const wallets = walletManager.createWallets();
|
|
14
|
+
const wallets = walletManager.createWallets(cluster);
|
|
15
|
+
const zeroGAddress = (0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.zeroG);
|
|
16
|
+
const stellarAddress = (0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.stellar);
|
|
11
17
|
workspace.writeVerifierConfig({
|
|
12
18
|
verifierId: '',
|
|
13
19
|
displayName: 'My Verifier',
|
|
@@ -16,13 +22,13 @@ async function runVerifierInitCommand() {
|
|
|
16
22
|
erc8004TokenId: '',
|
|
17
23
|
agentRegistry: '',
|
|
18
24
|
agentUri: '',
|
|
19
|
-
ownerAddress:
|
|
25
|
+
ownerAddress: zeroGAddress,
|
|
20
26
|
domain: 'myverifier.0g',
|
|
21
27
|
domainType: 'space-id',
|
|
22
28
|
},
|
|
23
29
|
authority: {
|
|
24
30
|
path: './wallets.json',
|
|
25
|
-
actor:
|
|
31
|
+
actor: authorities.zeroG,
|
|
26
32
|
},
|
|
27
33
|
settlementWallets: (0, authority_util_1.createDefaultSettlementWallets)(wallets),
|
|
28
34
|
stake: {
|
|
@@ -41,7 +47,7 @@ async function runVerifierInitCommand() {
|
|
|
41
47
|
verifiability: 'TeeML',
|
|
42
48
|
},
|
|
43
49
|
sdk: {
|
|
44
|
-
network:
|
|
50
|
+
network: cluster,
|
|
45
51
|
},
|
|
46
52
|
timeout: 60,
|
|
47
53
|
});
|
|
@@ -63,7 +69,29 @@ async function runVerifierInitCommand() {
|
|
|
63
69
|
maxConcurrentJobs: 5,
|
|
64
70
|
minConfidenceThreshold: 0.75,
|
|
65
71
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
(0, console_1.printInitSummary)({
|
|
73
|
+
title: 'Verifier workspace initialized',
|
|
74
|
+
subtitle: `Cluster: ${cluster}`,
|
|
75
|
+
rows: [
|
|
76
|
+
{ label: 'Actor', value: authorities.zeroG },
|
|
77
|
+
{ label: 'Owner', value: zeroGAddress },
|
|
78
|
+
{ label: 'Settlement', value: `${authorities.zeroG}, ${authorities.stellar}` },
|
|
79
|
+
{ label: 'Stellar', value: stellarAddress },
|
|
80
|
+
],
|
|
81
|
+
files: [
|
|
82
|
+
'wallets.json',
|
|
83
|
+
'halot.verifier.json',
|
|
84
|
+
'model.config.json',
|
|
85
|
+
'inference.json',
|
|
86
|
+
'specializations.json',
|
|
87
|
+
'.gitignore',
|
|
88
|
+
],
|
|
89
|
+
warnings: ['wallets.json contains private keys. Do not commit it.'],
|
|
90
|
+
nextSteps: [
|
|
91
|
+
'Edit halot.verifier.json',
|
|
92
|
+
'Edit model.config.json, inference.json, and specializations.json',
|
|
93
|
+
`Run ${(0, console_1.command)('halot verifier register')}`,
|
|
94
|
+
`Run ${(0, console_1.command)('halot verifier run')}`,
|
|
95
|
+
],
|
|
96
|
+
});
|
|
69
97
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
4
9
|
const commander_1 = require("commander");
|
|
5
10
|
const browse_command_1 = require("@halot/cli/features/browse/browse.command");
|
|
6
11
|
const job_create_command_1 = require("@halot/cli/features/jobs/job-create.command");
|
|
@@ -28,7 +33,7 @@ const program = new commander_1.Command();
|
|
|
28
33
|
program
|
|
29
34
|
.name('halot')
|
|
30
35
|
.description('Halot protocol CLI')
|
|
31
|
-
.version(
|
|
36
|
+
.version(resolveCliVersion());
|
|
32
37
|
program
|
|
33
38
|
.command('browse')
|
|
34
39
|
.option('--server <url>', 'Halot server url', defaultServerUrl)
|
|
@@ -43,9 +48,15 @@ program
|
|
|
43
48
|
const requester = program.command('requester').description('Requester workspace');
|
|
44
49
|
requester
|
|
45
50
|
.command('init')
|
|
51
|
+
.option('--testnet', 'Initialize a testnet requester workspace', false)
|
|
52
|
+
.option('--mainnet', 'Initialize a mainnet requester workspace', false)
|
|
46
53
|
.action(requester_init_command_1.runRequesterInitCommand);
|
|
47
54
|
const provider = program.command('provider').description('Provider workspace');
|
|
48
|
-
provider
|
|
55
|
+
provider
|
|
56
|
+
.command('init')
|
|
57
|
+
.option('--testnet', 'Initialize a testnet provider workspace', false)
|
|
58
|
+
.option('--mainnet', 'Initialize a mainnet provider workspace', false)
|
|
59
|
+
.action(provider_init_command_1.runProviderInitCommand);
|
|
49
60
|
provider
|
|
50
61
|
.command('register')
|
|
51
62
|
.option('--server <url>', 'Halot server url', defaultServerUrl)
|
|
@@ -92,7 +103,11 @@ service
|
|
|
92
103
|
.option('--server <url>', 'Halot server url', defaultServerUrl)
|
|
93
104
|
.action(service_remove_command_1.runServiceRemoveCommand);
|
|
94
105
|
const verifier = program.command('verifier').description('Verifier workspace');
|
|
95
|
-
verifier
|
|
106
|
+
verifier
|
|
107
|
+
.command('init')
|
|
108
|
+
.option('--testnet', 'Initialize a testnet verifier workspace', false)
|
|
109
|
+
.option('--mainnet', 'Initialize a mainnet verifier workspace', false)
|
|
110
|
+
.action(verifier_init_command_1.runVerifierInitCommand);
|
|
96
111
|
verifier
|
|
97
112
|
.command('register')
|
|
98
113
|
.option('--server <url>', 'Halot server url', defaultServerUrl)
|
|
@@ -132,3 +147,13 @@ program.parseAsync().catch((error) => {
|
|
|
132
147
|
console.error(error instanceof Error ? error.message : error);
|
|
133
148
|
process.exitCode = 1;
|
|
134
149
|
});
|
|
150
|
+
function resolveCliVersion() {
|
|
151
|
+
try {
|
|
152
|
+
const packageJsonPath = node_path_1.default.resolve(__dirname, '..', 'package.json');
|
|
153
|
+
const packageJson = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, 'utf8'));
|
|
154
|
+
return packageJson.version ?? '0.0.0';
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return '0.0.0';
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printInitSummary = printInitSummary;
|
|
4
|
+
exports.command = command;
|
|
5
|
+
const HALOT_ASCII = [
|
|
6
|
+
' _ _ _ _ ___ _____',
|
|
7
|
+
'| | | | / \\ | | / _ \\_ _|',
|
|
8
|
+
'| |_| | / _ \\ | | | | | || |',
|
|
9
|
+
'| _ |/ ___ \\| |__| |_| || |',
|
|
10
|
+
'|_| |_/_/ \\_\\_____\\___/ |_|',
|
|
11
|
+
].join('\n');
|
|
12
|
+
const colorEnabled = Boolean(process.stdout.isTTY && !process.env.NO_COLOR);
|
|
13
|
+
const paint = {
|
|
14
|
+
bold: (value) => wrap(value, '1', '22'),
|
|
15
|
+
dim: (value) => wrap(value, '2', '22'),
|
|
16
|
+
green: (value) => wrap(value, '32', '39'),
|
|
17
|
+
orange: (value) => wrap(value, '38;5;215', '39'),
|
|
18
|
+
cyan: (value) => wrap(value, '36', '39'),
|
|
19
|
+
};
|
|
20
|
+
function printInitSummary(summary) {
|
|
21
|
+
const output = [
|
|
22
|
+
'',
|
|
23
|
+
paint.orange(HALOT_ASCII),
|
|
24
|
+
'',
|
|
25
|
+
paint.bold(summary.title),
|
|
26
|
+
summary.subtitle ? paint.dim(summary.subtitle) : undefined,
|
|
27
|
+
summary.rows?.length ? renderRows(summary.rows) : undefined,
|
|
28
|
+
summary.files?.length ? renderList('Files', summary.files) : undefined,
|
|
29
|
+
summary.warnings?.length ? renderList('Notes', summary.warnings) : undefined,
|
|
30
|
+
summary.nextSteps?.length ? renderNumberedList('Next', summary.nextSteps) : undefined,
|
|
31
|
+
'',
|
|
32
|
+
].filter((line) => Boolean(line));
|
|
33
|
+
console.log(output.join('\n'));
|
|
34
|
+
}
|
|
35
|
+
function command(value) {
|
|
36
|
+
return paint.cyan(value);
|
|
37
|
+
}
|
|
38
|
+
function renderRows(rows) {
|
|
39
|
+
const width = rows.reduce((max, row) => Math.max(max, row.label.length), 0);
|
|
40
|
+
return rows
|
|
41
|
+
.map((row) => `${paint.dim(row.label.padEnd(width))} ${paint.green(row.value)}`)
|
|
42
|
+
.join('\n');
|
|
43
|
+
}
|
|
44
|
+
function renderList(title, items) {
|
|
45
|
+
return [
|
|
46
|
+
paint.bold(title),
|
|
47
|
+
...items.map((item) => `- ${item}`),
|
|
48
|
+
].join('\n');
|
|
49
|
+
}
|
|
50
|
+
function renderNumberedList(title, items) {
|
|
51
|
+
return [
|
|
52
|
+
paint.bold(title),
|
|
53
|
+
...items.map((item, index) => `${index + 1}. ${item}`),
|
|
54
|
+
].join('\n');
|
|
55
|
+
}
|
|
56
|
+
function wrap(value, open, close) {
|
|
57
|
+
if (!colorEnabled) {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
return `\x1b[${open}m${value}\x1b[${close}m`;
|
|
61
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveClusterAuthorities = resolveClusterAuthorities;
|
|
3
4
|
exports.resolveAuthorityWallet = resolveAuthorityWallet;
|
|
4
5
|
exports.resolveActorWallet = resolveActorWallet;
|
|
5
6
|
exports.resolveAuthorityAddress = resolveAuthorityAddress;
|
|
@@ -10,8 +11,18 @@ exports.isMainnetAuthority = isMainnetAuthority;
|
|
|
10
11
|
const stellar_sdk_1 = require("@stellar/stellar-sdk");
|
|
11
12
|
const ethers_1 = require("ethers");
|
|
12
13
|
const sdk_1 = require("@halot/sdk");
|
|
14
|
+
function resolveClusterAuthorities(cluster) {
|
|
15
|
+
return {
|
|
16
|
+
zeroG: `0g:${cluster}`,
|
|
17
|
+
stellar: `stellar:${cluster}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
13
20
|
function resolveAuthorityWallet(wallets, authority) {
|
|
14
|
-
|
|
21
|
+
const wallet = wallets.authorities[authority];
|
|
22
|
+
if (!wallet) {
|
|
23
|
+
throw new Error(`Wallet authority ${authority} is missing from wallets.json`);
|
|
24
|
+
}
|
|
25
|
+
return wallet;
|
|
15
26
|
}
|
|
16
27
|
function resolveActorWallet(wallets, authority) {
|
|
17
28
|
return new ethers_1.Wallet(resolveAuthorityWallet(wallets, authority).privateKey);
|
|
@@ -30,12 +41,12 @@ function deriveVerifierSigningPublicKey(wallets, authority) {
|
|
|
30
41
|
return new ethers_1.SigningKey(resolveAuthorityWallet(wallets, asZeroGAuthority(authority)).privateKey).publicKey;
|
|
31
42
|
}
|
|
32
43
|
function createDefaultSettlementWallets(wallets) {
|
|
33
|
-
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
44
|
+
return sdk_1.settlementNetworkValues.reduce((settlementWallets, network) => {
|
|
45
|
+
if (wallets.authorities[network]) {
|
|
46
|
+
settlementWallets[network] = resolveAuthorityAddress(wallets, network);
|
|
47
|
+
}
|
|
48
|
+
return settlementWallets;
|
|
49
|
+
}, {});
|
|
39
50
|
}
|
|
40
51
|
function resolveZeroGAuthorityProfile(authority) {
|
|
41
52
|
return (0, sdk_1.resolveZeroGAuthorityProfile)(asZeroGAuthority(authority));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveInitCluster = resolveInitCluster;
|
|
4
|
+
exports.describeClusterAuthorities = describeClusterAuthorities;
|
|
5
|
+
const authority_util_1 = require("@halot/cli/shared/wallet/authority.util");
|
|
6
|
+
function resolveInitCluster(options = {}) {
|
|
7
|
+
if (options.testnet && options.mainnet) {
|
|
8
|
+
throw new Error('Choose either --testnet or --mainnet, not both.');
|
|
9
|
+
}
|
|
10
|
+
return options.mainnet ? 'mainnet' : 'testnet';
|
|
11
|
+
}
|
|
12
|
+
function describeClusterAuthorities(cluster) {
|
|
13
|
+
const authorities = (0, authority_util_1.resolveClusterAuthorities)(cluster);
|
|
14
|
+
return {
|
|
15
|
+
zeroG: authorities.zeroG,
|
|
16
|
+
stellar: authorities.stellar,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -4,29 +4,23 @@ exports.WalletManager = void 0;
|
|
|
4
4
|
const stellar_sdk_1 = require("@stellar/stellar-sdk");
|
|
5
5
|
const ethers_1 = require("ethers");
|
|
6
6
|
const workspace_service_1 = require("@halot/cli/shared/workspace/workspace.service");
|
|
7
|
+
const authority_util_1 = require("@halot/cli/shared/wallet/authority.util");
|
|
7
8
|
class WalletManager {
|
|
8
9
|
workspaceService;
|
|
9
10
|
constructor(workspaceService = new workspace_service_1.WorkspaceService()) {
|
|
10
11
|
this.workspaceService = workspaceService;
|
|
11
12
|
}
|
|
12
|
-
createWallets() {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const stellarMainnetWallet = stellar_sdk_1.Keypair.random();
|
|
13
|
+
createWallets(cluster = 'testnet') {
|
|
14
|
+
const zeroGWallet = ethers_1.Wallet.createRandom();
|
|
15
|
+
const stellarWallet = stellar_sdk_1.Keypair.random();
|
|
16
|
+
const authorities = (0, authority_util_1.resolveClusterAuthorities)(cluster);
|
|
17
17
|
const wallets = {
|
|
18
18
|
authorities: {
|
|
19
|
-
|
|
20
|
-
privateKey:
|
|
19
|
+
[authorities.zeroG]: {
|
|
20
|
+
privateKey: zeroGWallet.privateKey,
|
|
21
21
|
},
|
|
22
|
-
|
|
23
|
-
privateKey:
|
|
24
|
-
},
|
|
25
|
-
'stellar:testnet': {
|
|
26
|
-
privateKey: stellarTestnetWallet.secret(),
|
|
27
|
-
},
|
|
28
|
-
'stellar:mainnet': {
|
|
29
|
-
privateKey: stellarMainnetWallet.secret(),
|
|
22
|
+
[authorities.stellar]: {
|
|
23
|
+
privateKey: stellarWallet.secret(),
|
|
30
24
|
},
|
|
31
25
|
},
|
|
32
26
|
};
|
|
@@ -144,13 +144,15 @@ class WorkspaceService {
|
|
|
144
144
|
exports.WorkspaceService = WorkspaceService;
|
|
145
145
|
function normalizeWalletBundle(input) {
|
|
146
146
|
if (isRecord(input) && isRecord(input.authorities)) {
|
|
147
|
+
const authorities = {};
|
|
148
|
+
for (const network of sdk_1.settlementNetworkValues) {
|
|
149
|
+
const entry = input.authorities[network];
|
|
150
|
+
if (entry !== undefined) {
|
|
151
|
+
authorities[network] = normalizeAuthorityEntry(entry);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
147
154
|
return {
|
|
148
|
-
authorities
|
|
149
|
-
'0g:testnet': normalizeAuthorityEntry(input.authorities['0g:testnet']),
|
|
150
|
-
'0g:mainnet': normalizeAuthorityEntry(input.authorities['0g:mainnet']),
|
|
151
|
-
'stellar:testnet': normalizeAuthorityEntry(input.authorities['stellar:testnet']),
|
|
152
|
-
'stellar:mainnet': normalizeAuthorityEntry(input.authorities['stellar:mainnet']),
|
|
153
|
-
},
|
|
155
|
+
authorities,
|
|
154
156
|
};
|
|
155
157
|
}
|
|
156
158
|
if (isRecord(input) && input.zeroG && input.stellar) {
|
|
@@ -159,9 +161,7 @@ function normalizeWalletBundle(input) {
|
|
|
159
161
|
return {
|
|
160
162
|
authorities: {
|
|
161
163
|
'0g:testnet': zeroG,
|
|
162
|
-
'0g:mainnet': zeroG,
|
|
163
164
|
'stellar:testnet': stellar,
|
|
164
|
-
'stellar:mainnet': stellar,
|
|
165
165
|
},
|
|
166
166
|
};
|
|
167
167
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@halot/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Halot protocol CLI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"./*": "./dist/*.js"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@halot/sdk": "^1.0.
|
|
33
|
+
"@halot/sdk": "^1.0.2",
|
|
34
34
|
"@stellar/stellar-sdk": "^15.0.1",
|
|
35
35
|
"@web3-name-sdk/core": "^0.1.18",
|
|
36
36
|
"commander": "^14.0.3",
|