Skip to content

Commit

Permalink
Reworking instructions be single purpose.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Mar 5, 2024
1 parent 9dab7cd commit 7a1b140
Show file tree
Hide file tree
Showing 99 changed files with 7,295 additions and 1,376 deletions.
152 changes: 152 additions & 0 deletions clients/js/src/generated/instructions/addCollectionPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/**
* 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';
import {
AddPluginArgs,
AddPluginArgsArgs,
getAddPluginArgsSerializer,
} from '../types';

// Accounts.
export type AddCollectionPluginInstructionAccounts = {
/** The address of the asset */
collection: PublicKey | Pda;
/** The owner or delegate of the asset */
authority?: Signer;
/** The account paying for the storage fees */
payer?: Signer;
/** The system program */
systemProgram?: PublicKey | Pda;
/** The SPL Noop Program */
logWrapper?: PublicKey | Pda;
};

// Data.
export type AddCollectionPluginInstructionData = {
discriminator: number;
addPluginArgs: AddPluginArgs;
};

export type AddCollectionPluginInstructionDataArgs = {
addPluginArgs: AddPluginArgsArgs;
};

export function getAddCollectionPluginInstructionDataSerializer(): Serializer<
AddCollectionPluginInstructionDataArgs,
AddCollectionPluginInstructionData
> {
return mapSerializer<
AddCollectionPluginInstructionDataArgs,
any,
AddCollectionPluginInstructionData
>(
struct<AddCollectionPluginInstructionData>(
[
['discriminator', u8()],
['addPluginArgs', getAddPluginArgsSerializer()],
],
{ description: 'AddCollectionPluginInstructionData' }
),
(value) => ({ ...value, discriminator: 3 })
) as Serializer<
AddCollectionPluginInstructionDataArgs,
AddCollectionPluginInstructionData
>;
}

// Args.
export type AddCollectionPluginInstructionArgs =
AddCollectionPluginInstructionDataArgs;

// Instruction.
export function addCollectionPlugin(
context: Pick<Context, 'identity' | 'programs'>,
input: AddCollectionPluginInstructionAccounts &
AddCollectionPluginInstructionArgs
): TransactionBuilder {
// Program ID.
const programId = context.programs.getPublicKey(
'mplCore',
'CoREzp6dAdLVRKf3EM5tWrsXM2jQwRFeu5uhzsAyjYXL'
);

// Accounts.
const resolvedAccounts: ResolvedAccountsWithIndices = {
collection: { index: 0, isWritable: true, value: input.collection ?? null },
authority: { index: 1, isWritable: false, value: input.authority ?? null },
payer: { index: 2, isWritable: true, value: input.payer ?? null },
systemProgram: {
index: 3,
isWritable: false,
value: input.systemProgram ?? null,
},
logWrapper: {
index: 4,
isWritable: false,
value: input.logWrapper ?? null,
},
};

// Arguments.
const resolvedArgs: AddCollectionPluginInstructionArgs = { ...input };

// Default values.
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 = getAddCollectionPluginInstructionDataSerializer().serialize(
resolvedArgs as AddCollectionPluginInstructionDataArgs
);

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

return transactionBuilder([
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
]);
}
155 changes: 155 additions & 0 deletions clients/js/src/generated/instructions/addCollectionPluginAuthority.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/**
* 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';
import {
AddPluginAuthorityArgs,
AddPluginAuthorityArgsArgs,
getAddPluginAuthorityArgsSerializer,
} from '../types';

// Accounts.
export type AddCollectionPluginAuthorityInstructionAccounts = {
/** The address of the asset */
collection: PublicKey | Pda;
/** The owner or delegate of the asset */
authority?: Signer;
/** The account paying for the storage fees */
payer?: Signer;
/** The system program */
systemProgram?: PublicKey | Pda;
/** The SPL Noop Program */
logWrapper?: PublicKey | Pda;
};

// Data.
export type AddCollectionPluginAuthorityInstructionData = {
discriminator: number;
addPluginAuthorityArgs: AddPluginAuthorityArgs;
};

export type AddCollectionPluginAuthorityInstructionDataArgs = {
addPluginAuthorityArgs: AddPluginAuthorityArgsArgs;
};

