generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for setMint IX for backfilling.
- Loading branch information
1 parent
25f3fdf
commit b637a9f
Showing
15 changed files
with
813 additions
and
6 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
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
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
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,129 @@ | ||
/** | ||
* This code was AUTOGENERATED using the kinobi library. | ||
* Please DO NOT EDIT THIS FILE, instead use visitors | ||
* to add features, then rerun kinobi to update it. | ||
* | ||
* @see https://github.com/metaplex-foundation/kinobi | ||
*/ | ||
|
||
import { | ||
Context, | ||
Pda, | ||
PublicKey, | ||
Signer, | ||
TransactionBuilder, | ||
transactionBuilder, | ||
} from '@metaplex-foundation/umi'; | ||
import { | ||
Serializer, | ||
mapSerializer, | ||
struct, | ||
u8, | ||
} from '@metaplex-foundation/umi/serializers'; | ||
import { | ||
ResolvedAccount, | ||
ResolvedAccountsWithIndices, | ||
getAccountMetasAndSigners, | ||
} from '../shared'; | ||
|
||
// Accounts. | ||
export type SetMintInstructionAccounts = { | ||
/** The account where data is stored. */ | ||
mintInscriptionAccount: PublicKey | Pda; | ||
/** The account to store the inscription account's metadata in. */ | ||
inscriptionMetadataAccount: PublicKey | Pda; | ||
/** The mint that will be used to derive the PDA. */ | ||
mintAccount: PublicKey | Pda; | ||
/** The account that will pay for the transaction and rent. */ | ||
payer?: Signer; | ||
/** System program */ | ||
systemProgram?: PublicKey | Pda; | ||
}; | ||
|
||
// Data. | ||
export type SetMintInstructionData = { discriminator: number }; | ||
|
||
export type SetMintInstructionDataArgs = {}; | ||
|
||
export function getSetMintInstructionDataSerializer(): Serializer< | ||
SetMintInstructionDataArgs, | ||
SetMintInstructionData | ||
> { | ||
return mapSerializer<SetMintInstructionDataArgs, any, SetMintInstructionData>( | ||
struct<SetMintInstructionData>([['discriminator', u8()]], { | ||
description: 'SetMintInstructionData', | ||
}), | ||
(value) => ({ ...value, discriminator: 10 }) | ||
) as Serializer<SetMintInstructionDataArgs, SetMintInstructionData>; | ||
} | ||
|
||
// Instruction. | ||
export function setMint( | ||
context: Pick<Context, 'payer' | 'programs'>, | ||
input: SetMintInstructionAccounts | ||
): TransactionBuilder { | ||
// Program ID. | ||
const programId = context.programs.getPublicKey( | ||
'mplInscription', | ||
'1NSCRfGeyo7wPUazGbaPBUsTM49e1k2aXewHGARfzSo' | ||
); | ||
|
||
// Accounts. | ||
const resolvedAccounts: ResolvedAccountsWithIndices = { | ||
mintInscriptionAccount: { | ||
index: 0, | ||
isWritable: false, | ||
value: input.mintInscriptionAccount ?? null, | ||
}, | ||
inscriptionMetadataAccount: { | ||
index: 1, | ||
isWritable: true, | ||
value: input.inscriptionMetadataAccount ?? null, | ||
}, | ||
mintAccount: { | ||
index: 2, | ||
isWritable: false, | ||
value: input.mintAccount ?? null, | ||
}, | ||
payer: { index: 3, isWritable: true, value: input.payer ?? null }, | ||
systemProgram: { | ||
index: 4, | ||
isWritable: false, | ||
value: input.systemProgram ?? null, | ||
}, | ||
}; | ||
|
||
// Default values. | ||
if (!resolvedAccounts.payer.value) { | ||
resolvedAccounts.payer.value = context.payer; | ||
} | ||
if (!resolvedAccounts.systemProgram.value) { | ||
resolvedAccounts.systemProgram.value = context.programs.getPublicKey( | ||
'splSystem', | ||
'11111111111111111111111111111111' | ||
); | ||
resolvedAccounts.systemProgram.isWritable = false; | ||
} | ||
|
||
// Accounts in order. | ||
const orderedAccounts: ResolvedAccount[] = Object.values( | ||
resolvedAccounts | ||
).sort((a, b) => a.index - b.index); | ||
|
||
// Keys and Signers. | ||
const [keys, signers] = getAccountMetasAndSigners( | ||
orderedAccounts, | ||
'programId', | ||
programId | ||
); | ||
|
||
// Data. | ||
const data = getSetMintInstructionDataSerializer().serialize({}); | ||
|
||
// Bytes Created On Chain. | ||
const bytesCreatedOnChain = 0; | ||
|
||
return transactionBuilder([ | ||
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, | ||
]); | ||
} |
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
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
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
Oops, something went wrong.