Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding execute IX #210

Merged
merged 15 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

156 changes: 156 additions & 0 deletions clients/js/src/generated/accounts/assetSigner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/**
* 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,
bytes,
publicKey as publicKeySerializer,
string,
struct,
} from '@metaplex-foundation/umi/serializers';

export type AssetSigner = Account<AssetSignerAccountData>;

export type AssetSignerAccountData = { data: Uint8Array };

export type AssetSignerAccountDataArgs = AssetSignerAccountData;

export function getAssetSignerAccountDataSerializer(): Serializer<
AssetSignerAccountDataArgs,
AssetSignerAccountData
> {
return struct<AssetSignerAccountData>([['data', bytes()]], {
description: 'AssetSignerAccountData',
}) as Serializer<AssetSignerAccountDataArgs, AssetSignerAccountData>;
}

export function deserializeAssetSigner(rawAccount: RpcAccount): AssetSigner {
return deserializeAccount(rawAccount, getAssetSignerAccountDataSerializer());
}

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

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

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

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

export function getAssetSignerGpaBuilder(
context: Pick<Context, 'rpc' | 'programs'>
) {
const programId = context.programs.getPublicKey(
'mplCore',
'CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d'
);
return gpaBuilder(context, programId)
.registerFields<{ data: Uint8Array }>({ data: [0, bytes()] })
.deserializeUsing<AssetSigner>((account) =>
deserializeAssetSigner(account)
);
}

export function getAssetSignerSize(): number {
return 0;
}

export function findAssetSignerPda(
context: Pick<Context, 'eddsa' | 'programs'>,
seeds: {
/** The address of the asset account */
asset: PublicKey;
}
): Pda {
const programId = context.programs.getPublicKey(
'mplCore',
'CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d'
);
return context.eddsa.findPda(programId, [
string({ size: 'variable' }).serialize('mpl-core-execute'),
publicKeySerializer().serialize(seeds.asset),
]);
}

export async function fetchAssetSignerFromSeeds(
context: Pick<Context, 'eddsa' | 'programs' | 'rpc'>,
seeds: Parameters<typeof findAssetSignerPda>[1],
options?: RpcGetAccountOptions
): Promise<AssetSigner> {
return fetchAssetSigner(context, findAssetSignerPda(context, seeds), options);
}

export async function safeFetchAssetSignerFromSeeds(
context: Pick<Context, 'eddsa' | 'programs' | 'rpc'>,
seeds: Parameters<typeof findAssetSignerPda>[1],
options?: RpcGetAccountOptions
): Promise<AssetSigner | null> {
return safeFetchAssetSigner(
context,
findAssetSignerPda(context, seeds),
options
);
}
170 changes: 170 additions & 0 deletions clients/js/src/generated/accounts/collectionSigner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/**
* 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,
bytes,
publicKey as publicKeySerializer,
string,
struct,
} from '@metaplex-foundation/umi/serializers';

export type CollectionSigner = Account<CollectionSignerAccountData>;

export type CollectionSignerAccountData = { data: Uint8Array };

export type CollectionSignerAccountDataArgs = CollectionSignerAccountData;

export function getCollectionSignerAccountDataSerializer(): Serializer<
CollectionSignerAccountDataArgs,
CollectionSignerAccountData
> {
return struct<CollectionSignerAccountData>([['data', bytes()]], {
description: 'CollectionSignerAccountData',
}) as Serializer<
CollectionSignerAccountDataArgs,
CollectionSignerAccountData
>;
}

export function deserializeCollectionSigner(
rawAccount: RpcAccount
): CollectionSigner {
return deserializeAccount(
rawAccount,
getCollectionSignerAccountDataSerializer()
);
}

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

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

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

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

export function getCollectionSignerGpaBuilder(
context: Pick<Context, 'rpc' | 'programs'>
) {
const programId = context.programs.getPublicKey(
'mplCore',
'CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d'
);
return gpaBuilder(context, programId)
.registerFields<{ data: Uint8Array }>({ data: [0, bytes()] })
.deserializeUsing<CollectionSigner>((account) =>
deserializeCollectionSigner(account)
);
}

export function getCollectionSignerSize(): number {
return 0;
}

export function findCollectionSignerPda(
context: Pick<Context, 'eddsa' | 'programs'>,
seeds: {
/** The address of the collection account */
collection: PublicKey;
}
): Pda {
const programId = context.programs.getPublicKey(
'mplCore',
'CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d'
);
return context.eddsa.findPda(programId, [
string({ size: 'variable' }).serialize('mpl-core-execute'),
publicKeySerializer().serialize(seeds.collection),
]);
}

export async function fetchCollectionSignerFromSeeds(
context: Pick<Context, 'eddsa' | 'programs' | 'rpc'>,
seeds: Parameters<typeof findCollectionSignerPda>[1],
options?: RpcGetAccountOptions
): Promise<CollectionSigner> {
return fetchCollectionSigner(
context,
findCollectionSignerPda(context, seeds),
options
);
}

export async function safeFetchCollectionSignerFromSeeds(
context: Pick<Context, 'eddsa' | 'programs' | 'rpc'>,
seeds: Parameters<typeof findCollectionSignerPda>[1],
options?: RpcGetAccountOptions
): Promise<CollectionSigner | null> {
return safeFetchCollectionSigner(
context,
findCollectionSignerPda(context, seeds),
options
);
}
2 changes: 2 additions & 0 deletions clients/js/src/generated/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* @see https://github.com/metaplex-foundation/kinobi
*/

export * from './assetSigner';
export * from './assetV1';
export * from './collectionSigner';
export * from './collectionV1';
export * from './hashedAssetV1';
export * from './pluginHeaderV1';
Expand Down
17 changes: 17 additions & 0 deletions clients/js/src/generated/errors/mplCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,23 @@ nameToErrorMap.set(
PermanentDelegatesPreventMoveError
);

/** InvalidExecutePda: Invalid Signing PDA for Asset or Collection Execute */
export class InvalidExecutePdaError extends ProgramError {
override readonly name: string = 'InvalidExecutePda';

readonly code: number = 0x31; // 49

constructor(program: Program, cause?: Error) {
super(
'Invalid Signing PDA for Asset or Collection Execute',
program,
cause
);
}
}
codeToErrorMap.set(0x31, InvalidExecutePdaError);
nameToErrorMap.set('InvalidExecutePda', InvalidExecutePdaError);

/**
* Attempts to resolve a custom program error from the provided error code.
* @category Errors
Expand Down
Loading
Loading