Skip to content

Commit

Permalink
Showing 30 changed files with 721 additions and 198 deletions.
2 changes: 2 additions & 0 deletions clients/js/src/generated/accounts/index.ts
Original file line number Diff line number Diff line change
@@ -8,3 +8,5 @@

export * from './asset';
export * from './hashedAsset';
export * from './pluginHeader';
export * from './pluginRegistry';
127 changes: 127 additions & 0 deletions clients/js/src/generated/accounts/pluginHeader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* 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 {
Account,
Context,
Pda,
PublicKey,
RpcAccount,
RpcGetAccountOptions,
RpcGetAccountsOptions,
assertAccountExists,
deserializeAccount,
gpaBuilder,
publicKey as toPublicKey,
} from '@metaplex-foundation/umi';
import { Serializer, struct, u64 } from '@metaplex-foundation/umi/serializers';
import { Key, KeyArgs, getKeySerializer } from '../types';

export type PluginHeader = Account<PluginHeaderAccountData>;

export type PluginHeaderAccountData = {
key: Key;
pluginRegistryOffset: bigint;
};

export type PluginHeaderAccountDataArgs = {
key: KeyArgs;
pluginRegistryOffset: number | bigint;
};

export function getPluginHeaderAccountDataSerializer(): Serializer<
PluginHeaderAccountDataArgs,
PluginHeaderAccountData
> {
return struct<PluginHeaderAccountData>(
[
['key', getKeySerializer()],
['pluginRegistryOffset', u64()],
],
{ description: 'PluginHeaderAccountData' }
) as Serializer<PluginHeaderAccountDataArgs, PluginHeaderAccountData>;
}

export function deserializePluginHeader(rawAccount: RpcAccount): PluginHeader {
return deserializeAccount(rawAccount, getPluginHeaderAccountDataSerializer());
}

export async function fetchPluginHeader(
context: Pick<Context, 'rpc'>,
publicKey: PublicKey | Pda,
options?: RpcGetAccountOptions
): Promise<PluginHeader> {
const maybeAccount = await context.rpc.getAccount(
toPublicKey(publicKey, false),
options
);
assertAccountExists(maybeAccount, 'PluginHeader');
return deserializePluginHeader(maybeAccount);
}

export async function safeFetchPluginHeader(
context: Pick<Context, 'rpc'>,
publicKey: PublicKey | Pda,
options?: RpcGetAccountOptions
): Promise<PluginHeader | null> {
const maybeAccount = await context.rpc.getAccount(
toPublicKey(publicKey, false),
options
);
return maybeAccount.exists ? deserializePluginHeader(maybeAccount) : null;
}

export async function fetchAllPluginHeader(
context: Pick<Context, 'rpc'>,
publicKeys: Array<PublicKey | Pda>,
options?: RpcGetAccountsOptions
): Promise<PluginHeader[]> {
const maybeAccounts = await context.rpc.getAccounts(
publicKeys.map((key) => toPublicKey(key, false)),
options
);
return maybeAccounts.map((maybeAccount) => {
assertAccountExists(maybeAccount, 'PluginHeader');
return deserializePluginHeader(maybeAccount);
});
}

export async function safeFetchAllPluginHeader(
context: Pick<Context, 'rpc'>,
publicKeys: Array<PublicKey | Pda>,
options?: RpcGetAccountsOptions
): Promise<PluginHeader[]> {
const maybeAccounts = await context.rpc.getAccounts(
publicKeys.map((key) => toPublicKey(key, false)),
options
);
return maybeAccounts
.filter((maybeAccount) => maybeAccount.exists)
.map((maybeAccount) => deserializePluginHeader(maybeAccount as RpcAccount));
}

export function getPluginHeaderGpaBuilder(
context: Pick<Context, 'rpc' | 'programs'>
) {
const programId = context.programs.getPublicKey(
'mplAsset',
'ASSETp3DinZKfiAyvdQG16YWWLJ2X3ZKjg9zku7n1sZD'
);
return gpaBuilder(context, programId)
.registerFields<{ key: KeyArgs; pluginRegistryOffset: number | bigint }>({
key: [0, getKeySerializer()],
pluginRegistryOffset: [1, u64()],
})
.deserializeUsing<PluginHeader>((account) =>
deserializePluginHeader(account)
);
}

