genlayer 0.28.0 → 0.29.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.29.0 (2025-09-03)
4
+
5
+ ### Features
6
+
7
+ * rename studio validators commands ([#249](https://github.com/yeagerai/genlayer-cli/issues/249)) ([fb875e5](https://github.com/yeagerai/genlayer-cli/commit/fb875e5569d21346507eab07b8eacb88b395a15d))
8
+
9
+ ## 0.28.1 (2025-09-03)
10
+
3
11
  ## 0.28.0 (2025-09-03)
4
12
 
5
13
  ### Features
package/README.md CHANGED
@@ -238,13 +238,13 @@ EXAMPLES:
238
238
  genlayer update ollama --model deepseek-r1 --remove
239
239
  ```
240
240
 
241
- #### Validator Management
241
+ #### Localnet Validator Management
242
242
 
243
- Manage validator operations.
243
+ Manage localnet validator operations.
244
244
 
245
245
  ```bash
246
246
  USAGE:
247
- genlayer validators <command> [options]
247
+ genlayer localnet validators <command> [options]
248
248
 
249
249
  COMMANDS:
250
250
  get [--address <validatorAddress>] Retrieve details of a specific validator or all validators
@@ -272,16 +272,16 @@ OPTIONS (create):
272
272
  --model <model> Specify the model for the validator
273
273
 
274
274
  EXAMPLES:
275
- genlayer validators get
276
- genlayer validators get --address 0x123456789abcdef
275
+ genlayer localnet validators get
276
+ genlayer localnet validators get --address 0x123456789abcdef
277
277
 
278
- genlayer validators count
279
- genlayer validators delete --address 0x123456789abcdef
280
- genlayer validators update 0x123456789abcdef --stake 100 --provider openai --model gpt-4
278
+ genlayer localnet validators count
279
+ genlayer localnet validators delete --address 0x123456789abcdef
280
+ genlayer localnet validators update 0x123456789abcdef --stake 100 --provider openai --model gpt-4
281
281
 
282
- genlayer validators create
283
- genlayer validators create --stake 50 --provider openai --model gpt-4
284
- genlayer validators create-random --count 3 --providers openai --models gpt-4 gpt-4o
282
+ genlayer localnet validators create
283
+ genlayer localnet validators create --stake 50 --provider openai --model gpt-4
284
+ genlayer localnet validators create-random --count 3 --providers openai --models gpt-4 gpt-4o
285
285
  ```
286
286
 
287
287
  ### Running the CLI from the repository
package/dist/index.js CHANGED
@@ -17856,7 +17856,7 @@ var require_semver2 = __commonJS({
17856
17856
  import { program } from "commander";
17857
17857
 
17858
17858
  // package.json
17859
- var version = "0.28.0";
17859
+ var version = "0.29.0";
17860
17860
  var package_default = {
17861
17861
  name: "genlayer",
17862
17862
  version,
@@ -17923,7 +17923,7 @@ var package_default = {
17923
17923
  dotenv: "^17.0.0",
17924
17924
  ethers: "^6.13.4",
17925
17925
  "fs-extra": "^11.3.0",
17926
- "genlayer-js": "^0.11.0",
17926
+ "genlayer-js": "0.15.1",
17927
17927
  inquirer: "^12.0.0",
17928
17928
  keytar: "^7.9.0",
17929
17929
  "node-fetch": "^3.0.0",
@@ -40019,6 +40019,7 @@ var calldata_exports = {};
40019
40019
  __export2(calldata_exports, {
40020
40020
  decode: () => decode2,
40021
40021
  encode: () => encode4,
40022
+ makeCalldataObject: () => makeCalldataObject,
40022
40023
  toString: () => toString
40023
40024
  });
40024
40025
  var BITS_IN_TYPE = 3;
@@ -40161,6 +40162,32 @@ function encode4(data) {
40161
40162
  encodeImpl(arr, data);
40162
40163
  return new Uint8Array(arr);
40163
40164
  }
40165
+ function makeCalldataObject(method, args, kwargs) {
40166
+ let ret = {};
40167
+ if (method) {
40168
+ ret["method"] = method;
40169
+ }
40170
+ if (args && args.length > 0) {
40171
+ ret["args"] = args;
40172
+ }
40173
+ if (kwargs) {
40174
+ if (kwargs instanceof Map) {
40175
+ if (kwargs.size > 0) {
40176
+ ret["kwargs"] = kwargs;
40177
+ }
40178
+ } else {
40179
+ let hasVal = false;
40180
+ for (const _k in kwargs) {
40181
+ hasVal = true;
40182
+ break;
40183
+ }
40184
+ if (hasVal) {
40185
+ ret["kwargs"] = kwargs;
40186
+ }
40187
+ }
40188
+ }
40189
+ return ret;
40190
+ }
40164
40191
  function readULeb128(data, index2) {
40165
40192
  let res = 0n;
40166
40193
  let accum = 0n;
@@ -40329,32 +40356,6 @@ function serializeOne(data) {
40329
40356
  function serialize(data) {
40330
40357
  return toRlp(data.map(serializeOne));
40331
40358
  }
40332
- function makeCalldataObject(method, args, kwargs) {
40333
- let ret = {};
40334
- if (method) {
40335
- ret["method"] = method;
40336
- }
40337
- if (args && args.length > 0) {
40338
- ret["args"] = args;
40339
- }
40340
- if (kwargs) {
40341
- if (kwargs instanceof Map) {
40342
- if (kwargs.size > 0) {
40343
- ret["kwargs"] = kwargs;
40344
- }
40345
- } else {
40346
- let hasVal = false;
40347
- for (const _k in kwargs) {
40348
- hasVal = true;
40349
- break;
40350
- }
40351
- if (hasVal) {
40352
- ret["kwargs"] = kwargs;
40353
- }
40354
- }
40355
- }
40356
- return ret;
40357
- }
40358
40359
  var contractActions = (client, publicClient) => {
40359
40360
  return {
40360
40361
  getContractSchema: async (address) => {
@@ -40385,8 +40386,8 @@ var contractActions = (client, publicClient) => {
40385
40386
  args: callArgs,
40386
40387
  kwargs,
40387
40388
  leaderOnly = false,
40388
- transactionHashVariant = "latest-final"
40389
- /* LATEST_FINAL */
40389
+ transactionHashVariant = "latest-nonfinal"
40390
+ /* LATEST_NONFINAL */
40390
40391
  } = args;
40391
40392
  const encodedData = [encode4(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
40392
40393
  const serializedData = serialize(encodedData);
@@ -40537,14 +40538,16 @@ var _sendTransaction = async ({
40537
40538
  data: encodedData,
40538
40539
  type: "legacy",
40539
40540
  nonce: Number(nonce),
40540
- value
40541
+ value,
40542
+ gas: 21000n
40541
40543
  });
40542
40544
  if (validatedSenderAccount?.type !== "local") {
40543
40545
  const formattedRequest = {
40544
40546
  from: transactionRequest.from,
40545
40547
  to: transactionRequest.to,
40546
40548
  data: encodedData,
40547
- value: transactionRequest.value ? `0x${transactionRequest.value.toString(16)}` : "0x0"
40549
+ value: transactionRequest.value ? `0x${transactionRequest.value.toString(16)}` : "0x0",
40550
+ gas: transactionRequest.gas ? `0x${transactionRequest.gas.toString(16)}` : "0x5208"
40548
40551
  };
40549
40552
  return await client.request({
40550
40553
  method: "eth_sendTransaction",
@@ -40622,66 +40625,49 @@ function resultToUserFriendlyJson(cd64) {
40622
40625
  payload
40623
40626
  };
40624
40627
  }
40625
- var receiptActions = (client, publicClient) => ({
40626
- waitForTransactionReceipt: async ({
40627
- hash: hash2,
40628
- status = "ACCEPTED",
40629
- interval = transactionsConfig.waitInterval,
40630
- retries = transactionsConfig.retries
40631
- }) => {
40632
- const transaction = await client.getTransaction({
40633
- hash: hash2
40634
- });
40635
- if (!transaction) {
40636
- throw new Error("Transaction not found");
40637
- }
40638
- const transactionStatusString = String(transaction.status);
40639
- const transactionStatusFinalized = transactionsStatusNameToNumber[
40640
- "FINALIZED"
40641
- /* FINALIZED */
40642
- ];
40643
- const requestedStatus = transactionsStatusNameToNumber[status];
40644
- if (transactionStatusString === requestedStatus || status === "ACCEPTED" && transactionStatusString === transactionStatusFinalized) {
40645
- if (client.chain.id === localnet.id) {
40646
- return _decodeLocalnetTransaction(transaction);
40647
- }
40648
- return transaction;
40649
- }
40650
- if (retries === 0) {
40651
- throw new Error("Transaction status is not " + status);
40652
- }
40653
- await sleep(interval);
40654
- return receiptActions(client, publicClient).waitForTransactionReceipt({
40655
- hash: hash2,
40656
- status,
40657
- interval,
40658
- retries: retries - 1
40659
- });
40660
- }
40661
- });
40662
- var transactionActions = (client, publicClient) => ({
40663
- getTransaction: async ({ hash: hash2 }) => {
40664
- if (client.chain.id === localnet.id) {
40665
- const transaction2 = await client.getTransaction({ hash: hash2 });
40666
- const localnetStatus = transaction2.status === "ACTIVATED" ? "PENDING" : transaction2.status;
40667
- transaction2.status = Number(transactionsStatusNameToNumber[localnetStatus]);
40668
- transaction2.statusName = localnetStatus;
40669
- return _decodeLocalnetTransaction(transaction2);
40670
- }
40671
- const transaction = await publicClient.readContract({
40672
- address: client.chain.consensusDataContract?.address,
40673
- abi: client.chain.consensusDataContract?.abi,
40674
- functionName: "getTransactionData",
40675
- args: [
40676
- hash2,
40677
- Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3)
40678
- // unix seconds
40679
- ]
40680
- });
40681
- return _decodeTransaction(transaction);
40682
- }
40683
- });
40684
- var _decodeInputData = (rlpEncodedAppData, recipient) => {
40628
+ var FIELDS_TO_REMOVE = [
40629
+ "raw",
40630
+ "contract_state",
40631
+ "base64",
40632
+ "consensus_history",
40633
+ "tx_data",
40634
+ "eq_blocks_outputs",
40635
+ "r",
40636
+ "s",
40637
+ "v",
40638
+ "created_timestamp",
40639
+ "current_timestamp",
40640
+ "tx_execution_hash",
40641
+ "random_seed",
40642
+ "states",
40643
+ "contract_code",
40644
+ "appeal_failed",
40645
+ "appeal_leader_timeout",
40646
+ "appeal_processing_time",
40647
+ "appeal_undetermined",
40648
+ "appealed",
40649
+ "timestamp_appeal",
40650
+ "config_rotation_rounds",
40651
+ "rotation_count",
40652
+ "queue_position",
40653
+ "queue_type",
40654
+ "leader_timeout_validators",
40655
+ "triggered_by",
40656
+ "num_of_initial_validators",
40657
+ "timestamp_awaiting_finalization",
40658
+ "last_vote_timestamp",
40659
+ "read_state_block_range",
40660
+ "tx_slot",
40661
+ "blockHash",
40662
+ "blockNumber",
40663
+ "to",
40664
+ "transactionIndex"
40665
+ ];
40666
+ var FIELD_NAME_MAPPINGS = {
40667
+ statusName: "status_name",
40668
+ typeHex: "type"
40669
+ };
40670
+ var decodeInputData = (rlpEncodedAppData, recipient) => {
40685
40671
  if (!rlpEncodedAppData || rlpEncodedAppData === "0x" || rlpEncodedAppData.length <= 2) {
40686
40672
  return null;
40687
40673
  }
@@ -40719,8 +40705,8 @@ var _decodeInputData = (rlpEncodedAppData, recipient) => {
40719
40705
  return null;
40720
40706
  }
40721
40707
  };
40722
- var _decodeTransaction = (tx) => {
40723
- const txDataDecoded = _decodeInputData(tx.txData, tx.recipient);
40708
+ var decodeTransaction = (tx) => {
40709
+ const txDataDecoded = decodeInputData(tx.txData, tx.recipient);
40724
40710
  const decodedTx = {
40725
40711
  ...tx,
40726
40712
  txData: tx.txData,
@@ -40755,7 +40741,78 @@ var _decodeTransaction = (tx) => {
40755
40741
  };
40756
40742
  return decodedTx;
40757
40743
  };
40758
- var _decodeLocalnetTransaction = (tx) => {
40744
+ var simplifyTransactionReceipt = (tx) => {
40745
+ const simplifyObject = (obj, path6 = "") => {
40746
+ if (obj === null || obj === void 0) return obj;
40747
+ if (Array.isArray(obj)) {
40748
+ return obj.map((item) => simplifyObject(item, path6)).filter((item) => item !== void 0);
40749
+ }
40750
+ if (typeof obj === "object") {
40751
+ const result = {};
40752
+ for (const [key, value] of Object.entries(obj)) {
40753
+ const currentPath = path6 ? `${path6}.${key}` : key;
40754
+ if (FIELDS_TO_REMOVE.includes(key)) {
40755
+ continue;
40756
+ }
40757
+ if (key === "node_config" && !path6.includes("consensus_data")) {
40758
+ continue;
40759
+ }
40760
+ if (key === "consensus_data" && typeof value === "object" && value !== null) {
40761
+ const simplifiedConsensus = {};
40762
+ if ("votes" in value) {
40763
+ simplifiedConsensus.votes = value.votes;
40764
+ }
40765
+ if ("leader_receipt" in value && Array.isArray(value.leader_receipt)) {
40766
+ simplifiedConsensus.leader_receipt = value.leader_receipt.map((receipt) => {
40767
+ const simplifiedReceipt = {};
40768
+ ["execution_result", "genvm_result", "mode", "vote", "node_config"].forEach((field) => {
40769
+ if (field in receipt) {
40770
+ simplifiedReceipt[field] = receipt[field];
40771
+ }
40772
+ });
40773
+ if (receipt.calldata && typeof receipt.calldata === "object" && "readable" in receipt.calldata) {
40774
+ simplifiedReceipt.calldata = { readable: receipt.calldata.readable };
40775
+ }
40776
+ if (receipt.eq_outputs) {
40777
+ simplifiedReceipt.eq_outputs = simplifyObject(receipt.eq_outputs, currentPath);
40778
+ }
40779
+ if (receipt.result) {
40780
+ simplifiedReceipt.result = simplifyObject(receipt.result, currentPath);
40781
+ }
40782
+ return simplifiedReceipt;
40783
+ });
40784
+ }
40785
+ if ("validators" in value && Array.isArray(value.validators)) {
40786
+ const simplifiedValidators = value.validators.map((validator) => {
40787
+ const simplifiedValidator = {};
40788
+ ["execution_result", "genvm_result", "mode", "vote", "node_config"].forEach((field) => {
40789
+ if (field in validator) {
40790
+ simplifiedValidator[field] = validator[field];
40791
+ }
40792
+ });
40793
+ return simplifiedValidator;
40794
+ }).filter((validator) => Object.keys(validator).length > 0);
40795
+ if (simplifiedValidators.length > 0) {
40796
+ simplifiedConsensus.validators = simplifiedValidators;
40797
+ }
40798
+ }
40799
+ result[key] = simplifiedConsensus;
40800
+ continue;
40801
+ }
40802
+ const simplifiedValue = simplifyObject(value, currentPath);
40803
+ const shouldInclude = simplifiedValue !== void 0 && !(typeof simplifiedValue === "object" && simplifiedValue !== null && Object.keys(simplifiedValue).length === 0);
40804
+ if (shouldInclude || simplifiedValue === 0) {
40805
+ const mappedKey = FIELD_NAME_MAPPINGS[key] || key;
40806
+ result[mappedKey] = simplifiedValue;
40807
+ }
40808
+ }
40809
+ return result;
40810
+ }
40811
+ return obj;
40812
+ };
40813
+ return simplifyObject({ ...tx });
40814
+ };
40815
+ var decodeLocalnetTransaction = (tx) => {
40759
40816
  if (!tx.data) return tx;
40760
40817
  try {
40761
40818
  const leaderReceipt = tx.consensus_data?.leader_receipt;
@@ -40772,11 +40829,20 @@ var _decodeLocalnetTransaction = (tx) => {
40772
40829
  };
40773
40830
  }
40774
40831
  if (receipt.eq_outputs) {
40775
- receipt.eq_outputs = Object.fromEntries(
40776
- Object.entries(receipt.eq_outputs).map(([key, value]) => {
40777
- return [key, resultToUserFriendlyJson(String(value))];
40778
- })
40779
- );
40832
+ const decodedOutputs = {};
40833
+ for (const [key, value] of Object.entries(receipt.eq_outputs)) {
40834
+ if (typeof value === "object" && value !== null) {
40835
+ decodedOutputs[key] = value;
40836
+ } else {
40837
+ try {
40838
+ decodedOutputs[key] = resultToUserFriendlyJson(value);
40839
+ } catch (e2) {
40840
+ console.warn(`Error decoding eq_output ${key}: ${e2}`);
40841
+ decodedOutputs[key] = value;
40842
+ }
40843
+ }
40844
+ }
40845
+ receipt.eq_outputs = decodedOutputs;
40780
40846
  }
40781
40847
  });
40782
40848
  }
@@ -40787,10 +40853,75 @@ var _decodeLocalnetTransaction = (tx) => {
40787
40853
  };
40788
40854
  }
40789
40855
  } catch (e2) {
40790
- console.error("Error in _decodeLocalnetTransaction:", e2);
40856
+ console.error("Error in decodeLocalnetTransaction:", e2);
40791
40857
  }
40792
40858
  return tx;
40793
40859
  };
40860
+ var receiptActions = (client, publicClient) => ({
40861
+ waitForTransactionReceipt: async ({
40862
+ hash: hash2,
40863
+ status = "ACCEPTED",
40864
+ interval = transactionsConfig.waitInterval,
40865
+ retries = transactionsConfig.retries,
40866
+ fullTransaction = false
40867
+ }) => {
40868
+ const transaction = await client.getTransaction({
40869
+ hash: hash2
40870
+ });
40871
+ if (!transaction) {
40872
+ throw new Error("Transaction not found");
40873
+ }
40874
+ const transactionStatusString = String(transaction.status);
40875
+ const transactionStatusFinalized = transactionsStatusNameToNumber[
40876
+ "FINALIZED"
40877
+ /* FINALIZED */
40878
+ ];
40879
+ const requestedStatus = transactionsStatusNameToNumber[status];
40880
+ if (transactionStatusString === requestedStatus || status === "ACCEPTED" && transactionStatusString === transactionStatusFinalized) {
40881
+ let finalTransaction = transaction;
40882
+ if (client.chain.id === localnet.id) {
40883
+ finalTransaction = decodeLocalnetTransaction(transaction);
40884
+ }
40885
+ if (!fullTransaction) {
40886
+ return simplifyTransactionReceipt(finalTransaction);
40887
+ }
40888
+ return finalTransaction;
40889
+ }
40890
+ if (retries === 0) {
40891
+ throw new Error("Transaction status is not " + status);
40892
+ }
40893
+ await sleep(interval);
40894
+ return receiptActions(client, publicClient).waitForTransactionReceipt({
40895
+ hash: hash2,
40896
+ status,
40897
+ interval,
40898
+ retries: retries - 1,
40899
+ fullTransaction
40900
+ });
40901
+ }
40902
+ });
40903
+ var transactionActions = (client, publicClient) => ({
40904
+ getTransaction: async ({ hash: hash2 }) => {
40905
+ if (client.chain.id === localnet.id) {
40906
+ const transaction2 = await client.getTransaction({ hash: hash2 });
40907
+ const localnetStatus = transaction2.status === "ACTIVATED" ? "PENDING" : transaction2.status;
40908
+ transaction2.status = Number(transactionsStatusNameToNumber[localnetStatus]);
40909
+ transaction2.statusName = localnetStatus;
40910
+ return decodeLocalnetTransaction(transaction2);
40911
+ }
40912
+ const transaction = await publicClient.readContract({
40913
+ address: client.chain.consensusDataContract?.address,
40914
+ abi: client.chain.consensusDataContract?.abi,
40915
+ functionName: "getTransactionData",
40916
+ args: [
40917
+ hash2,
40918
+ Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3)
40919
+ // unix seconds
40920
+ ]
40921
+ });
40922
+ return decodeTransaction(transaction);
40923
+ }
40924
+ });
40794
40925
  var snapID = {
40795
40926
  local: "local:http://localhost:8081",
40796
40927
  npm: "npm:genlayer-wallet-plugin"
@@ -40923,9 +41054,13 @@ var getCustomTransportConfig = (config) => {
40923
41054
  async request({ method, params = [] }) {
40924
41055
  if (method.startsWith("eth_") && isAddress2) {
40925
41056
  try {
40926
- return await window.ethereum?.request({ method, params });
41057
+ const provider = config.provider || window.ethereum;
41058
+ if (!provider) {
41059
+ throw new Error("No wallet provider available");
41060
+ }
41061
+ return await provider.request({ method, params });
40927
41062
  } catch (err) {
40928
- console.warn(`Error using window.ethereum for method ${method}:`, err);
41063
+ console.warn(`Error using provider for method ${method}:`, err);
40929
41064
  throw err;
40930
41065
  }
40931
41066
  } else {
@@ -40963,7 +41098,7 @@ var createClient2 = (config = { chain: localnet }) => {
40963
41098
  if (config.endpoint) {
40964
41099
  chainConfig.rpcUrls.default.http = [config.endpoint];
40965
41100
  }
40966
- const customTransport = custom(getCustomTransportConfig(config));
41101
+ const customTransport = custom(getCustomTransportConfig(config), { retryCount: 0, retryDelay: 0 });
40967
41102
  const publicClient = createPublicClient2(chainConfig, customTransport).extend(
40968
41103
  publicActions
40969
41104
  );
@@ -42753,7 +42888,7 @@ function initializeConfigCommands(program2) {
42753
42888
  return program2;
42754
42889
  }
42755
42890
 
42756
- // src/commands/validators/validators.ts
42891
+ // src/commands/localnet/validators.ts
42757
42892
  import inquirer4 from "inquirer";
42758
42893
  var ValidatorsAction = class extends BaseAction {
42759
42894
  async getValidator(options) {
@@ -42947,10 +43082,11 @@ var ValidatorsAction = class extends BaseAction {
42947
43082
  }
42948
43083
  };
42949
43084
 
42950
- // src/commands/validators/index.ts
43085
+ // src/commands/localnet/index.ts
42951
43086
  function initializeValidatorCommands(program2) {
42952
43087
  const validatorsAction = new ValidatorsAction();
42953
- const validatorsCommand = program2.command("validators").description("Manage validator operations");
43088
+ const localnetCommand = program2.command("localnet").description("Manage localnet operations");
43089
+ const validatorsCommand = localnetCommand.command("validators").description("Manage localnet validators operations");
42954
43090
  validatorsCommand.command("get").description("Retrieve details of a specific validator or all validators").option("--address <validatorAddress>", "The address of the validator to retrieve (omit to retrieve all validators)").action(async (options) => {
42955
43091
  await validatorsAction.getValidator({ address: options.address });
42956
43092
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genlayer",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "GenLayer Command Line Tool",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -64,7 +64,7 @@
64
64
  "dotenv": "^17.0.0",
65
65
  "ethers": "^6.13.4",
66
66
  "fs-extra": "^11.3.0",
67
- "genlayer-js": "^0.11.0",
67
+ "genlayer-js": "0.15.1",
68
68
  "inquirer": "^12.0.0",
69
69
  "keytar": "^7.9.0",
70
70
  "node-fetch": "^3.0.0",
@@ -4,9 +4,13 @@ import { ValidatorsAction } from "./validators";
4
4
  export function initializeValidatorCommands(program: Command) {
5
5
  const validatorsAction = new ValidatorsAction();
6
6
 
7
- const validatorsCommand = program
7
+ const localnetCommand = program
8
+ .command("localnet")
9
+ .description("Manage localnet operations");
10
+
11
+ const validatorsCommand = localnetCommand
8
12
  .command("validators")
9
- .description("Manage validator operations");
13
+ .description("Manage localnet validators operations");
10
14
 
11
15
  validatorsCommand
12
16
  .command("get")
@@ -77,7 +81,7 @@ export function initializeValidatorCommands(program: Command) {
77
81
  .option("--stake <stake>", "Stake amount for the validator (default: 1)", "1")
78
82
  .option(
79
83
  "--config <config>",
80
- 'Optional JSON configuration for the validator (e.g., \'{"max_tokens": 500, "temperature": 0.75}\')'
84
+ `Optional JSON configuration for the validator (e.g., '{"max_tokens": 500, "temperature": 0.75}')`
81
85
  )
82
86
  .option("--provider <provider>", "Specify the provider for the validator")
83
87
  .option("--model <model>", "Specify the model for the validator")
@@ -92,3 +96,5 @@ export function initializeValidatorCommands(program: Command) {
92
96
 
93
97
  return program;
94
98
  }
99
+
100
+
@@ -265,3 +265,5 @@ export class ValidatorsAction extends BaseAction {
265
265
  }
266
266
  }
267
267
  }
268
+
269
+
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@ import {initializeGeneralCommands} from "../src/commands/general";
6
6
  import {initializeKeygenCommands} from "../src/commands/keygen";
7
7
  import {initializeContractsCommands} from "../src/commands/contracts";
8
8
  import {initializeConfigCommands} from "../src/commands/config";
9
- import {initializeValidatorCommands} from "../src/commands/validators";
9
+ import {initializeValidatorCommands} from "../src/commands/localnet";
10
10
  import {initializeUpdateCommands} from "../src/commands/update";
11
11
  import {initializeScaffoldCommands} from "../src/commands/scaffold";
12
12
  import {initializeNetworkCommands} from "../src/commands/network";
@@ -1,5 +1,5 @@
1
1
  import { describe, test, vi, beforeEach, afterEach, expect } from "vitest";
2
- import { ValidatorsAction } from "../../src/commands/validators/validators";
2
+ import { ValidatorsAction } from "../../src/commands/localnet/validators";
3
3
  import { rpcClient } from "../../src/lib/clients/jsonRpcClient";
4
4
  import inquirer from "inquirer";
5
5
 
@@ -1,11 +1,11 @@
1
1
  import { Command } from "commander";
2
2
  import { vi, describe, beforeEach, afterEach, test, expect } from "vitest";
3
- import { initializeValidatorCommands } from "../../src/commands/validators";
4
- import { ValidatorsAction } from "../../src/commands/validators/validators";
3
+ import { initializeValidatorCommands } from "../../src/commands/localnet";
4
+ import { ValidatorsAction } from "../../src/commands/localnet/validators";
5
5
 
6
- vi.mock("../../src/commands/validators/validators");
6
+ vi.mock("../../src/commands/localnet/validators");
7
7
 
8
- describe("validators command", () => {
8
+ describe("localnet validator command", () => {
9
9
  let program: Command;
10
10
 
11
11
  beforeEach(() => {
@@ -18,7 +18,7 @@ describe("validators command", () => {
18
18
  });
19
19
 
20
20
  test("ValidatorsAction.getValidator is called with address option", async () => {
21
- program.parse(["node", "test", "validators", "get", "--address", "mocked_address"]);
21
+ program.parse(["node", "test", "localnet", "validators", "get", "--address", "mocked_address"]);
22
22
  expect(ValidatorsAction).toHaveBeenCalledTimes(1);
23
23
  expect(ValidatorsAction.prototype.getValidator).toHaveBeenCalledWith({
24
24
  address: "mocked_address",
@@ -26,13 +26,13 @@ describe("validators command", () => {
26
26
  });
27
27
 
28
28
  test("ValidatorsAction.getValidator is called without address option", async () => {
29
- program.parse(["node", "test", "validators", "get"]);
29
+ program.parse(["node", "test", "localnet", "validators", "get"]);
30
30
  expect(ValidatorsAction).toHaveBeenCalledTimes(1);
31
31
  expect(ValidatorsAction.prototype.getValidator).toHaveBeenCalledWith({});
32
32
  });
33
33
 
34
34
  test("ValidatorsAction.deleteValidator is called with address option", async () => {
35
- program.parse(["node", "test", "validators", "delete", "--address", "mocked_address"]);
35
+ program.parse(["node", "test", "localnet", "validators", "delete", "--address", "mocked_address"]);
36
36
  expect(ValidatorsAction).toHaveBeenCalledTimes(1);
37
37
  expect(ValidatorsAction.prototype.deleteValidator).toHaveBeenCalledWith({
38
38
  address: "mocked_address",
@@ -40,13 +40,13 @@ describe("validators command", () => {
40
40
  });
41
41
 
42
42
  test("ValidatorsAction.deleteValidator is called without address option", async () => {
43
- program.parse(["node", "test", "validators", "delete"]);
43
+ program.parse(["node", "test", "localnet", "validators", "delete"]);
44
44
  expect(ValidatorsAction).toHaveBeenCalledTimes(1);
45
45
  expect(ValidatorsAction.prototype.deleteValidator).toHaveBeenCalledWith({});
46
46
  });
47
47
 
48
48
  test("ValidatorsAction.countValidators is called", async () => {
49
- program.parse(["node", "test", "validators", "count"]);
49
+ program.parse(["node", "test", "localnet", "validators", "count"]);
50
50
  expect(ValidatorsAction).toHaveBeenCalledTimes(1);
51
51
  expect(ValidatorsAction.prototype.countValidators).toHaveBeenCalled();
52
52
  });
@@ -55,6 +55,7 @@ describe("validators command", () => {
55
55
  program.parse([
56
56
  "node",
57
57
  "test",
58
+ "localnet",
58
59
  "validators",
59
60
  "update",
60
61
  "mocked_address",
@@ -81,6 +82,7 @@ describe("validators command", () => {
81
82
  program.parse([
82
83
  "node",
83
84
  "test",
85
+ "localnet",
84
86
  "validators",
85
87
  "create-random",
86
88
  "--count",
@@ -98,7 +100,7 @@ describe("validators command", () => {
98
100
  });
99
101
 
100
102
  test("ValidatorsAction.createValidator is called with default stake", async () => {
101
- program.parse(["node", "test", "validators", "create"]);
103
+ program.parse(["node", "test", "localnet", "validators", "create"]);
102
104
  expect(ValidatorsAction).toHaveBeenCalledTimes(1);
103
105
  expect(ValidatorsAction.prototype.createValidator).toHaveBeenCalledWith({
104
106
  stake: "1",
@@ -110,6 +112,7 @@ describe("validators command", () => {
110
112
  program.parse([
111
113
  "node",
112
114
  "test",
115
+ "localnet",
113
116
  "validators",
114
117
  "create",
115
118
  "--stake",
@@ -123,5 +126,6 @@ describe("validators command", () => {
123
126
  config: '{"temperature":0.8}',
124
127
  });
125
128
  });
126
-
127
129
  });
130
+
131
+
@@ -25,7 +25,7 @@ vi.mock("../src/commands/config", () => ({
25
25
  initializeConfigCommands: vi.fn(),
26
26
  }));
27
27
 
28
- vi.mock("../src/commands/validators", () => ({
28
+ vi.mock("../src/commands/localnet", () => ({
29
29
  initializeValidatorCommands: vi.fn(),
30
30
  }));
31
31