From 7fe3d22c5f6673494d242358ada6d88092dbb30d Mon Sep 17 00:00:00 2001 From: blockiosaurus Date: Wed, 10 Apr 2024 10:52:18 -0400 Subject: [PATCH] Bummping Kinobi version and adding from-primitive derives. --- .../rust/src/generated/types/data_state.rs | 5 +- clients/rust/src/generated/types/key.rs | 5 +- .../rust/src/generated/types/plugin_type.rs | 5 +- clients/rust/src/hooked/mod.rs | 33 +-------- clients/rust/src/hooked/plugin.rs | 1 + clients/rust/src/indexable_asset.rs | 1 + package.json | 4 +- pnpm-lock.yaml | 73 ++++++++++++++----- 8 files changed, 72 insertions(+), 55 deletions(-) diff --git a/clients/rust/src/generated/types/data_state.rs b/clients/rust/src/generated/types/data_state.rs index 2c913cd7..c3f910a7 100644 --- a/clients/rust/src/generated/types/data_state.rs +++ b/clients/rust/src/generated/types/data_state.rs @@ -7,8 +7,11 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +use num_derive::FromPrimitive; -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[derive( + BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash, FromPrimitive, +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum DataState { AccountState, diff --git a/clients/rust/src/generated/types/key.rs b/clients/rust/src/generated/types/key.rs index 411e370a..451a6393 100644 --- a/clients/rust/src/generated/types/key.rs +++ b/clients/rust/src/generated/types/key.rs @@ -7,8 +7,11 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +use num_derive::FromPrimitive; -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[derive( + BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash, FromPrimitive, +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Key { Uninitialized, diff --git a/clients/rust/src/generated/types/plugin_type.rs b/clients/rust/src/generated/types/plugin_type.rs index e77335a8..58640a04 100644 --- a/clients/rust/src/generated/types/plugin_type.rs +++ b/clients/rust/src/generated/types/plugin_type.rs @@ -7,8 +7,11 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +use num_derive::FromPrimitive; -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[derive( + BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash, FromPrimitive, +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum PluginType { Royalties, diff --git a/clients/rust/src/hooked/mod.rs b/clients/rust/src/hooked/mod.rs index 13a027fa..860e42a6 100644 --- a/clients/rust/src/hooked/mod.rs +++ b/clients/rust/src/hooked/mod.rs @@ -11,6 +11,7 @@ pub mod collection; pub use collection::*; use borsh::{BorshDeserialize, BorshSerialize}; +use num_traits::FromPrimitive; use std::{cmp::Ordering, mem::size_of}; use crate::{ @@ -20,24 +21,6 @@ use crate::{ }; use solana_program::account_info::AccountInfo; -impl PluginType { - // Needed to determine if a plugin is a known or unknown type. - pub fn from_u8(n: u8) -> Option { - match n { - 0 => Some(PluginType::Royalties), - 1 => Some(PluginType::FreezeDelegate), - 2 => Some(PluginType::BurnDelegate), - 3 => Some(PluginType::TransferDelegate), - 4 => Some(PluginType::UpdateDelegate), - 5 => Some(PluginType::PermanentFreezeDelegate), - 6 => Some(PluginType::Attributes), - 7 => Some(PluginType::PermanentTransferDelegate), - 8 => Some(PluginType::PermanentBurnDelegate), - _ => None, - } - } -} - impl From<&Plugin> for PluginType { fn from(plugin: &Plugin) -> Self { match plugin { @@ -113,20 +96,6 @@ impl SolanaAccount for PluginHeaderV1 { } } -impl Key { - pub fn from_u8(value: u8) -> Option { - match value { - 0 => Some(Key::Uninitialized), - 1 => Some(Key::AssetV1), - 2 => Some(Key::HashedAssetV1), - 3 => Some(Key::PluginHeaderV1), - 4 => Some(Key::PluginRegistryV1), - 5 => Some(Key::CollectionV1), - _ => None, - } - } -} - /// Load the one byte key from the account data at the given offset. pub fn load_key(account: &AccountInfo, offset: usize) -> Result { let key = Key::from_u8((*account.data).borrow()[offset]).ok_or(std::io::Error::new( diff --git a/clients/rust/src/hooked/plugin.rs b/clients/rust/src/hooked/plugin.rs index 713c11c7..8f7ae261 100644 --- a/clients/rust/src/hooked/plugin.rs +++ b/clients/rust/src/hooked/plugin.rs @@ -1,4 +1,5 @@ use borsh::BorshDeserialize; +use num_traits::FromPrimitive; use solana_program::account_info::AccountInfo; use crate::{ diff --git a/clients/rust/src/indexable_asset.rs b/clients/rust/src/indexable_asset.rs index b458aa23..bd3c0147 100644 --- a/clients/rust/src/indexable_asset.rs +++ b/clients/rust/src/indexable_asset.rs @@ -1,5 +1,6 @@ use base64::prelude::*; use borsh::BorshDeserialize; +use num_traits::FromPrimitive; use solana_program::pubkey::Pubkey; use std::{collections::HashMap, io::ErrorKind}; diff --git a/package.json b/package.json index 83512b6c..ecfe3e28 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,9 @@ }, "devDependencies": { "@metaplex-foundation/amman": "^0.12.1", - "@metaplex-foundation/kinobi": "^0.17.7", + "@metaplex-foundation/kinobi": "^0.18.3", "@metaplex-foundation/shank-js": "^0.1.7", "typescript": "^4.9.4" }, "packageManager": "pnpm@8.9.0" -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 93c01b4d..19fba33a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ devDependencies: specifier: ^0.12.1 version: 0.12.1(typescript@4.9.4) '@metaplex-foundation/kinobi': - specifier: ^0.17.7 - version: 0.17.7(fastestsmallesttextencoderdecoder@1.0.22) + specifier: ^0.18.3 + version: 0.18.3(fastestsmallesttextencoderdecoder@1.0.22) '@metaplex-foundation/shank-js': specifier: ^0.1.7 version: 0.1.7 @@ -89,15 +89,16 @@ packages: resolution: {integrity: sha512-S9RulC2fFCFOQraz61bij+5YCHhSO9llJegK8c8Y6731fSi6snUSQJdCUqYS8AIgR0TKbQvdvgSyIIdbDFZbBA==} dev: true - /@metaplex-foundation/kinobi@0.17.7(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-cfx33zB/a0WH4q9ECoIIEGY3xmQZnmCQThz0oEqUZQ3755DIAv+WwHz3smTvKCLgNj2zchZ45O0xggo/egf1sA==} + /@metaplex-foundation/kinobi@0.18.3(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-va8n1DVYlzhVA6xLpTgiUzxRUB3Dvo53pwDUYYEuKBX43zXKrgg5SWZ438UX23/5iFNv+6M01L+5/Z4oh43fAw==} dependencies: '@noble/hashes': 1.4.0 - '@solana/codecs-strings': 2.0.0-experimental.a157265(fastestsmallesttextencoderdecoder@1.0.22) + '@prettier/sync': 0.5.1(prettier@3.2.5) + '@solana/codecs-strings': 2.0.0-preview.1(fastestsmallesttextencoderdecoder@1.0.22) chalk: 4.1.2 json-stable-stringify: 1.1.1 nunjucks: 3.2.4 - prettier: 2.8.8 + prettier: 3.2.5 transitivePeerDependencies: - chokidar - fastestsmallesttextencoderdecoder @@ -135,6 +136,15 @@ packages: engines: {node: '>= 16'} dev: true + /@prettier/sync@0.5.1(prettier@3.2.5): + resolution: {integrity: sha512-tpF+A1e4ynO2U4fTH21Sjgm9EYENmqg4zmJCMLrmLVfzIzuDc1cKGXyxrxbFgcH8qQRfowyDCZFAUukwhiZlsw==} + peerDependencies: + prettier: '*' + dependencies: + make-synchronized: 0.2.8 + prettier: 3.2.5 + dev: true + /@sideway/address@4.1.5: resolution: {integrity: sha512-IqO/DUQHUkPeixNQ8n0JA6102hT9CmaljNTPmQ1u8MEhBo/R4Q8eKLN/vGZxuebwOroDB4cbpjheD4+/sKFK4Q==} dependencies: @@ -174,26 +184,38 @@ packages: buffer: 6.0.3 dev: true - /@solana/codecs-core@2.0.0-experimental.a157265: - resolution: {integrity: sha512-78SjZiLWWjAn5sVL92T5W+4LXYG01Vu28tVbtiCWi4QEX21794bW6lMcXbPmbivFPbD8Dje+EHAYADfxYj6RTA==} + /@solana/codecs-core@2.0.0-preview.1: + resolution: {integrity: sha512-0y3kgFSJAOApNGefEOgLRMiXOHVmcF29Xw3zmR4LDUABvytG3ecKMXGz5oLt3vdaU2CyN3tuUVeGmQjrd0U1kw==} + dependencies: + '@solana/errors': 2.0.0-preview.1 dev: true - /@solana/codecs-numbers@2.0.0-experimental.a157265: - resolution: {integrity: sha512-Bkp7Y1KyhMsu8tHKxwHDXCnYxEawT0P4kEsIO1Fzs54pxOS1jtwJHo7e4FE8Kv8ZSajUQAnbmQqj5GaIU08h9A==} + /@solana/codecs-numbers@2.0.0-preview.1: + resolution: {integrity: sha512-NFA8itgcYUY3hkWMBpVRozd2poy1zfOvkIWZKx/D69oIMUtQTBpKrodRVBuhlBkAv12vDNkFljqVySpcMZMl7A==} dependencies: - '@solana/codecs-core': 2.0.0-experimental.a157265 + '@solana/codecs-core': 2.0.0-preview.1 + '@solana/errors': 2.0.0-preview.1 dev: true - /@solana/codecs-strings@2.0.0-experimental.a157265(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-1AypxqrFipI053/EOHZnDDcfKBduLjJdrpkbcqrgWJyciv/7+fMQjkgjbG+C8Vcqx5G8weUesXCcvAhqbdRwMw==} + /@solana/codecs-strings@2.0.0-preview.1(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-kBAxE9ZD5/c8j9CkPxqc55dbo7R50Re3k94SXR+k13DZCCs37Fyn0/mAkw/S95fofbi/zsi4jSfmsT5vCZD75A==} peerDependencies: fastestsmallesttextencoderdecoder: ^1.0.22 dependencies: - '@solana/codecs-core': 2.0.0-experimental.a157265 - '@solana/codecs-numbers': 2.0.0-experimental.a157265 + '@solana/codecs-core': 2.0.0-preview.1 + '@solana/codecs-numbers': 2.0.0-preview.1 + '@solana/errors': 2.0.0-preview.1 fastestsmallesttextencoderdecoder: 1.0.22 dev: true + /@solana/errors@2.0.0-preview.1: + resolution: {integrity: sha512-mnBWfLVwMH4hxwb4sWZ7G7djQCMsyymjysvUPDiF89LueTBm1hfdxUv8Cy1uUCGsJ3jO3scdPwB4noOgr0rG/g==} + hasBin: true + dependencies: + chalk: 5.3.0 + commander: 12.0.0 + dev: true + /@solana/spl-token-registry@0.2.4574: resolution: {integrity: sha512-JzlfZmke8Rxug20VT/VpI2XsXlsqMlcORIUivF+Yucj7tFi7A0dXG7h+2UnD0WaZJw8BrUz2ABNkUnv89vbv1A==} engines: {node: '>=10'} @@ -438,6 +460,11 @@ packages: supports-color: 7.2.0 dev: true + /chalk@5.3.0: + resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + dev: true + /check-more-types@2.24.0: resolution: {integrity: sha512-Pj779qHxV2tuapviy1bSZNEL1maXr13bPYpsvSDB68HlYcYuhlDrmGd63i0JHMCLKzc7rUSNIrpdJlhVlNwrxA==} engines: {node: '>= 0.8.0'} @@ -470,6 +497,11 @@ packages: delayed-stream: 1.0.0 dev: true + /commander@12.0.0: + resolution: {integrity: sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==} + engines: {node: '>=18'} + dev: true + /commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} dev: true @@ -876,6 +908,10 @@ packages: yallist: 4.0.0 dev: true + /make-synchronized@0.2.8: + resolution: {integrity: sha512-jtXnKYCxjmGaXiZhXbDbGPbh4YyTvIIbOgcQjtAboc4RSm9k3nyhTFvFQB0cfs7QFKuZXKe2D2RvOkv1c+vpxg==} + dev: true + /map-stream@0.1.0: resolution: {integrity: sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==} dev: true @@ -943,6 +979,7 @@ packages: /node-gyp-build@4.8.0: resolution: {integrity: sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==} hasBin: true + requiresBuild: true dev: true /npm-run-path@4.0.1: @@ -1007,9 +1044,9 @@ packages: selective-whitespace: 1.0.4 dev: true - /prettier@2.8.8: - resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} - engines: {node: '>=10.13.0'} + /prettier@3.2.5: + resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} + engines: {node: '>=14'} hasBin: true dev: true