export function getPluginHeaderSize(): number {
return 9;
}
152 changes: 152 additions & 0 deletions clients/js/src/generated/accounts/pluginRegistry.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 {
Account,
Context,
Pda,
PublicKey,
RpcAccount,
RpcGetAccountOptions,
RpcGetAccountsOptions,
assertAccountExists,
deserializeAccount,
gpaBuilder,
publicKey as toPublicKey,
} from '@metaplex-foundation/umi';
import {
Serializer,
array,
struct,
} from '@metaplex-foundation/umi/serializers';
import {
ExternalPluginRecord,
ExternalPluginRecordArgs,
Key,
KeyArgs,
RegistryRecord,
RegistryRecordArgs,
getExternalPluginRecordSerializer,
getKeySerializer,
getRegistryRecordSerializer,
} from '../types';

export type PluginRegistry = Account<PluginRegistryAccountData>;

export type PluginRegistryAccountData = {
key: Key;
registry: Array<RegistryRecord>;
externalPlugins: Array<ExternalPluginRecord>;
};

export type PluginRegistryAccountDataArgs = {
key: KeyArgs;
registry: Array<RegistryRecordArgs>;
externalPlugins: Array<ExternalPluginRecordArgs>;
};

export function getPluginRegistryAccountDataSerializer(): Serializer<
PluginRegistryAccountDataArgs,
PluginRegistryAccountData
> {
return struct<PluginRegistryAccountData>(
[
['key', getKeySerializer()],
['registry', array(getRegistryRecordSerializer())],
['externalPlugins', array(getExternalPluginRecordSerializer())],
],
{ description: 'PluginRegistryAccountData' }
) as Serializer<PluginRegistryAccountDataArgs, PluginRegistryAccountData>;
}

export function deserializePluginRegistry(
rawAccount: RpcAccount
): PluginRegistry {
return deserializeAccount(
rawAccount,
getPluginRegistryAccountDataSerializer()
);
}

export async function fetchPluginRegistry(
context: Pick<Context, 'rpc'>,
publicKey: PublicKey | Pda,
options?: RpcGetAccountOptions
): Promise<PluginRegistry> {
const maybeAccount = await context.rpc.getAccount(
toPublicKey(publicKey, false),
options
);
assertAccountExists(maybeAccount, 'PluginRegistry');
return deserializePluginRegistry(maybeAccount);
}

export async function safeFetchPluginRegistry(
context: Pick<Context, 'rpc'>,
publicKey: PublicKey | Pda,
options?: RpcGetAccountOptions
): Promise<PluginRegistry | null> {
const maybeAccount = await context.rpc.getAccount(
toPublicKey(publicKey, false),
options
);
return maybeAccount.exists ? deserializePluginRegistry(maybeAccount) : null;
}

export async function fetchAllPluginRegistry(
context: Pick<Context, 'rpc'>,
publicKeys: Array<PublicKey | Pda>,
options?: RpcGetAccountsOptions
): Promise<PluginRegistry[]> {
const maybeAccounts = await context.rpc.getAccounts(
publicKeys.map((key) => toPublicKey(key, false)),
options
);
return maybeAccounts.map((maybeAccount) => {
assertAccountExists(maybeAccount, 'PluginRegistry');
return deserializePluginRegistry(maybeAccount);
});
}

export async function safeFetchAllPluginRegistry(
context: Pick<Context, 'rpc'>,
publicKeys: Array<PublicKey | Pda>,
options?: RpcGetAccountsOptions
): Promise<PluginRegistry[]> {
const maybeAccounts = await context.rpc.getAccounts(
publicKeys.map((key) => toPublicKey(key, false)),
options
);
return maybeAccounts
.filter((maybeAccount) => maybeAccount.exists)
.map((maybeAccount) =>
deserializePluginRegistry(maybeAccount as RpcAccount)
);
}

