@lightprotocol/zk-compression-cli 0.3.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/LICENSE +674 -0
- package/README.md +189 -0
- package/accounts/address_merkle_tree_C83cpRN6oaafjNgMQJvaYgAz592EP5wunKvbokeTKPLn.json +1 -0
- package/accounts/address_merkle_tree_queue_HNjtNrjt6irUPYEgxhx2Vcs42koK9fxzm3aFLHVaaRWz.json +1 -0
- package/accounts/governance_authority_pda_3MtrKu5Mjgh3JqeE5PeRzw2Ld28XjFgbbph67E6UERSx.json +1 -0
- package/accounts/group_pda_Edo2YjXU5eE17CejPBkupPgFLcYuAX47pGZmM7s2hAkj.json +1 -0
- package/accounts/merkle_tree_pubkey_5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W.json +1 -0
- package/accounts/nullifier_queue_pubkey_44J4oDXpjPAbzHCSc24q7NEiPekss4sAbLd8ka4gd9CZ.json +1 -0
- package/accounts/registered_program_pda_ytwwVWhQUMoTKdirKmvEW5xCRVr4B2dJZnToiHtE2L2.json +1 -0
- package/bin/account_compression.so +0 -0
- package/bin/light_compressed_pda.so +0 -0
- package/bin/light_compressed_token.so +0 -0
- package/bin/light_registry.so +0 -0
- package/bin/light_system_program.so +0 -0
- package/bin/prover-darwin-arm64 +0 -0
- package/bin/prover-darwin-x64 +0 -0
- package/bin/prover-linux-arm64 +0 -0
- package/bin/prover-linux-x64 +0 -0
- package/bin/prover-windows-arm64.exe +0 -0
- package/bin/prover-windows-x64.exe +0 -0
- package/bin/proving-keys/combined_26_1_1.key +0 -0
- package/bin/proving-keys/combined_26_1_1.vkey +1 -0
- package/bin/proving-keys/combined_26_1_2.key +0 -0
- package/bin/proving-keys/combined_26_1_2.vkey +1 -0
- package/bin/proving-keys/combined_26_2_1.key +0 -0
- package/bin/proving-keys/combined_26_2_1.vkey +1 -0
- package/bin/proving-keys/combined_26_2_2.key +0 -0
- package/bin/proving-keys/combined_26_2_2.vkey +1 -0
- package/bin/proving-keys/combined_26_3_1.key +0 -0
- package/bin/proving-keys/combined_26_3_1.vkey +1 -0
- package/bin/proving-keys/combined_26_3_2.key +0 -0
- package/bin/proving-keys/combined_26_3_2.vkey +1 -0
- package/bin/proving-keys/combined_26_4_1.key +0 -0
- package/bin/proving-keys/combined_26_4_1.vkey +1 -0
- package/bin/proving-keys/combined_26_4_2.key +0 -0
- package/bin/proving-keys/combined_26_4_2.vkey +1 -0
- package/bin/proving-keys/inclusion_26_1.key +0 -0
- package/bin/proving-keys/inclusion_26_1.vkey +1 -0
- package/bin/proving-keys/inclusion_26_2.key +0 -0
- package/bin/proving-keys/inclusion_26_2.vkey +1 -0
- package/bin/proving-keys/inclusion_26_3.key +0 -0
- package/bin/proving-keys/inclusion_26_3.vkey +1 -0
- package/bin/proving-keys/inclusion_26_4.key +0 -0
- package/bin/proving-keys/inclusion_26_4.vkey +1 -0
- package/bin/proving-keys/inclusion_26_8.key +0 -0
- package/bin/proving-keys/inclusion_26_8.vkey +1 -0
- package/bin/proving-keys/non-inclusion_26_1.key +0 -0
- package/bin/proving-keys/non-inclusion_26_1.vkey +1 -0
- package/bin/proving-keys/non-inclusion_26_2.key +0 -0
- package/bin/proving-keys/non-inclusion_26_2.vkey +1 -0
- package/bin/spl_noop.so +0 -0
- package/config.json +3 -0
- package/dist/commands/approve-and-mint-to/index.d.ts +14 -0
- package/dist/commands/approve-and-mint-to/index.js +64 -0
- package/dist/commands/balance/index.d.ts +12 -0
- package/dist/commands/balance/index.js +50 -0
- package/dist/commands/compress-sol/index.d.ts +12 -0
- package/dist/commands/compress-sol/index.js +48 -0
- package/dist/commands/compress-spl/index.d.ts +13 -0
- package/dist/commands/compress-spl/index.js +61 -0
- package/dist/commands/config/config.d.ts +11 -0
- package/dist/commands/config/config.js +69 -0
- package/dist/commands/config/index.d.ts +2 -0
- package/dist/commands/config/index.js +5 -0
- package/dist/commands/create-mint/index.d.ts +17 -0
- package/dist/commands/create-mint/index.js +67 -0
- package/dist/commands/decompress-sol/index.d.ts +12 -0
- package/dist/commands/decompress-sol/index.js +46 -0
- package/dist/commands/decompress-spl/index.d.ts +13 -0
- package/dist/commands/decompress-spl/index.js +60 -0
- package/dist/commands/mint-to/index.d.ts +14 -0
- package/dist/commands/mint-to/index.js +64 -0
- package/dist/commands/register-mint/index.d.ts +14 -0
- package/dist/commands/register-mint/index.js +50 -0
- package/dist/commands/start-prover/index.d.ts +11 -0
- package/dist/commands/start-prover/index.js +30 -0
- package/dist/commands/test-validator/index.d.ts +16 -0
- package/dist/commands/test-validator/index.js +61 -0
- package/dist/commands/transfer/index.d.ts +13 -0
- package/dist/commands/transfer/index.js +62 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/psp-utils/download.d.ts +34 -0
- package/dist/psp-utils/download.js +203 -0
- package/dist/psp-utils/index.d.ts +1 -0
- package/dist/psp-utils/index.js +4 -0
- package/dist/utils/constants.d.ts +14 -0
- package/dist/utils/constants.js +19 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/initTestEnv.d.ts +38 -0
- package/dist/utils/initTestEnv.js +171 -0
- package/dist/utils/process.d.ts +30 -0
- package/dist/utils/process.js +162 -0
- package/dist/utils/processPhotonIndexer.d.ts +1 -0
- package/dist/utils/processPhotonIndexer.js +45 -0
- package/dist/utils/processProverServer.d.ts +3 -0
- package/dist/utils/processProverServer.js +49 -0
- package/dist/utils/standardFlags.d.ts +8 -0
- package/dist/utils/standardFlags.js +36 -0
- package/dist/utils/utils.d.ts +26 -0
- package/dist/utils/utils.js +150 -0
- package/oclif.manifest.json +684 -0
- package/package.json +122 -0
- package/test_bin/dev +17 -0
- package/test_bin/run +5 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { Keypair } from "@solana/web3.js";
|
|
3
|
+
declare class CreateMintCommand extends Command {
|
|
4
|
+
static summary: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
"mint-keypair": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
"mint-authority": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
"mint-decimals": import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
static args: {};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
getMintDecimals(flags: any): number;
|
|
14
|
+
private getMintKeypair;
|
|
15
|
+
getMintAuthority(flags: any, payer: Keypair): Promise<Keypair>;
|
|
16
|
+
}
|
|
17
|
+
export default CreateMintCommand;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const helpers_1 = require("@solana-developers/helpers");
|
|
5
|
+
const utils_1 = require("../../utils/utils");
|
|
6
|
+
const compressed_token_1 = require("@lightprotocol/compressed-token");
|
|
7
|
+
const stateless_js_1 = require("@lightprotocol/stateless.js");
|
|
8
|
+
const hasher_rs_1 = require("@lightprotocol/hasher.rs");
|
|
9
|
+
const DEFAULT_DECIMAL_COUNT = 9;
|
|
10
|
+
class CreateMintCommand extends core_1.Command {
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(CreateMintCommand);
|
|
13
|
+
const loader = new utils_1.CustomLoader(`Performing create-mint...\n`);
|
|
14
|
+
loader.start();
|
|
15
|
+
try {
|
|
16
|
+
const payer = (0, utils_1.defaultSolanaWalletKeypair)();
|
|
17
|
+
const mintDecimals = this.getMintDecimals(flags);
|
|
18
|
+
const mintKeypair = await this.getMintKeypair(flags);
|
|
19
|
+
const mintAuthority = await this.getMintAuthority(flags, payer);
|
|
20
|
+
const lightWasm = await hasher_rs_1.WasmFactory.getInstance();
|
|
21
|
+
const rpc = await (0, stateless_js_1.getTestRpc)(lightWasm);
|
|
22
|
+
const { mint, transactionSignature } = await (0, compressed_token_1.createMint)(rpc, payer, mintAuthority, mintDecimals, mintKeypair);
|
|
23
|
+
loader.stop(false);
|
|
24
|
+
console.log("\x1b[1mMint public key:\x1b[0m ", mint.toBase58());
|
|
25
|
+
console.log("\x1b[1mMint tx:\x1b[0m ", (0, utils_1.generateSolanaTransactionURL)("tx", transactionSignature, "custom"));
|
|
26
|
+
console.log("create-mint successful");
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
this.error(`Failed to create-mint!\n${error}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
getMintDecimals(flags) {
|
|
33
|
+
return flags["mint-decimals"] ?? DEFAULT_DECIMAL_COUNT;
|
|
34
|
+
}
|
|
35
|
+
async getMintKeypair(flags) {
|
|
36
|
+
const mintKeypairFilePath = flags["mint-keypair"];
|
|
37
|
+
if (!mintKeypairFilePath) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const keypair = await (0, helpers_1.getKeypairFromFile)(mintKeypairFilePath);
|
|
41
|
+
return keypair;
|
|
42
|
+
}
|
|
43
|
+
async getMintAuthority(flags, payer) {
|
|
44
|
+
return flags["mint-authority"]
|
|
45
|
+
? await (0, helpers_1.getKeypairFromFile)(flags["mint-authority"])
|
|
46
|
+
: payer;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
CreateMintCommand.summary = "Create a new compressed token mint";
|
|
50
|
+
CreateMintCommand.examples = ["$ light create-mint --mint-decimals 5"];
|
|
51
|
+
CreateMintCommand.flags = {
|
|
52
|
+
"mint-keypair": core_1.Flags.string({
|
|
53
|
+
description: "Provide a path to a mint keypair file. Defaults to a random keypair",
|
|
54
|
+
required: false,
|
|
55
|
+
}),
|
|
56
|
+
"mint-authority": core_1.Flags.string({
|
|
57
|
+
description: "Specify a path to the mint authority keypair file. Defaults to your default local solana wallet file path",
|
|
58
|
+
required: false,
|
|
59
|
+
}),
|
|
60
|
+
"mint-decimals": core_1.Flags.integer({
|
|
61
|
+
description: `Number of base 10 digits to the right of the decimal place [default: ${DEFAULT_DECIMAL_COUNT}]`,
|
|
62
|
+
required: false,
|
|
63
|
+
default: DEFAULT_DECIMAL_COUNT,
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
CreateMintCommand.args = {};
|
|
67
|
+
exports.default = CreateMintCommand;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
declare class DecompressSolCommand extends Command {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
to: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
amount: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
static args: {};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export default DecompressSolCommand;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
const stateless_js_1 = require("@lightprotocol/stateless.js");
|
|
7
|
+
const hasher_rs_1 = require("@lightprotocol/hasher.rs");
|
|
8
|
+
class DecompressSolCommand extends core_1.Command {
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags } = await this.parse(DecompressSolCommand);
|
|
11
|
+
const to = flags["to"];
|
|
12
|
+
const amount = flags["amount"];
|
|
13
|
+
if (!to || !amount) {
|
|
14
|
+
throw new Error("Invalid arguments");
|
|
15
|
+
}
|
|
16
|
+
const loader = new utils_1.CustomLoader(`Performing decompress-sol...\n`);
|
|
17
|
+
loader.start();
|
|
18
|
+
try {
|
|
19
|
+
const toPublicKey = new web3_js_1.PublicKey(to);
|
|
20
|
+
const payer = (0, utils_1.defaultSolanaWalletKeypair)();
|
|
21
|
+
const lightWasm = await hasher_rs_1.WasmFactory.getInstance();
|
|
22
|
+
const rpc = await (0, stateless_js_1.getTestRpc)(lightWasm);
|
|
23
|
+
const txId = await (0, stateless_js_1.decompress)(rpc, payer, amount, toPublicKey);
|
|
24
|
+
loader.stop(false);
|
|
25
|
+
console.log("\x1b[32mdecompress-sol:\x1b[0m ", (0, utils_1.generateSolanaTransactionURL)("tx", txId, "custom"));
|
|
26
|
+
console.log("decompress-sol successful");
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
this.error(`Failed to decompress-sol!\n${error}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
DecompressSolCommand.summary = "Decompress SOL.";
|
|
34
|
+
DecompressSolCommand.examples = ["$ light decompress-sol --to PublicKey --amount 10"];
|
|
35
|
+
DecompressSolCommand.flags = {
|
|
36
|
+
to: core_1.Flags.string({
|
|
37
|
+
description: "Specify the recipient address.",
|
|
38
|
+
required: true,
|
|
39
|
+
}),
|
|
40
|
+
amount: core_1.Flags.integer({
|
|
41
|
+
description: "Amount to decompress, in lamports.",
|
|
42
|
+
required: true,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
DecompressSolCommand.args = {};
|
|
46
|
+
exports.default = DecompressSolCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
declare class DecompressSplCommand extends Command {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
mint: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
to: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
amount: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static args: {};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export default DecompressSplCommand;
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
const stateless_js_1 = require("@lightprotocol/stateless.js");
|
|
7
|
+
const compressed_token_1 = require("@lightprotocol/compressed-token");
|
|
8
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
9
|
+
const hasher_rs_1 = require("@lightprotocol/hasher.rs");
|
|
10
|
+
/// TODO: add ability to decompress from non-fee payer
|
|
11
|
+
class DecompressSplCommand extends core_1.Command {
|
|
12
|
+
async run() {
|
|
13
|
+
const { flags } = await this.parse(DecompressSplCommand);
|
|
14
|
+
const to = flags["to"];
|
|
15
|
+
const mint = flags["mint"];
|
|
16
|
+
const amount = flags["amount"];
|
|
17
|
+
if (!to || !mint || !amount) {
|
|
18
|
+
throw new Error("Invalid arguments");
|
|
19
|
+
}
|
|
20
|
+
const loader = new utils_1.CustomLoader(`Performing decompress-spl...\n`);
|
|
21
|
+
loader.start();
|
|
22
|
+
let txId;
|
|
23
|
+
try {
|
|
24
|
+
const toPublicKey = new web3_js_1.PublicKey(to);
|
|
25
|
+
const mintPublicKey = new web3_js_1.PublicKey(mint);
|
|
26
|
+
const payer = (0, utils_1.defaultSolanaWalletKeypair)();
|
|
27
|
+
const lightWasm = await hasher_rs_1.WasmFactory.getInstance();
|
|
28
|
+
const rpc = await (0, stateless_js_1.getTestRpc)(lightWasm);
|
|
29
|
+
const recipientAta = await (0, spl_token_1.getOrCreateAssociatedTokenAccount)(rpc, payer, mintPublicKey, toPublicKey);
|
|
30
|
+
txId = await (0, compressed_token_1.decompress)(rpc, payer, mintPublicKey, amount, payer, recipientAta.address);
|
|
31
|
+
loader.stop(false);
|
|
32
|
+
console.log("\x1b[32mtxId:\x1b[0m ", (0, utils_1.generateSolanaTransactionURL)("tx", txId, "custom"));
|
|
33
|
+
console.log("decompress-spl successful");
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.log("decompress-spl failed", txId);
|
|
37
|
+
this.error(`Failed to decompress-spl!\n${error}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
DecompressSplCommand.summary = "Decompress into SPL tokens.";
|
|
42
|
+
DecompressSplCommand.examples = [
|
|
43
|
+
"$ light decompress-spl --mint PublicKey --to PublicKey --amount 10",
|
|
44
|
+
];
|
|
45
|
+
DecompressSplCommand.flags = {
|
|
46
|
+
mint: core_1.Flags.string({
|
|
47
|
+
description: "Specify the mint address.",
|
|
48
|
+
required: true,
|
|
49
|
+
}),
|
|
50
|
+
to: core_1.Flags.string({
|
|
51
|
+
description: "Specify the recipient address. (owner of destination token account)",
|
|
52
|
+
required: true,
|
|
53
|
+
}),
|
|
54
|
+
amount: core_1.Flags.integer({
|
|
55
|
+
description: "Amount to decompress, in tokens.",
|
|
56
|
+
required: true,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
DecompressSplCommand.args = {};
|
|
60
|
+
exports.default = DecompressSplCommand;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
declare class MintToCommand extends Command {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
"mint-authority": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
mint: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
to: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
amount: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
static args: {};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export default MintToCommand;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 helpers_1 = require("@solana-developers/helpers");
|
|
6
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
7
|
+
const compressed_token_1 = require("@lightprotocol/compressed-token");
|
|
8
|
+
const stateless_js_1 = require("@lightprotocol/stateless.js");
|
|
9
|
+
const hasher_rs_1 = require("@lightprotocol/hasher.rs");
|
|
10
|
+
class MintToCommand extends core_1.Command {
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(MintToCommand);
|
|
13
|
+
const mint = flags["mint"];
|
|
14
|
+
const to = flags["to"];
|
|
15
|
+
const amount = flags["amount"];
|
|
16
|
+
if (!mint || !to || !amount) {
|
|
17
|
+
throw new Error("Invalid arguments");
|
|
18
|
+
}
|
|
19
|
+
const loader = new utils_1.CustomLoader(`Performing mint-to...\n`);
|
|
20
|
+
loader.start();
|
|
21
|
+
try {
|
|
22
|
+
const mintPublicKey = new web3_js_1.PublicKey(mint);
|
|
23
|
+
const toPublicKey = new web3_js_1.PublicKey(to);
|
|
24
|
+
const payer = (0, utils_1.defaultSolanaWalletKeypair)();
|
|
25
|
+
let mintAuthority = payer;
|
|
26
|
+
if (flags["mint-authority"] !== undefined) {
|
|
27
|
+
mintAuthority = await (0, helpers_1.getKeypairFromFile)(flags["mint-authority"]);
|
|
28
|
+
}
|
|
29
|
+
const lightWasm = await hasher_rs_1.WasmFactory.getInstance();
|
|
30
|
+
const rpc = await (0, stateless_js_1.getTestRpc)(lightWasm);
|
|
31
|
+
const txId = await (0, compressed_token_1.mintTo)(rpc, payer, mintPublicKey, toPublicKey, mintAuthority, amount);
|
|
32
|
+
loader.stop(false);
|
|
33
|
+
console.log("\x1b[1mMint tx:\x1b[0m ", (0, utils_1.generateSolanaTransactionURL)("tx", txId, "custom"));
|
|
34
|
+
console.log("mint-to successful");
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
this.error(`Failed to create-mint!\n${error}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
MintToCommand.summary = "Mint tokens to an account.";
|
|
42
|
+
MintToCommand.examples = [
|
|
43
|
+
"$ light mint-to --mint PublicKey --to PublicKey --amount 1000",
|
|
44
|
+
];
|
|
45
|
+
MintToCommand.flags = {
|
|
46
|
+
"mint-authority": core_1.Flags.string({
|
|
47
|
+
description: "Specify the filepath of the mint authority keypair. Defaults to your local solana wallet.",
|
|
48
|
+
required: false,
|
|
49
|
+
}),
|
|
50
|
+
mint: core_1.Flags.string({
|
|
51
|
+
description: "Specify the mint address.",
|
|
52
|
+
required: true,
|
|
53
|
+
}),
|
|
54
|
+
to: core_1.Flags.string({
|
|
55
|
+
description: "Specify the recipient address.",
|
|
56
|
+
required: true,
|
|
57
|
+
}),
|
|
58
|
+
amount: core_1.Flags.integer({
|
|
59
|
+
description: "Amount to mint, in tokens.",
|
|
60
|
+
required: true,
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
MintToCommand.args = {};
|
|
64
|
+
exports.default = MintToCommand;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { Keypair } from "@solana/web3.js";
|
|
3
|
+
declare class RegisterMintCommand extends Command {
|
|
4
|
+
static summary: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
mint: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
"mint-authority": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static args: {};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
getMintAuthority(flags: any, payer: Keypair): Promise<Keypair>;
|
|
13
|
+
}
|
|
14
|
+
export default RegisterMintCommand;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const helpers_1 = require("@solana-developers/helpers");
|
|
5
|
+
const utils_1 = require("../../utils/utils");
|
|
6
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
7
|
+
const stateless_js_1 = require("@lightprotocol/stateless.js");
|
|
8
|
+
const compressed_token_1 = require("@lightprotocol/compressed-token");
|
|
9
|
+
const hasher_rs_1 = require("@lightprotocol/hasher.rs");
|
|
10
|
+
class RegisterMintCommand extends core_1.Command {
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(RegisterMintCommand);
|
|
13
|
+
const loader = new utils_1.CustomLoader(`Performing register-mint...\n`);
|
|
14
|
+
loader.start();
|
|
15
|
+
try {
|
|
16
|
+
const payer = (0, utils_1.defaultSolanaWalletKeypair)();
|
|
17
|
+
const mintAddress = new web3_js_1.PublicKey(flags.mint);
|
|
18
|
+
const mintAuthority = await this.getMintAuthority(flags, payer);
|
|
19
|
+
const lightWasm = await hasher_rs_1.WasmFactory.getInstance();
|
|
20
|
+
const rpc = await (0, stateless_js_1.getTestRpc)(lightWasm);
|
|
21
|
+
const txId = await (0, compressed_token_1.registerMint)(rpc, payer, mintAuthority, mintAddress);
|
|
22
|
+
loader.stop(false);
|
|
23
|
+
console.log("\x1b[1mMint public key:\x1b[0m ", mintAddress.toBase58());
|
|
24
|
+
console.log("\x1b[1mMint tx:\x1b[0m ", (0, utils_1.generateSolanaTransactionURL)("tx", txId, "custom"));
|
|
25
|
+
console.log("register-mint successful");
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
this.error(`Failed to register-mint!\n${error}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async getMintAuthority(flags, payer) {
|
|
32
|
+
return flags["mint-authority"]
|
|
33
|
+
? await (0, helpers_1.getKeypairFromFile)(flags["mint-authority"])
|
|
34
|
+
: payer;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
RegisterMintCommand.summary = "Register an existing mint with the CompressedToken program";
|
|
38
|
+
RegisterMintCommand.examples = ["$ light register-mint --mint-decimals 5"];
|
|
39
|
+
RegisterMintCommand.flags = {
|
|
40
|
+
mint: core_1.Flags.string({
|
|
41
|
+
description: "Provide a base58 encoded mint address to register",
|
|
42
|
+
required: true,
|
|
43
|
+
}),
|
|
44
|
+
"mint-authority": core_1.Flags.string({
|
|
45
|
+
description: "Specify a path to the mint authority keypair file. Defaults to your default local solana wallet file path",
|
|
46
|
+
required: false,
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
RegisterMintCommand.args = {};
|
|
50
|
+
exports.default = RegisterMintCommand;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
declare class StartProver extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
protected finally(_: Error | undefined): Promise<any>;
|
|
5
|
+
static flags: {
|
|
6
|
+
"skip-prove-compressed-accounts": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
"skip-prove-new-addresses": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export default StartProver;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const index_1 = require("../../utils/index");
|
|
5
|
+
class StartProver extends core_1.Command {
|
|
6
|
+
finally(_) {
|
|
7
|
+
process.exit();
|
|
8
|
+
}
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags } = await this.parse(StartProver);
|
|
11
|
+
const loader = new index_1.CustomLoader("Performing setup tasks...\n");
|
|
12
|
+
loader.start();
|
|
13
|
+
await (0, index_1.startProver)(!flags["skip-prove-compressed-accounts"], !flags["skip-prove-new-addresses"]);
|
|
14
|
+
this.log("\nSetup tasks completed successfully \x1b[32m✔\x1b[0m");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
StartProver.description = "Start gnark prover";
|
|
18
|
+
StartProver.flags = {
|
|
19
|
+
"skip-prove-compressed-accounts": core_1.Flags.boolean({
|
|
20
|
+
description: "Skip proving of compressed accounts.",
|
|
21
|
+
default: false,
|
|
22
|
+
char: "c",
|
|
23
|
+
}),
|
|
24
|
+
"skip-prove-new-addresses": core_1.Flags.boolean({
|
|
25
|
+
description: "Skip proving of new addresses.",
|
|
26
|
+
default: false,
|
|
27
|
+
char: "n",
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
exports.default = StartProver;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
declare class SetupCommand extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
protected finally(_: Error | undefined): Promise<any>;
|
|
5
|
+
static flags: {
|
|
6
|
+
"skip-indexer": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
"skip-prover": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
"skip-system-accounts": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
"prove-compressed-accounts": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
"prove-new-addresses": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
"relax-indexer-version-constraint": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
"indexer-db-url": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export default SetupCommand;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const initTestEnv_1 = require("../../utils/initTestEnv");
|
|
5
|
+
const index_1 = require("../../utils/index");
|
|
6
|
+
class SetupCommand extends core_1.Command {
|
|
7
|
+
finally(_) {
|
|
8
|
+
process.exit();
|
|
9
|
+
}
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(SetupCommand);
|
|
12
|
+
const loader = new index_1.CustomLoader("Performing setup tasks...\n");
|
|
13
|
+
loader.start();
|
|
14
|
+
await (0, initTestEnv_1.initTestEnv)({
|
|
15
|
+
skipSystemAccounts: flags["skip-system-accounts"],
|
|
16
|
+
indexer: !flags["skip-indexer"],
|
|
17
|
+
prover: !flags["skip-prover"],
|
|
18
|
+
proveCompressedAccounts: flags["prove-compressed-accounts"],
|
|
19
|
+
proveNewAddresses: flags["prove-new-addresses"],
|
|
20
|
+
checkPhotonVersion: !flags["relax-indexer-version-constraint"],
|
|
21
|
+
photonDatabaseUrl: flags["indexer-db-url"],
|
|
22
|
+
});
|
|
23
|
+
this.log("\nSetup tasks completed successfully \x1b[32m✔\x1b[0m");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
SetupCommand.description = "Perform setup tasks";
|
|
27
|
+
SetupCommand.flags = {
|
|
28
|
+
"skip-indexer": core_1.Flags.boolean({
|
|
29
|
+
description: "Runs a test validator without starting a new indexer.",
|
|
30
|
+
default: false,
|
|
31
|
+
}),
|
|
32
|
+
"skip-prover": core_1.Flags.boolean({
|
|
33
|
+
description: "Runs a test validator without starting a new prover service.",
|
|
34
|
+
default: false,
|
|
35
|
+
}),
|
|
36
|
+
"skip-system-accounts": core_1.Flags.boolean({
|
|
37
|
+
description: "Runs a test validator without initialized light system accounts.",
|
|
38
|
+
default: false,
|
|
39
|
+
}),
|
|
40
|
+
"prove-compressed-accounts": core_1.Flags.boolean({
|
|
41
|
+
description: "Enable proving of compressed accounts.",
|
|
42
|
+
default: true,
|
|
43
|
+
exclusive: ["skip-prover"],
|
|
44
|
+
}),
|
|
45
|
+
"prove-new-addresses": core_1.Flags.boolean({
|
|
46
|
+
description: "Enable proving of new addresses.",
|
|
47
|
+
default: false,
|
|
48
|
+
exclusive: ["skip-prover"],
|
|
49
|
+
}),
|
|
50
|
+
"relax-indexer-version-constraint": core_1.Flags.boolean({
|
|
51
|
+
description: "Disables indexer version check. Only use if you know what you are doing.",
|
|
52
|
+
default: false,
|
|
53
|
+
exclusive: ["skip-indexer"],
|
|
54
|
+
}),
|
|
55
|
+
"indexer-db-url": core_1.Flags.string({
|
|
56
|
+
description: "Custom indexer database URL to store indexing data. By default we use an in-memory SQLite database.",
|
|
57
|
+
required: false,
|
|
58
|
+
exclusive: ["skip-indexer"],
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
exports.default = SetupCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
declare class TransferCommand extends Command {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
mint: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
to: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
amount: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
"fee-payer": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export default TransferCommand;
|
|
@@ -0,0 +1,62 @@
|
|
|
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 compressed_token_1 = require("@lightprotocol/compressed-token");
|
|
6
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
7
|
+
const helpers_1 = require("@solana-developers/helpers");
|
|
8
|
+
const stateless_js_1 = require("@lightprotocol/stateless.js");
|
|
9
|
+
const hasher_rs_1 = require("@lightprotocol/hasher.rs");
|
|
10
|
+
class TransferCommand extends core_1.Command {
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(TransferCommand);
|
|
13
|
+
const loader = new utils_1.CustomLoader(`Performing transfer...\n`);
|
|
14
|
+
loader.start();
|
|
15
|
+
try {
|
|
16
|
+
const mint = flags["mint"];
|
|
17
|
+
const to = flags["to"];
|
|
18
|
+
const amount = flags["amount"];
|
|
19
|
+
if (!mint || !to || !amount) {
|
|
20
|
+
throw new Error("Invalid arguments");
|
|
21
|
+
}
|
|
22
|
+
const mintPublicKey = new web3_js_1.PublicKey(mint);
|
|
23
|
+
const toPublicKey = new web3_js_1.PublicKey(to);
|
|
24
|
+
let payer = (0, utils_1.defaultSolanaWalletKeypair)();
|
|
25
|
+
if (flags["fee-payer"] !== undefined) {
|
|
26
|
+
payer = await (0, helpers_1.getKeypairFromFile)(flags["fee-payer"]);
|
|
27
|
+
}
|
|
28
|
+
const lightWasm = await hasher_rs_1.WasmFactory.getInstance();
|
|
29
|
+
const rpc = await (0, stateless_js_1.getTestRpc)(lightWasm);
|
|
30
|
+
const txId = await (0, compressed_token_1.transfer)(rpc, payer, mintPublicKey, amount, payer, toPublicKey);
|
|
31
|
+
loader.stop(false);
|
|
32
|
+
console.log("\x1b[1mTransfer tx:\x1b[0m ", (0, utils_1.generateSolanaTransactionURL)("tx", txId, "custom"));
|
|
33
|
+
console.log("transfer successful");
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
this.error(`Failed to transfer!\n${error}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
TransferCommand.summary = "Transfer tokens from one account to another.";
|
|
41
|
+
TransferCommand.examples = [
|
|
42
|
+
"$ light transfer --mint PublicKey --to PublicKey --amount 1000",
|
|
43
|
+
];
|
|
44
|
+
TransferCommand.flags = {
|
|
45
|
+
mint: core_1.Flags.string({
|
|
46
|
+
description: "Mint to transfer",
|
|
47
|
+
required: true,
|
|
48
|
+
}),
|
|
49
|
+
to: core_1.Flags.string({
|
|
50
|
+
description: "Recipient address",
|
|
51
|
+
required: true,
|
|
52
|
+
}),
|
|
53
|
+
amount: core_1.Flags.integer({
|
|
54
|
+
description: "Amount to send, in tokens",
|
|
55
|
+
required: true,
|
|
56
|
+
}),
|
|
57
|
+
"fee-payer": core_1.Flags.string({
|
|
58
|
+
description: "Specify the fee-payer account. Defaults to the client keypair.",
|
|
59
|
+
required: false,
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
exports.default = TransferCommand;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.run = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
var core_1 = require("@oclif/core");
|
|
6
|
+
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
|
|
7
|
+
tslib_1.__exportStar(require("./utils"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./psp-utils"), exports);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downloads a file from the given URL to the given local file path.
|
|
3
|
+
* @param localFilePath - The local file path to download the file to. If
|
|
4
|
+
* provided and the download file is an archive, only the file with the same
|
|
5
|
+
* name as `localFilePath` will be extracted from the archive. If not provided,
|
|
6
|
+
* all files will be extracted to `dirPath`.
|
|
7
|
+
* @param dirPath - The path to the directory where the file(s) will be created.
|
|
8
|
+
* @param url - The URL to download the file from.
|
|
9
|
+
* @returns {Promise<void>}
|
|
10
|
+
*/
|
|
11
|
+
export declare function downloadFile({ localFilePath, dirPath, url, }: {
|
|
12
|
+
localFilePath?: string;
|
|
13
|
+
dirPath: string;
|
|
14
|
+
url: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Download a binary from the given release artifact of the GitHub repository,
|
|
18
|
+
* if it was not already downloaded.
|
|
19
|
+
* @param localFilePath - The path to the local file (which either already
|
|
20
|
+
* exists or will be created).
|
|
21
|
+
* @param dirPath - The path to the directory where the file(s) will be created.
|
|
22
|
+
* @param owner - The owner of the GitHub repository.
|
|
23
|
+
* @param repoName - The name of the GitHub repository.
|
|
24
|
+
* @param remoteFileName - The name of the file in the GitHub release artifact.
|
|
25
|
+
* @returns {Promise<void>}
|
|
26
|
+
*/
|
|
27
|
+
export declare function downloadBinIfNotExists({ localFilePath, dirPath, owner, repoName, remoteFileName, tag, }: {
|
|
28
|
+
localFilePath: string;
|
|
29
|
+
dirPath: string;
|
|
30
|
+
owner: string;
|
|
31
|
+
repoName: string;
|
|
32
|
+
remoteFileName: string;
|
|
33
|
+
tag?: string;
|
|
34
|
+
}): Promise<void>;
|