From 3c293eb67b3b3ce093f445922085b166b8438526 Mon Sep 17 00:00:00 2001 From: Michael Danenberg <56533526+danenbm@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:05:20 -0800 Subject: [PATCH] Regenerate IDL and clients --- .../generated/accounts/hashedAssetSchema.ts | 143 ------------------ clients/js/src/generated/accounts/index.ts | 1 - .../src/generated/types/hashedAssetSchema.ts | 38 +++++ clients/js/src/generated/types/index.ts | 1 + clients/rust/src/generated/accounts/mod.rs | 2 - .../hashed_asset_schema.rs | 19 --- clients/rust/src/generated/types/mod.rs | 2 + idls/mpl_asset_program.json | 50 +++--- 8 files changed, 66 insertions(+), 190 deletions(-) delete mode 100644 clients/js/src/generated/accounts/hashedAssetSchema.ts create mode 100644 clients/js/src/generated/types/hashedAssetSchema.ts rename clients/rust/src/generated/{accounts => types}/hashed_asset_schema.rs (51%) diff --git a/clients/js/src/generated/accounts/hashedAssetSchema.ts b/clients/js/src/generated/accounts/hashedAssetSchema.ts deleted file mode 100644 index 7486487b..00000000 --- a/clients/js/src/generated/accounts/hashedAssetSchema.ts +++ /dev/null @@ -1,143 +0,0 @@ -/** - * 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, - bytes, - struct, -} from '@metaplex-foundation/umi/serializers'; -import { PluginHash, PluginHashArgs, getPluginHashSerializer } from '../types'; - -export type HashedAssetSchema = Account; - -export type HashedAssetSchemaAccountData = { - assetHash: Uint8Array; - pluginHashes: Array; -}; - -export type HashedAssetSchemaAccountDataArgs = { - assetHash: Uint8Array; - pluginHashes: Array; -}; - -export function getHashedAssetSchemaAccountDataSerializer(): Serializer< - HashedAssetSchemaAccountDataArgs, - HashedAssetSchemaAccountData -> { - return struct( - [ - ['assetHash', bytes({ size: 32 })], - ['pluginHashes', array(getPluginHashSerializer())], - ], - { description: 'HashedAssetSchemaAccountData' } - ) as Serializer< - HashedAssetSchemaAccountDataArgs, - HashedAssetSchemaAccountData - >; -} - -export function deserializeHashedAssetSchema( - rawAccount: RpcAccount -): HashedAssetSchema { - return deserializeAccount( - rawAccount, - getHashedAssetSchemaAccountDataSerializer() - ); -} - -export async function fetchHashedAssetSchema( - context: Pick, - publicKey: PublicKey | Pda, - options?: RpcGetAccountOptions -): Promise { - const maybeAccount = await context.rpc.getAccount( - toPublicKey(publicKey, false), - options - ); - assertAccountExists(maybeAccount, 'HashedAssetSchema'); - return deserializeHashedAssetSchema(maybeAccount); -} - -export async function safeFetchHashedAssetSchema( - context: Pick, - publicKey: PublicKey | Pda, - options?: RpcGetAccountOptions -): Promise { - const maybeAccount = await context.rpc.getAccount( - toPublicKey(publicKey, false), - options - ); - return maybeAccount.exists - ? deserializeHashedAssetSchema(maybeAccount) - : null; -} - -export async function fetchAllHashedAssetSchema( - context: Pick, - publicKeys: Array, - options?: RpcGetAccountsOptions -): Promise { - const maybeAccounts = await context.rpc.getAccounts( - publicKeys.map((key) => toPublicKey(key, false)), - options - ); - return maybeAccounts.map((maybeAccount) => { - assertAccountExists(maybeAccount, 'HashedAssetSchema'); - return deserializeHashedAssetSchema(maybeAccount); - }); -} - -export async function safeFetchAllHashedAssetSchema( - context: Pick, - publicKeys: Array, - options?: RpcGetAccountsOptions -): Promise { - const maybeAccounts = await context.rpc.getAccounts( - publicKeys.map((key) => toPublicKey(key, false)), - options - ); - return maybeAccounts - .filter((maybeAccount) => maybeAccount.exists) - .map((maybeAccount) => - deserializeHashedAssetSchema(maybeAccount as RpcAccount) - ); -} - -export function getHashedAssetSchemaGpaBuilder( - context: Pick -) { - const programId = context.programs.getPublicKey( - 'mplAsset', - 'ASSETp3DinZKfiAyvdQG16YWWLJ2X3ZKjg9zku7n1sZD' - ); - return gpaBuilder(context, programId) - .registerFields<{ - assetHash: Uint8Array; - pluginHashes: Array; - }>({ - assetHash: [0, bytes({ size: 32 })], - pluginHashes: [32, array(getPluginHashSerializer())], - }) - .deserializeUsing((account) => - deserializeHashedAssetSchema(account) - ); -} diff --git a/clients/js/src/generated/accounts/index.ts b/clients/js/src/generated/accounts/index.ts index 9f425e40..2419a1f2 100644 --- a/clients/js/src/generated/accounts/index.ts +++ b/clients/js/src/generated/accounts/index.ts @@ -8,6 +8,5 @@ export * from './asset'; export * from './hashedAsset'; -export * from './hashedAssetSchema'; export * from './pluginHeader'; export * from './pluginRegistry'; diff --git a/clients/js/src/generated/types/hashedAssetSchema.ts b/clients/js/src/generated/types/hashedAssetSchema.ts new file mode 100644 index 00000000..2ac4339f --- /dev/null +++ b/clients/js/src/generated/types/hashedAssetSchema.ts @@ -0,0 +1,38 @@ +/** + * 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 { + Serializer, + array, + bytes, + struct, +} from '@metaplex-foundation/umi/serializers'; +import { PluginHash, PluginHashArgs, getPluginHashSerializer } from '.'; + +export type HashedAssetSchema = { + assetHash: Uint8Array; + pluginHashes: Array; +}; + +export type HashedAssetSchemaArgs = { + assetHash: Uint8Array; + pluginHashes: Array; +}; + +export function getHashedAssetSchemaSerializer(): Serializer< + HashedAssetSchemaArgs, + HashedAssetSchema +> { + return struct( + [ + ['assetHash', bytes({ size: 32 })], + ['pluginHashes', array(getPluginHashSerializer())], + ], + { description: 'HashedAssetSchema' } + ) as Serializer; +} diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index c96191a2..779362fa 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -15,6 +15,7 @@ export * from './dataState'; export * from './externalPluginRecord'; export * from './extraAccounts'; export * from './freeze'; +export * from './hashedAssetSchema'; export * from './key'; export * from './migrationLevel'; export * from './plugin'; diff --git a/clients/rust/src/generated/accounts/mod.rs b/clients/rust/src/generated/accounts/mod.rs index 4b9c310e..6f60f76e 100644 --- a/clients/rust/src/generated/accounts/mod.rs +++ b/clients/rust/src/generated/accounts/mod.rs @@ -7,12 +7,10 @@ pub(crate) mod asset; pub(crate) mod hashed_asset; -pub(crate) mod hashed_asset_schema; pub(crate) mod plugin_header; pub(crate) mod plugin_registry; pub use self::asset::*; pub use self::hashed_asset::*; -pub use self::hashed_asset_schema::*; pub use self::plugin_header::*; pub use self::plugin_registry::*; diff --git a/clients/rust/src/generated/accounts/hashed_asset_schema.rs b/clients/rust/src/generated/types/hashed_asset_schema.rs similarity index 51% rename from clients/rust/src/generated/accounts/hashed_asset_schema.rs rename to clients/rust/src/generated/types/hashed_asset_schema.rs index ea983bb8..f282fa66 100644 --- a/clients/rust/src/generated/accounts/hashed_asset_schema.rs +++ b/clients/rust/src/generated/types/hashed_asset_schema.rs @@ -15,22 +15,3 @@ pub struct HashedAssetSchema { pub asset_hash: [u8; 32], pub plugin_hashes: Vec, } - -impl HashedAssetSchema { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for HashedAssetSchema { - type Error = std::io::Error; - - fn try_from( - account_info: &solana_program::account_info::AccountInfo<'a>, - ) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index 6417d891..47bec8a0 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -14,6 +14,7 @@ pub(crate) mod data_state; pub(crate) mod external_plugin_record; pub(crate) mod extra_accounts; pub(crate) mod freeze; +pub(crate) mod hashed_asset_schema; pub(crate) mod key; pub(crate) mod migration_level; pub(crate) mod plugin; @@ -34,6 +35,7 @@ pub use self::data_state::*; pub use self::external_plugin_record::*; pub use self::extra_accounts::*; pub use self::freeze::*; +pub use self::hashed_asset_schema::*; pub use self::key::*; pub use self::migration_level::*; pub use self::plugin::*; diff --git a/idls/mpl_asset_program.json b/idls/mpl_asset_program.json index 22c2052f..a15cd3d5 100644 --- a/idls/mpl_asset_program.json +++ b/idls/mpl_asset_program.json @@ -835,31 +835,6 @@ } ] } - }, - { - "name": "HashedAssetSchema", - "type": { - "kind": "struct", - "fields": [ - { - "name": "assetHash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "pluginHashes", - "type": { - "vec": { - "defined": "PluginHash" - } - } - } - ] - } } ], "types": [ @@ -1233,6 +1208,31 @@ ] } }, + { + "name": "HashedAssetSchema", + "type": { + "kind": "struct", + "fields": [ + { + "name": "assetHash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "pluginHashes", + "type": { + "vec": { + "defined": "PluginHash" + } + } + } + ] + } + }, { "name": "Plugin", "type": {