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

V2/recipe #7

Merged
merged 9 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/build-programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ jobs:
name: program-builds
# First wildcard ensures exported paths are consistently under the programs folder.
path: ./program*/.bin/*.so
include-hidden-files: true
if-no-files-found: error
1 change: 1 addition & 0 deletions .github/workflows/build-rust-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ jobs:
name: rust-client-builds
# First wildcard ensures exported paths are consistently under the clients folder.
path: ./targe*/release/*mpl_hybrid*
include-hidden-files: true
if-no-files-found: error
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ dist
.yarn
programs/.bin
clients/js/output.json
mp14o4AQcmE5meFDxCscervMc1E4zyKEyDp3398PcwU.json
MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb.json
1 change: 1 addition & 0 deletions Cargo.lock

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

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

export type EscrowV2 = Account<EscrowV2AccountData>;

export type EscrowV2AccountData = {
discriminator: Array<number>;
authority: PublicKey;
bump: number;
};

export type EscrowV2AccountDataArgs = { authority: PublicKey; bump: number };

export function getEscrowV2AccountDataSerializer(): Serializer<
EscrowV2AccountDataArgs,
EscrowV2AccountData
> {
return mapSerializer<EscrowV2AccountDataArgs, any, EscrowV2AccountData>(
struct<EscrowV2AccountData>(
[
['discriminator', array(u8(), { size: 8 })],
['authority', publicKeySerializer()],
['bump', u8()],
],
{ description: 'EscrowV2AccountData' }
),
(value) => ({
...value,
discriminator: [229, 26, 241, 181, 158, 158, 70, 190],
})
) as Serializer<EscrowV2AccountDataArgs, EscrowV2AccountData>;
}

export function deserializeEscrowV2(rawAccount: RpcAccount): EscrowV2 {
return deserializeAccount(rawAccount, getEscrowV2AccountDataSerializer());
}

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

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

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

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

export function getEscrowV2GpaBuilder(
context: Pick<Context, 'rpc' | 'programs'>
) {
const programId = context.programs.getPublicKey(
'mplHybrid',
'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb'
);
return gpaBuilder(context, programId)
.registerFields<{
discriminator: Array<number>;
authority: PublicKey;
bump: number;
}>({
discriminator: [0, array(u8(), { size: 8 })],
authority: [8, publicKeySerializer()],
bump: [40, u8()],
})
.deserializeUsing<EscrowV2>((account) => deserializeEscrowV2(account))
.whereField('discriminator', [229, 26, 241, 181, 158, 158, 70, 190]);
}

export function getEscrowV2Size(): number {
return 41;
}
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 @@ -7,4 +7,6 @@
*/

export * from './escrowV1';
export * from './escrowV2';
export * from './nftDataV1';
export * from './recipeV1';
214 changes: 214 additions & 0 deletions clients/js/src/generated/accounts/recipeV1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
/**
* 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,
mapSerializer,
publicKey as publicKeySerializer,
string,
struct,
u16,
u64,
u8,
} from '@metaplex-foundation/umi/serializers';

export type RecipeV1 = Account<RecipeV1AccountData>;

export type RecipeV1AccountData = {
discriminator: Array<number>;
collection: PublicKey;
authority: PublicKey;
token: PublicKey;
feeLocation: PublicKey;
name: string;
uri: string;
max: bigint;
min: bigint;
amount: bigint;
feeAmountCapture: bigint;
solFeeAmountCapture: bigint;
feeAmountRelease: bigint;
solFeeAmountRelease: bigint;
count: bigint;
path: number;
bump: number;
};

export type RecipeV1AccountDataArgs = {
collection: PublicKey;
authority: PublicKey;
token: PublicKey;
feeLocation: PublicKey;
name: string;
uri: string;
max: number | bigint;
min: number | bigint;
amount: number | bigint;
feeAmountCapture: number | bigint;
solFeeAmountCapture: number | bigint;
feeAmountRelease: number | bigint;
solFeeAmountRelease: number | bigint;
count: number | bigint;
path: number;
bump: number;
};

export function getRecipeV1AccountDataSerializer(): Serializer<
RecipeV1AccountDataArgs,
RecipeV1AccountData
> {
return mapSerializer<RecipeV1AccountDataArgs, any, RecipeV1AccountData>(
struct<RecipeV1AccountData>(
[
['discriminator', array(u8(), { size: 8 })],
['collection', publicKeySerializer()],
['authority', publicKeySerializer()],
['token', publicKeySerializer()],
['feeLocation', publicKeySerializer()],
['name', string()],
['uri', string()],
['max', u64()],
['min', u64()],
['amount', u64()],
['feeAmountCapture', u64()],
['solFeeAmountCapture', u64()],
['feeAmountRelease', u64()],
['solFeeAmountRelease', u64()],
['count', u64()],
['path', u16()],
['bump', u8()],
],
{ description: 'RecipeV1AccountData' }
),
(value) => ({
...value,
discriminator: [137, 249, 37, 80, 19, 50, 78, 169],
})
) as Serializer<RecipeV1AccountDataArgs, RecipeV1AccountData>;
}

export function deserializeRecipeV1(rawAccount: RpcAccount): RecipeV1 {
return deserializeAccount(rawAccount, getRecipeV1AccountDataSerializer());
}

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

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

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

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

export function getRecipeV1GpaBuilder(
context: Pick<Context, 'rpc' | 'programs'>
) {
const programId = context.programs.getPublicKey(
'mplHybrid',
'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb'
);
return gpaBuilder(context, programId)
.registerFields<{
discriminator: Array<number>;
collection: PublicKey;
authority: PublicKey;
token: PublicKey;
feeLocation: PublicKey;
name: string;
uri: string;
max: number | bigint;
min: number | bigint;
amount: number | bigint;
feeAmountCapture: number | bigint;
solFeeAmountCapture: number | bigint;
feeAmountRelease: number | bigint;
solFeeAmountRelease: number | bigint;
count: number | bigint;
path: number;
bump: number;
}>({
discriminator: [0, array(u8(), { size: 8 })],
collection: [8, publicKeySerializer()],
authority: [40, publicKeySerializer()],
token: [72, publicKeySerializer()],
feeLocation: [104, publicKeySerializer()],
name: [136, string()],
uri: [null, string()],
max: [null, u64()],
min: [null, u64()],
amount: [null, u64()],
feeAmountCapture: [null, u64()],
solFeeAmountCapture: [null, u64()],
feeAmountRelease: [null, u64()],
solFeeAmountRelease: [null, u64()],
count: [null, u64()],
path: [null, u16()],
bump: [null, u8()],
})
.deserializeUsing<RecipeV1>((account) => deserializeRecipeV1(account))
.whereField('discriminator', [137, 249, 37, 80, 19, 50, 78, 169]);
}
Loading
Loading