@halot/cli 1.0.0 → 1.0.2

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
@@ -12,13 +12,13 @@ It covers:
12
12
  ## Install
13
13
 
14
14
  ```bash
15
- npm install -g halot
15
+ npm install -g @halot/cli
16
16
  ```
17
17
 
18
18
  or run it without a global install:
19
19
 
20
20
  ```bash
21
- npx halot --help
21
+ npx @halot/cli --help
22
22
  ```
23
23
 
24
24
  ## Provider Flow
@@ -300,8 +300,7 @@ This creates:
300
300
  "verifiability": "TeeML"
301
301
  },
302
302
  "sdk": {
303
- "network": "testnet",
304
- "rpcUrl": "https://evmrpc-testnet.0g.ai"
303
+ "network": "testnet"
305
304
  },
306
305
  "timeout": 60
307
306
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JobFundingService = void 0;
4
4
  const stellar_sdk_1 = require("@stellar/stellar-sdk");
5
5
  const ethers_1 = require("ethers");
6
- const env_1 = require("@halot/cli/shared/config/env");
6
+ const sdk_1 = require("@halot/sdk");
7
7
  const authority_util_1 = require("@halot/cli/shared/wallet/authority.util");
8
8
  const erc20Abi = [
9
9
  'function allowance(address owner, address spender) view returns (uint256)',
@@ -13,7 +13,6 @@ const zeroGEscrowAbi = [
13
13
  'function createJob(address token, bytes32 jobHash, address provider, address[] verifierAddresses, uint256 threshold, uint256 providerAmount, uint256 verifierPool, uint256 platformFee)',
14
14
  ];
15
15
  class JobFundingService {
16
- env = (0, env_1.loadCliEnv)();
17
16
  async fundPreparedJob(preparedJob, options) {
18
17
  if (preparedJob.paymentNetwork.startsWith('0g:')) {
19
18
  const authority = (0, authority_util_1.resolveAuthorityWallet)(options.wallets, preparedJob.paymentNetwork);
@@ -45,10 +44,8 @@ class JobFundingService {
45
44
  return transaction.hash;
46
45
  }
47
46
  async fundStellarPreparedJob(preparedJob, secretKey) {
48
- if (!this.env.defaultStellarRpcUrl || !this.env.defaultStellarNetworkPassphrase) {
49
- throw new Error('Missing HALOT_DEFAULT_STELLAR_RPC_URL or HALOT_DEFAULT_STELLAR_NETWORK_PASSPHRASE for Stellar funding');
50
- }
51
- const server = new stellar_sdk_1.rpc.Server(this.env.defaultStellarRpcUrl);
47
+ const stellar = (0, sdk_1.resolveStellarNetworkProfile)(preparedJob.paymentNetwork);
48
+ const server = new stellar_sdk_1.rpc.Server(stellar.rpcUrl);
52
49
  const keypair = stellar_sdk_1.Keypair.fromSecret(secretKey);
53
50
  const sourceAccount = await server.getAccount(keypair.publicKey());
54
51
  const contract = new stellar_sdk_1.Contract(preparedJob.settlementContractAddress);
@@ -56,7 +53,7 @@ class JobFundingService {
56
53
  const verifierPayouts = preparedJob.assignedVerifiers.map((verifier) => new stellar_sdk_1.Address(verifier.payoutAddress).toScVal());
57
54
  const transaction = new stellar_sdk_1.TransactionBuilder(sourceAccount, {
58
55
  fee: stellar_sdk_1.BASE_FEE,
59
- networkPassphrase: this.env.defaultStellarNetworkPassphrase,
56
+ networkPassphrase: stellar.networkPassphrase,
60
57
  })
61
58
  .addOperation(contract.call('create_job', new stellar_sdk_1.Address(preparedJob.settlementTokenAddress).toScVal(), stellar_sdk_1.xdr.ScVal.scvBytes(hexToBuffer(preparedJob.jobHash, 32)), new stellar_sdk_1.Address(preparedJob.requesterAddress).toScVal(), new stellar_sdk_1.Address(preparedJob.providerPayoutAddress).toScVal(), stellar_sdk_1.xdr.ScVal.scvVec(verifierPublicKeys), stellar_sdk_1.xdr.ScVal.scvVec(verifierPayouts), stellar_sdk_1.xdr.ScVal.scvU32(preparedJob.threshold), (0, stellar_sdk_1.nativeToScVal)(BigInt(preparedJob.providerAmountUnits), { type: 'i128' }), (0, stellar_sdk_1.nativeToScVal)(BigInt(preparedJob.verifierPoolUnits), { type: 'i128' }), (0, stellar_sdk_1.nativeToScVal)(BigInt(preparedJob.platformFeeUnits), { type: 'i128' })))
62
59
  .setTimeout(30)
@@ -70,6 +70,7 @@ async function runVerifierRegisterCommand(options) {
70
70
  console.log('Skipping Agent ID registration (testnet mode)');
71
71
  }
72
72
  const registryResult = await verifierRegistryService.registerVerifier({
73
+ network: chain.network,
73
74
  privateKey: verifierWallet.privateKey,
74
75
  rpcUrl: chain.rpcUrl,
75
76
  categories: specializations.categories,
@@ -13,10 +13,12 @@ async function runVerifierUnstakeCommand(options) {
13
13
  const chain = (0, authority_util_1.resolveZeroGAuthorityProfile)(config.authority.actor);
14
14
  const result = options.claim
15
15
  ? await registryService.withdrawStake({
16
+ network: chain.network,
16
17
  privateKey: verifierWallet.privateKey,
17
18
  rpcUrl: chain.rpcUrl,
18
19
  })
19
20
  : await registryService.requestUnstake({
21
+ network: chain.network,
20
22
  privateKey: verifierWallet.privateKey,
21
23
  rpcUrl: chain.rpcUrl,
22
24
  });
package/dist/index.js CHANGED
@@ -23,9 +23,7 @@ const verifier_register_command_1 = require("@halot/cli/features/verifier/verifi
23
23
  const verifier_run_command_1 = require("@halot/cli/features/verifier/verifier-run.command");
24
24
  const verifier_stats_command_1 = require("@halot/cli/features/verifier/verifier-stats.command");
25
25
  const verifier_unstake_command_1 = require("@halot/cli/features/verifier/verifier-unstake.command");
26
- const env_1 = require("@halot/cli/shared/config/env");
27
- (0, env_1.loadCliEnv)();
28
- const defaultServerUrl = (0, env_1.loadCliEnv)().serverUrl ?? 'http://localhost:3001';
26
+ const defaultServerUrl = 'http://localhost:3001';
29
27
  const program = new commander_1.Command();
30
28
  program
31
29
  .name('halot')
@@ -4,7 +4,7 @@ exports.AgentIdRegisterService = void 0;
4
4
  exports.createZeroGAgentUri = createZeroGAgentUri;
5
5
  const viem_1 = require("viem");
6
6
  const accounts_1 = require("viem/accounts");
7
- const env_1 = require("@halot/cli/shared/config/env");
7
+ const sdk_1 = require("@halot/sdk");
8
8
  const agentIdentityRegistryAbi = [
9
9
  {
10
10
  inputs: [{ internalType: 'string', name: 'agentURI', type: 'string' }],
@@ -53,19 +53,14 @@ const agentIdentityRegistryAbi = [
53
53
  },
54
54
  ];
55
55
  function createZeroGAgentUri(rootHash) {
56
- const env = (0, env_1.loadCliEnv)();
57
- const gateway = env.zeroGStorageGateway;
58
- if (gateway) {
59
- return `${gateway}/${rootHash}`;
60
- }
61
- return `0g://${rootHash}`;
56
+ return (0, sdk_1.createZeroGStorageUri)(rootHash);
62
57
  }
63
58
  class AgentIdRegisterService {
64
59
  async registerAgent(input) {
65
- const env = (0, env_1.loadCliEnv)();
66
- const registryAddress = input.registryAddress ?? env.agentIdRegistryAddress;
60
+ const authority = (0, sdk_1.resolveZeroGAuthorityByChainId)(input.chainId);
61
+ const registryAddress = input.registryAddress ?? (0, sdk_1.resolveZeroGAuthorityProfile)(authority).agentIdRegistryAddress;
67
62
  if (!registryAddress) {
68
- throw new Error('Agent ID registration requires HALOT_AGENT_ID_REGISTRY_ADDRESS.');
63
+ throw new Error(`Agent ID registry is not configured for ${authority}.`);
69
64
  }
70
65
  const account = (0, accounts_1.privateKeyToAccount)(input.privateKey);
71
66
  if (account.address.toLowerCase() !== input.ownerAddress.toLowerCase()) {
@@ -4,21 +4,9 @@ exports.SpaceIdRegisterService = void 0;
4
4
  const utils_1 = require("@web3-name-sdk/core/utils");
5
5
  const viem_1 = require("viem");
6
6
  const accounts_1 = require("viem/accounts");
7
- const env_1 = require("@halot/cli/shared/config/env");
7
+ const sdk_1 = require("@halot/sdk");
8
8
  const yearInSeconds = 31556952n;
9
- const zeroGSpaceIdDefaults = {
10
- tldId: 26,
11
- chainId: 16661,
12
- graphUrl: 'https://graphigo.prd.space.id/query',
13
- identifier: '449205675366457712613706471770511817162982777845754732038879201565074548',
14
- controllerAddress: '0xd7b837a0e388b4c25200983bdaa3ef3a83ca86b7',
15
- resolverAddress: '0x6D3B3F99177FB2A5de7F9E928a9BD807bF7b5BAD',
16
- registryAddress: '0x5dC881dDA4e4a8d312be3544AD13118D1a04Cb17',
17
- sannAddress: '0x9af6F1244df403dAe39Eb2D0be1C3fD0B38e0789',
18
- verifiedTldHubAddress: '0x754D6827A57334143eD5fB58C5b1A4aAe4396ba5',
19
- verifiedTldHubRpcUrl: 'https://ethereum-rpc.publicnode.com',
20
- defaultRpc: 'https://evmrpc.0g.ai',
21
- };
9
+ const zeroGSpaceIdDefaults = getZeroGSpaceIdDefaults();
22
10
  const sidV3ControllerAbi = [
23
11
  {
24
12
  inputs: [{ internalType: 'uint256', name: 'realPrice', type: 'uint256' }],
@@ -184,25 +172,20 @@ class SpaceIdRegisterService {
184
172
  };
185
173
  }
186
174
  async resolveConfig(input) {
187
- const env = (0, env_1.loadCliEnv)();
188
175
  const discovered = await this.discoverZeroGConfig(input).catch(() => null);
189
176
  const identifier = input.identifier
190
- ?? env.spaceIdIdentifier
191
177
  ?? discovered?.identifier
192
178
  ?? zeroGSpaceIdDefaults.identifier;
193
179
  const controllerAddress = input.controllerAddress
194
- ?? env.spaceIdControllerAddress
195
180
  ?? discovered?.controllerAddress
196
181
  ?? zeroGSpaceIdDefaults.controllerAddress;
197
182
  const resolverAddress = input.resolverAddress
198
- ?? env.spaceIdResolverAddress
199
183
  ?? discovered?.resolverAddress
200
184
  ?? zeroGSpaceIdDefaults.resolverAddress;
201
- const simulateAccount = input.simulateAccount
202
- ?? env.spaceIdSimulateAccount;
203
- const simulateValue = input.simulateValue ?? env.spaceIdSimulateValue;
185
+ const simulateAccount = input.simulateAccount;
186
+ const simulateValue = input.simulateValue;
204
187
  if (!identifier || !controllerAddress || !resolverAddress) {
205
- throw new Error('SPACE ID .0g registration requires HALOT_SPACE_ID_IDENTIFIER, HALOT_SPACE_ID_CONTROLLER_ADDRESS, and HALOT_SPACE_ID_RESOLVER_ADDRESS.');
188
+ throw new Error('SPACE ID .0g registration is not configured for the selected network.');
206
189
  }
207
190
  return {
208
191
  identifier: BigInt(identifier),
@@ -299,9 +282,7 @@ class SpaceIdRegisterService {
299
282
  throw new Error('SPACE ID rent price simulation did not return a price.');
300
283
  }
301
284
  async fetchGraphTld() {
302
- const env = (0, env_1.loadCliEnv)();
303
- const graphUrl = env.spaceIdGraphUrl || zeroGSpaceIdDefaults.graphUrl;
304
- const result = await this.queryGraph(graphUrl, 'query Tld($tldIDs: [Int!]!) { Tlds(tldIDs: $tldIDs) { tldID tldName identifier chainID controllerAddr } }', { tldIDs: [zeroGSpaceIdDefaults.tldId] });
285
+ const result = await this.queryGraph(zeroGSpaceIdDefaults.graphUrl, 'query Tld($tldIDs: [Int!]!) { Tlds(tldIDs: $tldIDs) { tldID tldName identifier chainID controllerAddr } }', { tldIDs: [zeroGSpaceIdDefaults.tldId] });
305
286
  const tld = result.Tlds[0];
306
287
  if (!tld) {
307
288
  throw new Error('SPACE ID graph did not return the .0g TLD row.');
@@ -309,9 +290,7 @@ class SpaceIdRegisterService {
309
290
  return tld;
310
291
  }
311
292
  async fetchSampleDomains() {
312
- const env = (0, env_1.loadCliEnv)();
313
- const graphUrl = env.spaceIdGraphUrl || zeroGSpaceIdDefaults.graphUrl;
314
- const result = await this.queryGraph(graphUrl, 'query domains($input: ListDomainsInput!) { domains(input: $input) { list { name } } }', {
293
+ const result = await this.queryGraph(zeroGSpaceIdDefaults.graphUrl, 'query domains($input: ListDomainsInput!) { domains(input: $input) { list { name } } }', {
315
294
  input: {
316
295
  tldID: zeroGSpaceIdDefaults.tldId,
317
296
  first: 5,
@@ -327,9 +306,6 @@ class SpaceIdRegisterService {
327
306
  return names;
328
307
  }
329
308
  async fetchVerifiedTld() {
330
- const env = (0, env_1.loadCliEnv)();
331
- const hubRpcUrl = env.spaceIdVerifiedTldHubRpcUrl || zeroGSpaceIdDefaults.verifiedTldHubRpcUrl;
332
- const hubAddress = env.spaceIdVerifiedTldHubAddress || zeroGSpaceIdDefaults.verifiedTldHubAddress;
333
309
  const publicClient = (0, viem_1.createPublicClient)({
334
310
  chain: (0, viem_1.defineChain)({
335
311
  id: 1,
@@ -340,14 +316,14 @@ class SpaceIdRegisterService {
340
316
  decimals: 18,
341
317
  },
342
318
  rpcUrls: {
343
- default: { http: [hubRpcUrl] },
344
- public: { http: [hubRpcUrl] },
319
+ default: { http: [zeroGSpaceIdDefaults.verifiedTldHubRpcUrl] },
320
+ public: { http: [zeroGSpaceIdDefaults.verifiedTldHubRpcUrl] },
345
321
  },
346
322
  }),
347
- transport: (0, viem_1.http)(hubRpcUrl),
323
+ transport: (0, viem_1.http)(zeroGSpaceIdDefaults.verifiedTldHubRpcUrl),
348
324
  });
349
325
  const rows = await publicClient.readContract({
350
- address: hubAddress,
326
+ address: zeroGSpaceIdDefaults.verifiedTldHubAddress,
351
327
  abi: verifiedTldHubAbi,
352
328
  functionName: 'getTldInfo',
353
329
  args: [['0g']],
@@ -465,3 +441,10 @@ class SpaceIdRegisterService {
465
441
  }
466
442
  }
467
443
  exports.SpaceIdRegisterService = SpaceIdRegisterService;
444
+ function getZeroGSpaceIdDefaults() {
445
+ const defaults = (0, sdk_1.resolveZeroGAuthorityProfile)('0g:mainnet').spaceId;
446
+ if (!defaults) {
447
+ throw new Error('SPACE ID defaults are not configured for 0g:mainnet.');
448
+ }
449
+ return defaults;
450
+ }
@@ -3,16 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZeroGVerifierRegistryService = void 0;
4
4
  const ethers_1 = require("ethers");
5
5
  const sdk_1 = require("@halot/sdk");
6
- const env_1 = require("@halot/cli/shared/config/env");
7
6
  const registryAbi = [
8
7
  'function upsertVerifier(uint256 categoryMask, bytes32[] allowedServiceHashes) payable',
9
8
  'function requestUnstake()',
10
9
  'function withdrawStake()',
11
10
  ];
12
11
  class ZeroGVerifierRegistryService {
13
- env = (0, env_1.loadCliEnv)();
14
12
  async registerVerifier(input) {
15
- const registry = this.getRegistry(input.privateKey, input.rpcUrl);
13
+ const registry = this.getRegistry(input.network, input.privateKey, input.rpcUrl);
16
14
  const categoryMask = (0, sdk_1.serviceCategoriesToMask)(input.categories);
17
15
  const serviceHashes = input.serviceIds.map((serviceId) => (0, sdk_1.hashText)(serviceId));
18
16
  const transaction = await registry.upsertVerifier(categoryMask, serviceHashes, { value: (0, ethers_1.parseEther)(input.stakeAmount) });
@@ -23,7 +21,7 @@ class ZeroGVerifierRegistryService {
23
21
  return { transactionHash: transaction.hash };
24
22
  }
25
23
  async requestUnstake(input) {
26
- const registry = this.getRegistry(input.privateKey, input.rpcUrl);
24
+ const registry = this.getRegistry(input.network, input.privateKey, input.rpcUrl);
27
25
  const transaction = await registry.requestUnstake();
28
26
  const receipt = await transaction.wait();
29
27
  if (!receipt || receipt.status !== 1) {
@@ -32,7 +30,7 @@ class ZeroGVerifierRegistryService {
32
30
  return { transactionHash: transaction.hash };
33
31
  }
34
32
  async withdrawStake(input) {
35
- const registry = this.getRegistry(input.privateKey, input.rpcUrl);
33
+ const registry = this.getRegistry(input.network, input.privateKey, input.rpcUrl);
36
34
  const transaction = await registry.withdrawStake();
37
35
  const receipt = await transaction.wait();
38
36
  if (!receipt || receipt.status !== 1) {
@@ -40,16 +38,17 @@ class ZeroGVerifierRegistryService {
40
38
  }
41
39
  return { transactionHash: transaction.hash };
42
40
  }
43
- getRegistry(privateKey, rpcUrl) {
41
+ getRegistry(network, privateKey, rpcUrl) {
44
42
  const provider = new ethers_1.JsonRpcProvider(rpcUrl);
45
43
  const wallet = new ethers_1.Wallet(privateKey, provider);
46
- return new ethers_1.Contract(this.getRegistryAddress(), registryAbi, wallet);
44
+ return new ethers_1.Contract(this.getRegistryAddress(network), registryAbi, wallet);
47
45
  }
48
- getRegistryAddress() {
49
- if (!this.env.zeroGVerifierRegistryAddress) {
50
- throw new Error('Missing HALOT_ZERO_G_VERIFIER_REGISTRY_ADDRESS');
46
+ getRegistryAddress(network) {
47
+ const registryAddress = (0, sdk_1.resolveZeroGAuthorityProfile)(network).verifierRegistryAddress;
48
+ if (!registryAddress) {
49
+ throw new Error(`0G verifier registry is not configured for ${network}`);
51
50
  }
52
- return this.env.zeroGVerifierRegistryAddress;
51
+ return registryAddress;
53
52
  }
54
53
  }
55
54
  exports.ZeroGVerifierRegistryService = ZeroGVerifierRegistryService;
@@ -9,18 +9,7 @@ exports.resolveZeroGAuthorityProfile = resolveZeroGAuthorityProfile;
9
9
  exports.isMainnetAuthority = isMainnetAuthority;
10
10
  const stellar_sdk_1 = require("@stellar/stellar-sdk");
11
11
  const ethers_1 = require("ethers");
12
- const zeroGAuthorityProfiles = {
13
- '0g:testnet': {
14
- networkMode: 'testnet',
15
- chainId: 16602,
16
- rpcUrl: 'https://evmrpc-testnet.0g.ai',
17
- },
18
- '0g:mainnet': {
19
- networkMode: 'mainnet',
20
- chainId: 16661,
21
- rpcUrl: 'https://evmrpc.0g.ai',
22
- },
23
- };
12
+ const sdk_1 = require("@halot/sdk");
24
13
  function resolveAuthorityWallet(wallets, authority) {
25
14
  return wallets.authorities[authority];
26
15
  }
@@ -49,10 +38,10 @@ function createDefaultSettlementWallets(wallets) {
49
38
  };
50
39
  }
51
40
  function resolveZeroGAuthorityProfile(authority) {
52
- return zeroGAuthorityProfiles[asZeroGAuthority(authority)];
41
+ return (0, sdk_1.resolveZeroGAuthorityProfile)(asZeroGAuthority(authority));
53
42
  }
54
43
  function isMainnetAuthority(authority) {
55
- return zeroGAuthorityProfiles[asZeroGAuthority(authority)].networkMode === 'mainnet';
44
+ return (0, sdk_1.resolveZeroGAuthorityProfile)(asZeroGAuthority(authority)).networkMode === 'mainnet';
56
45
  }
57
46
  function asZeroGAuthority(authority) {
58
47
  if (!authority.startsWith('0g:')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@halot/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Halot protocol CLI",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -23,7 +23,6 @@
23
23
  "dist/features",
24
24
  "dist/shared",
25
25
  "dist/index.js",
26
- ".env.example",
27
26
  "README.md"
28
27
  ],
29
28
  "exports": {
@@ -31,7 +30,7 @@
31
30
  "./*": "./dist/*.js"
32
31
  },
33
32
  "dependencies": {
34
- "@halot/sdk": "^1.0.0",
33
+ "@halot/sdk": "^1.0.1",
35
34
  "@stellar/stellar-sdk": "^15.0.1",
36
35
  "@web3-name-sdk/core": "^0.1.18",
37
36
  "commander": "^14.0.3",
package/.env.example DELETED
@@ -1,14 +0,0 @@
1
- HALOT_SERVER_URL=http://localhost:3001
2
- HALOT_SPACE_ID_IDENTIFIER=
3
- HALOT_SPACE_ID_CONTROLLER_ADDRESS=
4
- HALOT_SPACE_ID_RESOLVER_ADDRESS=
5
- HALOT_SPACE_ID_SIMULATE_ACCOUNT=
6
- HALOT_SPACE_ID_SIMULATE_VALUE=
7
- HALOT_SPACE_ID_GRAPH_URL=
8
- HALOT_SPACE_ID_VERIFIED_TLD_HUB_ADDRESS=
9
- HALOT_SPACE_ID_VERIFIED_TLD_HUB_RPC_URL=
10
- HALOT_ZERO_G_STORAGE_GATEWAY=
11
- HALOT_AGENT_ID_REGISTRY_ADDRESS=
12
- HALOT_ZERO_G_VERIFIER_REGISTRY_ADDRESS=
13
- HALOT_DEFAULT_STELLAR_RPC_URL=
14
- HALOT_DEFAULT_STELLAR_NETWORK_PASSPHRASE=Public Global Stellar Network ; September 2015
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadCliEnv = loadCliEnv;
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- const node_path_1 = __importDefault(require("node:path"));
9
- let cachedEnv = null;
10
- function loadCliEnv() {
11
- if (cachedEnv) {
12
- return cachedEnv;
13
- }
14
- hydrateEnvFile(node_path_1.default.join(process.cwd(), '.env'));
15
- const mode = (readStringEnv('HALOT_NETWORK_MODE') || 'testnet');
16
- const isTestnet = mode === 'testnet';
17
- const suffix = isTestnet ? '_TEST' : '_MAIN';
18
- cachedEnv = {
19
- networkMode: mode,
20
- serverUrl: readStringEnv('HALOT_SERVER_URL')?.replace(/\/+$/u, ''),
21
- spaceIdIdentifier: readStringEnv('HALOT_SPACE_ID_IDENTIFIER'),
22
- spaceIdControllerAddress: readAddressEnv(`HALOT_SPACE_ID_CONTROLLER_ADDRESS${suffix}`) || readAddressEnv('HALOT_SPACE_ID_CONTROLLER_ADDRESS'),
23
- spaceIdResolverAddress: readAddressEnv(`HALOT_SPACE_ID_RESOLVER_ADDRESS${suffix}`) || readAddressEnv('HALOT_SPACE_ID_RESOLVER_ADDRESS'),
24
- spaceIdSimulateAccount: readAddressEnv('HALOT_SPACE_ID_SIMULATE_ACCOUNT'),
25
- spaceIdSimulateValue: readStringEnv('HALOT_SPACE_ID_SIMULATE_VALUE'),
26
- spaceIdGraphUrl: readStringEnv('HALOT_SPACE_ID_GRAPH_URL'),
27
- spaceIdVerifiedTldHubAddress: readAddressEnv(`HALOT_SPACE_ID_VERIFIED_TLD_HUB_ADDRESS${suffix}`) || readAddressEnv('HALOT_SPACE_ID_VERIFIED_TLD_HUB_ADDRESS'),
28
- spaceIdVerifiedTldHubRpcUrl: readStringEnv(`HALOT_SPACE_ID_VERIFIED_TLD_HUB_RPC_URL${suffix}`) || readStringEnv('HALOT_SPACE_ID_VERIFIED_TLD_HUB_RPC_URL'),
29
- zeroGStorageGateway: readStringEnv(`HALOT_ZERO_G_STORAGE_GATEWAY${suffix}`)?.replace(/\/+$/u, '') || readStringEnv('HALOT_ZERO_G_STORAGE_GATEWAY')?.replace(/\/+$/u, ''),
30
- agentIdRegistryAddress: readAddressEnv(`HALOT_AGENT_ID_REGISTRY_ADDRESS${suffix}`) || readAddressEnv('HALOT_AGENT_ID_REGISTRY_ADDRESS'),
31
- zeroGVerifierRegistryAddress: readAddressEnv(`HALOT_ZERO_G_VERIFIER_REGISTRY_ADDRESS${suffix}`) || readAddressEnv('HALOT_ZERO_G_VERIFIER_REGISTRY_ADDRESS'),
32
- defaultStellarRpcUrl: readStringEnv(`HALOT_DEFAULT_STELLAR_RPC_URL${suffix}`) || readStringEnv('HALOT_DEFAULT_STELLAR_RPC_URL'),
33
- defaultStellarNetworkPassphrase: readStringEnv(`HALOT_DEFAULT_STELLAR_NETWORK_PASSPHRASE${suffix}`) || readStringEnv('HALOT_DEFAULT_STELLAR_NETWORK_PASSPHRASE'),
34
- };
35
- return cachedEnv;
36
- }
37
- function hydrateEnvFile(filePath) {
38
- if (!node_fs_1.default.existsSync(filePath)) {
39
- return;
40
- }
41
- const content = node_fs_1.default.readFileSync(filePath, 'utf8');
42
- for (const rawLine of content.split(/\r?\n/u)) {
43
- const line = rawLine.trim();
44
- if (!line || line.startsWith('#')) {
45
- continue;
46
- }
47
- const separatorIndex = line.indexOf('=');
48
- if (separatorIndex <= 0) {
49
- continue;
50
- }
51
- const key = line.slice(0, separatorIndex).trim();
52
- const rawValue = line.slice(separatorIndex + 1).trim();
53
- if (!key || process.env[key] !== undefined) {
54
- continue;
55
- }
56
- const value = stripWrappingQuotes(rawValue);
57
- process.env[key] = value;
58
- }
59
- }
60
- function stripWrappingQuotes(value) {
61
- if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith('\'') && value.endsWith('\''))) {
62
- return value.slice(1, -1);
63
- }
64
- return value;
65
- }
66
- function readStringEnv(key) {
67
- const value = process.env[key]?.trim();
68
- return value ? value : undefined;
69
- }
70
- function readAddressEnv(key) {
71
- const value = readStringEnv(key);
72
- return value;
73
- }
74
- function readNumberEnv(key) {
75
- const value = readStringEnv(key);
76
- return value ? Number(value) : undefined;
77
- }