@lightprotocol/zk-compression-cli 0.27.1-alpha.5 → 0.27.1-alpha.6

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.
Binary file
@@ -119,6 +119,7 @@ async function initTestEnv({ additionalPrograms, skipSystemAccounts, indexer = t
119
119
  });
120
120
  await (0, process_1.waitForServers)([{ port: rpcPort, path: "/health" }]);
121
121
  await (0, process_1.confirmServerStability)(`http://127.0.0.1:${rpcPort}/health`);
122
+ await (0, process_1.confirmRpcReadiness)(`http://127.0.0.1:${rpcPort}`);
122
123
  if (indexer) {
123
124
  const config = (0, utils_1.getConfig)();
124
125
  config.indexerUrl = `http://127.0.0.1:${indexerPort}`;
@@ -33,3 +33,13 @@ export declare function waitForServers(servers: {
33
33
  path: string;
34
34
  }[]): Promise<void>;
35
35
  export declare function confirmServerStability(url: string, attempts?: number): Promise<void>;
36
+ /**
37
+ * Confirms that the Solana RPC is fully ready to process requests.
38
+ * This goes beyond HTTP availability and verifies the RPC can handle actual Solana requests.
39
+ *
40
+ * @param rpcUrl - The RPC endpoint URL
41
+ * @param maxAttempts - Maximum number of attempts (default: 30)
42
+ * @param delayMs - Delay between attempts in milliseconds (default: 500ms)
43
+ * @throws Error if RPC doesn't become ready within maxAttempts
44
+ */
45
+ export declare function confirmRpcReadiness(rpcUrl: string, maxAttempts?: number, delayMs?: number): Promise<void>;
@@ -8,6 +8,7 @@ exports.execute = execute;
8
8
  exports.spawnBinary = spawnBinary;
9
9
  exports.waitForServers = waitForServers;
10
10
  exports.confirmServerStability = confirmServerStability;
11
+ exports.confirmRpcReadiness = confirmRpcReadiness;
11
12
  const tslib_1 = require("tslib");
12
13
  const child_process_1 = require("child_process");
13
14
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -242,3 +243,50 @@ async function confirmServerStability(url, attempts = 20) {
242
243
  throw error;
243
244
  }
244
245
  }
246
+ /**
247
+ * Confirms that the Solana RPC is fully ready to process requests.
248
+ * This goes beyond HTTP availability and verifies the RPC can handle actual Solana requests.
249
+ *
250
+ * @param rpcUrl - The RPC endpoint URL
251
+ * @param maxAttempts - Maximum number of attempts (default: 30)
252
+ * @param delayMs - Delay between attempts in milliseconds (default: 500ms)
253
+ * @throws Error if RPC doesn't become ready within maxAttempts
254
+ */
255
+ async function confirmRpcReadiness(rpcUrl, maxAttempts = 30, delayMs = 500) {
256
+ let lastError;
257
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
258
+ try {
259
+ const response = await axios_1.default.post(rpcUrl, {
260
+ jsonrpc: "2.0",
261
+ id: 1,
262
+ method: "getHealth",
263
+ params: [],
264
+ }, {
265
+ headers: { "Content-Type": "application/json" },
266
+ timeout: 3000,
267
+ });
268
+ if (response.data?.result === "ok") {
269
+ console.log(`RPC is ready after ${attempt} attempt${attempt > 1 ? "s" : ""}.`);
270
+ return;
271
+ }
272
+ // Response received but not "ok"
273
+ lastError = new Error(`RPC returned unexpected result: ${JSON.stringify(response.data)}`);
274
+ }
275
+ catch (error) {
276
+ lastError = error;
277
+ // Log connection errors only on later attempts to reduce noise
278
+ if (attempt > 5 && attempt % 5 === 0) {
279
+ const errorMsg = error instanceof Error ? error.message : String(error);
280
+ console.log(`RPC not ready yet (attempt ${attempt}/${maxAttempts}): ${errorMsg}`);
281
+ }
282
+ }
283
+ // Don't sleep after the last attempt
284
+ if (attempt < maxAttempts) {
285
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
286
+ }
287
+ }
288
+ // If we get here, all attempts failed
289
+ const errorMsg = lastError instanceof Error ? lastError.message : String(lastError);
290
+ const totalTime = Math.round((maxAttempts * delayMs) / 1000);
291
+ throw new Error(`RPC failed to become ready after ${maxAttempts} attempts (~${totalTime}s). Last error: ${errorMsg}`);
292
+ }
@@ -623,6 +623,104 @@
623
623
  "index.js"
