@lightprotocol/zk-compression-cli 0.23.0 → 0.25.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.
Files changed (78) hide show
  1. package/README.md +1 -1
  2. package/accounts/address_merkle_tree_amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2.json +1 -1
  3. package/accounts/batch_address_merkle_tree_EzKE84aVTkCUhDHLELqyJaq1Y7UVVmqxXqZjVHwHY3rK.json +1 -0
  4. package/accounts/batch_state_merkle_tree_HLKs5NJ8FXkJg8BrzJt56adFYYuwg5etzDtBbQYTsixu.json +1 -0
  5. package/accounts/batched_output_queue_6L7SzhYB3anwEQ9cphpJ1U7Scwj57bx2xueReg7R9cKU.json +1 -0
  6. package/accounts/cpi_context_2_cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK.json +1 -0
  7. package/accounts/cpi_context_cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK.json +1 -0
  8. package/accounts/group_pda_32tgQWfaASE7SfTQvMaSJDrqe728tJQ2SGzxtDDrpDwS.json +1 -0
  9. package/accounts/merkle_tree_pubkey_2_smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho.json +1 -0
  10. package/accounts/merkle_tree_pubkey_smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho.json +1 -0
  11. package/accounts/nullifier_queue_pubkey_2_nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X.json +1 -0
  12. package/accounts/nullifier_queue_pubkey_nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X.json +1 -0
  13. package/accounts/registered_program_pda_35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh.json +1 -1
  14. package/accounts/registered_registry_program_pda_DumMsyvkaGJG4QnQ1BhTgvoRMXsgGxfpKDUCr22Xqu4w.json +1 -1
  15. package/bin/account_compression.so +0 -0
  16. package/bin/light_compressed_token.so +0 -0
  17. package/bin/light_registry.so +0 -0
  18. package/bin/light_system_program_pinocchio.so +0 -0
  19. package/bin/prover-darwin-arm64 +0 -0
  20. package/bin/prover-darwin-x64 +0 -0
  21. package/bin/prover-linux-arm64 +0 -0
  22. package/bin/prover-linux-x64 +0 -0
  23. package/bin/prover-windows-arm64.exe +0 -0
  24. package/bin/prover-windows-x64.exe +0 -0
  25. package/bin/proving-keys/combined_32_40_1_1.key +0 -0
  26. package/bin/proving-keys/{combined_26_3_2.key → combined_32_40_1_2.key} +0 -0
  27. package/bin/proving-keys/{combined_26_2_2.key → combined_32_40_2_1.key} +0 -0
  28. package/bin/proving-keys/inclusion_32_1.key +0 -0
  29. package/bin/proving-keys/inclusion_32_2.key +0 -0
  30. package/bin/proving-keys/{combined_26_3_1.key → inclusion_32_3.key} +0 -0
  31. package/bin/proving-keys/{combined_26_4_1.key → inclusion_32_4.key} +0 -0
  32. package/bin/proving-keys/non-inclusion_40_1.key +0 -0
  33. package/bin/proving-keys/non-inclusion_40_2.key +0 -0
  34. package/dist/commands/balance/index.d.ts +0 -1
  35. package/dist/commands/balance/index.js +10 -17
  36. package/dist/commands/compress-spl/index.js +3 -1
  37. package/dist/commands/decompress-spl/index.js +3 -1
  38. package/dist/commands/init/index.js +21 -3
  39. package/dist/commands/start-prover/index.d.ts +2 -0
  40. package/dist/commands/start-prover/index.js +31 -6
  41. package/dist/commands/test-validator/index.d.ts +11 -1
  42. package/dist/commands/test-validator/index.js +82 -2
  43. package/dist/commands/token-balance/index.d.ts +12 -0
  44. package/dist/commands/token-balance/index.js +55 -0
  45. package/dist/utils/constants.d.ts +21 -11
  46. package/dist/utils/constants.js +25 -12
  47. package/dist/utils/initTestEnv.d.ts +9 -1
  48. package/dist/utils/initTestEnv.js +38 -28
  49. package/dist/utils/process.d.ts +4 -0
  50. package/dist/utils/process.js +41 -2
  51. package/dist/utils/processPhotonIndexer.d.ts +1 -1
  52. package/dist/utils/processPhotonIndexer.js +33 -24
  53. package/dist/utils/processProverServer.d.ts +3 -1
  54. package/dist/utils/processProverServer.js +83 -2
  55. package/oclif.manifest.json +170 -112
  56. package/package.json +30 -19
  57. package/bin/proving-keys/CHECKSUM +0 -112
  58. package/bin/proving-keys/combined_26_1_1.vkey +0 -1
  59. package/bin/proving-keys/combined_26_1_2.vkey +0 -1
  60. package/bin/proving-keys/combined_26_2_1.vkey +0 -1
  61. package/bin/proving-keys/combined_26_2_2.vkey +0 -1
  62. package/bin/proving-keys/combined_26_3_1.vkey +0 -1
  63. package/bin/proving-keys/combined_26_3_2.vkey +0 -1
  64. package/bin/proving-keys/combined_26_4_1.vkey +0 -1
  65. package/bin/proving-keys/combined_26_4_2.key +0 -0
  66. package/bin/proving-keys/combined_26_4_2.vkey +0 -1
  67. package/bin/proving-keys/inclusion_26_1.vkey +0 -1
  68. package/bin/proving-keys/inclusion_26_2.vkey +0 -1
  69. package/bin/proving-keys/inclusion_26_3.vkey +0 -1
  70. package/bin/proving-keys/inclusion_26_4.vkey +0 -1
  71. package/bin/proving-keys/inclusion_26_8.key +0 -0
  72. package/bin/proving-keys/inclusion_26_8.vkey +0 -1
  73. package/bin/proving-keys/non-inclusion_26_1.vkey +0 -1
  74. package/bin/proving-keys/non-inclusion_26_2.vkey +0 -1
  75. /package/bin/proving-keys/{inclusion_26_1.key → mainnet_inclusion_26_1.key} +0 -0
  76. /package/bin/proving-keys/{inclusion_26_2.key → mainnet_inclusion_26_2.key} +0 -0
  77. /package/bin/proving-keys/{inclusion_26_3.key → mainnet_inclusion_26_3.key} +0 -0
  78. /package/bin/proving-keys/{inclusion_26_4.key → mainnet_inclusion_26_4.key} +0 -0
