Skip to content

Commit

Permalink
Plugin registry init.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Feb 17, 2024
1 parent 9c28bb0 commit 433025d
Show file tree
Hide file tree
Showing 63 changed files with 7,563 additions and 243 deletions.
28 changes: 7 additions & 21 deletions clients/js/src/generated/accounts/hashedAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import {
Account,
Context,
Option,
OptionOrNullable,
Pda,
PublicKey,
RpcAccount,
Expand All @@ -24,25 +22,15 @@ import {
import {
Serializer,
bytes,
option,
struct,
u64,
} from '@metaplex-foundation/umi/serializers';
import { Key, KeyArgs, getKeySerializer } from '../types';

export type HashedAsset = Account<HashedAssetAccountData>;

export type HashedAssetAccountData = {
key: Key;
hash: Uint8Array;
watermarkSlot: Option<bigint>;
};
export type HashedAssetAccountData = { key: Key; hash: Uint8Array };

export type HashedAssetAccountDataArgs = {
key: KeyArgs;
hash: Uint8Array;
watermarkSlot: OptionOrNullable<number | bigint>;
};
export type HashedAssetAccountDataArgs = { key: KeyArgs; hash: Uint8Array };

export function getHashedAssetAccountDataSerializer(): Serializer<
HashedAssetAccountDataArgs,
Expand All @@ -52,7 +40,6 @@ export function getHashedAssetAccountDataSerializer(): Serializer<
[
['key', getKeySerializer()],
['hash', bytes({ size: 32 })],
['watermarkSlot', option(u64())],
],
{ description: 'HashedAssetAccountData' }
) as Serializer<HashedAssetAccountDataArgs, HashedAssetAccountData>;
Expand Down Expand Up @@ -124,16 +111,15 @@ export function getHashedAssetGpaBuilder(
'ASSETp3DinZKfiAyvdQG16YWWLJ2X3ZKjg9zku7n1sZD'
);
return gpaBuilder(context, programId)
.registerFields<{
key: KeyArgs;
hash: Uint8Array;
watermarkSlot: OptionOrNullable<number | bigint>;
}>({
.registerFields<{ key: KeyArgs; hash: Uint8Array }>({
key: [0, getKeySerializer()],
hash: [1, bytes({ size: 32 })],
watermarkSlot: [33, option(u64())],
})
.deserializeUsing<HashedAsset>((account) =>
deserializeHashedAsset(account)
);
}

export function getHashedAssetSize(): number {
return 33;
}
26 changes: 26 additions & 0 deletions clients/js/src/generated/errors/mplAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@ export class SerializationErrorError extends ProgramError {
codeToErrorMap.set(0x2, SerializationErrorError);
nameToErrorMap.set('SerializationError', SerializationErrorError);

/** PluginsNotInitialized: Plugins not initialized */
export class PluginsNotInitializedError extends ProgramError {
readonly name: string = 'PluginsNotInitialized';

readonly code: number = 0x3; // 3

constructor(program: Program, cause?: Error) {
super('Plugins not initialized', program, cause);
}
}
codeToErrorMap.set(0x3, PluginsNotInitializedError);
nameToErrorMap.set('PluginsNotInitialized', PluginsNotInitializedError);

/** PluginNotFound: Plugin not found */
export class PluginNotFoundError extends ProgramError {
readonly name: string = 'PluginNotFound';

readonly code: number = 0x4; // 4

constructor(program: Program, cause?: Error) {
super('Plugin not found', program, cause);
}
}
codeToErrorMap.set(0x4, PluginNotFoundError);
nameToErrorMap.set('PluginNotFound', PluginNotFoundError);

/**
* Attempts to resolve a custom program error from the provided error code.
* @category Errors
Expand Down
114 changes: 114 additions & 0 deletions clients/js/src/generated/instructions/burn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* 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';

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

// Data.
export type BurnInstructionData = { discriminator: number };

export type BurnInstructionDataArgs = {};

export function getBurnInstructionDataSerializer(): Serializer<
BurnInstructionDataArgs,
BurnInstructionData
> {
return mapSerializer<BurnInstructionDataArgs, any, BurnInstructionData>(
struct<BurnInstructionData>([['discriminator', u8()]], {
description: 'BurnInstructionData',
}),
(value) => ({ ...value, discriminator: 3 })
) as Serializer<BurnInstructionDataArgs, BurnInstructionData>;
}

// Instruction.
export function burn(
context: Pick<Context, 'identity' | 'programs'>,
input: BurnInstructionAccounts
): TransactionBuilder {
// Program ID.
const programId = context.programs.getPublicKey(
'mplAsset',
'ASSETp3DinZKfiAyvdQG16YWWLJ2X3ZKjg9zku7n1sZD'
);

// Accounts.
const resolvedAccounts: ResolvedAccountsWithIndices = {
assetAddress: {
index: 0,
isWritable: true,
value: input.assetAddress ?? 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 },
logWrapper: {
index: 4,
isWritable: false,
value: input.logWrapper ?? null,
},
};

// Default values.
if (!resolvedAccounts.authority.value) {
resolvedAccounts.authority.value = context.identity;
}

// 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 = getBurnInstructionDataSerializer().serialize({});

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

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

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

// Data.
export type CompressInstructionData = { discriminator: number };

export type CompressInstructionDataArgs = {};

export function getCompressInstructionDataSerializer(): Serializer<
CompressInstructionDataArgs,
CompressInstructionData
> {
return mapSerializer<
CompressInstructionDataArgs,
any,
CompressInstructionData
>(
struct<CompressInstructionData>([['discriminator', u8()]], {
description: 'CompressInstructionData',
}),
(value) => ({ ...value, discriminator: 8 })
) as Serializer<CompressInstructionDataArgs, CompressInstructionData>;
}

// Instruction.
export function compress(
context: Pick<Context, 'programs'>,
input: CompressInstructionAccounts
): TransactionBuilder {
// Program ID.
const programId = context.programs.getPublicKey(
'mplAsset',
'ASSETp3DinZKfiAyvdQG16YWWLJ2X3ZKjg9zku7n1sZD'
);

// Accounts.
const resolvedAccounts: ResolvedAccountsWithIndices = {
assetAddress: {
index: 0,
isWritable: true,
value: input.assetAddress ?? null,
},
owner: { index: 1, isWritable: false, value: input.owner ?? 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,
},
};

// Default values.
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 = getCompressInstructionDataSerializer().serialize({});

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

return transactionBuilder([
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
]);
}
Loading

0 comments on commit 433025d

Please sign in to comment.