generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
375ccd5
commit 25f3fdf
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { fetchInscriptionMetadataFromSeeds, 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 fetchInscriptionsByMint(rpc: string, mints: PublicKey[], concurrency: number, output: string) { | ||
const umi = createUmi(rpc); | ||
umi.use(mplInscription()); | ||
|
||
const inscriptionMetadataAccounts = await pMap(mints, async (mint) => { | ||
const mintInscription = findMintInscriptionPda(umi, { mint }); | ||
const inscriptionMetadata = await fetchInscriptionMetadataFromSeeds(umi, { inscriptionAccount: mintInscription[0] }); | ||
delete inscriptionMetadata["header"]; | ||
delete inscriptionMetadata["padding"]; | ||
return inscriptionMetadata; | ||
}, { concurrency }); | ||
|
||
inscriptionMetadataAccounts.sort((a, b) => { | ||
if (a.inscriptionRank < b.inscriptionRank) { | ||
return -1; | ||
} | ||
if (a.inscriptionRank > b.inscriptionRank) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
|
||
writeFileSync(output, JSON.stringify([...inscriptionMetadataAccounts], (key, value) => | ||
typeof value === 'bigint' | ||
? value.toString() | ||
: value, | ||
2)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters