// Generated Imports import * as Web3 from '@solana/web3.js'; import * as DataSource from '@staratlas/data-source'; // ---- BEGIN CUSTOM IMPORTS ---- import { AccountMeta, SYSVAR_INSTRUCTIONS_PUBKEY } from '@solana/web3.js'; import { CrewConfig, CrewIDLProgram, MintCrewMemberInput, mintCrewMemberAccounts, } from '@staratlas/crew'; import { SageIDLProgram } from './constants'; type MintKeys = { sageProgram: SageIDLProgram; sageCrewConfig: Web3.PublicKey; }; export type MintToGameKeys = MintKeys & { starbase: Web3.PublicKey; starbasePlayer: Web3.PublicKey; }; export type DirectMintingKeys = MintToGameKeys; /** * * @param crewProgram - The crew program * @param key - The key authorizing the transaction * @param profile - The profile containing the authorizing crew permissions * @param rentRecipient - The key that reclaims the rent once all are minted * @param sagePlayerProfile - The SagePlayerProfile in sage for direct minting * @param userRedemption - The user redemption account * @param packType - The pack type account * @param packTiers - The pack tiers account * @param collectionMint - The collection mint account * @param collectionAuthority - The current update authority on the collection nft * @param merkleTree - The merkle tree account * @param serverHashPreimage - The preimage bytes as a public key * @param directMinting - Keys to pass in for directly minting to sage * @param input - {@link Types.MintCrewMemberInput} * @param crewConfig - Optional to override default crew config (with default seed pubkey) * @returns DataSource.InstructionReturn */ // ----- END CUSTOM IMPORTS ----- export function mintCrewMemberToSage( crewProgram: CrewIDLProgram, key: DataSource.AsyncSigner, profile: Web3.PublicKey, rentRecipient: Web3.PublicKey, sagePlayerProfile: Web3.PublicKey, userRedemption: Web3.PublicKey, packType: Web3.PublicKey, packTiers: Web3.PublicKey, collectionMint: Web3.PublicKey, collectionAuthority: Web3.PublicKey, merkleTree: Web3.PublicKey, serverHashPreimage: Web3.PublicKey, directMinting: DirectMintingKeys, input: MintCrewMemberInput, crewConfig: Web3.PublicKey = CrewConfig.findAddress(crewProgram)[0], ): DataSource.InstructionReturn { // ----- BEGIN CUSTOM LOGIC ----- const { accounts, signers } = mintCrewMemberAccounts( crewProgram, key, profile, rentRecipient, sagePlayerProfile, userRedemption, packType, packTiers, collectionMint, collectionAuthority, merkleTree, serverHashPreimage, crewConfig, ); const remainingAccounts: AccountMeta[] = []; remainingAccounts.push({ pubkey: directMinting.sageProgram.programId, isWritable: false, isSigner: false, }); remainingAccounts.push({ pubkey: directMinting.starbase, isWritable: true, isSigner: false, }); remainingAccounts.push({ pubkey: directMinting.starbasePlayer, isWritable: true, isSigner: false, }); remainingAccounts.push({ pubkey: directMinting.sageCrewConfig, isWritable: false, isSigner: false, }); remainingAccounts.push({ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY, isWritable: false, isSigner: false, }); // ------ END CUSTOM LOGIC ------ return async () => ({ instruction: await crewProgram.methods .mintCrewMember(input) .accountsStrict(accounts) .remainingAccounts(remainingAccounts) .instruction(), signers, }); }