-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from potatoe-dev/v2/recipe
V2/recipe
- Loading branch information
Showing
52 changed files
with
9,083 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | ||
} |
Oops, something went wrong.