export function getPluginRegistryGpaBuilder(
context: Pick<Context, 'rpc' | 'programs'>
) {
const programId = context.programs.getPublicKey(
'mplAsset',
'ASSETp3DinZKfiAyvdQG16YWWLJ2X3ZKjg9zku7n1sZD'
);
return gpaBuilder(context, programId)
.registerFields<{
key: KeyArgs;
registry: Array<RegistryRecordArgs>;
externalPlugins: Array<ExternalPluginRecordArgs>;
}>({
key: [0, getKeySerializer()],
registry: [1, array(getRegistryRecordSerializer())],
externalPlugins: [null, array(getExternalPluginRecordSerializer())],
})
.deserializeUsing<PluginRegistry>((account) =>
deserializePluginRegistry(account)
);
}
21 changes: 17 additions & 4 deletions clients/js/src/generated/errors/mplAsset.ts
Original file line number Diff line number Diff line change
@@ -80,30 +80,43 @@ export class PluginNotFoundError extends ProgramError {
codeToErrorMap.set(0x4, PluginNotFoundError);
nameToErrorMap.set('PluginNotFound', PluginNotFoundError);

/** NumericalOverflow: Numerical Overflow */
export class NumericalOverflowError extends ProgramError {
readonly name: string = 'NumericalOverflow';

readonly code: number = 0x5; // 5

constructor(program: Program, cause?: Error) {
super('Numerical Overflow', program, cause);
}
}
codeToErrorMap.set(0x5, NumericalOverflowError);
nameToErrorMap.set('NumericalOverflow', NumericalOverflowError);

/** IncorrectAccount: Incorrect account */
export class IncorrectAccountError extends ProgramError {
readonly name: string = 'IncorrectAccount';

readonly code: number = 0x5; // 5
readonly code: number = 0x6; // 6

constructor(program: Program, cause?: Error) {
super('Incorrect account', program, cause);
}
}
codeToErrorMap.set(0x5, IncorrectAccountError);
codeToErrorMap.set(0x6, IncorrectAccountError);
nameToErrorMap.set('IncorrectAccount', IncorrectAccountError);

/** IncorrectAssetHash: Incorrect asset hash */
export class IncorrectAssetHashError extends ProgramError {
readonly name: string = 'IncorrectAssetHash';

readonly code: number = 0x6; // 6
readonly code: number = 0x7; // 7

constructor(program: Program, cause?: Error) {
super('Incorrect asset hash', program, cause);
}
}
codeToErrorMap.set(0x6, IncorrectAssetHashError);
codeToErrorMap.set(0x7, IncorrectAssetHashError);
nameToErrorMap.set('IncorrectAssetHash', IncorrectAssetHashError);

/**
12 changes: 12 additions & 0 deletions clients/js/src/generated/types/authority.ts
Original file line number Diff line number Diff line change
@@ -20,12 +20,14 @@ import { Plugin, PluginArgs, getPluginSerializer } from '.';

export type Authority =
| { __kind: 'Owner' }
| { __kind: 'Pubkey'; address: PublicKey }
| { __kind: 'Permanent'; address: PublicKey }
| { __kind: 'SameAs'; plugin: Plugin }
| { __kind: 'Collection' };

export type AuthorityArgs =
| { __kind: 'Owner' }
| { __kind: 'Pubkey'; address: PublicKey }
| { __kind: 'Permanent'; address: PublicKey }
| { __kind: 'SameAs'; plugin: PluginArgs }
| { __kind: 'Collection' };
@@ -34,6 +36,12 @@ export function getAuthoritySerializer(): Serializer<AuthorityArgs, Authority> {
return dataEnum<Authority>(
[
['Owner', unit()],
[
'Pubkey',
struct<GetDataEnumKindContent<Authority, 'Pubkey'>>([
['address', publicKeySerializer()],
]),
],
[
'Permanent',
struct<GetDataEnumKindContent<Authority, 'Permanent'>>([
@@ -56,6 +64,10 @@ export function getAuthoritySerializer(): Serializer<AuthorityArgs, Authority> {
export function authority(
kind: 'Owner'
): GetDataEnumKind<AuthorityArgs, 'Owner'>;
export function authority(
kind: 'Pubkey',
data: GetDataEnumKindContent<AuthorityArgs, 'Pubkey'>
): GetDataEnumKind<AuthorityArgs, 'Pubkey'>;
export function authority(
kind: 'Permanent',
data: GetDataEnumKindContent<AuthorityArgs, 'Permanent'>
15 changes: 10 additions & 5 deletions clients/js/src/generated/types/delegate.ts
Original file line number Diff line number Diff line change
@@ -7,13 +7,18 @@
*/

import { Serializer, bool, struct } from '@metaplex-foundation/umi/serializers';
import { Key, KeyArgs, getKeySerializer } from '.';

export type Delegate = { frozen: boolean };
export type Delegate = { key: Key; frozen: boolean };

export type DelegateArgs = Delegate;
export type DelegateArgs = { key: KeyArgs; frozen: boolean };

export function getDelegateSerializer(): Serializer<DelegateArgs, Delegate> {
return struct<Delegate>([['frozen', bool()]], {
description: 'Delegate',
}) as Serializer<DelegateArgs, Delegate>;
return struct<Delegate>(
[
['key', getKeySerializer()],
['frozen', bool()],
],
{ description: 'Delegate' }
) as Serializer<DelegateArgs, Delegate>;
}
Loading

0 comments on commit 885328d

Please sign in to comment.