Skip to content

Commit

Permalink
Nhan/rename external plugin (#119)
Browse files Browse the repository at this point in the history
* bump version v1-alpha

* bump version v1-alpha

* initial rename

* Rename Oracle pda - stacked onto rename external plugin (#121)

* Format fix

* Rename oracle pda to base_address_config in program

* Regenerate IDL and clients

* Update oracle SDK functions

* Format JS and fix all tests

* rename to external plugin adapater

* formatting

* rename back to external validation result

* use internal validationresult type

* rename a few more things

* minor nits, comments

---------

Co-authored-by: Michael Danenberg <[email protected]>
  • Loading branch information
nhanphan and danenbm authored May 10, 2024
1 parent 1d05919 commit c7d78b9
Show file tree
Hide file tree
Showing 130 changed files with 2,495 additions and 2,294 deletions.
60 changes: 35 additions & 25 deletions clients/js/src/generated/errors/mplCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,33 +433,40 @@ export class InvalidLogWrapperProgramError extends ProgramError {
codeToErrorMap.set(0x1e, InvalidLogWrapperProgramError);
nameToErrorMap.set('InvalidLogWrapperProgram', InvalidLogWrapperProgramError);

/** ExternalPluginNotFound: External Plugin not found */
export class ExternalPluginNotFoundError extends ProgramError {
override readonly name: string = 'ExternalPluginNotFound';
/** ExternalPluginAdapterNotFound: External PluginExternalPluginAdapter not found */
export class ExternalPluginAdapterNotFoundError extends ProgramError {
override readonly name: string = 'ExternalPluginAdapterNotFound';

readonly code: number = 0x1f; // 31

constructor(program: Program, cause?: Error) {
super('External Plugin not found', program, cause);
super('External PluginExternalPluginAdapter not found', program, cause);
}
}
codeToErrorMap.set(0x1f, ExternalPluginNotFoundError);
nameToErrorMap.set('ExternalPluginNotFound', ExternalPluginNotFoundError);
codeToErrorMap.set(0x1f, ExternalPluginAdapterNotFoundError);
nameToErrorMap.set(
'ExternalPluginAdapterNotFound',
ExternalPluginAdapterNotFoundError
);

/** ExternalPluginAlreadyExists: External Plugin already exists */
export class ExternalPluginAlreadyExistsError extends ProgramError {
override readonly name: string = 'ExternalPluginAlreadyExists';
/** ExternalPluginAdapterAlreadyExists: External PluginExternalPluginAdapter already exists */
export class ExternalPluginAdapterAlreadyExistsError extends ProgramError {
override readonly name: string = 'ExternalPluginAdapterAlreadyExists';

readonly code: number = 0x20; // 32

constructor(program: Program, cause?: Error) {
super('External Plugin already exists', program, cause);
super(
'External PluginExternalPluginAdapter already exists',
program,
cause
);
}
}
codeToErrorMap.set(0x20, ExternalPluginAlreadyExistsError);
codeToErrorMap.set(0x20, ExternalPluginAdapterAlreadyExistsError);
nameToErrorMap.set(
'ExternalPluginAlreadyExists',
ExternalPluginAlreadyExistsError
'ExternalPluginAdapterAlreadyExists',
ExternalPluginAdapterAlreadyExistsError
);

/** MissingAsset: Missing asset needed for extra account PDA derivation */
Expand All @@ -479,28 +486,31 @@ export class MissingAssetError extends ProgramError {
codeToErrorMap.set(0x21, MissingAssetError);
nameToErrorMap.set('MissingAsset', MissingAssetError);

/** MissingExternalAccount: Missing account needed for external plugin */
export class MissingExternalAccountError extends ProgramError {
override readonly name: string = 'MissingExternalAccount';
/** MissingExternalPluginAdapterAccount: Missing account needed for external plugin adapter */
export class MissingExternalPluginAdapterAccountError extends ProgramError {
override readonly name: string = 'MissingExternalPluginAdapterAccount';

readonly code: number = 0x22; // 34

constructor(program: Program, cause?: Error) {
super('Missing account needed for external plugin', program, cause);
super('Missing account needed for external plugin adapter', program, cause);
}
}
codeToErrorMap.set(0x22, MissingExternalAccountError);
nameToErrorMap.set('MissingExternalAccount', MissingExternalAccountError);
codeToErrorMap.set(0x22, MissingExternalPluginAdapterAccountError);
nameToErrorMap.set(
'MissingExternalPluginAdapterAccount',
MissingExternalPluginAdapterAccountError
);

/** OracleCanRejectOnly: Oracle external plugin can only be configured to reject */
/** OracleCanRejectOnly: Oracle external plugin adapter can only be configured to reject */
export class OracleCanRejectOnlyError extends ProgramError {
override readonly name: string = 'OracleCanRejectOnly';

readonly code: number = 0x23; // 35

constructor(program: Program, cause?: Error) {
super(
'Oracle external plugin can only be configured to reject',
'Oracle external plugin adapter can only be configured to reject',
program,
cause
);
Expand All @@ -509,15 +519,15 @@ export class OracleCanRejectOnlyError extends ProgramError {
codeToErrorMap.set(0x23, OracleCanRejectOnlyError);
nameToErrorMap.set('OracleCanRejectOnly', OracleCanRejectOnlyError);

/** RequiresLifecycleCheck: External plugin must have at least one lifecycle check */
/** RequiresLifecycleCheck: External plugin adapter must have at least one lifecycle check */
export class RequiresLifecycleCheckError extends ProgramError {
override readonly name: string = 'RequiresLifecycleCheck';

readonly code: number = 0x24; // 36

constructor(program: Program, cause?: Error) {
super(
'External plugin must have at least one lifecycle check',
'External plugin adapter must have at least one lifecycle check',
program,
cause
);
Expand All @@ -526,15 +536,15 @@ export class RequiresLifecycleCheckError extends ProgramError {
codeToErrorMap.set(0x24, RequiresLifecycleCheckError);
nameToErrorMap.set('RequiresLifecycleCheck', RequiresLifecycleCheckError);

/** DuplicateLifecycleChecks: Duplicate lifecycle checks were provided for external plugin */
/** DuplicateLifecycleChecks: Duplicate lifecycle checks were provided for external plugin adapter */
export class DuplicateLifecycleChecksError extends ProgramError {
override readonly name: string = 'DuplicateLifecycleChecks';

readonly code: number = 0x25; // 37

constructor(program: Program, cause?: Error) {
super(
'Duplicate lifecycle checks were provided for external plugin',
'Duplicate lifecycle checks were provided for external plugin adapter ',
program,
cause
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import {
getAccountMetasAndSigners,
} from '../shared';
import {
BaseExternalPluginInitInfo,
BaseExternalPluginInitInfoArgs,
getBaseExternalPluginInitInfoSerializer,
BaseExternalPluginAdapterInitInfo,
BaseExternalPluginAdapterInitInfoArgs,
getBaseExternalPluginAdapterInitInfoSerializer,
} from '../types';

// Accounts.
export type AddCollectionExternalPluginV1InstructionAccounts = {
export type AddCollectionExternalPluginAdapterV1InstructionAccounts = {
/** The address of the asset */
collection: PublicKey | Pda;
/** The account paying for the storage fees */
Expand All @@ -46,47 +46,47 @@ export type AddCollectionExternalPluginV1InstructionAccounts = {
};

// Data.
export type AddCollectionExternalPluginV1InstructionData = {
export type AddCollectionExternalPluginAdapterV1InstructionData = {
discriminator: number;
initInfo: BaseExternalPluginInitInfo;
initInfo: BaseExternalPluginAdapterInitInfo;
};

export type AddCollectionExternalPluginV1InstructionDataArgs = {
initInfo: BaseExternalPluginInitInfoArgs;
export type AddCollectionExternalPluginAdapterV1InstructionDataArgs = {
initInfo: BaseExternalPluginAdapterInitInfoArgs;
};

export function getAddCollectionExternalPluginV1InstructionDataSerializer(): Serializer<
AddCollectionExternalPluginV1InstructionDataArgs,
AddCollectionExternalPluginV1InstructionData
export function getAddCollectionExternalPluginAdapterV1InstructionDataSerializer(): Serializer<
AddCollectionExternalPluginAdapterV1InstructionDataArgs,
AddCollectionExternalPluginAdapterV1InstructionData
> {
return mapSerializer<
AddCollectionExternalPluginV1InstructionDataArgs,
AddCollectionExternalPluginAdapterV1InstructionDataArgs,
any,
AddCollectionExternalPluginV1InstructionData
AddCollectionExternalPluginAdapterV1InstructionData
>(
struct<AddCollectionExternalPluginV1InstructionData>(
struct<AddCollectionExternalPluginAdapterV1InstructionData>(
[
['discriminator', u8()],
['initInfo', getBaseExternalPluginInitInfoSerializer()],
['initInfo', getBaseExternalPluginAdapterInitInfoSerializer()],
],
{ description: 'AddCollectionExternalPluginV1InstructionData' }
{ description: 'AddCollectionExternalPluginAdapterV1InstructionData' }
),
(value) => ({ ...value, discriminator: 23 })
) as Serializer<
AddCollectionExternalPluginV1InstructionDataArgs,
AddCollectionExternalPluginV1InstructionData
AddCollectionExternalPluginAdapterV1InstructionDataArgs,
AddCollectionExternalPluginAdapterV1InstructionData
>;
}

// Args.
export type AddCollectionExternalPluginV1InstructionArgs =
AddCollectionExternalPluginV1InstructionDataArgs;
export type AddCollectionExternalPluginAdapterV1InstructionArgs =
AddCollectionExternalPluginAdapterV1InstructionDataArgs;

// Instruction.
export function addCollectionExternalPluginV1(
export function addCollectionExternalPluginAdapterV1(
context: Pick<Context, 'payer' | 'programs'>,
input: AddCollectionExternalPluginV1InstructionAccounts &
AddCollectionExternalPluginV1InstructionArgs
input: AddCollectionExternalPluginAdapterV1InstructionAccounts &
AddCollectionExternalPluginAdapterV1InstructionArgs
): TransactionBuilder {
// Program ID.
const programId = context.programs.getPublicKey(
Expand Down Expand Up @@ -124,7 +124,7 @@ export function addCollectionExternalPluginV1(
} satisfies ResolvedAccountsWithIndices;

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

Expand Down Expand Up @@ -154,8 +154,8 @@ export function addCollectionExternalPluginV1(

// Data.
const data =
getAddCollectionExternalPluginV1InstructionDataSerializer().serialize(
resolvedArgs as AddCollectionExternalPluginV1InstructionDataArgs
getAddCollectionExternalPluginAdapterV1InstructionDataSerializer().serialize(
resolvedArgs as AddCollectionExternalPluginAdapterV1InstructionDataArgs
);

// Bytes Created On Chain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import {
getAccountMetasAndSigners,
} from '../shared';
import {
BaseExternalPluginInitInfo,
BaseExternalPluginInitInfoArgs,
getBaseExternalPluginInitInfoSerializer,
BaseExternalPluginAdapterInitInfo,
BaseExternalPluginAdapterInitInfoArgs,
getBaseExternalPluginAdapterInitInfoSerializer,
} from '../types';

// Accounts.
export type AddExternalPluginV1InstructionAccounts = {
export type AddExternalPluginAdapterV1InstructionAccounts = {
/** The address of the asset */
asset: PublicKey | Pda;
/** The collection to which the asset belongs */
Expand All @@ -48,47 +48,47 @@ export type AddExternalPluginV1InstructionAccounts = {
};

// Data.
export type AddExternalPluginV1InstructionData = {
export type AddExternalPluginAdapterV1InstructionData = {
discriminator: number;
initInfo: BaseExternalPluginInitInfo;
initInfo: BaseExternalPluginAdapterInitInfo;
};

export type AddExternalPluginV1InstructionDataArgs = {
initInfo: BaseExternalPluginInitInfoArgs;
export type AddExternalPluginAdapterV1InstructionDataArgs = {
initInfo: BaseExternalPluginAdapterInitInfoArgs;
};

export function getAddExternalPluginV1InstructionDataSerializer(): Serializer<
AddExternalPluginV1InstructionDataArgs,
AddExternalPluginV1InstructionData
export function getAddExternalPluginAdapterV1InstructionDataSerializer(): Serializer<
AddExternalPluginAdapterV1InstructionDataArgs,
AddExternalPluginAdapterV1InstructionData
> {
return mapSerializer<
AddExternalPluginV1InstructionDataArgs,
AddExternalPluginAdapterV1InstructionDataArgs,
any,
AddExternalPluginV1InstructionData
AddExternalPluginAdapterV1InstructionData
>(
struct<AddExternalPluginV1InstructionData>(
struct<AddExternalPluginAdapterV1InstructionData>(
[
['discriminator', u8()],
['initInfo', getBaseExternalPluginInitInfoSerializer()],
['initInfo', getBaseExternalPluginAdapterInitInfoSerializer()],
],
{ description: 'AddExternalPluginV1InstructionData' }
{ description: 'AddExternalPluginAdapterV1InstructionData' }
),
(value) => ({ ...value, discriminator: 22 })
) as Serializer<
AddExternalPluginV1InstructionDataArgs,
AddExternalPluginV1InstructionData
AddExternalPluginAdapterV1InstructionDataArgs,
AddExternalPluginAdapterV1InstructionData
>;
}

// Args.
export type AddExternalPluginV1InstructionArgs =
AddExternalPluginV1InstructionDataArgs;
export type AddExternalPluginAdapterV1InstructionArgs =
AddExternalPluginAdapterV1InstructionDataArgs;

// Instruction.
export function addExternalPluginV1(
export function addExternalPluginAdapterV1(
context: Pick<Context, 'payer' | 'programs'>,
input: AddExternalPluginV1InstructionAccounts &
AddExternalPluginV1InstructionArgs
input: AddExternalPluginAdapterV1InstructionAccounts &
AddExternalPluginAdapterV1InstructionArgs
): TransactionBuilder {
// Program ID.
const programId = context.programs.getPublicKey(
Expand Down Expand Up @@ -131,7 +131,7 @@ export function addExternalPluginV1(
} satisfies ResolvedAccountsWithIndices;

// Arguments.
const resolvedArgs: AddExternalPluginV1InstructionArgs = { ...input };
const resolvedArgs: AddExternalPluginAdapterV1InstructionArgs = { ...input };

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

// Data.
const data = getAddExternalPluginV1InstructionDataSerializer().serialize(
resolvedArgs as AddExternalPluginV1InstructionDataArgs
);
const data =
getAddExternalPluginAdapterV1InstructionDataSerializer().serialize(
resolvedArgs as AddExternalPluginAdapterV1InstructionDataArgs
);

// Bytes Created On Chain.
const bytesCreatedOnChain = 0;
Expand Down
18 changes: 10 additions & 8 deletions clients/js/src/generated/instructions/createCollectionV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import {
getAccountMetasAndSigners,
} from '../shared';
import {
BaseExternalPluginInitInfo,
BaseExternalPluginInitInfoArgs,
BaseExternalPluginAdapterInitInfo,
BaseExternalPluginAdapterInitInfoArgs,
PluginAuthorityPair,
PluginAuthorityPairArgs,
getBaseExternalPluginInitInfoSerializer,
getBaseExternalPluginAdapterInitInfoSerializer,
getPluginAuthorityPairSerializer,
} from '../types';

Expand All @@ -58,14 +58,16 @@ export type CreateCollectionV2InstructionData = {
name: string;
uri: string;
plugins: Option<Array<PluginAuthorityPair>>;
externalPlugins: Option<Array<BaseExternalPluginInitInfo>>;
externalPluginAdapters: Option<Array<BaseExternalPluginAdapterInitInfo>>;
};

export type CreateCollectionV2InstructionDataArgs = {
name: string;
uri: string;
plugins?: OptionOrNullable<Array<PluginAuthorityPairArgs>>;
externalPlugins?: OptionOrNullable<Array<BaseExternalPluginInitInfoArgs>>;
externalPluginAdapters?: OptionOrNullable<
Array<BaseExternalPluginAdapterInitInfoArgs>
>;
};

export function getCreateCollectionV2InstructionDataSerializer(): Serializer<
Expand All @@ -84,8 +86,8 @@ export function getCreateCollectionV2InstructionDataSerializer(): Serializer<
['uri', string()],
['plugins', option(array(getPluginAuthorityPairSerializer()))],
[
'externalPlugins',
option(array(getBaseExternalPluginInitInfoSerializer())),
'externalPluginAdapters',
option(array(getBaseExternalPluginAdapterInitInfoSerializer())),
],
],
{ description: 'CreateCollectionV2InstructionData' }
Expand All @@ -94,7 +96,7 @@ export function getCreateCollectionV2InstructionDataSerializer(): Serializer<
...value,
discriminator: 21,
plugins: value.plugins ?? none(),
externalPlugins: value.externalPlugins ?? [],
externalPluginAdapters: value.externalPluginAdapters ?? [],
})
) as Serializer<
CreateCollectionV2InstructionDataArgs,
Expand Down
Loading

0 comments on commit c7d78b9

Please sign in to comment.