generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- release/core@0.9.1
- release/core@0.9.0
- mpl-core-v0.4.1
- mpl-core-v0.4.0
- mpl-core-v0.3.0
- mpl-core-v0.2.0
- mpl-core-v0.1.0
- mpl-core@v0.8.1-beta.1
- mpl-core@v0.8.0
- mpl-core@v0.8.0-beta.1
- mpl-core@v0.8.0-alpha.2
- mpl-core@v0.8.0-alpha.1
- mpl-core@v0.7.2
- mpl-core@v0.7.1
- mpl-core@v0.7.0
- mpl-core@v0.6.1
- mpl-core@v0.6.0
- mpl-core@v0.5.1
- mpl-core@v0.5.0
- mpl-core@v0.4.4
- mpl-core@v0.4.3
- mpl-core@v0.4.2
- js@v1.1.1
- js@v1.1.0
- js@v1.1.0-alpha.1
- js@v1.1.0-alpha.0
- js@v1.0.2
- js@v1.0.1
- js@v1.0.0
- js@v0.4.7
- js@v0.4.6
- js@v0.4.5
- devnet-20240503
- core-devnet
1 parent
99f16c6
commit 885328d
Showing
30 changed files
with
721 additions
and
198 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
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; | ||
} |
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,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) | ||
); | ||
} |
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
Oops, something went wrong.