Merge branch 'metaplex-foundation:master' into master

This commit is contained in:
stegaBOB 2021-09-13 20:44:08 -04:00 committed by GitHub
commit 3db534e9f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -35,7 +35,6 @@ programCommand('upload')
.option('-n, --number <number>', 'Number of images to upload') .option('-n, --number <number>', 'Number of images to upload')
.action(async (files: string[], options, cmd) => { .action(async (files: string[], options, cmd) => {
const {number, keypair, env, cacheName} = cmd.opts(); const {number, keypair, env, cacheName} = cmd.opts();
const parsedNumber = parseInt(number);
const pngFileCount = files.filter(it => { const pngFileCount = files.filter(it => {
return it.endsWith(EXTENSION_PNG); return it.endsWith(EXTENSION_PNG);
@ -44,18 +43,23 @@ programCommand('upload')
return it.endsWith(EXTENSION_JSON); return it.endsWith(EXTENSION_JSON);
}).length; }).length;
const parsedNumber = parseInt(number);
const elemCount = parsedNumber ? parsedNumber : pngFileCount;
if (pngFileCount !== jsonFileCount) { if (pngFileCount !== jsonFileCount) {
throw new Error(`number of png files (${pngFileCount}) is different than the number of json files (${jsonFileCount})`); throw new Error(`number of png files (${pngFileCount}) is different than the number of json files (${jsonFileCount})`);
} }
if (parsedNumber < pngFileCount) { if (elemCount < pngFileCount) {
throw new Error(`max number (${parsedNumber})cannot be smaller than the number of elements in the source folder (${pngFileCount})`); throw new Error(`max number (${elemCount})cannot be smaller than the number of elements in the source folder (${pngFileCount})`);
} }
log.info(`Beginning the upload for ${elemCount} (png+json) pairs`)
const startMs = Date.now(); const startMs = Date.now();
log.info("started at: " + startMs.toString()) log.info("started at: " + startMs.toString())
for (; ;) { for (; ;) {
const successful = await upload(files, cacheName, env, keypair, parsedNumber); const successful = await upload(files, cacheName, env, keypair, elemCount);
if (successful) { if (successful) {
break; break;
} else { } else {

View File

@ -148,6 +148,6 @@ export async function loadAnchorProgram(walletKeyPair: Keypair, env: string) {
const idl = await anchor.Program.fetchIdl(CANDY_MACHINE_PROGRAM_ID, provider); const idl = await anchor.Program.fetchIdl(CANDY_MACHINE_PROGRAM_ID, provider);
const program = new anchor.Program(idl, CANDY_MACHINE_PROGRAM_ID, provider); const program = new anchor.Program(idl, CANDY_MACHINE_PROGRAM_ID, provider);
log.info("program id from anchor", program.programId.toBase58()); log.debug("program id from anchor", program.programId.toBase58());
return program; return program;
} }