From f9873398c52a409cbdba1356c7aa499cb76b42bc Mon Sep 17 00:00:00 2001 From: Fernando Otero Date: Wed, 10 Jan 2024 12:01:14 +0000 Subject: [PATCH] Add support to prefix string type (#148) * Add support for prefix string * Update tests * Add changeset --- .changeset/smart-singers-press.md | 5 + .../rust/GetRustTypeManifestVisitor.ts | 30 +- .../src/generated/types/index.ts | 2 + .../src/generated/types/link.ts | 37 +++ .../src/generated/types/links.ts | 36 ++ test/packages/js/src/generated/types/index.ts | 2 + test/packages/js/src/generated/types/link.ts | 28 ++ test/packages/js/src/generated/types/links.ts | 25 ++ test/packages/rust/Cargo.lock | 308 ++++++++++-------- .../packages/rust/src/generated/types/link.rs | 17 + .../rust/src/generated/types/links.rs | 17 + test/packages/rust/src/generated/types/mod.rs | 4 + test/testFile.cjs | 46 +++ 13 files changed, 422 insertions(+), 135 deletions(-) create mode 100644 .changeset/smart-singers-press.md create mode 100644 test/packages/js-experimental/src/generated/types/link.ts create mode 100644 test/packages/js-experimental/src/generated/types/links.ts create mode 100644 test/packages/js/src/generated/types/link.ts create mode 100644 test/packages/js/src/generated/types/links.ts create mode 100644 test/packages/rust/src/generated/types/link.rs create mode 100644 test/packages/rust/src/generated/types/links.rs diff --git a/.changeset/smart-singers-press.md b/.changeset/smart-singers-press.md new file mode 100644 index 000000000..3be05928b --- /dev/null +++ b/.changeset/smart-singers-press.md @@ -0,0 +1,5 @@ +--- +'@metaplex-foundation/kinobi': patch +--- + +Add support to prefix string type in Rust client diff --git a/src/renderers/rust/GetRustTypeManifestVisitor.ts b/src/renderers/rust/GetRustTypeManifestVisitor.ts index 143d335d5..bd5b8f29c 100644 --- a/src/renderers/rust/GetRustTypeManifestVisitor.ts +++ b/src/renderers/rust/GetRustTypeManifestVisitor.ts @@ -423,14 +423,32 @@ export class GetRustTypeManifestVisitor implements Visitor { visitStringType(stringType: nodes.StringTypeNode): RustTypeManifest { if ( stringType.size.kind === 'prefixed' && - stringType.size.prefix.format === 'u32' && stringType.size.prefix.endian === 'le' ) { - return { - type: 'String', - imports: new RustImportMap(), - nestedStructs: [], - }; + switch (stringType.size.prefix.format) { + case 'u32': + return { + type: 'String', + imports: new RustImportMap(), + nestedStructs: [], + }; + case 'u8': + case 'u16': + case 'u64': { + const prefix = stringType.size.prefix.format.toUpperCase(); + return { + type: `${prefix}PrefixString`, + imports: new RustImportMap().add( + `kaigan::types::${prefix}PrefixString` + ), + nestedStructs: [], + }; + } + default: + throw new Error( + `'String size not supported: ${stringType.size.prefix.format}` + ); + } } if (stringType.size.kind === 'fixed') { diff --git a/test/packages/js-experimental/src/generated/types/index.ts b/test/packages/js-experimental/src/generated/types/index.ts index 4ab4cf5a9..e82925ec0 100644 --- a/test/packages/js-experimental/src/generated/types/index.ts +++ b/test/packages/js-experimental/src/generated/types/index.ts @@ -26,6 +26,8 @@ export * from './dummyLines'; export * from './escrowAuthority'; export * from './extendedPayload'; export * from './hiddenSettings'; +export * from './link'; +export * from './links'; export * from './migrateArgs'; export * from './mintArgs'; export * from './mintNewEditionFromMasterEditionViaTokenArgs'; diff --git a/test/packages/js-experimental/src/generated/types/link.ts b/test/packages/js-experimental/src/generated/types/link.ts new file mode 100644 index 000000000..913c097fe --- /dev/null +++ b/test/packages/js-experimental/src/generated/types/link.ts @@ -0,0 +1,37 @@ +/** + * 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 { Codec, Decoder, Encoder, combineCodec } from '@solana/codecs-core'; +import { + getStructDecoder, + getStructEncoder, +} from '@solana/codecs-data-structures'; +import { getU8Decoder, getU8Encoder } from '@solana/codecs-numbers'; +import { getStringDecoder, getStringEncoder } from '@solana/codecs-strings'; + +export type Link = { name: string; uri: string }; + +export type LinkArgs = Link; + +export function getLinkEncoder() { + return getStructEncoder([ + ['name', getStringEncoder({ size: getU8Encoder() })], + ['uri', getStringEncoder({ size: getU8Encoder() })], + ]) satisfies Encoder; +} + +export function getLinkDecoder() { + return getStructDecoder([ + ['name', getStringDecoder({ size: getU8Decoder() })], + ['uri', getStringDecoder({ size: getU8Decoder() })], + ]) satisfies Decoder; +} + +export function getLinkCodec(): Codec { + return combineCodec(getLinkEncoder(), getLinkDecoder()); +} diff --git a/test/packages/js-experimental/src/generated/types/links.ts b/test/packages/js-experimental/src/generated/types/links.ts new file mode 100644 index 000000000..8e706d830 --- /dev/null +++ b/test/packages/js-experimental/src/generated/types/links.ts @@ -0,0 +1,36 @@ +/** + * 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 { Codec, Decoder, Encoder, combineCodec } from '@solana/codecs-core'; +import { + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, +} from '@solana/codecs-data-structures'; +import { Link, LinkArgs, getLinkDecoder, getLinkEncoder } from '.'; + +export type Links = { values: Array }; + +export type LinksArgs = { values: Array }; + +export function getLinksEncoder() { + return getStructEncoder([ + ['values', getArrayEncoder(getLinkEncoder(), { size: 'remainder' })], + ]) satisfies Encoder; +} + +export function getLinksDecoder() { + return getStructDecoder([ + ['values', getArrayDecoder(getLinkDecoder(), { size: 'remainder' })], + ]) satisfies Decoder; +} + +export function getLinksCodec(): Codec { + return combineCodec(getLinksEncoder(), getLinksDecoder()); +} diff --git a/test/packages/js/src/generated/types/index.ts b/test/packages/js/src/generated/types/index.ts index 4ab4cf5a9..e82925ec0 100644 --- a/test/packages/js/src/generated/types/index.ts +++ b/test/packages/js/src/generated/types/index.ts @@ -26,6 +26,8 @@ export * from './dummyLines'; export * from './escrowAuthority'; export * from './extendedPayload'; export * from './hiddenSettings'; +export * from './link'; +export * from './links'; export * from './migrateArgs'; export * from './mintArgs'; export * from './mintNewEditionFromMasterEditionViaTokenArgs'; diff --git a/test/packages/js/src/generated/types/link.ts b/test/packages/js/src/generated/types/link.ts new file mode 100644 index 000000000..fcfa8baa9 --- /dev/null +++ b/test/packages/js/src/generated/types/link.ts @@ -0,0 +1,28 @@ +/** + * 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, + string, + struct, + u8, +} from '@metaplex-foundation/umi/serializers'; + +export type Link = { name: string; uri: string }; + +export type LinkArgs = Link; + +export function getLinkSerializer(): Serializer { + return struct( + [ + ['name', string({ size: u8() })], + ['uri', string({ size: u8() })], + ], + { description: 'Link' } + ) as Serializer; +} diff --git a/test/packages/js/src/generated/types/links.ts b/test/packages/js/src/generated/types/links.ts new file mode 100644 index 000000000..890e9900d --- /dev/null +++ b/test/packages/js/src/generated/types/links.ts @@ -0,0 +1,25 @@ +/** + * 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, + struct, +} from '@metaplex-foundation/umi/serializers'; +import { Link, LinkArgs, getLinkSerializer } from '.'; + +export type Links = { values: Array }; + +export type LinksArgs = { values: Array }; + +export function getLinksSerializer(): Serializer { + return struct( + [['values', array(getLinkSerializer(), { size: 'remainder' })]], + { description: 'Links' } + ) as Serializer; +} diff --git a/test/packages/rust/Cargo.lock b/test/packages/rust/Cargo.lock index d097afc0e..d55689ec1 100644 --- a/test/packages/rust/Cargo.lock +++ b/test/packages/rust/Cargo.lock @@ -8,19 +8,19 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.12", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", - "getrandom 0.2.10", + "getrandom 0.2.12", "once_cell", "version_check", "zerocopy", @@ -43,9 +43,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "ark-bn254" @@ -190,9 +190,9 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "c79fed4cdb43e993fcdadc7e58a09fd0e3e649c4436fa11da71c9f1f3ee7feb9" [[package]] name = "bincode" @@ -388,7 +388,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -423,7 +423,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -454,51 +454,43 @@ checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crunchy" @@ -561,7 +553,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -572,14 +564,14 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", "serde", @@ -666,9 +658,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "js-sys", @@ -698,14 +690,14 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.7", ] [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "hex" @@ -736,9 +728,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -797,7 +789,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "serde", ] @@ -812,9 +804,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" @@ -827,18 +819,18 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] [[package]] name = "kaigan" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ade400c53c86236d5b03b681e6c4e3d1d8da674e78a3916480886614674f017" +checksum = "e623cca1f0e2a0919032c1bdabbf81dd9aa34658d5066aca7bb90d608317ab91" dependencies = [ "borsh 0.10.3", "serde", @@ -875,9 +867,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libsecp256k1" @@ -929,12 +921,13 @@ dependencies = [ [[package]] name = "light-poseidon" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b439809cdfc0d86ecc7317f1724df13dfa665df48991b79e90e689411451f7" +checksum = "3c9a85a9752c549ceb7578064b4ed891179d20acd85f27318573b64d2d7ee7ee" dependencies = [ "ark-bn254", "ark-ff", + "num-bigint", "thiserror", ] @@ -1015,9 +1008,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -1045,7 +1038,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1086,18 +1079,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1161,7 +1154,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.12", ] [[package]] @@ -1234,9 +1227,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "scopeguard" @@ -1246,44 +1239,44 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "serde" -version = "1.0.190" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.12" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -1296,7 +1289,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ - "base64 0.21.5", + "base64 0.21.6", "chrono", "hex", "indexmap 1.9.3", @@ -1316,7 +1309,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -1365,17 +1358,17 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "solana-frozen-abi" -version = "1.17.4" +version = "1.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80447a64ba88aff4ab1fe70c646b9a0ee65f190aa2977b1e7360066445f8ed34" +checksum = "8e2c5e5dde22cac045d29675b3fefa84817e1f63b0b911d094c599e80c0c07d9" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.7", "blake3", "block-buffer 0.10.4", "bs58", @@ -1401,27 +1394,27 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.17.4" +version = "1.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28b7325d40b3b3fef0db6917972e8121bec05fa2b59904212b25478c85924cd" +checksum = "296e4cf0e2479e4c21afe4d17e32526f71f1bcd93b1c7c660900bc3e4233447a" dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] name = "solana-program" -version = "1.17.4" +version = "1.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fe4a811ec2c4b0c3773e5661ecfaff81f822c9e18866097caeba6be9338dab" +checksum = "8e3a3b9623f09e2c480b4e129c92d7a036f8614fd0fc7519791bd44e64061ce8" dependencies = [ "ark-bn254", "ark-ec", "ark-ff", "ark-serialize", - "base64 0.21.5", + "base64 0.21.6", "bincode", "bitflags 2.4.1", "blake3", @@ -1434,7 +1427,7 @@ dependencies = [ "console_error_panic_hook", "console_log", "curve25519-dalek", - "getrandom 0.2.10", + "getrandom 0.2.12", "itertools", "js-sys", "lazy_static", @@ -1467,15 +1460,15 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.17.4" +version = "1.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97dce8e347d73bcd9a6fe0b37bf830a20d0a4913ac58046c79959d5e15bbbed3" +checksum = "60f58786e949f43b8c9b826fdfa5ad8586634b077ab04f989fb8e30535786712" dependencies = [ "bs58", "proc-macro2", "quote", "rustversion", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -1503,9 +1496,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -1514,29 +1507,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] name = "time" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" dependencies = [ "deranged", "itoa", @@ -1554,9 +1547,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" dependencies = [ "time-core", ] @@ -1645,9 +1638,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1655,24 +1648,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1680,28 +1673,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "web-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", @@ -1709,11 +1702,11 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.0", ] [[package]] @@ -1722,13 +1715,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -1737,60 +1745,102 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "zerocopy" -version = "0.7.25" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.25" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -1810,5 +1860,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] diff --git a/test/packages/rust/src/generated/types/link.rs b/test/packages/rust/src/generated/types/link.rs new file mode 100644 index 000000000..821f16df4 --- /dev/null +++ b/test/packages/rust/src/generated/types/link.rs @@ -0,0 +1,17 @@ +//! 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. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +use borsh::BorshDeserialize; +use borsh::BorshSerialize; +use kaigan::types::U8PrefixString; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Link { + pub name: U8PrefixString, + pub uri: U8PrefixString, +} diff --git a/test/packages/rust/src/generated/types/links.rs b/test/packages/rust/src/generated/types/links.rs new file mode 100644 index 000000000..28ca65dcd --- /dev/null +++ b/test/packages/rust/src/generated/types/links.rs @@ -0,0 +1,17 @@ +//! 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. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +use crate::generated::types::Link; +use borsh::BorshDeserialize; +use borsh::BorshSerialize; +use kaigan::types::RemainderVec; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Links { + pub values: RemainderVec, +} diff --git a/test/packages/rust/src/generated/types/mod.rs b/test/packages/rust/src/generated/types/mod.rs index 81261a013..f61ebeb34 100644 --- a/test/packages/rust/src/generated/types/mod.rs +++ b/test/packages/rust/src/generated/types/mod.rs @@ -25,6 +25,8 @@ pub(crate) mod r#dummy_lines; pub(crate) mod r#escrow_authority; pub(crate) mod r#extended_payload; pub(crate) mod r#hidden_settings; +pub(crate) mod r#link; +pub(crate) mod r#links; pub(crate) mod r#migrate_args; pub(crate) mod r#mint_args; pub(crate) mod r#mint_new_edition_from_master_edition_via_token_args; @@ -70,6 +72,8 @@ pub use self::r#dummy_lines::*; pub use self::r#escrow_authority::*; pub use self::r#extended_payload::*; pub use self::r#hidden_settings::*; +pub use self::r#link::*; +pub use self::r#links::*; pub use self::r#migrate_args::*; pub use self::r#mint_args::*; pub use self::r#mint_new_edition_from_master_edition_via_token_args::*; diff --git a/test/testFile.cjs b/test/testFile.cjs index ecea74588..a1b1e3134 100644 --- a/test/testFile.cjs +++ b/test/testFile.cjs @@ -15,6 +15,52 @@ kinobi.update( }) ); +kinobi.update( + new k.TransformNodesVisitor([ + { + selector: { kind: "programNode", name: "mplTokenMetadata" }, + transformer: (node) => { + k.assertProgramNode(node); + return k.programNode({ + ...node, + definedTypes: [ + ...node.definedTypes, + k.definedTypeNodeFromIdl({ + name: "links", + type: { + kind: "struct", + fields: [ + { + name: "values", + type: { vec: { defined: "link" }, size: "remainder" }, + }, + ], + }, + }), + k.definedTypeNode({ + name: "link", + data: k.structTypeNode([ + k.structFieldTypeNode({ + name: "name", + child: k.stringTypeNode({ + size: k.prefixedSize(k.numberTypeNode("u8")), + }), + }), + k.structFieldTypeNode({ + name: "uri", + child: k.stringTypeNode({ + size: k.prefixedSize(k.numberTypeNode("u8")), + }), + }), + ]), + }), + ], + }); + }, + }, + ]) +); + kinobi.update( new k.UpdateAccountsVisitor({ Metadata: { size: 679 },