export function getAddCollectionPluginAuthorityInstructionDataSerializer(): Serializer<
AddCollectionPluginAuthorityInstructionDataArgs,
AddCollectionPluginAuthorityInstructionData
> {
return mapSerializer<
AddCollectionPluginAuthorityInstructionDataArgs,
any,
AddCollectionPluginAuthorityInstructionData
>(
struct<AddCollectionPluginAuthorityInstructionData>(
[
['discriminator', u8()],
['addPluginAuthorityArgs', getAddPluginAuthorityArgsSerializer()],
],
{ description: 'AddCollectionPluginAuthorityInstructionData' }
),
(value) => ({ ...value, discriminator: 9 })
) as Serializer<
AddCollectionPluginAuthorityInstructionDataArgs,
AddCollectionPluginAuthorityInstructionData
>;
}

// Args.
export type AddCollectionPluginAuthorityInstructionArgs =
AddCollectionPluginAuthorityInstructionDataArgs;

// Instruction.
export function addCollectionPluginAuthority(
context: Pick<Context, 'identity' | 'programs'>,
input: AddCollectionPluginAuthorityInstructionAccounts &
AddCollectionPluginAuthorityInstructionArgs
): TransactionBuilder {
// Program ID.
const programId = context.programs.getPublicKey(
'mplCore',
'CoREzp6dAdLVRKf3EM5tWrsXM2jQwRFeu5uhzsAyjYXL'
);

// Accounts.
const resolvedAccounts: ResolvedAccountsWithIndices = {
collection: { index: 0, isWritable: true, value: input.collection ?? null },
authority: { index: 1, isWritable: false, value: input.authority ?? null },
payer: { index: 2, isWritable: true, value: input.payer ?? null },
systemProgram: {
index: 3,
isWritable: false,
value: input.systemProgram ?? null,
},
logWrapper: {
index: 4,
isWritable: false,
value: input.logWrapper ?? null,
},
};

// Arguments.
const resolvedArgs: AddCollectionPluginAuthorityInstructionArgs = {
...input,
};

// Default values.
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 =
getAddCollectionPluginAuthorityInstructionDataSerializer().serialize(
resolvedArgs as AddCollectionPluginAuthorityInstructionDataArgs
);

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

return transactionBuilder([
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
]);
}
20 changes: 10 additions & 10 deletions clients/js/src/generated/instructions/addPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ import {
ResolvedAccountsWithIndices,
getAccountMetasAndSigners,
} from '../shared';
import { Plugin, PluginArgs, getPluginSerializer } from '../types';
import {
AddPluginArgs,
AddPluginArgsArgs,
getAddPluginArgsSerializer,
} from '../types';

// Accounts.
export type AddPluginInstructionAccounts = {
/** The address of the asset */
assetAddress: PublicKey | Pda;
asset: PublicKey | Pda;
/** The collection to which the asset belongs */
collection?: PublicKey | Pda;
/** The owner or delegate of the asset */
Expand All @@ -46,10 +50,10 @@ export type AddPluginInstructionAccounts = {
// Data.
export type AddPluginInstructionData = {
discriminator: number;
plugin: Plugin;
addPluginArgs: AddPluginArgs;
};

export type AddPluginInstructionDataArgs = { plugin: PluginArgs };
export type AddPluginInstructionDataArgs = { addPluginArgs: AddPluginArgsArgs };

export function getAddPluginInstructionDataSerializer(): Serializer<
AddPluginInstructionDataArgs,
Expand All @@ -63,7 +67,7 @@ export function getAddPluginInstructionDataSerializer(): Serializer<
struct<AddPluginInstructionData>(
[
['discriminator', u8()],
['plugin', getPluginSerializer()],
['addPluginArgs', getAddPluginArgsSerializer()],
],
{ description: 'AddPluginInstructionData' }
),
Expand All @@ -87,11 +91,7 @@ export function addPlugin(

// Accounts.
const resolvedAccounts: ResolvedAccountsWithIndices = {
assetAddress: {
index: 0,
isWritable: true,
value: input.assetAddress ?? null,
},
asset: { index: 0, isWritable: true, value: input.asset ?? null },
collection: { index: 1, isWritable: true, value: input.collection ?? null },
authority: { index: 2, isWritable: false, value: input.authority ?? null },
payer: { index: 3, isWritable: true, value: input.payer ?? null },
Expand Down
Loading

0 comments on commit 7a1b140

Please sign in to comment.