@@ -1 +1 @@
1
- {"pubkey":"35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh","account":{"lamports":1392000,"data":["H/u06wN0MgQGp1X4ITkFTUQksVrwxDDPL0t/mHk62hJS1I82ZsbLzg/Y1EfToz5VLJjxHxd2rjLiDsKHFAg5RA9dMMbnV0jY","base64"],"owner":"compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","executable":false,"rentEpoch":18446744073709551615,"space":72}}
1
+ {"pubkey":"35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh","account":{"lamports":1614720,"data":["H/u06wN0MgQGp1X4ITkFTUQksVrwxDDPL0t/mHk62hJS1I82ZsbLzg/Y1EfToz5VLJjxHxd2rjLiDsKHFAg5RA9dMMbnV0jY+7ModRBcroW1tER2B+2/4UUnv7QjkRykBCO/0VJ6JnU=","base64"],"owner":"compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","executable":false,"rentEpoch":18446744073709551615,"space":104}}
@@ -1 +1 @@
1
- {"pubkey":"DumMsyvkaGJG4QnQ1BhTgvoRMXsgGxfpKDUCr22Xqu4w","account":{"lamports":1392000,"data":["H/u06wN0MgQFDSsTeVE2hc8C8rX9UpG9lZsrBgqlJepbNIE7Hbm3bg/Y1EfToz5VLJjxHxd2rjLiDsKHFAg5RA9dMMbnV0jY","base64"],"owner":"compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","executable":false,"rentEpoch":18446744073709551615,"space":72}}
1
+ {"pubkey":"DumMsyvkaGJG4QnQ1BhTgvoRMXsgGxfpKDUCr22Xqu4w","account":{"lamports":1614720,"data":["H/u06wN0MgQFDSsTeVE2hc8C8rX9UpG9lZsrBgqlJepbNIE7Hbm3bg/Y1EfToz5VLJjxHxd2rjLiDsKHFAg5RA9dMMbnV0jYEKZefdY5BPg4OtA83uB4uRTYcxiAOxU1gHDXkuBc/ec=","base64"],"owner":"compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","executable":false,"rentEpoch":18446744073709551615,"space":104}}
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -4,7 +4,6 @@ declare class BalanceCommand extends Command {
4
4
  static examples: string[];
5
5
  static flags: {
6
6
  owner: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
- mint: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
8
7
  };
9
8
  static args: {};
10
9
  run(): Promise<void>;
@@ -9,36 +9,29 @@ class BalanceCommand extends core_1.Command {
9
9
  const loader = new utils_1.CustomLoader(`Performing balance...\n`);
10
10
  loader.start();
11
11
  try {
12
- const refMint = new web3_js_1.PublicKey(flags["mint"]);
13
12
  const refOwner = new web3_js_1.PublicKey(flags["owner"]);
14
- const tokenAccounts = await (0, utils_1.rpc)().getCompressedTokenAccountsByOwner(refOwner, { mint: refMint });
13
+ const accounts = await (0, utils_1.rpc)().getCompressedAccountsByOwner(refOwner);
15
14
  loader.stop(false);
16
- if (tokenAccounts.items.length === 0) {
17
- console.log("No token accounts found");
15
+ if (accounts.items.length === 0) {
16
+ console.log("No accounts found");
18
17
  return;
19
18
  }
20
- const compressedTokenAccount = tokenAccounts.items.find((acc) => acc.parsed.mint.equals(refMint));
21
- if (compressedTokenAccount === undefined) {
22
- console.log("No token accounts found");
23
- return;
19
+ let totalAmount = 0;
20
+ for (const account of accounts.items) {
21
+ totalAmount += account.lamports.toNumber();
24
22
  }
25
- console.log("\x1b[1mBalance:\x1b[0m ", compressedTokenAccount.parsed.amount.toString());
26
- console.log("balance successful");
23
+ console.log("\x1b[1mCompressed SOL balance:\x1b[0m ", totalAmount.toString());
27
24
  }
28
25
  catch (error) {
29
26
  this.error(`Failed to get balance!\n${error}`);
30
27
  }
31
28
  }
32
29
  }
33
- BalanceCommand.summary = "Get balance";
34
- BalanceCommand.examples = ["$ light balance --mint=<ADDRESS> --owner=<ADDRESS>"];
30
+ BalanceCommand.summary = "Get compressed SOL balance";
31
+ BalanceCommand.examples = ["$ light balance --owner=<ADDRESS>"];
35
32
  BalanceCommand.flags = {
36
33
  owner: core_1.Flags.string({
37
- description: "Address of the compressed token owner.",
38
- required: true,
39
- }),
40
- mint: core_1.Flags.string({
41
- description: "Mint address of the compressed token account.",
34
+ description: "Address of the owner.",
42
35
  required: true,
43
36
  }),
44
37
  };
@@ -5,6 +5,7 @@ const utils_1 = require("../../utils/utils");
5
5
  const web3_js_1 = require("@solana/web3.js");
6
6
  const compressed_token_1 = require("@lightprotocol/compressed-token");
7
7
  const spl_token_1 = require("@solana/spl-token");
8
+ const compressed_token_2 = require("@lightprotocol/compressed-token");
8
9
  /// TODO: add ability to compress from non-fee payer
9
10
  class CompressSplCommand extends core_1.Command {
10
11
  async run() {
@@ -22,8 +23,9 @@ class CompressSplCommand extends core_1.Command {
22
23
  const toPublicKey = new web3_js_1.PublicKey(to);
23
24
  const mintPublicKey = new web3_js_1.PublicKey(mint);
24
25
  const payer = (0, utils_1.defaultSolanaWalletKeypair)();
26
+ const tokenProgramId = await compressed_token_2.CompressedTokenProgram.getMintProgramId(mintPublicKey, (0, utils_1.rpc)());
25
27
  /// TODO: add explicit check that the ata is valid
26
- const sourceAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mintPublicKey, payer.publicKey);
28
+ const sourceAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mintPublicKey, payer.publicKey, undefined, tokenProgramId);
27
29
  txId = await (0, compressed_token_1.compress)((0, utils_1.rpc)(), payer, mintPublicKey, amount, payer, sourceAta, toPublicKey);
28
30
  loader.stop(false);
29
31
  console.log("\x1b[32mtxId:\x1b[0m ", (0, utils_1.generateSolanaTransactionURL)("tx", txId, "custom"));
@@ -5,6 +5,7 @@ const utils_1 = require("../../utils/utils");
5
5
  const web3_js_1 = require("@solana/web3.js");
6
6
  const compressed_token_1 = require("@lightprotocol/compressed-token");
7
7
  const spl_token_1 = require("@solana/spl-token");
8
+ const compressed_token_2 = require("@lightprotocol/compressed-token");
8
9
  /// TODO: add ability to decompress from non-fee payer
9
10
  class DecompressSplCommand extends core_1.Command {
10
11
  async run() {
@@ -22,7 +23,8 @@ class DecompressSplCommand extends core_1.Command {
22
23
  const toPublicKey = new web3_js_1.PublicKey(to);
23
24
  const mintPublicKey = new web3_js_1.PublicKey(mint);
24
25
  const payer = (0, utils_1.defaultSolanaWalletKeypair)();
25
- const recipientAta = await (0, spl_token_1.getOrCreateAssociatedTokenAccount)((0, utils_1.rpc)(), payer, mintPublicKey, toPublicKey);
26
+ const tokenProgramId = await compressed_token_2.CompressedTokenProgram.getMintProgramId(mintPublicKey, (0, utils_1.rpc)());
27
+ const recipientAta = await (0, spl_token_1.getOrCreateAssociatedTokenAccount)((0, utils_1.rpc)(), payer, mintPublicKey, toPublicKey, undefined, undefined, undefined, tokenProgramId);
26
28
  txId = await (0, compressed_token_1.decompress)((0, utils_1.rpc)(), payer, mintPublicKey, amount, payer, recipientAta.address);
27
29
  loader.stop(false);
28
30
  console.log("\x1b[32mtxId:\x1b[0m ", (0, utils_1.generateSolanaTransactionURL)("tx", txId, "custom"));
@@ -65,21 +65,39 @@ const initRepo = async (name, flags) => {
65
65
  "--define",
66
66
  `light-hasher-version=${constants_1.LIGHT_HASHER_VERSION}`,
67
67
  "--define",
68
+ `light-macros-version=${constants_1.LIGHT_MACROS_VERSION}`,
69
+ "--define",
68
70
  `light-account-checks-version=${constants_1.LIGHT_ACCOUNT_CHECKS}`,
69
71
  "--define",
70
72
  `light-sdk-version=${constants_1.LIGHT_SDK_VERSION}`,
71
73
  "--define",
72
74
  `light-sdk-macros-version=${constants_1.LIGHT_SDK_MACROS_VERSION}`,
73
75
  "--define",
76
+ `light-utils-version=${constants_1.LIGHT_UTILS_VERSION}`,
77
+ "--define",
78
+ `light-compressed-account-version=${constants_1.LIGHT_COMPRESSED_ACCOUNT_VERSION}`,
79
+ "--define",
80
+ `light-verifier-version=${constants_1.LIGHT_VERIFIER_VERSION}`, // TODO: remove
81
+ "--define",
74
82
  `solana-sdk-version=${constants_1.SOLANA_SDK_VERSION}`,
75
83
  "--define",
76
84
  `light-client-version=${constants_1.LIGHT_CLIENT_VERSION}`,
77
85
  "--define",
78
86
  `light-test-utils-version=${constants_1.LIGHT_TEST_UTILS_VERSION}`,
79
87
  "--define",
80
- `solana-program-test-version=${constants_1.SOLANA_PROGRAM_TEST_VERSION}`,
88
+ `light-program-test-version=${constants_1.SOLANA_PROGRAM_TEST_VERSION}`,
89
+ "--define",
90
+ `solana-program-test-version=${constants_1.SOLANA_PROGRAM_TEST_VERSION}`, // TODO: remove
81
91
  "--define",
82
92
  `tokio-version=${constants_1.TOKIO_VERSION}`,
93
+ "--define",
94
+ `stateless-js-version=${constants_1.STATELESS_JS_VERSION}`,
95
+ "--define",
96
+ `anchor-js-version=${constants_1.ANCHOR_VERSION}`,
97
+ "--define",
98
+ `light-cli-version=${constants_1.LIGHT_CLI_VERSION}`,
99
+ "--define",
100
+ `solana-cli-version=${constants_1.SOLANA_CLI_VERSION}`,
83
101
  ],
84
102
  logFile: true,
85
103
  env: env,
@@ -114,12 +132,12 @@ exports.initFlags = {
114
132
  }),
115
133
  tag: core_1.Flags.string({
116
134
  aliases: ["t"],
117
- description: "Tag must be used in conjuction with --git",
135
+ description: "Tag must be used in conjunction with --git",
118
136
  required: false,
119
137
  }),
120
138
  branch: core_1.Flags.string({
121
139
  aliases: ["b"],
122
- description: "Branch must be used in conjuction with --git",
140
+ description: "Branch must be used in conjunction with --git",
123
141
  default: "main",
124
142
  required: false,
125
143
  }),
@@ -6,6 +6,8 @@ declare class StartProver extends Command {
6
6
  "prover-port": import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
7
7
  "run-mode": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
8
  circuit: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ redisUrl: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
11
  };
10
12
  run(): Promise<void>;
11
13
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const index_1 = require("../../utils/index");
5
+ const processProverServer_1 = require("../../utils/processProverServer");
5
6
  class StartProver extends core_1.Command {
6
7
  finally(_) {
7
8
  process.exit();
@@ -14,8 +15,18 @@ class StartProver extends core_1.Command {
14
15
  this.log("Please specify --run-mode or --circuit.");
15
16
  return;
16
17
  }
17
- await (0, index_1.startProver)(flags["prover-port"], flags["run-mode"], flags["circuit"]);
18
- this.log("\nSetup tasks completed successfully \x1b[32m✔\x1b[0m");
18
+ const proverPort = flags["prover-port"] || 3001;
19
+ const force = flags["force"] || false;
20
+ const redisUrl = flags["redisUrl"] || process.env.REDIS_URL || undefined;
21
+ await (0, processProverServer_1.startProver)(proverPort, flags["run-mode"], flags["circuit"], force, redisUrl);
22
+ const healthy = await (0, processProverServer_1.healthCheck)(proverPort, 10, 1000);
23
+ loader.stop();
24
+ if (healthy) {
25
+ this.log("\nProver started and passed health check \x1b[32m✔\x1b[0m");
26
+ }
27
+ else {
28
+ this.log("\nProver started but health check failed");
29
+ }
19
30
  }
20
31
  }
21
32
  StartProver.description = "Start gnark prover";
@@ -26,8 +37,15 @@ StartProver.flags = {
26
37
  default: 3001,
27
38
  }),
28
39
  "run-mode": core_1.Flags.string({
29
- description: "Specify the running mode (forester, forester-test, rpc, full, or full-test)",
30
- options: ["rpc", "forester", "forester-test", "full", "full-test"],
40
+ description: "Specify the running mode (local-rpc, forester, forester-test, rpc, or full). Default: local-rpc",
41
+ options: [
42
+ "local-rpc",
43
+ "rpc",
44
+ "forester",
45
+ "forester-test",
46
+ "full",
47
+ "full-test",
48
+ ],
31
49
  required: false,
32
50
  }),
33
51
  circuit: core_1.Flags.string({
@@ -37,16 +55,23 @@ StartProver.flags = {
37
55
  "non-inclusion",
38
56
  "combined",
39
57
  "append-with-proofs",
40
- "append-with-subtrees",
41
58
  "update",
42
59
  "address-append",
43
60
  "append-with-proofs-test",
44
- "append-with-subtrees-test",
45
61
  "update-test",
46
62
  "address-append-test",
47
63
  ],
48
64
  multiple: true,
49
65
  required: false,
50
66
  }),
67
+ force: core_1.Flags.boolean({
68
+ description: "Force restart the prover even if one is already running with the same flags.",
69
+ required: false,
70
+ default: false,
71
+ }),
72
+ redisUrl: core_1.Flags.string({
73
+ description: "Redis URL to use for the prover (e.g. redis://localhost:6379)",
74
+ required: false,
75
+ }),
51
76
  };
52
77
  exports.default = StartProver;
@@ -2,7 +2,7 @@ import { Command } from "@oclif/core";
2
2
  declare class SetupCommand extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
- protected finally(_: Error | undefined): Promise<any>;
5
+ protected finally(err: Error | undefined): Promise<any>;
6
6
  static flags: {
7
7
  "skip-indexer": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
8
  "skip-prover": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -19,7 +19,17 @@ declare class SetupCommand extends Command {
19
19
  stop: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
20
20
  "geyser-config": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
21
21
  "validator-args": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
22
+ "sbf-program": import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
22
23
  };
24
+ validatePrograms(programs: {
25
+ address: string;
26
+ path: string;
27
+ }[]): void;
23
28
  run(): Promise<void>;
24
29
  }
25
30
  export default SetupCommand;
31
+ export declare const SYSTEM_PROGRAMS: {
32
+ id: string;
33
+ name: string;
34
+ tag: string;
35
+ }[];
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SYSTEM_PROGRAMS = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const core_1 = require("@oclif/core");
5
6
  const initTestEnv_1 = require("../../utils/initTestEnv");
@@ -7,9 +8,40 @@ const index_1 = require("../../utils/index");
7
8
  const path_1 = tslib_1.__importDefault(require("path"));
8
9
  const fs_1 = tslib_1.__importDefault(require("fs"));
9
10
  class SetupCommand extends core_1.Command {
10
- finally(_) {
11
+ finally(err) {
12
+ if (err) {
13
+ console.error(err);
14
+ }
11
15
  process.exit();
12
16
  }
17
+ validatePrograms(programs) {
18
+ // Check for duplicate addresses among provided programs
19
+ const addresses = new Set();
20
+ for (const program of programs) {
21
+ if (addresses.has(program.address)) {
22
+ this.error(`Duplicate program address detected: ${program.address}`);
23
+ }
24
+ addresses.add(program.address);
25
+ // Get the program filename from the path
26
+ const programFileName = path_1.default.basename(program.path);
27
+ // Check for collisions with system programs (both address and filename)
28
+ const systemProgramCollision = exports.SYSTEM_PROGRAMS.find((sysProg) => sysProg.id === program.address ||
29
+ (sysProg.name && programFileName === sysProg.name));
30
+ if (systemProgramCollision) {
31
+ const collisionType = systemProgramCollision.id === program.address
32
+ ? `address (${program.address})`
33
+ : `filename (${programFileName})`;
34
+ this.error(`Program ${collisionType} collides with system program ` +
35
+ `"${systemProgramCollision.name || systemProgramCollision.id}". ` +
36
+ `System programs cannot be overwritten.`);
37
+ }
38
+ // Validate program file exists
39
+ const programPath = path_1.default.resolve(program.path);
40
+ if (!fs_1.default.existsSync(programPath)) {
41
+ this.error(`Program file not found: ${programPath}`);
42
+ }
43
+ }
44
+ }
13
45
  async run() {
14
46
  const { flags } = await this.parse(SetupCommand);
15
47
  const loader = new index_1.CustomLoader("Performing setup tasks...\n");
@@ -28,7 +60,20 @@ class SetupCommand extends core_1.Command {
28
60
  this.log("\nTest validator stopped successfully \x1b[32m✔\x1b[0m");
29
61
  }
30
62
  else {
63
+ const rawValues = flags["sbf-program"] || [];
64
+ if (rawValues.length % 2 !== 0) {
65
+ this.error("Each --sbf-program flag must have exactly two arguments");
66
+ }
67
+ const programs = [];
68
+ for (let i = 0; i < rawValues.length; i += 2) {
69
+ programs.push({
70
+ address: rawValues[i],
71
+ path: rawValues[i + 1],
72
+ });
73
+ }
74
+ this.validatePrograms(programs);
31
75
  await (0, initTestEnv_1.initTestEnv)({
76
+ additionalPrograms: programs,
32
77
  checkPhotonVersion: !flags["relax-indexer-version-constraint"],
33
78
  indexer: !flags["skip-indexer"],
34
79
  limitLedgerSize: flags["limit-ledger-size"],
@@ -54,6 +99,7 @@ SetupCommand.examples = [
54
99
  "$ light test-validator --skip-indexer",
55
100
  "$ light test-validator --geyser-config ./config.json",
56
101
  '$ light test-validator --validator-args "--limit-ledger-size 50000000"',
102
+ "$ light test-validator --sbf-program <address> <path/program>",
57
103
  ];
58
104
  SetupCommand.flags = {
59
105
  "skip-indexer": core_1.Flags.boolean({
@@ -96,8 +142,9 @@ SetupCommand.flags = {
96
142
  exclusive: ["skip-prover"],
97
143
  }),
98
144
  "prover-run-mode": core_1.Flags.string({
99
- description: "Specify the running mode for the prover (forester, forester-test, rpc, or full)",
145
+ description: "Specify the running mode for the prover (local-rpc, forester, forester-test, rpc, or full). Default: local-rpc",
100
146
  options: [
147
+ "local-rpc",
101
148
  "rpc",
102
149
  "forester",
103
150
  "forester-test",
@@ -146,5 +193,38 @@ SetupCommand.flags = {
146
193
  required: false,
147
194
  exclusive: ["geyser-config"],
148
195
  }),
196
+ "sbf-program": core_1.Flags.string({
197
+ description: "Add a SBF program to the genesis configuration with upgrades disabled. If the ledger already exists then this parameter is silently ignored. First argument can be a pubkey string or path to a keypair",
198
+ required: false,
199
+ multiple: true,
200
+ summary: "Usage: --sbf-program <address> <path/program_name.so>",
201
+ }),
149
202
  };
150
203
  exports.default = SetupCommand;
204
+ exports.SYSTEM_PROGRAMS = [
205
+ {
206
+ id: "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV",
207
+ name: "spl_noop.so",
208
+ tag: index_1.SPL_NOOP_PROGRAM_TAG,
209
+ },
210
+ {
211
+ id: "SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7",
212
+ name: "light_system_program.so",
213
+ tag: index_1.LIGHT_SYSTEM_PROGRAM_TAG,
214
+ },
215
+ {
216
+ id: "cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m",
217
+ name: "light_compressed_token.so",
218
+ tag: index_1.LIGHT_COMPRESSED_TOKEN_TAG,
219
+ },
220
+ {
221
+ id: "compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq",
222
+ name: "account_compression.so",
223
+ tag: index_1.LIGHT_ACCOUNT_COMPRESSION_TAG,
224
+ },
225
+ {
226
+ id: "Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX",
227
+ name: "light_registry.so",
228
+ tag: index_1.LIGHT_REGISTRY_TAG,
229
+ },
230
+ ];
@@ -0,0 +1,12 @@
1
+ import { Command } from "@oclif/core";
2
+ declare class TokenBalanceCommand extends Command {
3
+ static summary: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ owner: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ mint: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ };
9
+ static args: {};
10
+ run(): Promise<void>;
11
+ }
12
+ export default TokenBalanceCommand;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../utils/utils");
5
+ const web3_js_1 = require("@solana/web3.js");
6
+ class TokenBalanceCommand extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(TokenBalanceCommand);
9
+ const loader = new utils_1.CustomLoader(`Performing balance...\n`);
10
+ loader.start();
11
+ try {
12
+ const refMint = new web3_js_1.PublicKey(flags["mint"]);
13
+ const refOwner = new web3_js_1.PublicKey(flags["owner"]);
14
+ const tokenAccounts = await (0, utils_1.rpc)().getCompressedTokenAccountsByOwner(refOwner, { mint: refMint });
15
+ loader.stop(false);
16
+ // Handle case when no token accounts are found
17
+ if (tokenAccounts.items.length === 0) {
18
+ console.log("\x1b[1mBalance:\x1b[0m 0");
19
+ console.log("No token accounts found");
20
+ return;
21
+ }
22
+ const compressedTokenAccounts = tokenAccounts.items.filter((acc) => acc.parsed.mint.equals(refMint));
23
+ if (compressedTokenAccounts.length === 0) {
24
+ console.log("\x1b[1mBalance:\x1b[0m 0");
25
+ console.log("No token accounts found for this mint");
26
+ return;
27
+ }
28
+ let totalBalance = BigInt(0);
29
+ compressedTokenAccounts.forEach((account) => {
30
+ const amount = account.parsed.amount;
31
+ totalBalance += BigInt(amount.toString());
32
+ });
33
+ console.log(`\x1b[1mBalance:\x1b[0m ${totalBalance.toString()}`);
34
+ }
35
+ catch (error) {
36
+ this.error(`Failed to get balance!\n${error}`);
37
+ }
38
+ }
39
+ }
40
+ TokenBalanceCommand.summary = "Get balance";
41
+ TokenBalanceCommand.examples = [
42
+ "$ light token-balance --mint=<ADDRESS> --owner=<ADDRESS>",
43
+ ];
44
+ TokenBalanceCommand.flags = {
45
+ owner: core_1.Flags.string({
46
+ description: "Address of the compressed token owner.",
47
+ required: true,
48
+ }),
49
+ mint: core_1.Flags.string({
50
+ description: "Mint address of the compressed token account.",
51
+ required: true,
52
+ }),
53
+ };
54
+ TokenBalanceCommand.args = {};
55
+ exports.default = TokenBalanceCommand;
@@ -12,19 +12,29 @@ export declare const CARGO_GENERATE_TAG = "v0.18.4";
12
12
  export declare const SOLANA_VALIDATOR_PROCESS_NAME = "solana-test-validator";
13
13
  export declare const LIGHT_PROVER_PROCESS_NAME = "light-prover";
14
14
  export declare const INDEXER_PROCESS_NAME = "photon";
15
- export declare const PHOTON_VERSION = "0.50.0";
15
+ export declare const PHOTON_VERSION = "0.50.1";
16
+ export declare const USE_PHOTON_FROM_GIT = true;
17
+ export declare const PHOTON_GIT_REPO = "https://github.com/lightprotocol/photon.git";
18
+ export declare const PHOTON_GIT_COMMIT = "49b7e7f0d668babbc4d65fe8a0a7236df76f75a8";
16
19
  export declare const LIGHT_PROTOCOL_PROGRAMS_DIR_ENV = "LIGHT_PROTOCOL_PROGRAMS_DIR";
17
20
  export declare const BASE_PATH = "../../bin/";
18
21
  export declare const PROGRAM_ID = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS";
19
- export declare const ANCHOR_VERSION = "0.29.0";
20
- export declare const BORSH_VERSION = "0.9.2";
21
- export declare const SOLANA_PROGRAM_TEST_VERSION = "1.18.22";
22
- export declare const SOLANA_SDK_VERSION = "1.18.22";
22
+ export declare const SOLANA_SDK_VERSION = "2.2";
23
+ export declare const ANCHOR_VERSION = "0.31.1";
24
+ export declare const BORSH_VERSION = "0.10.4";
25
+ export declare const COMPRESSED_PROGRAM_TEMPLATE_TAG = "v0.3.0";
23
26
  export declare const TOKIO_VERSION = "1.36.0";
24
- export declare const LIGHT_SDK_VERSION = "0.10.0";
25
- export declare const LIGHT_TEST_UTILS_VERSION = "1.2.1";
27
+ export declare const SOLANA_PROGRAM_TEST_VERSION = "2.2";
28
+ export declare const SOLANA_CLI_VERSION = "2.2.15";
29
+ export declare const LIGHT_HASHER_VERSION = "3.1.0";
30
+ export declare const LIGHT_MACROS_VERSION = "2.1.0";
31
+ export declare const LIGHT_SDK_VERSION = "0.13.0";
32
+ export declare const LIGHT_SDK_MACROS_VERSION = "0.13.0";
33
+ export declare const LIGHT_UTILS_VERSION = "0.13.0";
34
+ export declare const LIGHT_COMPRESSED_ACCOUNT_VERSION = "0.3.0";
35
+ export declare const LIGHT_VERIFIER_VERSION = "2.0.0";
26
36
  export declare const LIGHT_CLIENT_VERSION = "0.9.1";
27
- export declare const COMPRESSED_PROGRAM_TEMPLATE_TAG = "v0.2.0-alpha";
28
- export declare const LIGHT_ACCOUNT_CHECKS = "0.1.0";
29
- export declare const LIGHT_HASHER_VERSION = "2.0.0";
30
- export declare const LIGHT_SDK_MACROS_VERSION = "0.5.1";
37
+ export declare const LIGHT_TEST_UTILS_VERSION = "1.2.1";
38
+ export declare const LIGHT_ACCOUNT_CHECKS = "0.3.0";
39
+ export declare const STATELESS_JS_VERSION = "0.22.0";
40
+ export declare const LIGHT_CLI_VERSION = "0.25.0";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LIGHT_SDK_MACROS_VERSION = exports.LIGHT_HASHER_VERSION = exports.LIGHT_ACCOUNT_CHECKS = exports.COMPRESSED_PROGRAM_TEMPLATE_TAG = exports.LIGHT_CLIENT_VERSION = exports.LIGHT_TEST_UTILS_VERSION = exports.LIGHT_SDK_VERSION = exports.TOKIO_VERSION = exports.SOLANA_SDK_VERSION = exports.SOLANA_PROGRAM_TEST_VERSION = exports.BORSH_VERSION = exports.ANCHOR_VERSION = exports.PROGRAM_ID = exports.BASE_PATH = exports.LIGHT_PROTOCOL_PROGRAMS_DIR_ENV = exports.PHOTON_VERSION = exports.INDEXER_PROCESS_NAME = exports.LIGHT_PROVER_PROCESS_NAME = exports.SOLANA_VALIDATOR_PROCESS_NAME = exports.CARGO_GENERATE_TAG = exports.DEFAULT_CONFIG = exports.CONFIG_FILE_NAME = exports.CONFIG_PATH = exports.LIGHT_COMPRESSED_TOKEN_TAG = exports.LIGHT_REGISTRY_TAG = exports.LIGHT_SYSTEM_PROGRAM_TAG = exports.LIGHT_ACCOUNT_COMPRESSION_TAG = exports.SPL_NOOP_PROGRAM_TAG = void 0;
3
+ exports.LIGHT_CLI_VERSION = exports.STATELESS_JS_VERSION = exports.LIGHT_ACCOUNT_CHECKS = exports.LIGHT_TEST_UTILS_VERSION = exports.LIGHT_CLIENT_VERSION = exports.LIGHT_VERIFIER_VERSION = exports.LIGHT_COMPRESSED_ACCOUNT_VERSION = exports.LIGHT_UTILS_VERSION = exports.LIGHT_SDK_MACROS_VERSION = exports.LIGHT_SDK_VERSION = exports.LIGHT_MACROS_VERSION = exports.LIGHT_HASHER_VERSION = exports.SOLANA_CLI_VERSION = exports.SOLANA_PROGRAM_TEST_VERSION = exports.TOKIO_VERSION = exports.COMPRESSED_PROGRAM_TEMPLATE_TAG = exports.BORSH_VERSION = exports.ANCHOR_VERSION = exports.SOLANA_SDK_VERSION = exports.PROGRAM_ID = exports.BASE_PATH = exports.LIGHT_PROTOCOL_PROGRAMS_DIR_ENV = exports.PHOTON_GIT_COMMIT = exports.PHOTON_GIT_REPO = exports.USE_PHOTON_FROM_GIT = exports.PHOTON_VERSION = exports.INDEXER_PROCESS_NAME = exports.LIGHT_PROVER_PROCESS_NAME = exports.SOLANA_VALIDATOR_PROCESS_NAME = exports.CARGO_GENERATE_TAG = exports.DEFAULT_CONFIG = exports.CONFIG_FILE_NAME = exports.CONFIG_PATH = exports.LIGHT_COMPRESSED_TOKEN_TAG = exports.LIGHT_REGISTRY_TAG = exports.LIGHT_SYSTEM_PROGRAM_TAG = exports.LIGHT_ACCOUNT_COMPRESSION_TAG = exports.SPL_NOOP_PROGRAM_TAG = void 0;
4
4
  exports.SPL_NOOP_PROGRAM_TAG = "spl-noop-v0.2.0";
5
5
  exports.LIGHT_ACCOUNT_COMPRESSION_TAG = "account-compression-v1.0.0";
6
6
  exports.LIGHT_SYSTEM_PROGRAM_TAG = "light-system-program-v1.0.0";
@@ -17,19 +17,32 @@ exports.CARGO_GENERATE_TAG = "v0.18.4";
17
17
  exports.SOLANA_VALIDATOR_PROCESS_NAME = "solana-test-validator";
18
18
  exports.LIGHT_PROVER_PROCESS_NAME = "light-prover";
19
19
  exports.INDEXER_PROCESS_NAME = "photon";
20
- exports.PHOTON_VERSION = "0.50.0";
20
+ exports.PHOTON_VERSION = "0.50.1";
21
+ // Set these to override Photon requirements with a specific git commit:
22
+ exports.USE_PHOTON_FROM_GIT = true; // If true, will show git install command instead of crates.io.
23
+ exports.PHOTON_GIT_REPO = "https://github.com/lightprotocol/photon.git";
24
+ exports.PHOTON_GIT_COMMIT = "49b7e7f0d668babbc4d65fe8a0a7236df76f75a8"; // If empty, will use main branch.
21
25
  exports.LIGHT_PROTOCOL_PROGRAMS_DIR_ENV = "LIGHT_PROTOCOL_PROGRAMS_DIR";
22
26
  exports.BASE_PATH = "../../bin/";
23
27
  exports.PROGRAM_ID = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS";
24
- exports.ANCHOR_VERSION = "0.29.0";
25
- exports.BORSH_VERSION = "0.9.2";
26
- exports.SOLANA_PROGRAM_TEST_VERSION = "1.18.22";
27
- exports.SOLANA_SDK_VERSION = "1.18.22";
28
+ exports.SOLANA_SDK_VERSION = "2.2";
29
+ exports.ANCHOR_VERSION = "0.31.1";
30
+ exports.BORSH_VERSION = "0.10.4";
31
+ exports.COMPRESSED_PROGRAM_TEMPLATE_TAG = "v0.3.0";
28
32
  exports.TOKIO_VERSION = "1.36.0";
29
- exports.LIGHT_SDK_VERSION = "0.10.0";
30
- exports.LIGHT_TEST_UTILS_VERSION = "1.2.1";
33
+ exports.SOLANA_PROGRAM_TEST_VERSION = "2.2";
34
+ exports.SOLANA_CLI_VERSION = "2.2.15";
35
+ exports.LIGHT_HASHER_VERSION = "3.1.0";
36
+ exports.LIGHT_MACROS_VERSION = "2.1.0";
37
+ exports.LIGHT_SDK_VERSION = "0.13.0";
38
+ exports.LIGHT_SDK_MACROS_VERSION = "0.13.0";
39
+ exports.LIGHT_UTILS_VERSION = "0.13.0";
40
+ exports.LIGHT_COMPRESSED_ACCOUNT_VERSION = "0.3.0";
41
+ exports.LIGHT_VERIFIER_VERSION = "2.0.0";
31
42
  exports.LIGHT_CLIENT_VERSION = "0.9.1";
32
- exports.COMPRESSED_PROGRAM_TEMPLATE_TAG = "v0.2.0-alpha";
33
- exports.LIGHT_ACCOUNT_CHECKS = "0.1.0";
34
- exports.LIGHT_HASHER_VERSION = "2.0.0";
35
- exports.LIGHT_SDK_MACROS_VERSION = "0.5.1";
43
+ // TODO: replace with light program test
44
+ exports.LIGHT_TEST_UTILS_VERSION = "1.2.1";
45
+ exports.LIGHT_ACCOUNT_CHECKS = "0.3.0";
46
+ // js packages
47
+ exports.STATELESS_JS_VERSION = "0.22.0";
48
+ exports.LIGHT_CLI_VERSION = "0.25.0";