diff --git a/clients/cli/commands/fetch/shard.ts b/clients/cli/commands/fetch/shard.ts new file mode 100644 index 0000000..294b401 --- /dev/null +++ b/clients/cli/commands/fetch/shard.ts @@ -0,0 +1,28 @@ +import { fetchInscriptionMetadataFromSeeds, fetchInscriptionShardFromSeeds, findMintInscriptionPda, mplInscription } from "@metaplex-foundation/mpl-inscription"; +import { PublicKey } from "@metaplex-foundation/umi"; +import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; +import { writeFileSync } from "fs"; +import pMap from "p-map"; + +export async function fetchShard(rpc: string, shards: number[], concurrency: number, output: string) { + const umi = createUmi(rpc); + umi.use(mplInscription()); + + const shardAccounts = await pMap(shards, async (shard) => { + let shardAccount = await fetchInscriptionShardFromSeeds(umi, { + shardNumber: shard + }); + + delete shardAccount["header"]; + + shardAccount["realCount"] = Number(shardAccount.count) * 32 + shardAccount.shardNumber; + + return shardAccount; + }, { concurrency }); + + writeFileSync(output, JSON.stringify([...shardAccounts], (key, value) => + typeof value === 'bigint' + ? value.toString() + : value, + 2)); +} \ No newline at end of file diff --git a/clients/cli/index.ts b/clients/cli/index.ts index 05bec34..d17aefc 100644 --- a/clients/cli/index.ts +++ b/clients/cli/index.ts @@ -11,6 +11,7 @@ import { compress_images } from './commands/compress/images.js'; import { compress_json } from './commands/compress/json.js'; import { fetchInscriptionsByMint } from './commands/fetch/nft.js'; import { fetchInscriptionsByRank } from './commands/fetch/number.js'; +import { fetchShard } from './commands/fetch/shard.js'; const program = new Command(); @@ -170,6 +171,20 @@ fetchCmd.command('rank') await fetchInscriptionsByRank(rpc, ranks, parseInt(concurrency), output); }); +fetchCmd.command('shard') + .description('Print a Shard\'s data') + .option('-r --rpc ', 'The endpoint to connect to.') + .option('-n --shards ', 'The shard number') + .option('-c --concurrency ', 'Number of concurrent writes to perform', '10') + .option('-o --output ', 'Output file', 'output.json') + .action(async (str, options) => { + const { rpc, shards, concurrency, output } = options.opts(); + + const shardNumbers = shards.map((shard: string) => parseInt(shard)); + + await fetchShard(rpc, shardNumbers, parseInt(concurrency), output); + }); + const createCmd = program.command('create'); createCmd.command('shards') @@ -178,6 +193,7 @@ createCmd.command('shards') .option('-k --keypair ', 'Solana wallet location') .action(create_shards); + const testCmd = program.command('test'); testCmd.command('create_collection') diff --git a/clients/cli/output1.json b/clients/cli/output1.json new file mode 100644 index 0000000..9a99ae4 --- /dev/null +++ b/clients/cli/output1.json @@ -0,0 +1,258 @@ +[ + { + "publicKey": "GSp4Gw1zdtfMeV731F1kg8i3zv2y1vFfzLopdFuBMwMi", + "key": 3, + "bump": 255, + "shardNumber": 0, + "count": "2934", + "realCount": 93888 + }, + { + "publicKey": "76BsfqxZgmVg114yYtLFBopv6NAqvnxgcLvPKhxUMRHg", + "key": 3, + "bump": 251, + "shardNumber": 1, + "count": "3006", + "realCount": 96193 + }, + { + "publicKey": "4MDUEHvaJJ4xZ1WpB9MQcZi8s3UBsUwnWjoT8UuLDYwX", + "key": 3, + "bump": 255, + "shardNumber": 2, + "count": "2952", + "realCount": 94466 + }, + { + "publicKey": "DeqiwGEENcwy5NNVvgwzC1KavrauMjdnJ9K9zkc9eNj9", + "key": 3, + "bump": 254, + "shardNumber": 3, + "count": "2933", + "realCount": 93859 + }, + { + "publicKey": "6DrvZbrRsCB3WdbFyqTX45YobEY1ncjYhucYHkM2TMXJ", + "key": 3, + "bump": 255, + "shardNumber": 4, + "count": "2915", + "realCount": 93284 + }, + { + "publicKey": "2uxDRa888ANKQdqgXFYtCGdmJcCv3ouWtupsVWT6WJre", + "key": 3, + "bump": 255, + "shardNumber": 5, + "count": "2956", + "realCount": 94597 + }, + { + "publicKey": "CWsZMMav3KRRHSHXaQogVfnCekvNSUQRWQPeFHwbssSE", + "key": 3, + "bump": 253, + "shardNumber": 6, + "count": "2966", + "realCount": 94918 + }, + { + "publicKey": "14Nc84kfh3DQa4Kfepdyp9tes3ywST4cpzzELsdgNsTg", + "key": 3, + "bump": 254, + "shardNumber": 7, + "count": "2965", + "realCount": 94887 + }, + { + "publicKey": "57rsuF1Wi4fYYhPVRtvKhcDViePNurVmPmdwrdie5nyT", + "key": 3, + "bump": 253, + "shardNumber": 8, + "count": "2940", + "realCount": 94088 + }, + { + "publicKey": "HDG5yhSrB6dENWoHsTcVjm7gBd5bnGizhHTMidyPgakf", + "key": 3, + "bump": 251, + "shardNumber": 9, + "count": "2999", + "realCount": 95977 + }, + { + "publicKey": "9ZehrpDrwDxSTYZCAUs41nTvSTZfAqdzPmMqki8t1B2s", + "key": 3, + "bump": 255, + "shardNumber": 10, + "count": "2933", + "realCount": 93866 + }, + { + "publicKey": "BamGvQooPhsLWYREzCAtPdoboJWHrgyaPSVarNemNTms", + "key": 3, + "bump": 254, + "shardNumber": 11, + "count": "2939", + "realCount": 94059 + }, + { + "publicKey": "5tgjWMGGrYfKHwTaR8zg7tx4sh4DcTs3oKt2fXvDUFvL", + "key": 3, + "bump": 255, + "shardNumber": 12, + "count": "2917", + "realCount": 93356 + }, + { + "publicKey": "8aaSW1NsfdcxJw94vSTstGrv9jA41PhixAnoumMQ1vEU", + "key": 3, + "bump": 255, + "shardNumber": 13, + "count": "2934", + "realCount": 93901 + }, + { + "publicKey": "pNntqtzeZNJp6HJLVGhjq1DZgKCyq93VbVfgWQ3KbBX", + "key": 3, + "bump": 251, + "shardNumber": 14, + "count": "2932", + "realCount": 93838 + }, + { + "publicKey": "2kxRVydDG25U1tALXNout5YzUf8jgEhQhXBvaxvVR9rW", + "key": 3, + "bump": 255, + "shardNumber": 15, + "count": "2937", + "realCount": 93999 + }, + { + "publicKey": "4oJtYyuTG3vTjKae57NLdnCZPLbMquApjzKfW5nsKiLT", + "key": 3, + "bump": 255, + "shardNumber": 16, + "count": "3004", + "realCount": 96144 + }, + { + "publicKey": "7nEZkA66iuFByWfNokbHLmHCwDaCHNzhPi55Er57BPLQ", + "key": 3, + "bump": 255, + "shardNumber": 17, + "count": "2950", + "realCount": 94417 + }, + { + "publicKey": "848cGmcwAH35ZHiN36e1Zu9zbLa8ropepDtsK2CCc8BV", + "key": 3, + "bump": 255, + "shardNumber": 18, + "count": "2949", + "realCount": 94386 + }, + { + "publicKey": "7rAKQSRg9AB4gqzmidxNBiZnaqMHh2cgS3fy3inLpmSb", + "key": 3, + "bump": 253, + "shardNumber": 19, + "count": "2924", + "realCount": 93587 + }, + { + "publicKey": "AGSCoWHFb29mYiw2GUjim6YBw1KZARvixesCQcEpX8h2", + "key": 3, + "bump": 253, + "shardNumber": 20, + "count": "2981", + "realCount": 95412 + }, + { + "publicKey": "2gGv79zWgLXwPKTr2qXrQf9n19mMUx8wN4V4Udr9bhRu", + "key": 3, + "bump": 254, + "shardNumber": 21, + "count": "2996", + "realCount": 95893 + }, + { + "publicKey": "3UnU7WvgqRGsvih47A99FSbChmpkXskWv2twRij4wvqq", + "key": 3, + "bump": 254, + "shardNumber": 22, + "count": "2986", + "realCount": 95574 + }, + { + "publicKey": "Dv3yWqy8MzJm7oikQX3ZY8AuNECSweUcWPPuhMm56Tps", + "key": 3, + "bump": 255, + "shardNumber": 23, + "count": "2962", + "realCount": 94807 + }, + { + "publicKey": "DHKCH9mh8fDM3zzJKBYkgTCmWia7A7se2soh1NdQgNmR", + "key": 3, + "bump": 252, + "shardNumber": 24, + "count": "2935", + "realCount": 93944 + }, + { + "publicKey": "7uZqim6zwBQHaQDx5u7UJBCE3j9FsqH21y8ZYZLWYQWR", + "key": 3, + "bump": 255, + "shardNumber": 25, + "count": "2923", + "realCount": 93561 + }, + { + "publicKey": "GBWn2Nm1DyBzn8YxUbsyF3KvRGa1Jd76mw3pza9eBNNb", + "key": 3, + "bump": 255, + "shardNumber": 26, + "count": "3010", + "realCount": 96346 + }, + { + "publicKey": "7WGXpa1gLaj9cDbhMwp7t63thykWRCdWALXhv6v29v35", + "key": 3, + "bump": 254, + "shardNumber": 27, + "count": "2999", + "realCount": 95995 + }, + { + "publicKey": "G3DDQ1nyMk66hZkBxJd7eLvzAFY4a5h1kqqusDPnRGji", + "key": 3, + "bump": 255, + "shardNumber": 28, + "count": "2943", + "realCount": 94204 + }, + { + "publicKey": "3Sc2KPX3oXk2i4S9H7N8fn3DJFsd1vm6FNehhGhWbUfX", + "key": 3, + "bump": 255, + "shardNumber": 29, + "count": "2965", + "realCount": 94909 + }, + { + "publicKey": "7C1TqRFnodrAnLvaKRd9K4VLwkSpRBZH4e58xWhEc6qG", + "key": 3, + "bump": 253, + "shardNumber": 30, + "count": "2953", + "realCount": 94526 + }, + { + "publicKey": "AjxaQHcVyVpcF5ybeJ1SAe4XhRMW5QNPqH7RxuiA5PjK", + "key": 3, + "bump": 255, + "shardNumber": 31, + "count": "2936", + "realCount": 93983 + } +] \ No newline at end of file