624
624
  ]
625
625
  },
626
+ "token-balance": {
627
+ "aliases": [],
628
+ "args": {},
629
+ "examples": [
630
+ "$ light token-balance --mint=<ADDRESS> --owner=<ADDRESS>"
631
+ ],
632
+ "flags": {
633
+ "owner": {
634
+ "description": "Address of the compressed token owner.",
635
+ "name": "owner",
636
+ "required": true,
637
+ "hasDynamicHelp": false,
638
+ "multiple": false,
639
+ "type": "option"
640
+ },
641
+ "mint": {
642
+ "description": "Mint address of the compressed token account.",
643
+ "name": "mint",
644
+ "required": true,
645
+ "hasDynamicHelp": false,
646
+ "multiple": false,
647
+ "type": "option"
648
+ }
649
+ },
650
+ "hasDynamicHelp": false,
651
+ "hiddenAliases": [],
652
+ "id": "token-balance",
653
+ "pluginAlias": "@lightprotocol/zk-compression-cli",
654
+ "pluginName": "@lightprotocol/zk-compression-cli",
655
+ "pluginType": "core",
656
+ "strict": true,
657
+ "summary": "Get balance",
658
+ "enableJsonFlag": false,
659
+ "isESM": false,
660
+ "relativePath": [
661
+ "dist",
662
+ "commands",
663
+ "token-balance",
664
+ "index.js"
665
+ ]
666
+ },
667
+ "transfer": {
668
+ "aliases": [],
669
+ "args": {},
670
+ "examples": [
671
+ "$ light transfer --mint PublicKey --to PublicKey --amount 1000"
672
+ ],
673
+ "flags": {
674
+ "mint": {
675
+ "description": "Mint to transfer",
676
+ "name": "mint",
677
+ "required": true,
678
+ "hasDynamicHelp": false,
679
+ "multiple": false,
680
+ "type": "option"
681
+ },
682
+ "to": {
683
+ "description": "Recipient address",
684
+ "name": "to",
685
+ "required": true,
686
+ "hasDynamicHelp": false,
687
+ "multiple": false,
688
+ "type": "option"
689
+ },
690
+ "amount": {
691
+ "description": "Amount to send, in tokens",
692
+ "name": "amount",
693
+ "required": true,
694
+ "hasDynamicHelp": false,
695
+ "multiple": false,
696
+ "type": "option"
697
+ },
698
+ "fee-payer": {
699
+ "description": "Specify the fee-payer account. Defaults to the client keypair.",
700
+ "name": "fee-payer",
701
+ "required": false,
702
+ "hasDynamicHelp": false,
703
+ "multiple": false,
704
+ "type": "option"
705
+ }
706
+ },
707
+ "hasDynamicHelp": false,
708
+ "hiddenAliases": [],
709
+ "id": "transfer",
710
+ "pluginAlias": "@lightprotocol/zk-compression-cli",
711
+ "pluginName": "@lightprotocol/zk-compression-cli",
712
+ "pluginType": "core",
713
+ "strict": true,
714
+ "summary": "Transfer tokens from one account to another.",
715
+ "enableJsonFlag": false,
716
+ "isESM": false,
717
+ "relativePath": [
718
+ "dist",
719
+ "commands",
720
+ "transfer",
721
+ "index.js"
722
+ ]
723
+ },
626
724
  "test-validator": {
627
725
  "aliases": [],
628
726
  "args": {},
@@ -808,105 +906,7 @@
808
906
  "test-validator",
809
907
  "index.js"
810
908
  ]
