feat: add cli
This commit is contained in:
parent
a8b769d70f
commit
87922cd998
|
@ -17,13 +17,11 @@ import {
|
||||||
SYSVAR_RENT_PUBKEY,
|
SYSVAR_RENT_PUBKEY,
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
} from '@solana/web3.js';
|
} from '@solana/web3.js';
|
||||||
import { token } from '@project-serum/anchor/dist/utils';
|
|
||||||
|
|
||||||
const CACHE_PATH = './.cache';
|
const CACHE_PATH = './.cache';
|
||||||
const PAYMENT_WALLET = new anchor.web3.PublicKey(
|
const PAYMENT_WALLET = new anchor.web3.PublicKey(
|
||||||
'HvwC9QSAzvGXhhVrgPmauVwFWcYZhne3hVot9EbHuFTm',
|
'HvwC9QSAzvGXhhVrgPmauVwFWcYZhne3hVot9EbHuFTm',
|
||||||
);
|
);
|
||||||
const ENV = 'devnet';
|
|
||||||
const CANDY_MACHINE = 'candy_machine';
|
const CANDY_MACHINE = 'candy_machine';
|
||||||
|
|
||||||
const programId = new anchor.web3.PublicKey(
|
const programId = new anchor.web3.PublicKey(
|
||||||
|
@ -196,7 +194,6 @@ const createConfig = async function (
|
||||||
|
|
||||||
const config = anchor.web3.Keypair.generate();
|
const config = anchor.web3.Keypair.generate();
|
||||||
const uuid = config.publicKey.toBase58().slice(0, 6);
|
const uuid = config.publicKey.toBase58().slice(0, 6);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
config: config.publicKey,
|
config: config.publicKey,
|
||||||
uuid,
|
uuid,
|
||||||
|
@ -250,10 +247,12 @@ program
|
||||||
.option('-s, --start-with', 'Image index to start with', '0')
|
.option('-s, --start-with', 'Image index to start with', '0')
|
||||||
.option('-n, --number', 'Number of images to upload', '10000')
|
.option('-n, --number', 'Number of images to upload', '10000')
|
||||||
.option('-c, --cache-name <path>', 'Cache file name')
|
.option('-c, --cache-name <path>', 'Cache file name')
|
||||||
|
.option('-e, --env <name>', 'Environment')
|
||||||
.action(async (files: string[], options, cmd) => {
|
.action(async (files: string[], options, cmd) => {
|
||||||
const extension = '.png';
|
const extension = '.png';
|
||||||
const { startWith, keypair } = cmd.opts();
|
const { startWith, keypair } = cmd.opts();
|
||||||
const cacheName = program.getOptionValue('cacheName') || 'temp';
|
const cacheName = program.getOptionValue('cacheName') || 'temp';
|
||||||
|
const ENV = program.getOptionValue('env') || 'devnet';
|
||||||
const cachePath = path.join(CACHE_PATH, cacheName);
|
const cachePath = path.join(CACHE_PATH, cacheName);
|
||||||
const savedContent = fs.existsSync(cachePath)
|
const savedContent = fs.existsSync(cachePath)
|
||||||
? JSON.parse(fs.readFileSync(cachePath).toString())
|
? JSON.parse(fs.readFileSync(cachePath).toString())
|
||||||
|
@ -512,7 +511,9 @@ program
|
||||||
.option('-k, --keypair <path>', 'Solana wallet')
|
.option('-k, --keypair <path>', 'Solana wallet')
|
||||||
.option('-c, --cache-name <path>', 'Cache file name')
|
.option('-c, --cache-name <path>', 'Cache file name')
|
||||||
.option('-d, --date <string>', 'timestamp - eg "04 Dec 1995 00:12:00 GMT"')
|
.option('-d, --date <string>', 'timestamp - eg "04 Dec 1995 00:12:00 GMT"')
|
||||||
|
.option('-e, --env <name>', 'Environment')
|
||||||
.action(async (directory, cmd) => {
|
.action(async (directory, cmd) => {
|
||||||
|
const ENV = program.getOptionValue('env') || 'devnet';
|
||||||
const solConnection = new anchor.web3.Connection(
|
const solConnection = new anchor.web3.Connection(
|
||||||
`https://api.${ENV}.solana.com/`,
|
`https://api.${ENV}.solana.com/`,
|
||||||
);
|
);
|
||||||
|
@ -559,7 +560,9 @@ program
|
||||||
.option('-k, --keypair <path>', 'Solana wallet')
|
.option('-k, --keypair <path>', 'Solana wallet')
|
||||||
.option('-c, --cache-name <path>', 'Cache file name')
|
.option('-c, --cache-name <path>', 'Cache file name')
|
||||||
.option('-p, --price <string>', 'SOL price')
|
.option('-p, --price <string>', 'SOL price')
|
||||||
|
.option('-e, --env <name>', 'Environment')
|
||||||
.action(async (directory, cmd) => {
|
.action(async (directory, cmd) => {
|
||||||
|
const ENV = program.getOptionValue('env') || 'devnet';
|
||||||
const solConnection = new anchor.web3.Connection(
|
const solConnection = new anchor.web3.Connection(
|
||||||
`https://api.${ENV}.solana.com/`,
|
`https://api.${ENV}.solana.com/`,
|
||||||
);
|
);
|
||||||
|
@ -618,7 +621,9 @@ program
|
||||||
.command('mint_one_token')
|
.command('mint_one_token')
|
||||||
.option('-k, --keypair <path>', `The purchaser's wallet key`)
|
.option('-k, --keypair <path>', `The purchaser's wallet key`)
|
||||||
.option('-c, --cache-name <path>', 'Cache file name')
|
.option('-c, --cache-name <path>', 'Cache file name')
|
||||||
|
.option('-e, --env <name>', 'Environment')
|
||||||
.action(async (directory, cmd) => {
|
.action(async (directory, cmd) => {
|
||||||
|
const ENV = program.getOptionValue('env') || 'devnet';
|
||||||
const solConnection = new anchor.web3.Connection(
|
const solConnection = new anchor.web3.Connection(
|
||||||
`https://api.${ENV}.solana.com/`,
|
`https://api.${ENV}.solana.com/`,
|
||||||
);
|
);
|
||||||
|
@ -710,7 +715,9 @@ program
|
||||||
program
|
program
|
||||||
.command('verify')
|
.command('verify')
|
||||||
.option('-c, --cache-name <path>', 'Cache file name')
|
.option('-c, --cache-name <path>', 'Cache file name')
|
||||||
|
.option('-e, --env <name>', 'Environment')
|
||||||
.action(async (directory, second, options) => {
|
.action(async (directory, second, options) => {
|
||||||
|
const ENV = program.getOptionValue('env') || 'devnet';
|
||||||
const solConnection = new anchor.web3.Connection(
|
const solConnection = new anchor.web3.Connection(
|
||||||
`https://api.${ENV}.solana.com/`,
|
`https://api.${ENV}.solana.com/`,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue