Skip to content

Commit

Permalink
implement editions plugin (#55)
Browse files Browse the repository at this point in the history
edition plugin must be added at creation time and cannot be removed
edition plugin cannot be added to a collection
edition plugin can be updated by the authority
edition number can be made immutable
intended usage is with candy machine
  • Loading branch information
nhanphan authored Apr 8, 2024
1 parent bc05b24 commit f32a17e
Show file tree
Hide file tree
Showing 19 changed files with 510 additions and 7 deletions.
19 changes: 19 additions & 0 deletions clients/js/src/generated/types/edition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* 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 { Serializer, struct, u32 } from '@metaplex-foundation/umi/serializers';

export type Edition = { number: number };

export type EditionArgs = Edition;

export function getEditionSerializer(): Serializer<EditionArgs, Edition> {
return struct<Edition>([['number', u32()]], {
description: 'Edition',
}) as Serializer<EditionArgs, Edition>;
}
1 change: 1 addition & 0 deletions clients/js/src/generated/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export * from './burnDelegate';
export * from './compressionProof';
export * from './creator';
export * from './dataState';
export * from './edition';
export * from './externalPluginRecord';
export * from './extraAccounts';
export * from './freezeDelegate';
Expand Down
19 changes: 17 additions & 2 deletions clients/js/src/generated/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
AttributesArgs,
BurnDelegate,
BurnDelegateArgs,
Edition,
EditionArgs,
FreezeDelegate,
FreezeDelegateArgs,
PermanentBurnDelegate,
Expand All @@ -35,6 +37,7 @@ import {
UpdateDelegateArgs,
getAttributesSerializer,
getBurnDelegateSerializer,
getEditionSerializer,
getFreezeDelegateSerializer,
getPermanentBurnDelegateSerializer,
getPermanentFreezeDelegateSerializer,
Expand All @@ -53,7 +56,8 @@ export type Plugin =
| { __kind: 'PermanentFreezeDelegate'; fields: [PermanentFreezeDelegate] }
| { __kind: 'Attributes'; fields: [Attributes] }
| { __kind: 'PermanentTransferDelegate'; fields: [PermanentTransferDelegate] }
| { __kind: 'PermanentBurnDelegate'; fields: [PermanentBurnDelegate] };
| { __kind: 'PermanentBurnDelegate'; fields: [PermanentBurnDelegate] }
| { __kind: 'Edition'; fields: [Edition] };

export type PluginArgs =
| { __kind: 'Royalties'; fields: [RoyaltiesArgs] }
Expand All @@ -67,7 +71,8 @@ export type PluginArgs =
__kind: 'PermanentTransferDelegate';
fields: [PermanentTransferDelegateArgs];
}
| { __kind: 'PermanentBurnDelegate'; fields: [PermanentBurnDelegateArgs] };
| { __kind: 'PermanentBurnDelegate'; fields: [PermanentBurnDelegateArgs] }
| { __kind: 'Edition'; fields: [EditionArgs] };

export function getPluginSerializer(): Serializer<PluginArgs, Plugin> {
return dataEnum<Plugin>(
Expand Down Expand Up @@ -126,6 +131,12 @@ export function getPluginSerializer(): Serializer<PluginArgs, Plugin> {
['fields', tuple([getPermanentBurnDelegateSerializer()])],
]),
],
[
'Edition',
struct<GetDataEnumKindContent<Plugin, 'Edition'>>([
['fields', tuple([getEditionSerializer()])],
]),
],
],
{ description: 'Plugin' }
) as Serializer<PluginArgs, Plugin>;
Expand Down Expand Up @@ -171,6 +182,10 @@ export function plugin(
kind: 'PermanentBurnDelegate',
data: GetDataEnumKindContent<PluginArgs, 'PermanentBurnDelegate'>['fields']
): GetDataEnumKind<PluginArgs, 'PermanentBurnDelegate'>;
export function plugin(
kind: 'Edition',
data: GetDataEnumKindContent<PluginArgs, 'Edition'>['fields']
): GetDataEnumKind<PluginArgs, 'Edition'>;
export function plugin<K extends PluginArgs['__kind']>(
kind: K,
data?: any
Expand Down
1 change: 1 addition & 0 deletions clients/js/src/generated/types/pluginType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export enum PluginType {
Attributes,
PermanentTransferDelegate,
PermanentBurnDelegate,
Edition,
}

export type PluginTypeArgs = PluginType;
Expand Down
5 changes: 5 additions & 0 deletions clients/js/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
PermanentFreezeDelegateArgs,
PluginType,
UpdateDelegateArgs,
EditionArgs,
} from './generated';
import { BasePluginAuthority, PluginsList } from './types';
import { mapPluginAuthority } from './authority';
Expand Down Expand Up @@ -64,6 +65,10 @@ export type CreatePluginArgs =
}
| {
type: 'PermanentBurnDelegate';
}
| {
type: 'Edition';
data: EditionArgs;
};

export function createPlugin(args: CreatePluginArgs): BasePlugin {
Expand Down
3 changes: 3 additions & 0 deletions clients/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
PermanentTransferDelegate,
UpdateAuthority,
PermanentBurnDelegate,
Edition,
} from './generated';

export type BasePluginAuthority = {
Expand Down Expand Up @@ -42,6 +43,7 @@ export type AttributesPlugin = BasePlugin & Attributes;
export type PermanentTransferDelegatePlugin = BasePlugin &
PermanentTransferDelegate;
export type PermanentBurnDelegatePlugin = BasePlugin & PermanentBurnDelegate;
export type EditionPlugin = BasePlugin & Edition;

export type PluginsList = {
royalties?: RoyaltiesPlugin;
Expand All @@ -53,4 +55,5 @@ export type PluginsList = {
permanentFreezeDelegate?: PermanentFreezeDelegatePlugin;
permanentTransferDelegate?: PermanentTransferDelegatePlugin;
permanentBurnDelegate?: PermanentBurnDelegatePlugin;
edition?: EditionPlugin;
};
Loading

0 comments on commit f32a17e

Please sign in to comment.