diff --git a/.changeset/odd-beans-bake.md b/.changeset/odd-beans-bake.md new file mode 100644 index 0000000..c7b8f9a --- /dev/null +++ b/.changeset/odd-beans-bake.md @@ -0,0 +1,33 @@ +--- +'@codama/renderers-rust': major +--- + +Removed default `serde` support and replaced `kaigan` with `spl-collections` + +**BREAKING CHANGES:** + +- Generated variable-sized string/vector wrappers now come from `spl-collections` instead of `kaigan`. If you have handwritten code that references these generated wrapper types, update those imports and usages after regenerating your client: + - `kaigan::types::RemainderStr` -> `spl_collections::TrailingStr` + - `kaigan::types::RemainderVec` -> `spl_collections::TrailingVec` + - `kaigan::types::U8PrefixString`, `U16PrefixString`, `U64PrefixString` -> `spl_collections::U8PrefixedStr`, `U16PrefixedStr`, `U64PrefixedStr` + - `kaigan::types::U8PrefixVec`, `U16PrefixVec`, `U64PrefixVec` -> `spl_collections::U8PrefixedVec`, `U16PrefixedVec`, `U64PrefixedVec` +- `serde` is no longer part of the default or recommended generated client surface. The previous default derives on wrapper types were misleading because their `serde` representation does not match the Borsh/Wincode wire format. +- If you still want `serde` derives for a separate JSON representation, you can opt in explicitly via `traitOptions` as shown below. This does not make the generated types serde-compatible with their Borsh/Wincode wire format, but you can define a handwritten implementation with your own serde mapping as needed. + +```diff + traitOptions: { + baseDefaults: [ + 'borsh::BorshSerialize', + 'borsh::BorshDeserialize', ++ 'serde::Serialize', ++ 'serde::Deserialize', + 'Clone', + 'Debug', + 'Eq', + 'PartialEq', + ], ++ featureFlags: { ++ serde: ['serde::Serialize', 'serde::Deserialize'], ++ }, + } +``` diff --git a/Cargo.lock b/Cargo.lock index 6113331..da4d9bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,7 +210,7 @@ dependencies = [ "bincode", "borsh 0.10.4", "bytemuck", - "solana-program 2.3.0", + "solana-program", "thiserror 1.0.69", ] @@ -258,15 +258,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anyhow" version = "1.0.100" @@ -339,12 +330,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "assert_matches" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" - [[package]] name = "async-channel" version = "1.9.0" @@ -418,12 +403,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - [[package]] name = "base64" version = "0.12.3" @@ -711,40 +690,21 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "chrono" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" -dependencies = [ - "iana-time-zone", - "num-traits", - "serde", - "windows-link", -] - [[package]] name = "codama-renderers-rust-e2e-anchor" version = "0.0.0" dependencies = [ "anchor-lang", - "assert_matches", "borsh 1.5.7", - "kaigan", "num-derive", "num-traits", - "serde", - "serde-big-array", - "serde_with", "solana-account 3.0.0", "solana-account-info 3.1.0", "solana-address 2.2.0", "solana-client", "solana-cpi 3.1.0", - "solana-decode-error", "solana-instruction 3.2.0", "solana-program-error 3.0.0", - "solana-sdk", "thiserror 1.0.69", ] @@ -752,50 +712,25 @@ dependencies = [ name = "codama-renderers-rust-e2e-dummy" version = "0.0.0" dependencies = [ - "anchor-lang", - "assert_matches", "borsh 1.5.7", - "kaigan", - "num-derive", - "num-traits", - "serde", - "serde-big-array", - "serde_with", - "solana-account 3.0.0", "solana-account-info 3.1.0", "solana-address 2.2.0", - "solana-client", "solana-cpi 3.1.0", - "solana-decode-error", "solana-instruction 3.2.0", "solana-program-error 3.0.0", - "solana-sdk", - "thiserror 1.0.69", ] [[package]] name = "codama-renderers-rust-e2e-memo" version = "0.0.0" dependencies = [ - "anchor-lang", - "assert_matches", "borsh 1.5.7", - "kaigan", - "num-derive", - "num-traits", - "serde", - "serde-big-array", - "serde_with", - "solana-account 3.0.0", "solana-account-info 3.1.0", "solana-address 2.2.0", - "solana-client", "solana-cpi 3.1.0", - "solana-decode-error", "solana-instruction 3.2.0", "solana-program-error 3.0.0", - "solana-sdk", - "thiserror 1.0.69", + "spl-collections", ] [[package]] @@ -803,14 +738,9 @@ name = "codama-renderers-rust-e2e-meteora" version = "0.0.0" dependencies = [ "anchor-lang", - "assert_matches", "borsh 1.5.7", - "kaigan", "num-derive", "num-traits", - "serde", - "serde-big-array", - "serde_with", "solana-account 3.0.0", "solana-account-info 3.1.0", "solana-address 2.2.0", @@ -819,7 +749,7 @@ dependencies = [ "solana-decode-error", "solana-instruction 3.2.0", "solana-program-error 3.0.0", - "solana-sdk", + "spl-collections", "thiserror 1.0.69", ] @@ -828,23 +758,16 @@ name = "codama-renderers-rust-e2e-system" version = "0.0.0" dependencies = [ "anchor-lang", - "assert_matches", "borsh 1.5.7", - "kaigan", "num-derive", "num-traits", - "serde", - "serde-big-array", - "serde_with", "solana-account 3.0.0", "solana-account-info 3.1.0", "solana-address 2.2.0", "solana-client", "solana-cpi 3.1.0", - "solana-decode-error", "solana-instruction 3.2.0", "solana-program-error 3.0.0", - "solana-sdk", "thiserror 1.0.69", ] @@ -1017,18 +940,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -1152,15 +1063,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071" dependencies = [ "powerfmt", - "serde_core", ] -[[package]] -name = "derivation-path" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5c37193a1db1d8ed868c03ec7b152175f26160a5b740e5e484143877e0adf0" - [[package]] name = "digest" version = "0.9.0" @@ -1177,7 +1081,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid", "crypto-common", "subtle", ] @@ -1216,26 +1119,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "dyn-clone" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest 0.10.7", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - [[package]] name = "ed25519" version = "2.2.3" @@ -1261,43 +1144,12 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ed25519-dalek-bip32" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b49a684b133c4980d7ee783936af771516011c8cd15f429dbda77245e282f03" -dependencies = [ - "derivation-path", - "ed25519-dalek", - "hmac", - "sha2 0.10.9", -] - [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest 0.10.7", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core 0.6.4", - "sec1", - "subtle", - "zeroize", -] - [[package]] name = "encode_unicode" version = "1.0.0" @@ -1346,7 +1198,7 @@ dependencies = [ "getrandom 0.3.3", "libm", "rand 0.9.2", - "siphasher 1.0.1", + "siphasher", ] [[package]] @@ -1355,16 +1207,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" -[[package]] -name = "ff" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "fiat-crypto" version = "0.2.9" @@ -1553,7 +1395,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -1630,17 +1471,6 @@ dependencies = [ "spinning_top", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "hash32" version = "0.3.1" @@ -1686,12 +1516,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "histogram" version = "0.6.9" @@ -1818,30 +1642,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "iana-time-zone" -version = "0.1.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "log", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "icu_collections" version = "2.0.0" @@ -1955,17 +1755,6 @@ dependencies = [ "icu_properties", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" version = "2.11.4" @@ -1974,8 +1763,6 @@ checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" dependencies = [ "equivalent", "hashbrown 0.16.0", - "serde", - "serde_core", ] [[package]] @@ -2090,31 +1877,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "k256" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2 0.10.9", - "signature", -] - -[[package]] -name = "kaigan" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "358444e00cb7d2efdbe986f90c05466f222e0554c38834d03d994b0705621ab0" -dependencies = [ - "borsh 0.10.4", - "borsh 1.5.7", - "serde", -] - [[package]] name = "keccak" version = "0.1.5" @@ -2405,28 +2167,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" -dependencies = [ - "num_enum_derive", - "rustversion", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" -dependencies = [ - "proc-macro-crate 3.4.0", - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "object" version = "0.37.3" @@ -2616,15 +2356,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "qstring" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d464fae65fff2680baf48019211ce37aaec0c78e9264c84a3e484717f965104e" -dependencies = [ - "percent-encoding", -] - [[package]] name = "quanta" version = "0.12.6" @@ -2850,26 +2581,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "ref-cast" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "regex" version = "1.11.3" @@ -2954,16 +2665,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "ring" version = "0.17.14" @@ -3134,30 +2835,6 @@ dependencies = [ "windows-sys 0.61.1", ] -[[package]] -name = "schemars" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - -[[package]] -name = "schemars" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -3174,20 +2851,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "security-framework" version = "3.5.0" @@ -3306,18 +2969,9 @@ version = "3.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c522100790450cf78eeac1507263d0a350d4d5b30df0c8e1fe051a10c22b376e" dependencies = [ - "base64 0.22.1", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.11.4", - "schemars 0.9.0", - "schemars 1.0.4", "serde", "serde_derive", - "serde_json", "serde_with_macros", - "time", ] [[package]] @@ -3404,16 +3058,9 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest 0.10.7", "rand_core 0.6.4", ] -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - [[package]] name = "siphasher" version = "1.0.1" @@ -3508,8 +3155,6 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc3397241392f5756925029acaa8515dc70fcbe3d8059d4885d7d6533baf64fd" dependencies = [ - "bincode", - "serde_core", "solana-address 2.2.0", "solana-program-error 3.0.0", "solana-program-memory 3.1.0", @@ -3536,7 +3181,6 @@ dependencies = [ "curve25519-dalek", "five8 1.0.0", "five8_const 1.0.0", - "rand 0.9.2", "serde", "serde_derive", "sha2-const-stable", @@ -3566,22 +3210,10 @@ dependencies = [ ] [[package]] -name = "solana-address-lookup-table-interface" -version = "3.0.1" +name = "solana-atomic-u64" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e8df0b083c10ce32490410f3795016b1b5d9b4d094658c0a5e496753645b7cd" -dependencies = [ - "solana-clock 3.0.1", - "solana-pubkey 4.1.0", - "solana-sdk-ids 3.1.0", - "solana-slot-hashes 3.0.1", -] - -[[package]] -name = "solana-atomic-u64" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52e52720efe60465b052b9e7445a01c17550666beec855cce66f44766697bc2" +checksum = "d52e52720efe60465b052b9e7445a01c17550666beec855cce66f44766697bc2" dependencies = [ "parking_lot", ] @@ -3606,17 +3238,6 @@ dependencies = [ "solana-define-syscall 2.3.0", ] -[[package]] -name = "solana-big-mod-exp" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c80fb6d791b3925d5ec4bf23a7c169ef5090c013059ec3ed7d0b2c04efa085" -dependencies = [ - "num-bigint 0.4.6", - "num-traits", - "solana-define-syscall 3.0.0", -] - [[package]] name = "solana-bincode" version = "2.2.1" @@ -3640,17 +3261,6 @@ dependencies = [ "solana-sanitize 2.2.1", ] -[[package]] -name = "solana-blake3-hasher" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7116e1d942a2432ca3f514625104757ab8a56233787e95144c93950029e31176" -dependencies = [ - "blake3", - "solana-define-syscall 4.0.1", - "solana-hash 4.2.0", -] - [[package]] name = "solana-borsh" version = "2.2.1" @@ -3661,15 +3271,6 @@ dependencies = [ "borsh 1.5.7", ] -[[package]] -name = "solana-borsh" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4a37fc44f0633779a619840b5117c2a895996cec57eb3dc10597fac7867875" -dependencies = [ - "borsh 1.5.7", -] - [[package]] name = "solana-client" version = "3.0.14" @@ -3681,7 +3282,7 @@ dependencies = [ "dashmap", "futures", "futures-util", - "indexmap 2.11.4", + "indexmap", "indicatif", "log", "quinn", @@ -3792,7 +3393,7 @@ dependencies = [ "bincode", "crossbeam-channel", "futures-util", - "indexmap 2.11.4", + "indexmap", "log", "rand 0.8.5", "rayon", @@ -3848,12 +3449,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ae3e2abcf541c8122eafe9a625d4d194b4023c20adde1e251f94e056bb1aee2" -[[package]] -name = "solana-define-syscall" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9697086a4e102d28a156b8d6b521730335d6951bd39a5e766512bbe09007cee" - [[package]] name = "solana-define-syscall" version = "4.0.1" @@ -3866,17 +3461,6 @@ version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03aacdd7a61e2109887a7a7f046caebafce97ddf1150f33722eeac04f9039c73" -[[package]] -name = "solana-derivation-path" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff71743072690fdbdfcdc37700ae1cb77485aaad49019473a81aee099b1e0b8c" -dependencies = [ - "derivation-path", - "qstring", - "uriparse", -] - [[package]] name = "solana-epoch-info" version = "3.1.0" @@ -3915,17 +3499,6 @@ dependencies = [ "solana-sysvar-id 3.1.0", ] -[[package]] -name = "solana-epoch-rewards-hasher" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee8beac9bff4db9225e57d532d169b0be5e447f1e6601a2f50f27a01bf5518f" -dependencies = [ - "siphasher 0.3.11", - "solana-address 2.2.0", - "solana-hash 4.2.0", -] - [[package]] name = "solana-epoch-schedule" version = "2.2.1" @@ -3952,16 +3525,6 @@ dependencies = [ "solana-sysvar-id 3.1.0", ] -[[package]] -name = "solana-epoch-stake" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "027e6d0b9e7daac5b2ac7c3f9ca1b727861121d9ef05084cf435ff736051e7c2" -dependencies = [ - "solana-define-syscall 5.0.0", - "solana-pubkey 4.1.0", -] - [[package]] name = "solana-example-mocks" version = "2.2.1" @@ -3970,11 +3533,11 @@ checksum = "84461d56cbb8bb8d539347151e0525b53910102e4bced875d49d5139708e39d3" dependencies = [ "serde", "serde_derive", - "solana-address-lookup-table-interface 2.2.2", + "solana-address-lookup-table-interface", "solana-clock 2.2.2", "solana-hash 2.3.0", "solana-instruction 2.3.0", - "solana-keccak-hasher 2.2.1", + "solana-keccak-hasher", "solana-message 2.4.0", "solana-nonce 2.2.1", "solana-pubkey 2.3.0", @@ -3983,27 +3546,6 @@ dependencies = [ "thiserror 2.0.18", ] -[[package]] -name = "solana-example-mocks" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978855d164845c1b0235d4b4d101cadc55373fffaf0b5b6cfa2194d25b2ed658" -dependencies = [ - "serde", - "serde_derive", - "solana-address-lookup-table-interface 3.0.1", - "solana-clock 3.0.1", - "solana-hash 3.1.0", - "solana-instruction 3.2.0", - "solana-keccak-hasher 3.1.0", - "solana-message 3.1.0", - "solana-nonce 3.1.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.1.0", - "solana-system-interface 2.0.0", - "thiserror 2.0.18", -] - [[package]] name = "solana-feature-gate-interface" version = "2.2.2" @@ -4058,22 +3600,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "solana-fee-structure" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2abdb1223eea8ec64136f39cb1ffcf257e00f915c957c35c0dd9e3f4e700b0" -dependencies = [ - "serde", - "serde_derive", -] - -[[package]] -name = "solana-hard-forks" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c19418921b9369092a9583120dbbccbcc2d92bd0c6bf5adb5f80ffd4ea4c69" - [[package]] name = "solana-hash" version = "2.3.0" @@ -4123,10 +3649,6 @@ name = "solana-inflation" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e92f37a14e7c660628752833250dd3dcd8e95309876aee751d7f8769a27947c6" -dependencies = [ - "serde", - "serde_derive", -] [[package]] name = "solana-instruction" @@ -4155,7 +3677,6 @@ dependencies = [ "bincode", "borsh 1.5.7", "serde", - "serde_derive", "solana-define-syscall 5.0.0", "solana-instruction-error", "solana-pubkey 4.1.0", @@ -4220,17 +3741,6 @@ dependencies = [ "solana-sanitize 2.2.1", ] -[[package]] -name = "solana-keccak-hasher" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed1c0d16d6fdeba12291a1f068cdf0d479d9bff1141bf44afd7aa9d485f65ef8" -dependencies = [ - "sha3", - "solana-define-syscall 4.0.1", - "solana-hash 4.2.0", -] - [[package]] name = "solana-keypair" version = "3.1.2" @@ -4238,13 +3748,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "263d614c12aa267a3278703175fd6440552ca61bc960b5a02a4482720c53438b" dependencies = [ "ed25519-dalek", - "ed25519-dalek-bip32", "five8 1.0.0", "five8_core 1.0.0", "rand 0.9.2", "solana-address 2.2.0", - "solana-derivation-path", - "solana-seed-derivable", "solana-seed-phrase", "solana-signature", "solana-signer", @@ -4356,7 +3863,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0448b1fd891c5f46491e5dc7d9986385ba3c852c340db2911dd29faa01d2b08d" dependencies = [ "bincode", - "blake3", "lazy_static", "serde", "serde_derive", @@ -4409,12 +3915,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61515b880c36974053dd499c0510066783f0cc6ac17def0c7ef2a244874cf4a9" -[[package]] -name = "solana-native-token" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8dd4c280dca9d046139eb5b7a5ac9ad10403fbd64964c7d7571214950d758f" - [[package]] name = "solana-net-utils" version = "3.0.14" @@ -4464,22 +3964,6 @@ dependencies = [ "solana-sha256-hasher 3.1.0", ] -[[package]] -name = "solana-offchain-message" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e2a1141a673f72a05cf406b99e4b2b8a457792b7c01afa07b3f00d4e2de393" -dependencies = [ - "num_enum", - "solana-hash 3.1.0", - "solana-packet", - "solana-pubkey 3.0.0", - "solana-sanitize 3.0.1", - "solana-sha256-hasher 3.1.0", - "solana-signature", - "solana-signer", -] - [[package]] name = "solana-packet" version = "3.0.0" @@ -4526,17 +4010,6 @@ dependencies = [ "solana-time-utils", ] -[[package]] -name = "solana-presigner" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f704eaf825be3180832445b9e4983b875340696e8e7239bf2d535b0f86c14a2" -dependencies = [ - "solana-pubkey 3.0.0", - "solana-signature", - "solana-signer", -] - [[package]] name = "solana-program" version = "2.3.0" @@ -4563,44 +4036,44 @@ dependencies = [ "serde_bytes", "serde_derive", "solana-account-info 2.3.0", - "solana-address-lookup-table-interface 2.2.2", + "solana-address-lookup-table-interface", "solana-atomic-u64 2.2.1", - "solana-big-mod-exp 2.2.1", + "solana-big-mod-exp", "solana-bincode", - "solana-blake3-hasher 2.2.1", - "solana-borsh 2.2.1", + "solana-blake3-hasher", + "solana-borsh", "solana-clock 2.2.2", "solana-cpi 2.2.1", "solana-decode-error", "solana-define-syscall 2.3.0", "solana-epoch-rewards 2.2.1", "solana-epoch-schedule 2.2.1", - "solana-example-mocks 2.2.1", + "solana-example-mocks", "solana-feature-gate-interface 2.2.2", "solana-fee-calculator 2.2.1", "solana-hash 2.3.0", "solana-instruction 2.3.0", "solana-instructions-sysvar 2.2.2", - "solana-keccak-hasher 2.2.1", + "solana-keccak-hasher", "solana-last-restart-slot 2.2.1", "solana-loader-v2-interface", "solana-loader-v3-interface", "solana-loader-v4-interface", "solana-message 2.4.0", "solana-msg 2.2.1", - "solana-native-token 2.3.0", + "solana-native-token", "solana-nonce 2.2.1", "solana-program-entrypoint 2.3.0", "solana-program-error 2.2.2", "solana-program-memory 2.3.1", - "solana-program-option 2.2.1", - "solana-program-pack 2.2.1", + "solana-program-option", + "solana-program-pack", "solana-pubkey 2.3.0", "solana-rent 2.2.1", "solana-sanitize 2.2.1", "solana-sdk-ids 2.2.1", "solana-sdk-macro 2.2.1", - "solana-secp256k1-recover 2.2.1", + "solana-secp256k1-recover", "solana-serde-varint 2.2.2", "solana-serialize-utils 2.2.1", "solana-sha256-hasher 2.3.0", @@ -4617,53 +4090,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "solana-program" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91b12305dd81045d705f427acd0435a2e46444b65367d7179d7bdcfc3bc5f5eb" -dependencies = [ - "memoffset", - "solana-account-info 3.1.0", - "solana-big-mod-exp 3.0.0", - "solana-blake3-hasher 3.1.0", - "solana-borsh 3.0.1", - "solana-clock 3.0.1", - "solana-cpi 3.1.0", - "solana-define-syscall 3.0.0", - "solana-epoch-rewards 3.0.1", - "solana-epoch-schedule 3.0.0", - "solana-epoch-stake", - "solana-example-mocks 3.0.0", - "solana-fee-calculator 3.1.0", - "solana-hash 3.1.0", - "solana-instruction 3.2.0", - "solana-instruction-error", - "solana-instructions-sysvar 3.0.0", - "solana-keccak-hasher 3.1.0", - "solana-last-restart-slot 3.0.0", - "solana-msg 3.1.0", - "solana-native-token 3.0.0", - "solana-program-entrypoint 3.1.1", - "solana-program-error 3.0.0", - "solana-program-memory 3.1.0", - "solana-program-option 3.0.1", - "solana-program-pack 3.1.0", - "solana-pubkey 3.0.0", - "solana-rent 3.1.0", - "solana-sdk-ids 3.1.0", - "solana-secp256k1-recover 3.1.1", - "solana-serde-varint 3.0.1", - "solana-serialize-utils 3.1.1", - "solana-sha256-hasher 3.1.0", - "solana-short-vec 3.2.0", - "solana-slot-hashes 3.0.1", - "solana-slot-history 3.0.0", - "solana-stable-layout 3.0.0", - "solana-sysvar 3.1.1", - "solana-sysvar-id 3.1.0", -] - [[package]] name = "solana-program-entrypoint" version = "2.3.0" @@ -4709,11 +4135,6 @@ name = "solana-program-error" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1af32c995a7b692a915bb7414d5f8e838450cf7c70414e763d8abcae7b51f28" -dependencies = [ - "borsh 1.5.7", - "serde", - "serde_derive", -] [[package]] name = "solana-program-memory" @@ -4739,12 +4160,6 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc677a2e9bc616eda6dbdab834d463372b92848b2bfe4a1ed4e4b4adba3397d0" -[[package]] -name = "solana-program-option" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "362279f6e8020e4cf11313233789bf619420ad8835ebc91963ee5cec91bb05da" - [[package]] name = "solana-program-pack" version = "2.2.1" @@ -4754,15 +4169,6 @@ dependencies = [ "solana-program-error 2.2.2", ] -[[package]] -name = "solana-program-pack" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7701cb15b90667ae1c89ef4ac35a59c61e66ce58ddee13d729472af7f41d59" -dependencies = [ - "solana-program-error 3.0.0", -] - [[package]] name = "solana-pubkey" version = "2.3.0" @@ -4795,7 +4201,6 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8909d399deb0851aa524420beeb5646b115fd253ef446e35fe4504c904da3941" dependencies = [ - "rand 0.8.5", "solana-address 1.1.0", ] @@ -5051,44 +4456,6 @@ dependencies = [ "thiserror 2.0.18", ] -[[package]] -name = "solana-sdk" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f03df7969f5e723ad31b6c9eadccc209037ac4caa34d8dc259316b05c11e82b" -dependencies = [ - "bincode", - "bs58", - "serde", - "solana-account 3.0.0", - "solana-epoch-info", - "solana-epoch-rewards-hasher", - "solana-fee-structure", - "solana-inflation", - "solana-keypair", - "solana-message 3.1.0", - "solana-offchain-message", - "solana-presigner", - "solana-program 3.0.0", - "solana-program-memory 3.1.0", - "solana-pubkey 3.0.0", - "solana-sanitize 3.0.1", - "solana-sdk-ids 3.1.0", - "solana-sdk-macro 3.0.1", - "solana-seed-derivable", - "solana-seed-phrase", - "solana-serde", - "solana-serde-varint 3.0.1", - "solana-short-vec 3.2.0", - "solana-shred-version", - "solana-signature", - "solana-signer", - "solana-time-utils", - "solana-transaction", - "solana-transaction-error 3.1.0", - "thiserror 2.0.18", -] - [[package]] name = "solana-sdk-ids" version = "2.2.1" @@ -5142,26 +4509,6 @@ dependencies = [ "thiserror 2.0.18", ] -[[package]] -name = "solana-secp256k1-recover" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c5f18893d62e6c73117dcba48f8f5e3266d90e5ec3d0a0a90f9785adac36c1" -dependencies = [ - "k256", - "solana-define-syscall 5.0.0", - "thiserror 2.0.18", -] - -[[package]] -name = "solana-seed-derivable" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff7bdb72758e3bec33ed0e2658a920f1f35dfb9ed576b951d20d63cb61ecd95c" -dependencies = [ - "solana-derivation-path", -] - [[package]] name = "solana-seed-phrase" version = "3.0.0" @@ -5262,17 +4609,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "solana-shred-version" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c79722e299d957958bf33695f7cd1ef6724ff55563c60fd9e3e24487cccde2" -dependencies = [ - "solana-hard-forks", - "solana-hash 4.2.0", - "solana-sha256-hasher 3.1.0", -] - [[package]] name = "solana-signature" version = "3.3.0" @@ -5281,7 +4617,6 @@ checksum = "132a93134f1262aa832f1849b83bec6c9945669b866da18661a427943b9e801e" dependencies = [ "ed25519-dalek", "five8 1.0.0", - "rand 0.9.2", "serde", "serde-big-array", "serde_derive", @@ -5408,7 +4743,7 @@ dependencies = [ "futures-util", "governor", "histogram", - "indexmap 2.11.4", + "indexmap", "itertools", "libc", "log", @@ -5524,8 +4859,6 @@ checksum = "6690d3dd88f15c21edff68eb391ef8800df7a1f5cec84ee3e8d1abf05affdf74" dependencies = [ "base64 0.22.1", "bincode", - "bytemuck", - "bytemuck_derive", "lazy_static", "serde", "serde_derive", @@ -5598,7 +4931,7 @@ dependencies = [ "async-trait", "bincode", "futures-util", - "indexmap 2.11.4", + "indexmap", "indicatif", "log", "rayon", @@ -5818,6 +5151,15 @@ dependencies = [ "der", ] +[[package]] +name = "spl-collections" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f0cbfc37c8bc4f36b42e54a4728fe8d43f9801c723cd4a9b541b6455438ea6" +dependencies = [ + "borsh 1.5.7", +] + [[package]] name = "spl-generic-token" version = "2.0.1" @@ -6131,7 +5473,7 @@ version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.11.4", + "indexmap", "serde", "serde_spanned", "toml_datetime 0.6.11", @@ -6145,7 +5487,7 @@ version = "0.23.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b" dependencies = [ - "indexmap 2.11.4", + "indexmap", "toml_datetime 0.7.2", "toml_parser", "winnow", @@ -6314,16 +5656,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "uriparse" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0200d0fc04d809396c2ad43f3c95da3582a2556eba8d453c1087f4120ee352ff" -dependencies = [ - "fnv", - "lazy_static", -] - [[package]] name = "url" version = "2.5.7" @@ -6590,65 +5922,12 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "windows-core" -version = "0.62.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6844ee5416b285084d3d3fffd743b925a6c9385455f64f6d4fa3031c4c2749a9" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link", - "windows-result", - "windows-strings", -] - -[[package]] -name = "windows-implement" -version = "0.60.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb307e42a74fb6de9bf3a02d9712678b22399c87e6fa869d6dfcd8c1b7754e0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "windows-interface" -version = "0.59.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0abd1ddbc6964ac14db11c7213d6532ef34bd9aa042c2e5935f59d7908b46a5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "windows-link" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" -[[package]] -name = "windows-result" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-strings" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" -dependencies = [ - "windows-link", -] - [[package]] name = "windows-sys" version = "0.45.0" diff --git a/Cargo.toml b/Cargo.toml index 41f1340..f412555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,12 +5,8 @@ resolver = "2" [workspace.dependencies] anchor-lang = "~0.31" borsh = "^1.0" -kaigan = "0.5.0" num-derive = "^0.4" num-traits = "^0.2" -serde = "^1.0" -serde-big-array = "^0.5" -serde_with = "^3.0" solana-account = "~3.0" solana-account-info = "~3.1" solana-address = "~2.2" @@ -19,6 +15,5 @@ solana-cpi = "~3.1" solana-decode-error = "~2.3" solana-instruction = "~3.2" solana-program-error = "~3.0" -solana-sdk = "~3.0" +spl-collections = "0.1.1" thiserror = "^1.0" -assert_matches = "1.5.0" diff --git a/README.md b/README.md index dc31f62..8f71519 100644 --- a/README.md +++ b/README.md @@ -67,16 +67,7 @@ Note that you must provide the fully qualified name of the traits you provide (e ```ts const traitOptions = { - baseDefaults: [ - 'borsh::BorshSerialize', - 'borsh::BorshDeserialize', - 'serde::Serialize', - 'serde::Deserialize', - 'Clone', - 'Debug', - 'Eq', - 'PartialEq', - ], + baseDefaults: ['borsh::BorshSerialize', 'borsh::BorshDeserialize', 'Clone', 'Debug', 'Eq', 'PartialEq'], dataEnumDefaults: [], scalarEnumDefaults: ['Copy', 'PartialOrd', 'Hash', 'num_derive::FromPrimitive'], structDefaults: [], @@ -114,7 +105,15 @@ Now, if at any point, we encounter a `fruits::Apple` or `fruits::Banana` trait t #[cfg_attr(feature = "fruits", derive(fruits::Apple, fruits::Banana))] ``` -By default, the `featureFlags` option is set to the following: +By default, the `featureFlags` option is empty: + +```ts +const traitOptions = { + featureFlags: {}, +}; +``` + +If you want to make `serde` derives optional behind a `serde` feature, you may configure it like this: ```ts const traitOptions = { diff --git a/e2e/anchor/Cargo.toml b/e2e/anchor/Cargo.toml index dc6288b..96a2974 100644 --- a/e2e/anchor/Cargo.toml +++ b/e2e/anchor/Cargo.toml @@ -6,30 +6,19 @@ edition = "2021" [features] anchor = ["dep:anchor-lang"] anchor-idl-build = ["anchor", "anchor-lang?/idl-build"] -serde = ["dep:serde", "dep:serde_with"] test-sbf = [] -fetch = ["dep:solana-client", "dep:solana-sdk"] +fetch = ["dep:solana-client"] [dependencies] anchor-lang = { workspace = true, optional = true } borsh = { workspace = true } -kaigan = { workspace = true } num-derive = { workspace = true } num-traits = { workspace = true } -serde = { workspace = true, features = ["derive"], optional = true } -serde-big-array = { workspace = true, optional = true } -serde_with = { workspace = true, optional = true } solana-account = { workspace = true } solana-account-info = { workspace = true } +solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode"] } solana-client = { workspace = true, optional = true } solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } solana-instruction = { workspace = true } solana-program-error = { workspace = true } -solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode", "serde"] } -solana-sdk = { workspace = true, optional = true } thiserror = { workspace = true } - -[dev-dependencies] -assert_matches = { workspace = true } -solana-sdk = { workspace = true } diff --git a/e2e/anchor/src/generated/accounts/guard_v1.rs b/e2e/anchor/src/generated/accounts/guard_v1.rs index 3dcbb43..6575b57 100644 --- a/e2e/anchor/src/generated/accounts/guard_v1.rs +++ b/e2e/anchor/src/generated/accounts/guard_v1.rs @@ -13,14 +13,9 @@ use borsh::BorshSerialize; use solana_address::Address; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GuardV1 { pub discriminator: [u8; 8], /// Mint token representing the guard, do not confuse with the mint of the token being transferred. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] pub mint: Address, /// Bump seed for the guard account. pub bump: u8, diff --git a/e2e/anchor/src/generated/instructions/create_guard.rs b/e2e/anchor/src/generated/instructions/create_guard.rs index ea2608b..fd28a57 100644 --- a/e2e/anchor/src/generated/instructions/create_guard.rs +++ b/e2e/anchor/src/generated/instructions/create_guard.rs @@ -82,7 +82,6 @@ impl CreateGuard { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateGuardInstructionData { discriminator: [u8; 8], } @@ -106,7 +105,6 @@ impl Default for CreateGuardInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateGuardInstructionArgs { pub name: String, pub symbol: String, diff --git a/e2e/anchor/src/generated/instructions/execute.rs b/e2e/anchor/src/generated/instructions/execute.rs index 7754059..410cbe4 100644 --- a/e2e/anchor/src/generated/instructions/execute.rs +++ b/e2e/anchor/src/generated/instructions/execute.rs @@ -80,7 +80,6 @@ impl Execute { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ExecuteInstructionData { discriminator: [u8; 8], } @@ -104,7 +103,6 @@ impl Default for ExecuteInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ExecuteInstructionArgs { pub amount: u64, } diff --git a/e2e/anchor/src/generated/instructions/initialize.rs b/e2e/anchor/src/generated/instructions/initialize.rs index 53a90c8..ce30b3c 100644 --- a/e2e/anchor/src/generated/instructions/initialize.rs +++ b/e2e/anchor/src/generated/instructions/initialize.rs @@ -68,7 +68,6 @@ impl Initialize { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeInstructionData { discriminator: [u8; 8], } diff --git a/e2e/anchor/src/generated/instructions/update_guard.rs b/e2e/anchor/src/generated/instructions/update_guard.rs index 54d7b80..9eb70a1 100644 --- a/e2e/anchor/src/generated/instructions/update_guard.rs +++ b/e2e/anchor/src/generated/instructions/update_guard.rs @@ -75,7 +75,6 @@ impl UpdateGuard { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateGuardInstructionData { discriminator: [u8; 8], } @@ -99,7 +98,6 @@ impl Default for UpdateGuardInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateGuardInstructionArgs { pub cpi_rule: Option, pub transfer_amount_rule: Option, diff --git a/e2e/anchor/src/generated/types/cpi_rule.rs b/e2e/anchor/src/generated/types/cpi_rule.rs index 4211b9c..2b31887 100644 --- a/e2e/anchor/src/generated/types/cpi_rule.rs +++ b/e2e/anchor/src/generated/types/cpi_rule.rs @@ -12,16 +12,7 @@ use solana_address::Address; /// Controls which protocols can interact with the token by /// enforcing Allow and Deny lists. #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum CpiRule { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::>") - )] Allow(Vec
), - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::>") - )] Deny(Vec
), } diff --git a/e2e/anchor/src/generated/types/metadata_additional_field_restriction.rs b/e2e/anchor/src/generated/types/metadata_additional_field_restriction.rs index aca4ec2..e4e11d5 100644 --- a/e2e/anchor/src/generated/types/metadata_additional_field_restriction.rs +++ b/e2e/anchor/src/generated/types/metadata_additional_field_restriction.rs @@ -12,7 +12,6 @@ use borsh::BorshSerialize; /// * Includes - The field must include one of the values in the vector. /// * Excludes - The field must not include any of the values in the vector. #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum MetadataAdditionalFieldRestriction { Includes(Vec), Excludes(Vec), diff --git a/e2e/anchor/src/generated/types/metadata_additional_field_rule.rs b/e2e/anchor/src/generated/types/metadata_additional_field_rule.rs index f73ab01..5898536 100644 --- a/e2e/anchor/src/generated/types/metadata_additional_field_rule.rs +++ b/e2e/anchor/src/generated/types/metadata_additional_field_rule.rs @@ -12,7 +12,6 @@ use borsh::BorshSerialize; /// Enforces rules on a single additional field in the mint metadata. /// The field must exist and the value must pass the restriction. #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MetadataAdditionalFieldRule { pub field: String, pub value_restrictions: Option, diff --git a/e2e/anchor/src/generated/types/transfer_amount_rule.rs b/e2e/anchor/src/generated/types/transfer_amount_rule.rs index f1f4f2c..a9b19ef 100644 --- a/e2e/anchor/src/generated/types/transfer_amount_rule.rs +++ b/e2e/anchor/src/generated/types/transfer_amount_rule.rs @@ -11,7 +11,6 @@ use borsh::BorshSerialize; /// Enforces rules on the amount of tokens being transferred. /// The rules can be above, below, equal to, or within a range. #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum TransferAmountRule { Above(u64), Below(u64), diff --git a/e2e/dummy/Cargo.toml b/e2e/dummy/Cargo.toml index ac740d1..ea66d2b 100644 --- a/e2e/dummy/Cargo.toml +++ b/e2e/dummy/Cargo.toml @@ -4,30 +4,12 @@ version = "0.0.0" edition = "2021" [features] -anchor = ["dep:anchor-lang"] -anchor-idl-build = ["anchor", "anchor-lang?/idl-build"] -serde = ["dep:serde", "dep:serde_with", "dep:serde-big-array"] test-sbf = [] [dependencies] -anchor-lang = { workspace = true, optional = true } borsh = { workspace = true } -kaigan = { workspace = true } -num-derive = { workspace = true } -num-traits = { workspace = true } -serde = { workspace = true, features = ["derive"], optional = true } -serde-big-array = { workspace = true, optional = true } -serde_with = { workspace = true, optional = true } -solana-account = { workspace = true } solana-account-info = { workspace = true } -solana-client = { workspace = true, optional = true } +solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode"] } solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } solana-instruction = { workspace = true } solana-program-error = { workspace = true } -solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode", "serde"] } -thiserror = { workspace = true } - -[dev-dependencies] -assert_matches = { workspace = true } -solana-sdk = { workspace = true } diff --git a/e2e/dummy/src/generated/instructions/instruction1.rs b/e2e/dummy/src/generated/instructions/instruction1.rs index 42efc54..cae4c09 100644 --- a/e2e/dummy/src/generated/instructions/instruction1.rs +++ b/e2e/dummy/src/generated/instructions/instruction1.rs @@ -35,7 +35,6 @@ impl Instruction1 { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Instruction1InstructionData {} impl Instruction1InstructionData { diff --git a/e2e/dummy/src/generated/instructions/instruction2.rs b/e2e/dummy/src/generated/instructions/instruction2.rs index 35303a0..d946ef0 100644 --- a/e2e/dummy/src/generated/instructions/instruction2.rs +++ b/e2e/dummy/src/generated/instructions/instruction2.rs @@ -35,7 +35,6 @@ impl Instruction2 { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Instruction2InstructionData {} impl Instruction2InstructionData { diff --git a/e2e/dummy/src/generated/instructions/instruction3.rs b/e2e/dummy/src/generated/instructions/instruction3.rs index 7e47e31..876b035 100644 --- a/e2e/dummy/src/generated/instructions/instruction3.rs +++ b/e2e/dummy/src/generated/instructions/instruction3.rs @@ -37,7 +37,6 @@ impl Instruction3 { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Instruction3InstructionData { discriminator: u32, } diff --git a/e2e/dummy/src/generated/instructions/instruction4.rs b/e2e/dummy/src/generated/instructions/instruction4.rs index ac3529e..860b06e 100644 --- a/e2e/dummy/src/generated/instructions/instruction4.rs +++ b/e2e/dummy/src/generated/instructions/instruction4.rs @@ -41,7 +41,6 @@ impl Instruction4 { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Instruction4InstructionData {} impl Instruction4InstructionData { @@ -61,7 +60,6 @@ impl Default for Instruction4InstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Instruction4InstructionArgs { pub my_argument: u64, } diff --git a/e2e/dummy/src/generated/instructions/instruction5.rs b/e2e/dummy/src/generated/instructions/instruction5.rs index 0813ad1..da1301e 100644 --- a/e2e/dummy/src/generated/instructions/instruction5.rs +++ b/e2e/dummy/src/generated/instructions/instruction5.rs @@ -41,7 +41,6 @@ impl Instruction5 { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Instruction5InstructionData {} impl Instruction5InstructionData { @@ -61,7 +60,6 @@ impl Default for Instruction5InstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Instruction5InstructionArgs { pub my_argument: u64, } diff --git a/e2e/dummy/src/generated/instructions/instruction6.rs b/e2e/dummy/src/generated/instructions/instruction6.rs index cd932c3..a6762bf 100644 --- a/e2e/dummy/src/generated/instructions/instruction6.rs +++ b/e2e/dummy/src/generated/instructions/instruction6.rs @@ -38,7 +38,6 @@ impl Instruction6 { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Instruction6InstructionData {} impl Instruction6InstructionData { diff --git a/e2e/dummy/src/generated/instructions/instruction7.rs b/e2e/dummy/src/generated/instructions/instruction7.rs index 0d3cfcf..fff4818 100644 --- a/e2e/dummy/src/generated/instructions/instruction7.rs +++ b/e2e/dummy/src/generated/instructions/instruction7.rs @@ -45,7 +45,6 @@ impl Instruction7 { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Instruction7InstructionData {} impl Instruction7InstructionData { diff --git a/e2e/memo/Cargo.toml b/e2e/memo/Cargo.toml index 526d0e7..9d7e3a3 100644 --- a/e2e/memo/Cargo.toml +++ b/e2e/memo/Cargo.toml @@ -4,31 +4,13 @@ version = "0.0.0" edition = "2021" [features] -anchor = ["dep:anchor-lang"] -anchor-idl-build = ["anchor", "anchor-lang?/idl-build"] -serde = ["dep:serde", "dep:serde_with", "dep:serde-big-array"] test-sbf = [] [dependencies] -anchor-lang = { workspace = true, optional = true } borsh = { workspace = true } -kaigan = { workspace = true, features = ["serde", "borsh-v1"] } -num-derive = { workspace = true } -num-traits = { workspace = true } -serde = { workspace = true, features = ["derive"], optional = true } -serde-big-array = { workspace = true, optional = true } -serde_with = { workspace = true, optional = true } -solana-account = { workspace = true } solana-account-info = { workspace = true } -solana-client = { workspace = true, optional = true } +solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode"] } solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } solana-instruction = { workspace = true } solana-program-error = { workspace = true } -solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode", "serde"] } -solana-sdk = { workspace = true, optional = true } -thiserror = { workspace = true } - -[dev-dependencies] -assert_matches = { workspace = true } -solana-sdk = { workspace = true } +spl-collections = { workspace = true, features = ["borsh"] } diff --git a/e2e/memo/src/generated/instructions/add_memo.rs b/e2e/memo/src/generated/instructions/add_memo.rs index 924d29e..ab0460e 100644 --- a/e2e/memo/src/generated/instructions/add_memo.rs +++ b/e2e/memo/src/generated/instructions/add_memo.rs @@ -7,7 +7,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; -use kaigan::types::RemainderStr; +use spl_collections::TrailingStr; /// Accounts. #[derive(Debug)] @@ -39,7 +39,6 @@ impl AddMemo { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AddMemoInstructionData {} impl AddMemoInstructionData { @@ -59,9 +58,8 @@ impl Default for AddMemoInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AddMemoInstructionArgs { - pub memo: RemainderStr, + pub memo: TrailingStr, } impl AddMemoInstructionArgs { @@ -76,7 +74,7 @@ impl AddMemoInstructionArgs { /// #[derive(Clone, Debug, Default)] pub struct AddMemoBuilder { - memo: Option, + memo: Option, __remaining_accounts: Vec, } @@ -85,7 +83,7 @@ impl AddMemoBuilder { Self::default() } #[inline(always)] - pub fn memo(&mut self, memo: RemainderStr) -> &mut Self { + pub fn memo(&mut self, memo: TrailingStr) -> &mut Self { self.memo = Some(memo); self } @@ -206,7 +204,7 @@ impl<'a, 'b> AddMemoCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn memo(&mut self, memo: RemainderStr) -> &mut Self { + pub fn memo(&mut self, memo: TrailingStr) -> &mut Self { self.instruction.memo = Some(memo); self } @@ -261,7 +259,7 @@ impl<'a, 'b> AddMemoCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AddMemoCpiBuilderInstruction<'a, 'b> { __program: &'b solana_account_info::AccountInfo<'a>, - memo: Option, + memo: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/e2e/meteora/Cargo.toml b/e2e/meteora/Cargo.toml index 40dc867..f6f6d02 100644 --- a/e2e/meteora/Cargo.toml +++ b/e2e/meteora/Cargo.toml @@ -6,30 +6,21 @@ edition = "2021" [features] anchor = ["dep:anchor-lang"] anchor-idl-build = ["anchor", "anchor-lang?/idl-build"] -serde = ["dep:serde", "dep:serde_with"] test-sbf = [] -fetch = ["dep:solana-client", "dep:solana-sdk"] +fetch = ["dep:solana-client"] [dependencies] anchor-lang = { workspace = true, optional = true } borsh = { workspace = true } -kaigan = { workspace = true } num-derive = { workspace = true } num-traits = { workspace = true } -serde = { workspace = true, features = ["derive"], optional = true } -serde-big-array = { workspace = true, optional = true } -serde_with = { workspace = true, optional = true } solana-account = { workspace = true } solana-account-info = { workspace = true } +solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode"] } solana-client = { workspace = true, optional = true } solana-cpi = { workspace = true } solana-decode-error = { workspace = true } solana-instruction = { workspace = true } solana-program-error = { workspace = true } -solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode", "serde"] } -solana-sdk = { workspace = true, optional = true } +spl-collections = { workspace = true, features = ["borsh"] } thiserror = { workspace = true } - -[dev-dependencies] -assert_matches = { workspace = true } -solana-sdk = { workspace = true } diff --git a/e2e/system/Cargo.toml b/e2e/system/Cargo.toml index 51a5990..91ecb75 100644 --- a/e2e/system/Cargo.toml +++ b/e2e/system/Cargo.toml @@ -6,30 +6,19 @@ edition = "2021" [features] anchor = ["dep:anchor-lang"] anchor-idl-build = ["anchor", "anchor-lang?/idl-build"] -serde = ["dep:serde", "dep:serde_with", "dep:serde-big-array"] test-sbf = [] -fetch = ["dep:solana-client", "dep:solana-sdk"] +fetch = ["dep:solana-client"] [dependencies] anchor-lang = { workspace = true, optional = true } borsh = { workspace = true } -kaigan = { workspace = true } num-derive = { workspace = true } num-traits = { workspace = true } -serde = { workspace = true, features = ["derive"], optional = true } -serde-big-array = { workspace = true, optional = true } -serde_with = { workspace = true, optional = true } solana-account = { workspace = true } solana-account-info = { workspace = true } +solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode"] } solana-client = { workspace = true, optional = true } solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } solana-instruction = { workspace = true } solana-program-error = { workspace = true } -solana-address = { workspace = true, features = ["borsh", "copy", "curve25519", "decode", "serde"] } -solana-sdk = { workspace = true, optional = true } thiserror = { workspace = true } - -[dev-dependencies] -assert_matches = { workspace = true } -solana-sdk = { workspace = true } diff --git a/e2e/system/src/generated/accounts/nonce.rs b/e2e/system/src/generated/accounts/nonce.rs index bfcd5b3..c46f6d1 100644 --- a/e2e/system/src/generated/accounts/nonce.rs +++ b/e2e/system/src/generated/accounts/nonce.rs @@ -12,19 +12,10 @@ use borsh::BorshSerialize; use solana_address::Address; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Nonce { pub version: NonceVersion, pub state: NonceState, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] pub authority: Address, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] pub blockhash: Address, pub lamports_per_signature: u64, } diff --git a/e2e/system/src/generated/instructions/advance_nonce_account.rs b/e2e/system/src/generated/instructions/advance_nonce_account.rs index 222d88d..4858fa9 100644 --- a/e2e/system/src/generated/instructions/advance_nonce_account.rs +++ b/e2e/system/src/generated/instructions/advance_nonce_account.rs @@ -57,7 +57,6 @@ impl AdvanceNonceAccount { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AdvanceNonceAccountInstructionData { discriminator: u32, } diff --git a/e2e/system/src/generated/instructions/allocate.rs b/e2e/system/src/generated/instructions/allocate.rs index 01d03d5..ef7989f 100644 --- a/e2e/system/src/generated/instructions/allocate.rs +++ b/e2e/system/src/generated/instructions/allocate.rs @@ -43,7 +43,6 @@ impl Allocate { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AllocateInstructionData { discriminator: u32, } @@ -65,7 +64,6 @@ impl Default for AllocateInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AllocateInstructionArgs { pub space: u64, } diff --git a/e2e/system/src/generated/instructions/allocate_with_seed.rs b/e2e/system/src/generated/instructions/allocate_with_seed.rs index 9dddcb9..0064540 100644 --- a/e2e/system/src/generated/instructions/allocate_with_seed.rs +++ b/e2e/system/src/generated/instructions/allocate_with_seed.rs @@ -56,7 +56,6 @@ impl AllocateWithSeed { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AllocateWithSeedInstructionData { discriminator: u32, } @@ -78,7 +77,6 @@ impl Default for AllocateWithSeedInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AllocateWithSeedInstructionArgs { pub base: Address, pub seed: String, diff --git a/e2e/system/src/generated/instructions/assign.rs b/e2e/system/src/generated/instructions/assign.rs index 34cf6bb..4ccc263 100644 --- a/e2e/system/src/generated/instructions/assign.rs +++ b/e2e/system/src/generated/instructions/assign.rs @@ -44,7 +44,6 @@ impl Assign { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AssignInstructionData { discriminator: u32, } @@ -66,7 +65,6 @@ impl Default for AssignInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AssignInstructionArgs { pub program_address: Address, } diff --git a/e2e/system/src/generated/instructions/assign_with_seed.rs b/e2e/system/src/generated/instructions/assign_with_seed.rs index 31b0436..bd88c2f 100644 --- a/e2e/system/src/generated/instructions/assign_with_seed.rs +++ b/e2e/system/src/generated/instructions/assign_with_seed.rs @@ -53,7 +53,6 @@ impl AssignWithSeed { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AssignWithSeedInstructionData { discriminator: u32, } @@ -75,7 +74,6 @@ impl Default for AssignWithSeedInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AssignWithSeedInstructionArgs { pub base: Address, pub seed: String, diff --git a/e2e/system/src/generated/instructions/authorize_nonce_account.rs b/e2e/system/src/generated/instructions/authorize_nonce_account.rs index 77bed82..e881144 100644 --- a/e2e/system/src/generated/instructions/authorize_nonce_account.rs +++ b/e2e/system/src/generated/instructions/authorize_nonce_account.rs @@ -58,7 +58,6 @@ impl AuthorizeNonceAccount { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeNonceAccountInstructionData { discriminator: u32, } @@ -80,7 +79,6 @@ impl Default for AuthorizeNonceAccountInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeNonceAccountInstructionArgs { pub new_nonce_authority: Address, } diff --git a/e2e/system/src/generated/instructions/create_account.rs b/e2e/system/src/generated/instructions/create_account.rs index df6e4fa..b455e4c 100644 --- a/e2e/system/src/generated/instructions/create_account.rs +++ b/e2e/system/src/generated/instructions/create_account.rs @@ -50,7 +50,6 @@ impl CreateAccount { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateAccountInstructionData { discriminator: u32, } @@ -72,7 +71,6 @@ impl Default for CreateAccountInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateAccountInstructionArgs { pub lamports: u64, pub space: u64, diff --git a/e2e/system/src/generated/instructions/create_account_with_seed.rs b/e2e/system/src/generated/instructions/create_account_with_seed.rs index 3cd4bd2..97676e7 100644 --- a/e2e/system/src/generated/instructions/create_account_with_seed.rs +++ b/e2e/system/src/generated/instructions/create_account_with_seed.rs @@ -61,7 +61,6 @@ impl CreateAccountWithSeed { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateAccountWithSeedInstructionData { discriminator: u32, } @@ -83,7 +82,6 @@ impl Default for CreateAccountWithSeedInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateAccountWithSeedInstructionArgs { pub base: Address, pub seed: String, diff --git a/e2e/system/src/generated/instructions/initialize_nonce_account.rs b/e2e/system/src/generated/instructions/initialize_nonce_account.rs index 3de03b8..f453f48 100644 --- a/e2e/system/src/generated/instructions/initialize_nonce_account.rs +++ b/e2e/system/src/generated/instructions/initialize_nonce_account.rs @@ -64,7 +64,6 @@ impl InitializeNonceAccount { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeNonceAccountInstructionData { discriminator: u32, } @@ -86,7 +85,6 @@ impl Default for InitializeNonceAccountInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeNonceAccountInstructionArgs { pub nonce_authority: Address, } diff --git a/e2e/system/src/generated/instructions/transfer_sol.rs b/e2e/system/src/generated/instructions/transfer_sol.rs index 94067af..6403821 100644 --- a/e2e/system/src/generated/instructions/transfer_sol.rs +++ b/e2e/system/src/generated/instructions/transfer_sol.rs @@ -49,7 +49,6 @@ impl TransferSol { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TransferSolInstructionData { discriminator: u32, } @@ -71,7 +70,6 @@ impl Default for TransferSolInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TransferSolInstructionArgs { pub amount: u64, } diff --git a/e2e/system/src/generated/instructions/transfer_sol_with_seed.rs b/e2e/system/src/generated/instructions/transfer_sol_with_seed.rs index 17131ce..3fd3668 100644 --- a/e2e/system/src/generated/instructions/transfer_sol_with_seed.rs +++ b/e2e/system/src/generated/instructions/transfer_sol_with_seed.rs @@ -61,7 +61,6 @@ impl TransferSolWithSeed { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TransferSolWithSeedInstructionData { discriminator: u32, } @@ -83,7 +82,6 @@ impl Default for TransferSolWithSeedInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TransferSolWithSeedInstructionArgs { pub amount: u64, pub from_seed: String, diff --git a/e2e/system/src/generated/instructions/upgrade_nonce_account.rs b/e2e/system/src/generated/instructions/upgrade_nonce_account.rs index 6d48d63..7de98bc 100644 --- a/e2e/system/src/generated/instructions/upgrade_nonce_account.rs +++ b/e2e/system/src/generated/instructions/upgrade_nonce_account.rs @@ -45,7 +45,6 @@ impl UpgradeNonceAccount { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpgradeNonceAccountInstructionData { discriminator: u32, } diff --git a/e2e/system/src/generated/instructions/withdraw_nonce_account.rs b/e2e/system/src/generated/instructions/withdraw_nonce_account.rs index 229dfe2..da43d7d 100644 --- a/e2e/system/src/generated/instructions/withdraw_nonce_account.rs +++ b/e2e/system/src/generated/instructions/withdraw_nonce_account.rs @@ -75,7 +75,6 @@ impl WithdrawNonceAccount { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WithdrawNonceAccountInstructionData { discriminator: u32, } @@ -97,7 +96,6 @@ impl Default for WithdrawNonceAccountInstructionData { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WithdrawNonceAccountInstructionArgs { pub withdraw_amount: u64, } diff --git a/e2e/system/src/generated/types/nonce_state.rs b/e2e/system/src/generated/types/nonce_state.rs index 487ddd9..de390cf 100644 --- a/e2e/system/src/generated/types/nonce_state.rs +++ b/e2e/system/src/generated/types/nonce_state.rs @@ -21,7 +21,6 @@ use num_derive::FromPrimitive; Hash, FromPrimitive, )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum NonceState { Uninitialized, Initialized, diff --git a/e2e/system/src/generated/types/nonce_version.rs b/e2e/system/src/generated/types/nonce_version.rs index b6d1cff..906432e 100644 --- a/e2e/system/src/generated/types/nonce_version.rs +++ b/e2e/system/src/generated/types/nonce_version.rs @@ -21,7 +21,6 @@ use num_derive::FromPrimitive; Hash, FromPrimitive, )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum NonceVersion { Legacy, Current, diff --git a/src/getTypeManifestVisitor.ts b/src/getTypeManifestVisitor.ts index e3a3da6..5bddf8e 100644 --- a/src/getTypeManifestVisitor.ts +++ b/src/getTypeManifestVisitor.ts @@ -85,10 +85,10 @@ export function getTypeManifestVisitor(options: { } if (isNode(arrayType.count, 'remainderCountNode')) { - childManifest.imports.add('kaigan::types::RemainderVec'); + childManifest.imports.add('spl_collections::TrailingVec'); return { ...childManifest, - type: `RemainderVec<${childManifest.type}>`, + type: `TrailingVec<${childManifest.type}>`, }; } @@ -104,10 +104,10 @@ export function getTypeManifestVisitor(options: { case 'u16': case 'u64': { const prefixFormat = prefix.format.toUpperCase(); - childManifest.imports.add(`kaigan::types::${prefixFormat}PrefixVec`); + childManifest.imports.add(`spl_collections::${prefixFormat}PrefixedVec`); return { ...childManifest, - type: `${prefixFormat}PrefixVec<${childManifest.type}>`, + type: `${prefixFormat}PrefixedVec<${childManifest.type}>`, }; } case 'shortU16': { @@ -341,9 +341,9 @@ export function getTypeManifestVisitor(options: { visitStringType() { if (!parentSize) { return { - imports: new ImportMap().add(`kaigan::types::RemainderStr`), + imports: new ImportMap().add(`spl_collections::TrailingStr`), nestedStructs: [], - type: `RemainderStr`, + type: `TrailingStr`, }; } @@ -368,9 +368,9 @@ export function getTypeManifestVisitor(options: { case 'u64': { const prefix = parentSize.format.toUpperCase(); return { - imports: new ImportMap().add(`kaigan::types::${prefix}PrefixString`), + imports: new ImportMap().add(`spl_collections::${prefix}PrefixedStr`), nestedStructs: [], - type: `${prefix}PrefixString`, + type: `${prefix}PrefixedStr`, }; } default: diff --git a/src/utils/cargoToml.ts b/src/utils/cargoToml.ts index a1825bf..a7da14a 100644 --- a/src/utils/cargoToml.ts +++ b/src/utils/cargoToml.ts @@ -42,21 +42,17 @@ type CargoDependencyObject = { export const DEFAULT_DEPENDENCY_VERSIONS: CargoDependencies = { 'anchor-lang': { optional: true, version: '~0.31' }, borsh: '^1.0', - kaigan: { features: ['serde'], version: '^0.3' }, 'num-derive': '^0.4', 'num-traits': '^0.2', - serde: { features: ['derive'], optional: true, version: '^1.0' }, - 'serde-big-array': '^0.5', - serde_with: { optional: true, version: '^3.0' }, 'solana-account': '~3.0', 'solana-account-info': '~3.1', - 'solana-address': { features: ['borsh', 'copy', 'curve25519', 'decode', 'serde'], version: '~2.2' }, + 'solana-address': { features: ['borsh', 'copy', 'curve25519', 'decode'], version: '~2.2' }, 'solana-client': { optional: true, version: '^3.0' }, 'solana-cpi': '~3.1', 'solana-decode-error': '~2.3', 'solana-instruction': '~3.2', 'solana-program-error': '~3.0', - 'solana-sdk': { optional: true, version: '^3.0' }, + 'spl-collections': { features: ['borsh'], version: '^0.1' }, thiserror: '^1.0', }; @@ -108,8 +104,7 @@ export function createNewCargoToml(usedDependencies: CargoDependencies): CargoTo features: { anchor: ['dep:anchor-lang'], 'anchor-idl-build': ['anchor', 'anchor-lang?/idl-build'], - fetch: ['dep:solana-client', 'dep:solana-sdk'], - serde: ['dep:serde', 'dep:serde_with'], + fetch: ['dep:solana-client'], }, // eslint-disable-next-line sort-keys-fix/sort-keys-fix dependencies: {}, diff --git a/src/utils/traitOptions.ts b/src/utils/traitOptions.ts index 90998d3..da98dd9 100644 --- a/src/utils/traitOptions.ts +++ b/src/utils/traitOptions.ts @@ -38,18 +38,9 @@ export type TraitOptions = { }; export const DEFAULT_TRAIT_OPTIONS: Required = { - baseDefaults: [ - 'borsh::BorshSerialize', - 'borsh::BorshDeserialize', - 'serde::Serialize', - 'serde::Deserialize', - 'Clone', - 'Debug', - 'Eq', - 'PartialEq', - ], + baseDefaults: ['borsh::BorshSerialize', 'borsh::BorshDeserialize', 'Clone', 'Debug', 'Eq', 'PartialEq'], dataEnumDefaults: [], - featureFlags: { serde: ['serde::Serialize', 'serde::Deserialize'] }, + featureFlags: {}, overrides: {}, scalarEnumDefaults: ['Copy', 'PartialOrd', 'Hash', 'num_derive::FromPrimitive'], structDefaults: [], diff --git a/test/definedTypesPage.test.ts b/test/definedTypesPage.test.ts index 8eb05cd..b6ce948 100644 --- a/test/definedTypesPage.test.ts +++ b/test/definedTypesPage.test.ts @@ -40,8 +40,8 @@ test('it renders a prefix string on a defined type', () => { // Then we expect the following use and identifier to be rendered. codeContains(getFromRenderMap(renderMap, 'types/blob.rs').content, [ - `use kaigan::types::U8PrefixString;`, - `content_type: U8PrefixString,`, + `use spl_collections::U8PrefixedStr;`, + `content_type: U8PrefixedStr,`, ]); }); diff --git a/test/instructionsPage.test.ts b/test/instructionsPage.test.ts index 1d506b1..8d1ad3a 100644 --- a/test/instructionsPage.test.ts +++ b/test/instructionsPage.test.ts @@ -47,8 +47,8 @@ test('it renders an instruction with a remainder str', () => { // Then we expect the following pub struct. codeContains(getFromRenderMap(renderMap, 'instructions/add_memo.rs').content, [ - `use kaigan::types::RemainderStr`, - `pub memo: RemainderStr`, + `use spl_collections::TrailingStr`, + `pub memo: TrailingStr`, ]); }); diff --git a/test/utils/cargoToml.test.ts b/test/utils/cargoToml.test.ts index 7a35685..8147fba 100644 --- a/test/utils/cargoToml.test.ts +++ b/test/utils/cargoToml.test.ts @@ -106,8 +106,7 @@ describe('createNewCargoToml', () => { expect(cargoToml.features).toEqual({ anchor: ['dep:anchor-lang'], 'anchor-idl-build': ['anchor', 'anchor-lang?/idl-build'], - fetch: ['dep:solana-client', 'dep:solana-sdk'], - serde: ['dep:serde', 'dep:serde_with'], + fetch: ['dep:solana-client'], }); }); }); diff --git a/test/utils/traitOptions.test.ts b/test/utils/traitOptions.test.ts index c08faf5..5609923 100644 --- a/test/utils/traitOptions.test.ts +++ b/test/utils/traitOptions.test.ts @@ -7,7 +7,6 @@ import { enumEmptyVariantTypeNode, enumStructVariantTypeNode, enumTypeNode, - fixedCountNode, fixedSizeTypeNode, instructionArgumentNode, instructionNode, @@ -44,10 +43,7 @@ describe('default values', () => { const { render, imports } = getTraitsFromNode(node); // Then we expect the following traits to be rendered. - expect(render).toBe( - `#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]\n` + - `#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]\n`, - ); + expect(render).toBe(`#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]\n`); // And the following imports to be used. expect([...imports.imports]).toStrictEqual(['borsh::BorshSerialize', 'borsh::BorshDeserialize']); @@ -65,8 +61,7 @@ describe('default values', () => { // Then we expect the following traits to be rendered. expect(render).toBe( - `#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, Copy, PartialOrd, Hash, FromPrimitive)]\n` + - `#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]\n`, + `#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, Copy, PartialOrd, Hash, FromPrimitive)]\n`, ); // And the following imports to be used. @@ -91,10 +86,7 @@ describe('default values', () => { const { render, imports } = getTraitsFromNode(node); // Then we expect the following traits to be rendered. - expect(render).toBe( - `#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]\n` + - `#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]\n`, - ); + expect(render).toBe(`#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]\n`); // And the following imports to be used. expect([...imports.imports]).toStrictEqual(['borsh::BorshSerialize', 'borsh::BorshDeserialize']); @@ -140,7 +132,7 @@ describe('default values', () => { }); // Then we expect the following traits to be rendered. - expect(render).toBe(`#[derive(My, Traits)]\n#[cfg_attr(feature = "serde", derive(serde::Serialize))]\n`); + expect(render).toBe(`#[derive(My, Traits, Serialize)]\n`); }); }); @@ -489,35 +481,6 @@ describe('conditional try_to_vec generation', () => { }); describe('conditional serde field attributes', () => { - test('it generates cfg_attr serde field attributes when serde is feature-flagged (default)', () => { - // Given an account with a Pubkey field. - const node = accountNode({ - data: structTypeNode([ - structFieldTypeNode({ name: 'authority', type: publicKeyTypeNode() }), - structFieldTypeNode({ - name: 'tokens', - type: arrayTypeNode(publicKeyTypeNode(), prefixedCountNode(numberTypeNode('u32'))), - }), - ]), - name: 'myAccount', - }); - - // When we render with default traits (serde is feature-flagged). - const renderMap = visit( - rootNode(programNode({ accounts: [node], name: 'myProgram', publicKey: '1111' })), - getRenderMapVisitor(), - ); - - // Then we expect field attributes to be wrapped in cfg_attr. - const account = getFromRenderMap(renderMap, 'accounts/my_account.rs').content; - expect(account).toContain( - '#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))]', - ); - expect(account).toContain( - '#[cfg_attr(feature = "serde", serde(with = "serde_with::As::>"))]', - ); - }); - test('it generates plain serde field attributes when serde is not feature-flagged', () => { // Given an account with a Pubkey field. const node = accountNode({ @@ -589,29 +552,6 @@ describe('conditional serde field attributes', () => { expect(account).not.toContain('DisplayFromStr'); }); - test('it handles large array serde attributes conditionally', () => { - // Given an account with a large fixed array field. - const node = accountNode({ - data: structTypeNode([ - structFieldTypeNode({ - name: 'data', - type: fixedSizeTypeNode(arrayTypeNode(numberTypeNode('u8'), fixedCountNode(64)), 64), - }), - ]), - name: 'myAccount', - }); - - // When we render with default traits (serde is feature-flagged). - const renderMap = visit( - rootNode(programNode({ accounts: [node], name: 'myProgram', publicKey: '1111' })), - getRenderMapVisitor(), - ); - - // Then we expect the big array attribute to be feature-flagged. - const account = getFromRenderMap(renderMap, 'accounts/my_account.rs').content; - expect(account).toContain('#[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]'); - }); - test('it handles bytes serde attributes conditionally', () => { // Given an account with a fixed-size bytes field. const node = accountNode({