Skip to content

Commit

Permalink
change implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
daoplays committed May 3, 2024
1 parent bfd460b commit e99a8e8
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 276 deletions.
4 changes: 2 additions & 2 deletions clients/js/src/generated/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ export * from './compressV1';
export * from './createCollectionV1';
export * from './createV1';
export * from './decompressV1';
export * from './extendAtrributesPluginV1';
export * from './extendCollectionAtrributesPluginV1';
export * from './removeCollectionPluginV1';
export * from './removePluginV1';
export * from './revokeCollectionPluginAuthorityV1';
export * from './revokePluginAuthorityV1';
export * from './transferV1';
export * from './updateCollectionPluginV1';
export * from './updateCollectionPluginV2';
export * from './updateCollectionV1';
export * from './updatePluginV1';
export * from './updatePluginV2';
export * from './updateV1';
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import {
Context,
Option,
OptionOrNullable,
Pda,
PublicKey,
Signer,
Expand All @@ -17,6 +19,7 @@ import {
import {
Serializer,
mapSerializer,
option,
struct,
u8,
} from '@metaplex-foundation/umi/serializers';
Expand All @@ -25,10 +28,10 @@ import {
ResolvedAccountsWithIndices,
getAccountMetasAndSigners,
} from '../shared';
import { Attribute, AttributeArgs, getAttributeSerializer } from '../types';
import { Plugin, PluginArgs, getPluginSerializer } from '../types';

// Accounts.
export type ExtendCollectionAtrributesPluginV1InstructionAccounts = {
export type UpdateCollectionPluginV2InstructionAccounts = {
/** The address of the asset */
collection: PublicKey | Pda;
/** The account paying for the storage fees */
Expand All @@ -39,50 +42,52 @@ export type ExtendCollectionAtrributesPluginV1InstructionAccounts = {
systemProgram?: PublicKey | Pda;
/** The SPL Noop Program */
logWrapper?: PublicKey | Pda;
/** Optional buffer account containing plugin data */
bufferAccount?: PublicKey | Pda;
};

// Data.
export type ExtendCollectionAtrributesPluginV1InstructionData = {
export type UpdateCollectionPluginV2InstructionData = {
discriminator: number;
attribute: Attribute;
plugin: Option<Plugin>;
};

export type ExtendCollectionAtrributesPluginV1InstructionDataArgs = {
attribute: AttributeArgs;
export type UpdateCollectionPluginV2InstructionDataArgs = {
plugin: OptionOrNullable<PluginArgs>;
};

export function getExtendCollectionAtrributesPluginV1InstructionDataSerializer(): Serializer<
ExtendCollectionAtrributesPluginV1InstructionDataArgs,
ExtendCollectionAtrributesPluginV1InstructionData
export function getUpdateCollectionPluginV2InstructionDataSerializer(): Serializer<
UpdateCollectionPluginV2InstructionDataArgs,
UpdateCollectionPluginV2InstructionData
> {
return mapSerializer<
ExtendCollectionAtrributesPluginV1InstructionDataArgs,
UpdateCollectionPluginV2InstructionDataArgs,
any,
ExtendCollectionAtrributesPluginV1InstructionData
UpdateCollectionPluginV2InstructionData
>(
struct<ExtendCollectionAtrributesPluginV1InstructionData>(
struct<UpdateCollectionPluginV2InstructionData>(
[
['discriminator', u8()],
['attribute', getAttributeSerializer()],
['plugin', option(getPluginSerializer())],
],
{ description: 'ExtendCollectionAtrributesPluginV1InstructionData' }
{ description: 'UpdateCollectionPluginV2InstructionData' }
),
(value) => ({ ...value, discriminator: 21 })
) as Serializer<
ExtendCollectionAtrributesPluginV1InstructionDataArgs,
ExtendCollectionAtrributesPluginV1InstructionData
UpdateCollectionPluginV2InstructionDataArgs,
UpdateCollectionPluginV2InstructionData
>;
}

// Args.
export type ExtendCollectionAtrributesPluginV1InstructionArgs =
ExtendCollectionAtrributesPluginV1InstructionDataArgs;
export type UpdateCollectionPluginV2InstructionArgs =
UpdateCollectionPluginV2InstructionDataArgs;

// Instruction.
export function extendCollectionAtrributesPluginV1(
export function updateCollectionPluginV2(
context: Pick<Context, 'payer' | 'programs'>,
input: ExtendCollectionAtrributesPluginV1InstructionAccounts &
ExtendCollectionAtrributesPluginV1InstructionArgs
input: UpdateCollectionPluginV2InstructionAccounts &
UpdateCollectionPluginV2InstructionArgs
): TransactionBuilder {
// Program ID.
const programId = context.programs.getPublicKey(
Expand Down Expand Up @@ -117,12 +122,15 @@ export function extendCollectionAtrributesPluginV1(
isWritable: false as boolean,
value: input.logWrapper ?? null,
},
bufferAccount: {
index: 5,
isWritable: false as boolean,
value: input.bufferAccount ?? null,
},
} satisfies ResolvedAccountsWithIndices;

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

// Default values.
if (!resolvedAccounts.payer.value) {
Expand All @@ -149,10 +157,9 @@ export function extendCollectionAtrributesPluginV1(
);

// Data.
const data =
getExtendCollectionAtrributesPluginV1InstructionDataSerializer().serialize(
resolvedArgs as ExtendCollectionAtrributesPluginV1InstructionDataArgs
);
const data = getUpdateCollectionPluginV2InstructionDataSerializer().serialize(
resolvedArgs as UpdateCollectionPluginV2InstructionDataArgs
);

// Bytes Created On Chain.
const bytesCreatedOnChain = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import {
Context,
Option,
OptionOrNullable,
Pda,
PublicKey,
Signer,
Expand All @@ -17,6 +19,7 @@ import {
import {
Serializer,
mapSerializer,
option,
struct,
u8,
} from '@metaplex-foundation/umi/serializers';
Expand All @@ -25,10 +28,10 @@ import {
ResolvedAccountsWithIndices,
getAccountMetasAndSigners,
} from '../shared';
import { Attribute, AttributeArgs, getAttributeSerializer } from '../types';
import { Plugin, PluginArgs, getPluginSerializer } from '../types';

// Accounts.
export type ExtendAtrributesPluginV1InstructionAccounts = {
export type UpdatePluginV2InstructionAccounts = {
/** The address of the asset */
asset: PublicKey | Pda;
/** The collection to which the asset belongs */
Expand All @@ -41,50 +44,50 @@ export type ExtendAtrributesPluginV1InstructionAccounts = {
systemProgram?: PublicKey | Pda;
/** The SPL Noop Program */
logWrapper?: PublicKey | Pda;
/** Optional buffer account containing plugin data */
bufferAccount?: PublicKey | Pda;
};

// Data.
export type ExtendAtrributesPluginV1InstructionData = {
export type UpdatePluginV2InstructionData = {
discriminator: number;
attribute: Attribute;
plugin: Option<Plugin>;
};

export type ExtendAtrributesPluginV1InstructionDataArgs = {
attribute: AttributeArgs;
export type UpdatePluginV2InstructionDataArgs = {
plugin: OptionOrNullable<PluginArgs>;
};

export function getExtendAtrributesPluginV1InstructionDataSerializer(): Serializer<
ExtendAtrributesPluginV1InstructionDataArgs,
ExtendAtrributesPluginV1InstructionData
export function getUpdatePluginV2InstructionDataSerializer(): Serializer<
UpdatePluginV2InstructionDataArgs,
UpdatePluginV2InstructionData
> {
return mapSerializer<
ExtendAtrributesPluginV1InstructionDataArgs,
UpdatePluginV2InstructionDataArgs,
any,
ExtendAtrributesPluginV1InstructionData
UpdatePluginV2InstructionData
>(
struct<ExtendAtrributesPluginV1InstructionData>(
struct<UpdatePluginV2InstructionData>(
[
['discriminator', u8()],
['attribute', getAttributeSerializer()],
['plugin', option(getPluginSerializer())],
],
{ description: 'ExtendAtrributesPluginV1InstructionData' }
{ description: 'UpdatePluginV2InstructionData' }
),
(value) => ({ ...value, discriminator: 20 })
) as Serializer<
ExtendAtrributesPluginV1InstructionDataArgs,
ExtendAtrributesPluginV1InstructionData
UpdatePluginV2InstructionDataArgs,
UpdatePluginV2InstructionData
>;
}

// Args.
export type ExtendAtrributesPluginV1InstructionArgs =
ExtendAtrributesPluginV1InstructionDataArgs;
export type UpdatePluginV2InstructionArgs = UpdatePluginV2InstructionDataArgs;

// Instruction.
export function extendAtrributesPluginV1(
export function updatePluginV2(
context: Pick<Context, 'payer' | 'programs'>,
input: ExtendAtrributesPluginV1InstructionAccounts &
ExtendAtrributesPluginV1InstructionArgs
input: UpdatePluginV2InstructionAccounts & UpdatePluginV2InstructionArgs
): TransactionBuilder {
// Program ID.
const programId = context.programs.getPublicKey(
Expand Down Expand Up @@ -124,10 +127,15 @@ export function extendAtrributesPluginV1(
isWritable: false as boolean,
value: input.logWrapper ?? null,
},
bufferAccount: {
index: 6,
isWritable: false as boolean,
value: input.bufferAccount ?? null,
},
} satisfies ResolvedAccountsWithIndices;

// Arguments.
const resolvedArgs: ExtendAtrributesPluginV1InstructionArgs = { ...input };
const resolvedArgs: UpdatePluginV2InstructionArgs = { ...input };

// Default values.
if (!resolvedAccounts.payer.value) {
Expand All @@ -154,8 +162,8 @@ export function extendAtrributesPluginV1(
);

// Data.
const data = getExtendAtrributesPluginV1InstructionDataSerializer().serialize(
resolvedArgs as ExtendAtrributesPluginV1InstructionDataArgs
const data = getUpdatePluginV2InstructionDataSerializer().serialize(
resolvedArgs as UpdatePluginV2InstructionDataArgs
);

// Bytes Created On Chain.
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/generated/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ pub(crate) mod r#compress_v1;
pub(crate) mod r#create_collection_v1;
pub(crate) mod r#create_v1;
pub(crate) mod r#decompress_v1;
pub(crate) mod r#extend_atrributes_plugin_v1;
pub(crate) mod r#extend_collection_atrributes_plugin_v1;
pub(crate) mod r#remove_collection_plugin_v1;
pub(crate) mod r#remove_plugin_v1;
pub(crate) mod r#revoke_collection_plugin_authority_v1;
pub(crate) mod r#revoke_plugin_authority_v1;
pub(crate) mod r#transfer_v1;
pub(crate) mod r#update_collection_plugin_v1;
pub(crate) mod r#update_collection_plugin_v2;
pub(crate) mod r#update_collection_v1;
pub(crate) mod r#update_plugin_v1;
pub(crate) mod r#update_plugin_v2;
pub(crate) mod r#update_v1;

pub use self::r#add_collection_plugin_v1::*;
Expand All @@ -39,14 +39,14 @@ pub use self::r#compress_v1::*;
pub use self::r#create_collection_v1::*;
pub use self::r#create_v1::*;
pub use self::r#decompress_v1::*;
pub use self::r#extend_atrributes_plugin_v1::*;
pub use self::r#extend_collection_atrributes_plugin_v1::*;
pub use self::r#remove_collection_plugin_v1::*;
pub use self::r#remove_plugin_v1::*;
pub use self::r#revoke_collection_plugin_authority_v1::*;
pub use self::r#revoke_plugin_authority_v1::*;
pub use self::r#transfer_v1::*;
pub use self::r#update_collection_plugin_v1::*;
pub use self::r#update_collection_plugin_v2::*;
pub use self::r#update_collection_v1::*;
pub use self::r#update_plugin_v1::*;
pub use self::r#update_plugin_v2::*;
pub use self::r#update_v1::*;
Loading

0 comments on commit e99a8e8

Please sign in to comment.