@halot/cli 1.0.1 → 1.0.3

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 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
- "0g:mainnet": "0x...",
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
- "0g:mainnet": "0x...",
279
- "stellar:testnet": "G...",
280
- "stellar:mainnet": "G..."
274
+ "stellar:testnet": "G..."
281
275
  },
282
276
  "stake": {
283
277
  "amount": "1000",
@@ -300,8 +294,7 @@ This creates:
300
294
  "verifiability": "TeeML"
301
295
  },
302
296
  "sdk": {
303
- "network": "testnet",
304
- "rpcUrl": "https://evmrpc-testnet.0g.ai"
297
+ "network": "testnet"
305
298
  },
306
299
  "timeout": 60
307
300
  }
@@ -3,11 +3,14 @@ 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
- async function runProviderInitCommand() {
8
+ async function runProviderInitCommand(options = {}) {
9
+ const cluster = (0, init_cluster_util_1.resolveInitCluster)(options);
10
+ const authorities = (0, init_cluster_util_1.describeClusterAuthorities)(cluster);
8
11
  const workspace = new workspace_service_1.WorkspaceService();
9
12
  const walletManager = new wallet_manager_1.WalletManager(workspace);
10
- const wallets = walletManager.createWallets();
13
+ const wallets = walletManager.createWallets(cluster);
11
14
  workspace.writeProviderConfig({
12
15
  providerId: '',
13
16
  displayName: 'My Provider',
@@ -17,17 +20,17 @@ async function runProviderInitCommand() {
17
20
  erc8004TokenId: '',
18
21
  agentRegistry: '',
19
22
  agentUri: '',
20
- ownerAddress: (0, authority_util_1.resolveAuthorityAddress)(wallets, '0g:testnet'),
23
+ ownerAddress: (0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.zeroG),
21
24
  domain: 'myprovider.0g',
22
25
  domainType: 'space-id',
23
26
  },
24
27
  authority: {
25
28
  path: './wallets.json',
26
- actor: '0g:testnet',
29
+ actor: authorities.zeroG,
27
30
  },
28
31
  settlementWallets: (0, authority_util_1.createDefaultSettlementWallets)(wallets),
29
32
  });
30
- console.log('Provider workspace initialized.');
31
- console.log(`0G testnet authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, '0g:testnet')}`);
32
- console.log(`Stellar testnet authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, 'stellar:testnet')}`);
33
+ console.log(`Provider ${cluster} workspace initialized.`);
34
+ console.log(`${authorities.zeroG} authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.zeroG)}`);
35
+ console.log(`${authorities.stellar} authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.stellar)}`);
33
36
  }
@@ -3,20 +3,23 @@ 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
- async function runRequesterInitCommand() {
8
+ async function runRequesterInitCommand(options = {}) {
9
+ const cluster = (0, init_cluster_util_1.resolveInitCluster)(options);
10
+ const authorities = (0, init_cluster_util_1.describeClusterAuthorities)(cluster);
8
11
  const workspace = new workspace_service_1.WorkspaceService();
9
12
  const walletManager = new wallet_manager_1.WalletManager(workspace);
10
- const wallets = walletManager.createWallets();
13
+ const wallets = walletManager.createWallets(cluster);
11
14
  workspace.writeRequesterConfig({
12
15
  requesterId: '',
13
16
  displayName: 'Halot Requester',
14
17
  authority: {
15
18
  path: './wallets.json',
16
- actor: '0g:testnet',
19
+ actor: authorities.zeroG,
17
20
  },
18
21
  });
19
- console.log('Requester workspace initialized.');
20
- console.log(`0G testnet authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, '0g:testnet')}`);
21
- console.log(`Stellar testnet authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, 'stellar:testnet')}`);
22
+ console.log(`Requester ${cluster} workspace initialized.`);
23
+ console.log(`${authorities.zeroG} authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.zeroG)}`);
24
+ console.log(`${authorities.stellar} authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.stellar)}`);
22
25
  }
@@ -3,11 +3,14 @@ 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
- async function runVerifierInitCommand() {
8
+ async function runVerifierInitCommand(options = {}) {
9
+ const cluster = (0, init_cluster_util_1.resolveInitCluster)(options);
10
+ const authorities = (0, init_cluster_util_1.describeClusterAuthorities)(cluster);
8
11
  const workspace = new workspace_service_1.WorkspaceService();
9
12
  const walletManager = new wallet_manager_1.WalletManager(workspace);
10
- const wallets = walletManager.createWallets();
13
+ const wallets = walletManager.createWallets(cluster);
11
14
  workspace.writeVerifierConfig({
12
15
  verifierId: '',
13
16
  displayName: 'My Verifier',
@@ -16,13 +19,13 @@ async function runVerifierInitCommand() {
16
19
  erc8004TokenId: '',
17
20
  agentRegistry: '',
18
21
  agentUri: '',
19
- ownerAddress: (0, authority_util_1.resolveAuthorityAddress)(wallets, '0g:testnet'),
22
+ ownerAddress: (0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.zeroG),
20
23
  domain: 'myverifier.0g',
21
24
  domainType: 'space-id',
22
25
  },
23
26
  authority: {
24
27
  path: './wallets.json',
25
- actor: '0g:testnet',
28
+ actor: authorities.zeroG,
26
29
  },
27
30
  settlementWallets: (0, authority_util_1.createDefaultSettlementWallets)(wallets),
28
31
  stake: {
@@ -41,7 +44,7 @@ async function runVerifierInitCommand() {
41
44
  verifiability: 'TeeML',
42
45
  },
43
46
  sdk: {
44
- network: 'testnet',
47
+ network: cluster,
45
48
  },
46
49
  timeout: 60,
47
50
  });
@@ -63,7 +66,7 @@ async function runVerifierInitCommand() {
63
66
  maxConcurrentJobs: 5,
64
67
  minConfidenceThreshold: 0.75,
65
68
  });
66
- console.log('Verifier workspace initialized.');
67
- console.log(`0G testnet authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, '0g:testnet')}`);
68
- console.log(`Stellar testnet authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, 'stellar:testnet')}`);
69
+ console.log(`Verifier ${cluster} workspace initialized.`);
70
+ console.log(`${authorities.zeroG} authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.zeroG)}`);
71
+ console.log(`${authorities.stellar} authority: ${(0, authority_util_1.resolveAuthorityAddress)(wallets, authorities.stellar)}`);
69
72
  }
package/dist/index.js CHANGED
@@ -43,9 +43,15 @@ program
43
43
  const requester = program.command('requester').description('Requester workspace');
44
44
  requester
45
45
  .command('init')
46
+ .option('--testnet', 'Initialize a testnet requester workspace', false)
47
+ .option('--mainnet', 'Initialize a mainnet requester workspace', false)
46
48
  .action(requester_init_command_1.runRequesterInitCommand);
47
49
  const provider = program.command('provider').description('Provider workspace');
48
- provider.command('init').action(provider_init_command_1.runProviderInitCommand);
50
+ provider
51
+ .command('init')
52
+ .option('--testnet', 'Initialize a testnet provider workspace', false)
53
+ .option('--mainnet', 'Initialize a mainnet provider workspace', false)
54
+ .action(provider_init_command_1.runProviderInitCommand);
49
55
  provider
50
56
  .command('register')
51
57
  .option('--server <url>', 'Halot server url', defaultServerUrl)
@@ -92,7 +98,11 @@ service
92
98
  .option('--server <url>', 'Halot server url', defaultServerUrl)
93
99
  .action(service_remove_command_1.runServiceRemoveCommand);
94
100
  const verifier = program.command('verifier').description('Verifier workspace');
95
- verifier.command('init').action(verifier_init_command_1.runVerifierInitCommand);
101
+ verifier
102
+ .command('init')
103
+ .option('--testnet', 'Initialize a testnet verifier workspace', false)
104
+ .option('--mainnet', 'Initialize a mainnet verifier workspace', false)
105
+ .action(verifier_init_command_1.runVerifierInitCommand);
96
106
  verifier
97
107
  .command('register')
98
108
  .option('--server <url>', 'Halot server url', defaultServerUrl)
@@ -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
- return wallets.authorities[authority];
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
- '0g:testnet': resolveAuthorityAddress(wallets, '0g:testnet'),
35
- '0g:mainnet': resolveAuthorityAddress(wallets, '0g:mainnet'),
36
- 'stellar:testnet': resolveAuthorityAddress(wallets, 'stellar:testnet'),
37
- 'stellar:mainnet': resolveAuthorityAddress(wallets, 'stellar:mainnet'),
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 zeroGTestnetWallet = ethers_1.Wallet.createRandom();
14
- const zeroGMainnetWallet = ethers_1.Wallet.createRandom();
15
- const stellarTestnetWallet = stellar_sdk_1.Keypair.random();
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
- '0g:testnet': {
20
- privateKey: zeroGTestnetWallet.privateKey,
19
+ [authorities.zeroG]: {
20
+ privateKey: zeroGWallet.privateKey,
21
21
  },
22
- '0g:mainnet': {
23
- privateKey: zeroGMainnetWallet.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.1",
3
+ "version": "1.0.3",
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.1",
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",