Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions clients/js/src/generated/instructions/closeTree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/**
* 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,
array,
mapSerializer,
struct,
u8,
} from '@metaplex-foundation/umi/serializers';
import { findTreeConfigPda } from '../accounts';
import {
ResolvedAccount,
ResolvedAccountsWithIndices,
expectPublicKey,
getAccountMetasAndSigners,
} from '../shared';

// Accounts.
export type CloseTreeInstructionAccounts = {
treeConfig?: PublicKey | Pda;
/** Tree creator or delegate. */
authority?: Signer;
merkleTree: PublicKey | Pda;
/**
* Recipient for reclaimed lamports (tree + config PDA). Must be the creator
* or the delegate.
*/

recipient: PublicKey | Pda;
compressionProgram: PublicKey | Pda;
logWrapper: PublicKey | Pda;
systemProgram?: PublicKey | Pda;
};

// Data.
export type CloseTreeInstructionData = { discriminator: Array<number> };

export type CloseTreeInstructionDataArgs = {};

export function getCloseTreeInstructionDataSerializer(): Serializer<
CloseTreeInstructionDataArgs,
CloseTreeInstructionData
> {
return mapSerializer<
CloseTreeInstructionDataArgs,
any,
CloseTreeInstructionData
>(
struct<CloseTreeInstructionData>(
[['discriminator', array(u8(), { size: 8 })]],
{ description: 'CloseTreeInstructionData' }
),
(value) => ({
...value,
discriminator: [9, 124, 164, 131, 238, 218, 148, 212],
})
) as Serializer<CloseTreeInstructionDataArgs, CloseTreeInstructionData>;
}

// Instruction.
export function closeTree(
context: Pick<Context, 'eddsa' | 'identity' | 'programs'>,
input: CloseTreeInstructionAccounts
): TransactionBuilder {
// Program ID.
const programId = context.programs.getPublicKey(
'mplBubblegum',
'BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY'
);

// Accounts.
const resolvedAccounts: ResolvedAccountsWithIndices = {
treeConfig: { index: 0, isWritable: true, value: input.treeConfig ?? null },
authority: { index: 1, isWritable: false, value: input.authority ?? null },
merkleTree: { index: 2, isWritable: true, value: input.merkleTree ?? null },
recipient: { index: 3, isWritable: true, value: input.recipient ?? null },
compressionProgram: {
index: 4,
isWritable: false,
value: input.compressionProgram ?? null,
},
logWrapper: {
index: 5,
isWritable: false,
value: input.logWrapper ?? null,
},
systemProgram: {
index: 6,
isWritable: false,
value: input.systemProgram ?? null,
},
};

// Default values.
if (!resolvedAccounts.treeConfig.value) {
resolvedAccounts.treeConfig.value = findTreeConfigPda(context, {
merkleTree: expectPublicKey(resolvedAccounts.merkleTree.value),
});
}
if (!resolvedAccounts.authority.value) {
resolvedAccounts.authority.value = context.identity;
}
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 = getCloseTreeInstructionDataSerializer().serialize({});

// Bytes Created On Chain.
const bytesCreatedOnChain = 0;

return transactionBuilder([
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
]);
}
1 change: 1 addition & 0 deletions clients/js/src/generated/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export * from './burn';
export * from './burnV2';
export * from './cancelRedeem';
export * from './closeTree';
export * from './collectV2';
export * from './createTreeConfig';
export * from './createTreeConfigV2';
Expand Down
Loading