811
- },
812
- "token-balance": {
813
- "aliases": [],
814
- "args": {},
815
- "examples": [
816
- "$ light token-balance --mint=<ADDRESS> --owner=<ADDRESS>"
817
- ],
818
- "flags": {
819
- "owner": {
820
- "description": "Address of the compressed token owner.",
821
- "name": "owner",
822
- "required": true,
823
- "hasDynamicHelp": false,
824
- "multiple": false,
825
- "type": "option"
826
- },
827
- "mint": {
828
- "description": "Mint address of the compressed token account.",
829
- "name": "mint",
830
- "required": true,
831
- "hasDynamicHelp": false,
832
- "multiple": false,
833
- "type": "option"
834
- }
835
- },
836
- "hasDynamicHelp": false,
837
- "hiddenAliases": [],
838
- "id": "token-balance",
839
- "pluginAlias": "@lightprotocol/zk-compression-cli",
840
- "pluginName": "@lightprotocol/zk-compression-cli",
841
- "pluginType": "core",
842
- "strict": true,
843
- "summary": "Get balance",
844
- "enableJsonFlag": false,
845
- "isESM": false,
846
- "relativePath": [
847
- "dist",
848
- "commands",
849
- "token-balance",
850
- "index.js"
851
- ]
852
- },
853
- "transfer": {
854
- "aliases": [],
855
- "args": {},
856
- "examples": [
857
- "$ light transfer --mint PublicKey --to PublicKey --amount 1000"
858
- ],
859
- "flags": {
860
- "mint": {
861
- "description": "Mint to transfer",
862
- "name": "mint",
863
- "required": true,
864
- "hasDynamicHelp": false,
865
- "multiple": false,
866
- "type": "option"
867
- },
868
- "to": {
869
- "description": "Recipient address",
870
- "name": "to",
871
- "required": true,
872
- "hasDynamicHelp": false,
873
- "multiple": false,
874
- "type": "option"
875
- },
876
- "amount": {
877
- "description": "Amount to send, in tokens",
878
- "name": "amount",
879
- "required": true,
880
- "hasDynamicHelp": false,
881
- "multiple": false,
882
- "type": "option"
883
- },
884
- "fee-payer": {
885
- "description": "Specify the fee-payer account. Defaults to the client keypair.",
886
- "name": "fee-payer",
887
- "required": false,
888
- "hasDynamicHelp": false,
889
- "multiple": false,
890
- "type": "option"
891
- }
892
- },
893
- "hasDynamicHelp": false,
894
- "hiddenAliases": [],
895
- "id": "transfer",
896
- "pluginAlias": "@lightprotocol/zk-compression-cli",
897
- "pluginName": "@lightprotocol/zk-compression-cli",
898
- "pluginType": "core",
899
- "strict": true,
900
- "summary": "Transfer tokens from one account to another.",
901
- "enableJsonFlag": false,
902
- "isESM": false,
903
- "relativePath": [
904
- "dist",
905
- "commands",
906
- "transfer",
907
- "index.js"
908
- ]
909
909
  }
910
910
  },
911
- "version": "0.27.1-alpha.5"
911
+ "version": "0.27.1-alpha.6"
912
912
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightprotocol/zk-compression-cli",
3
- "version": "0.27.1-alpha.5",
3
+ "version": "0.27.1-alpha.6",
4
4
  "description": "ZK Compression: Secure Scaling on Solana",
5
5
  "maintainers": [
6
6
  {
@@ -49,8 +49,8 @@
49
49
  "tweetnacl": "^1.0.3",
50
50
  "wait-on": "^7.2.0",
51
51
  "which": "^5.0.0",
52
- "@lightprotocol/compressed-token": "0.22.1-alpha.3",
53
- "@lightprotocol/stateless.js": "0.22.1-alpha.2"
52
+ "@lightprotocol/compressed-token": "0.22.1-alpha.4",
53
+ "@lightprotocol/stateless.js": "0.22.1-alpha.3"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@eslint/js": "9.36.0",