diff --git a/.changeset/healthy-adults-teach.md b/.changeset/healthy-adults-teach.md new file mode 100644 index 000000000..7f5026b05 --- /dev/null +++ b/.changeset/healthy-adults-teach.md @@ -0,0 +1,5 @@ +--- +'@metaplex-foundation/kinobi': patch +--- + +Improve rust modules diff --git a/src/renderers/rust/GetRustRenderMapVisitor.ts b/src/renderers/rust/GetRustRenderMapVisitor.ts index 4676d5fda..49d17fcd8 100644 --- a/src/renderers/rust/GetRustRenderMapVisitor.ts +++ b/src/renderers/rust/GetRustRenderMapVisitor.ts @@ -91,9 +91,7 @@ export class GetRustRenderMapVisitor extends BaseThrowVisitor { map.add('instructions/mod.rs', this.render('instructionsMod.njk', ctx)); } if (definedTypesToExport.length > 0) { - map - .add('types/mod.rs', this.render('definedTypesMod.njk', ctx)) - .add('types/helper/mod.rs', this.render('sharedPage.njk', ctx)); + map.add('types/mod.rs', this.render('definedTypesMod.njk', ctx)); } return map diff --git a/src/renderers/rust/GetRustTypeManifestVisitor.ts b/src/renderers/rust/GetRustTypeManifestVisitor.ts index 5677d4dd1..d9096dfeb 100644 --- a/src/renderers/rust/GetRustTypeManifestVisitor.ts +++ b/src/renderers/rust/GetRustTypeManifestVisitor.ts @@ -126,7 +126,7 @@ export class GetRustTypeManifestVisitor implements Visitor { } if (arrayType.size.kind === 'remainder') { - childManifest.imports.add('crate::types::helper::RemainderVec'); + childManifest.imports.add('kaigan::types::RemainderVec'); return { ...childManifest, type: `RemainderVec<${childManifest.type}>`, diff --git a/src/renderers/rust/templates/accountsMod.njk b/src/renderers/rust/templates/accountsMod.njk index 8368f4c0f..7393e16a9 100644 --- a/src/renderers/rust/templates/accountsMod.njk +++ b/src/renderers/rust/templates/accountsMod.njk @@ -3,10 +3,11 @@ {% block main %} {% for account in accountsToExport | sort(false, false, 'name') %} -mod {{ account.name | snakeCase }}; +pub mod {{ account.name | snakeCase }}; {% endfor %} {% for account in accountsToExport | sort(false, false, 'name') %} -pub use {{ account.name | snakeCase }}::*; +pub use self::{{ account.name | snakeCase }}::*; {% endfor %} -{% endblock %} \ No newline at end of file + +{% endblock %} diff --git a/src/renderers/rust/templates/definedTypesMod.njk b/src/renderers/rust/templates/definedTypesMod.njk index bafe19b76..768c878a1 100644 --- a/src/renderers/rust/templates/definedTypesMod.njk +++ b/src/renderers/rust/templates/definedTypesMod.njk @@ -3,10 +3,11 @@ {% block main %} {% for definedType in definedTypesToExport | sort(false, false, 'name') %} -mod {{ definedType.name | snakeCase }}; +pub mod {{ definedType.name | snakeCase }}; {% endfor %} {% for definedType in definedTypesToExport | sort(false, false, 'name') %} -pub use {{ definedType.name | snakeCase }}::*; +pub use self::{{ definedType.name | snakeCase }}::*; {% endfor %} -{% endblock %} \ No newline at end of file + +{% endblock %} diff --git a/src/renderers/rust/templates/definedTypesPage.njk b/src/renderers/rust/templates/definedTypesPage.njk index b16e81605..cb9876903 100644 --- a/src/renderers/rust/templates/definedTypesPage.njk +++ b/src/renderers/rust/templates/definedTypesPage.njk @@ -6,9 +6,10 @@ {{ imports }} {{ macros.docblock(definedType.docs) }} -{{ typeManifest.type }} +{{- typeManifest.type }} {% for nestedStruct in typeManifest.nestedStructs %} {{ nestedStruct }} {% endfor %} + {% endblock %} diff --git a/src/renderers/rust/templates/errorsMod.njk b/src/renderers/rust/templates/errorsMod.njk index 17b9d6269..d025ac719 100644 --- a/src/renderers/rust/templates/errorsMod.njk +++ b/src/renderers/rust/templates/errorsMod.njk @@ -3,10 +3,11 @@ {% block main %} {% for program in programsToExport | sort(false, false, 'name') %} -mod {{ program.name | snakeCase }}; +pub mod {{ program.name | snakeCase }}; {% endfor %} {% for program in programsToExport | sort(false, false, 'name') %} -pub use {{ program.name | snakeCase }}::{{ program.name | pascalCase }}Error; +pub use self::{{ program.name | snakeCase }}::{{ program.name | pascalCase }}Error; {% endfor %} -{% endblock %} \ No newline at end of file + +{% endblock %} diff --git a/src/renderers/rust/templates/errorsPage.njk b/src/renderers/rust/templates/errorsPage.njk index cc5e781a9..b4d92fe65 100644 --- a/src/renderers/rust/templates/errorsPage.njk +++ b/src/renderers/rust/templates/errorsPage.njk @@ -19,4 +19,5 @@ impl solana_program::program_error::PrintProgramError for {{ program.name | pasc solana_program::msg!(&self.to_string()); } } -{% endblock %} \ No newline at end of file + +{% endblock %} diff --git a/src/renderers/rust/templates/instructionsCpiPageBuilder.njk b/src/renderers/rust/templates/instructionsCpiPageBuilder.njk index b8b998848..2ea65e31b 100644 --- a/src/renderers/rust/templates/instructionsCpiPageBuilder.njk +++ b/src/renderers/rust/templates/instructionsCpiPageBuilder.njk @@ -89,4 +89,4 @@ struct {{ instruction.name | pascalCase }}CpiBuilderInstruction<'a> { {{ arg.name | snakeCase }}: {{ arg.type if arg.innerOptionType else 'Option<' + arg.type + '>' }}, {% endif %} {% endfor %} -} \ No newline at end of file +} diff --git a/src/renderers/rust/templates/instructionsMod.njk b/src/renderers/rust/templates/instructionsMod.njk index 71f7bf9c0..453b847d6 100644 --- a/src/renderers/rust/templates/instructionsMod.njk +++ b/src/renderers/rust/templates/instructionsMod.njk @@ -7,6 +7,7 @@ pub mod {{ instruction.name | snakeCase }}; {% endfor %} {% for instruction in instructionsToExport | sort(false, false, 'name') %} -pub use {{ instruction.name | snakeCase }}::*; +pub use self::{{ instruction.name | snakeCase }}::*; {% endfor %} -{% endblock %} \ No newline at end of file + +{% endblock %} diff --git a/src/renderers/rust/templates/programsMod.njk b/src/renderers/rust/templates/programsMod.njk index 749d6215d..9b0f7a4cb 100644 --- a/src/renderers/rust/templates/programsMod.njk +++ b/src/renderers/rust/templates/programsMod.njk @@ -9,4 +9,5 @@ use solana_program::{pubkey, pubkey::Pubkey}; /// `{{ program.name | snakeCase }}` program ID. pub const {{ program.name | snakeCase | upper }}_ID: Pubkey = pubkey!("{{ program.publicKey }}"); {% endfor %} + {% endblock %} diff --git a/src/renderers/rust/templates/rootMod.njk b/src/renderers/rust/templates/rootMod.njk index 48a4b30df..54e28448e 100644 --- a/src/renderers/rust/templates/rootMod.njk +++ b/src/renderers/rust/templates/rootMod.njk @@ -21,6 +21,6 @@ {% endif %} {% if programsToExport.length > 0 %} - pub use programs::*; + pub(crate) use programs::*; {% endif %} {% endblock %} diff --git a/test/mpl_candy_machine_core.json b/test/mpl_candy_machine_core.json index f4cac38df..e9876ec88 100644 --- a/test/mpl_candy_machine_core.json +++ b/test/mpl_candy_machine_core.json @@ -688,6 +688,29 @@ } ] } + }, + { + "name": "DummyLines", + "docs": [ + "Dummy lines." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "lines", + "docs": [ + "The dummy lines." + ], + "type": { + "vec": { + "defined": "ConfigLine" + }, + "size": "remainder" + } + } + ] + } } ], "errors": [ diff --git a/test/packages/js/src/generated/types/dummyLines.ts b/test/packages/js/src/generated/types/dummyLines.ts new file mode 100644 index 000000000..fa131b022 --- /dev/null +++ b/test/packages/js/src/generated/types/dummyLines.ts @@ -0,0 +1,42 @@ +/** + * 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 { ConfigLine, ConfigLineArgs, getConfigLineSerializer } from '.'; + +/** Dummy lines. */ +export type DummyLines = { + /** The dummy lines. */ + lines: Array; +}; + +export type DummyLinesArgs = { + /** The dummy lines. */ + lines: Array; +}; + +/** @deprecated Use `getDummyLinesSerializer()` without any argument instead. */ +export function getDummyLinesSerializer( + _context: object +): Serializer; +export function getDummyLinesSerializer(): Serializer< + DummyLinesArgs, + DummyLines +>; +export function getDummyLinesSerializer( + _context: object = {} +): Serializer { + return struct( + [['lines', array(getConfigLineSerializer(), { size: 'remainder' })]], + { description: 'DummyLines' } + ) as Serializer; +} diff --git a/test/packages/js/src/generated/types/index.ts b/test/packages/js/src/generated/types/index.ts index 4d1a8ab06..4ab4cf5a9 100644 --- a/test/packages/js/src/generated/types/index.ts +++ b/test/packages/js/src/generated/types/index.ts @@ -22,6 +22,7 @@ export * from './dataV2'; export * from './delegateArgs'; export * from './delegateRole'; export * from './delegateState'; +export * from './dummyLines'; export * from './escrowAuthority'; export * from './extendedPayload'; export * from './hiddenSettings'; diff --git a/test/packages/rust/Cargo.lock b/test/packages/rust/Cargo.lock index 47d6186e5..002eff48b 100644 --- a/test/packages/rust/Cargo.lock +++ b/test/packages/rust/Cargo.lock @@ -13,11 +13,146 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "getrandom 0.2.10", + "once_cell", + "version_check", +] + [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "ark-bn254" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.10.7", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "array-bytes" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ad284aeb45c13f2fb4f084de4a420ebf447423bdf9386c0540ce33cb3ef4b8c" [[package]] name = "arrayref" @@ -45,9 +180,9 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "base64" -version = "0.13.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "bincode" @@ -75,9 +210,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" +checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" dependencies = [ "arrayref", "arrayvec", @@ -93,7 +228,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding", "generic-array", ] @@ -106,30 +240,47 @@ dependencies = [ "generic-array", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "borsh" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" dependencies = [ - "borsh-derive", + "borsh-derive 0.9.3", "hashbrown 0.11.2", ] +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive 0.10.3", + "hashbrown 0.13.2", +] + [[package]] name = "borsh-derive" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", + "borsh-derive-internal 0.9.3", + "borsh-schema-derive-internal 0.9.3", + "proc-macro-crate", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal 0.10.3", + "borsh-schema-derive-internal 0.10.3", "proc-macro-crate", "proc-macro2", "syn 1.0.109", @@ -146,6 +297,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "borsh-schema-derive-internal" version = "0.9.3" @@ -157,6 +319,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bs58" version = "0.4.0" @@ -196,7 +369,7 @@ checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -207,9 +380,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", "libc", @@ -243,9 +416,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.1.5" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "cpufeatures" @@ -286,7 +459,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.9.0", + "memoffset", "scopeguard", ] @@ -339,6 +512,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "digest" version = "0.9.0" @@ -414,16 +598,16 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash", + "ahash 0.7.6", ] [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash", + "ahash 0.8.3", ] [[package]] @@ -502,6 +686,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "kaigan" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ed6e2dabe34b706323b7243e4411a16f77161bffbe19748cd7ae2c6918c7b2" +dependencies = [ + "borsh 0.10.3", +] + [[package]] name = "keccak" version = "0.1.4" @@ -515,7 +708,8 @@ dependencies = [ name = "kinobi-dummy-generated" version = "0.1.0" dependencies = [ - "borsh", + "borsh 0.10.3", + "kaigan", "num-derive", "num-traits", "solana-program", @@ -547,7 +741,7 @@ dependencies = [ "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", - "rand", + "rand 0.7.3", "serde", "sha2 0.9.9", "typenum", @@ -594,9 +788,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memmap2" @@ -609,20 +803,22 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] [[package]] -name = "memoffset" -version = "0.9.0" +name = "num-bigint" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ "autocfg", + "num-integer", + "num-traits", ] [[package]] @@ -636,6 +832,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.16" @@ -690,6 +896,12 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "pbkdf2" version = "0.4.0" @@ -725,9 +937,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -740,11 +952,21 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom 0.1.16", "libc", - "rand_chacha", + "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -755,6 +977,16 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -863,9 +1095,9 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.183" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" dependencies = [ "serde_derive", ] @@ -881,20 +1113,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.183" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -953,13 +1185,13 @@ checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "solana-frozen-abi" -version = "1.14.23" +version = "1.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bb8ca009e59759c2042db41b924b9e31e4c03ca339a1a69ac4224bef3ca912" +checksum = "d89ed0a4ba426c461866700f082a00d490e4bde6d27d2d88e129acb3fde79054" dependencies = [ - "ahash", + "ahash 0.8.3", "blake3", - "block-buffer 0.9.0", + "block-buffer 0.10.4", "bs58", "bv", "byteorder", @@ -967,7 +1199,6 @@ dependencies = [ "either", "generic-array", "getrandom 0.1.16", - "hashbrown 0.12.3", "im", "lazy_static", "log", @@ -987,28 +1218,33 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.14.23" +version = "1.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c860200b0a94729a43f15f5c4ab45f953802f2042ff88b4424fb44f834f89497" +checksum = "b69dd83d2d675cad4ed0f0086a7d0c669dc407213b4bc916555ed329ea93f531" dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", + "syn 2.0.29", ] [[package]] name = "solana-program" -version = "1.14.23" +version = "1.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02279241c22c5a051511ba3b8442f9b33094c7108772b7d5a33f1a15c9491a78" +checksum = "c38a798723409541aae8ddc9b69c4c78b798e6c219e3e526b5bd4280974a5f29" dependencies = [ - "base64 0.13.1", + "ark-bn254", + "ark-ec", + "ark-ff", + "ark-serialize", + "array-bytes", + "base64 0.21.2", "bincode", "bitflags", "blake3", - "borsh", - "borsh-derive", + "borsh 0.10.3", + "borsh 0.9.3", "bs58", "bv", "bytemuck", @@ -1023,12 +1259,13 @@ dependencies = [ "libc", "libsecp256k1", "log", - "memoffset 0.6.5", + "memoffset", + "num-bigint", "num-derive", "num-traits", "parking_lot", - "rand", - "rand_chacha", + "rand 0.7.3", + "rand_chacha 0.2.2", "rustc_version", "rustversion", "serde", @@ -1048,15 +1285,15 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.14.23" +version = "1.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d5464d292deadd7a676e619f7922e3b0fc69ba3466237977588cf798418763f" +checksum = "e3e5a8c7e9e91c7d35f24ffd47a04221f76edb9aba968d79ee10e1cb26f16d2f" dependencies = [ "bs58", "proc-macro2", "quote", "rustversion", - "syn 1.0.109", + "syn 2.0.29", ] [[package]] @@ -1078,9 +1315,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -1089,22 +1326,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1117,7 +1354,7 @@ dependencies = [ "hmac", "once_cell", "pbkdf2", - "rand", + "rand 0.7.3", "rustc-hash", "sha2 0.9.9", "thiserror", @@ -1210,7 +1447,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", "wasm-bindgen-shared", ] @@ -1232,7 +1469,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1255,9 +1492,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1270,45 +1507,45 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "zeroize" @@ -1327,5 +1564,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] diff --git a/test/packages/rust/Cargo.toml b/test/packages/rust/Cargo.toml index 70acca950..8af7fb0ff 100644 --- a/test/packages/rust/Cargo.toml +++ b/test/packages/rust/Cargo.toml @@ -7,6 +7,7 @@ publish = false [dependencies] solana-program = "^1.10" borsh = ">= 0.9" +kaigan = ">= 0.1" num-derive = "^0.3" num-traits = "^0.2" thiserror = "~1.0" diff --git a/test/packages/rust/src/generated/accounts/mod.rs b/test/packages/rust/src/generated/accounts/mod.rs index 99a4eec7a..d9cfd5309 100644 --- a/test/packages/rust/src/generated/accounts/mod.rs +++ b/test/packages/rust/src/generated/accounts/mod.rs @@ -5,30 +5,30 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -mod candy_machine; -mod collection_authority_record; -mod delegate_record; -mod edition; -mod edition_marker; -mod frequency_account; -mod master_edition_v1; -mod master_edition_v2; -mod metadata; -mod reservation_list_v1; -mod reservation_list_v2; -mod token_owned_escrow; -mod use_authority_record; +pub mod candy_machine; +pub mod collection_authority_record; +pub mod delegate_record; +pub mod edition; +pub mod edition_marker; +pub mod frequency_account; +pub mod master_edition_v1; +pub mod master_edition_v2; +pub mod metadata; +pub mod reservation_list_v1; +pub mod reservation_list_v2; +pub mod token_owned_escrow; +pub mod use_authority_record; -pub use candy_machine::*; -pub use collection_authority_record::*; -pub use delegate_record::*; -pub use edition::*; -pub use edition_marker::*; -pub use frequency_account::*; -pub use master_edition_v1::*; -pub use master_edition_v2::*; -pub use metadata::*; -pub use reservation_list_v1::*; -pub use reservation_list_v2::*; -pub use token_owned_escrow::*; -pub use use_authority_record::*; +pub use self::candy_machine::*; +pub use self::collection_authority_record::*; +pub use self::delegate_record::*; +pub use self::edition::*; +pub use self::edition_marker::*; +pub use self::frequency_account::*; +pub use self::master_edition_v1::*; +pub use self::master_edition_v2::*; +pub use self::metadata::*; +pub use self::reservation_list_v1::*; +pub use self::reservation_list_v2::*; +pub use self::token_owned_escrow::*; +pub use self::use_authority_record::*; diff --git a/test/packages/rust/src/generated/errors/mod.rs b/test/packages/rust/src/generated/errors/mod.rs index c2889d73b..8b4c1bdf7 100644 --- a/test/packages/rust/src/generated/errors/mod.rs +++ b/test/packages/rust/src/generated/errors/mod.rs @@ -5,10 +5,10 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -mod mpl_candy_machine_core; -mod mpl_token_auth_rules; -mod mpl_token_metadata; +pub mod mpl_candy_machine_core; +pub mod mpl_token_auth_rules; +pub mod mpl_token_metadata; -pub use mpl_candy_machine_core::MplCandyMachineCoreError; -pub use mpl_token_auth_rules::MplTokenAuthRulesError; -pub use mpl_token_metadata::MplTokenMetadataError; +pub use self::mpl_candy_machine_core::MplCandyMachineCoreError; +pub use self::mpl_token_auth_rules::MplTokenAuthRulesError; +pub use self::mpl_token_metadata::MplTokenMetadataError; diff --git a/test/packages/rust/src/generated/instructions/mod.rs b/test/packages/rust/src/generated/instructions/mod.rs index 58ac919c1..1be366de1 100644 --- a/test/packages/rust/src/generated/instructions/mod.rs +++ b/test/packages/rust/src/generated/instructions/mod.rs @@ -70,67 +70,67 @@ pub mod verify_collection; pub mod verify_sized_collection_item; pub mod withdraw; -pub use add_config_lines::*; -pub use approve_collection_authority::*; -pub use approve_use_authority::*; -pub use bubblegum_set_collection_size::*; -pub use burn::*; -pub use burn_edition_nft::*; -pub use burn_nft::*; -pub use close_escrow_account::*; -pub use convert_master_edition_v1_to_v2::*; -pub use create_escrow_account::*; -pub use create_frequency_rule::*; -pub use create_master_edition::*; -pub use create_master_edition_v3::*; -pub use create_metadata_account::*; -pub use create_metadata_account_v2::*; -pub use create_metadata_account_v3::*; -pub use create_reservation_list::*; -pub use create_rule_set::*; -pub use create_v1::*; -pub use create_v2::*; -pub use delegate::*; -pub use deprecated_create_master_edition::*; -pub use deprecated_mint_new_edition_from_master_edition_via_printing_token::*; -pub use deprecated_mint_printing_tokens::*; -pub use deprecated_mint_printing_tokens_via_token::*; -pub use deprecated_set_reservation_list::*; -pub use dummy::*; -pub use freeze_delegated_account::*; -pub use initialize::*; -pub use migrate::*; -pub use mint::*; -pub use mint_from_candy_machine::*; -pub use mint_new_edition_from_master_edition_via_token::*; -pub use mint_new_edition_from_master_edition_via_vault_proxy::*; -pub use puff_metadata::*; -pub use remove_creator_verification::*; -pub use revoke::*; -pub use revoke_collection_authority::*; -pub use revoke_use_authority::*; -pub use set_and_verify_collection::*; -pub use set_and_verify_sized_collection_item::*; -pub use set_authority::*; -pub use set_collection::*; -pub use set_collection_size::*; -pub use set_mint_authority::*; -pub use set_token_standard::*; -pub use sign_metadata::*; -pub use thaw_delegated_account::*; -pub use transfer::*; -pub use transfer_out_of_escrow::*; -pub use unverify_collection::*; -pub use unverify_sized_collection_item::*; -pub use update_candy_machine::*; -pub use update_metadata_account::*; -pub use update_metadata_account_v2::*; -pub use update_primary_sale_happened_via_token::*; -pub use update_v1::*; -pub use use_asset::*; -pub use utilize::*; -pub use validate::*; -pub use verify::*; -pub use verify_collection::*; -pub use verify_sized_collection_item::*; -pub use withdraw::*; +pub use self::add_config_lines::*; +pub use self::approve_collection_authority::*; +pub use self::approve_use_authority::*; +pub use self::bubblegum_set_collection_size::*; +pub use self::burn::*; +pub use self::burn_edition_nft::*; +pub use self::burn_nft::*; +pub use self::close_escrow_account::*; +pub use self::convert_master_edition_v1_to_v2::*; +pub use self::create_escrow_account::*; +pub use self::create_frequency_rule::*; +pub use self::create_master_edition::*; +pub use self::create_master_edition_v3::*; +pub use self::create_metadata_account::*; +pub use self::create_metadata_account_v2::*; +pub use self::create_metadata_account_v3::*; +pub use self::create_reservation_list::*; +pub use self::create_rule_set::*; +pub use self::create_v1::*; +pub use self::create_v2::*; +pub use self::delegate::*; +pub use self::deprecated_create_master_edition::*; +pub use self::deprecated_mint_new_edition_from_master_edition_via_printing_token::*; +pub use self::deprecated_mint_printing_tokens::*; +pub use self::deprecated_mint_printing_tokens_via_token::*; +pub use self::deprecated_set_reservation_list::*; +pub use self::dummy::*; +pub use self::freeze_delegated_account::*; +pub use self::initialize::*; +pub use self::migrate::*; +pub use self::mint::*; +pub use self::mint_from_candy_machine::*; +pub use self::mint_new_edition_from_master_edition_via_token::*; +pub use self::mint_new_edition_from_master_edition_via_vault_proxy::*; +pub use self::puff_metadata::*; +pub use self::remove_creator_verification::*; +pub use self::revoke::*; +pub use self::revoke_collection_authority::*; +pub use self::revoke_use_authority::*; +pub use self::set_and_verify_collection::*; +pub use self::set_and_verify_sized_collection_item::*; +pub use self::set_authority::*; +pub use self::set_collection::*; +pub use self::set_collection_size::*; +pub use self::set_mint_authority::*; +pub use self::set_token_standard::*; +pub use self::sign_metadata::*; +pub use self::thaw_delegated_account::*; +pub use self::transfer::*; +pub use self::transfer_out_of_escrow::*; +pub use self::unverify_collection::*; +pub use self::unverify_sized_collection_item::*; +pub use self::update_candy_machine::*; +pub use self::update_metadata_account::*; +pub use self::update_metadata_account_v2::*; +pub use self::update_primary_sale_happened_via_token::*; +pub use self::update_v1::*; +pub use self::use_asset::*; +pub use self::utilize::*; +pub use self::validate::*; +pub use self::verify::*; +pub use self::verify_collection::*; +pub use self::verify_sized_collection_item::*; +pub use self::withdraw::*; diff --git a/test/packages/rust/src/generated/mod.rs b/test/packages/rust/src/generated/mod.rs index 5a39b0d1b..1dc8fd1f0 100644 --- a/test/packages/rust/src/generated/mod.rs +++ b/test/packages/rust/src/generated/mod.rs @@ -11,4 +11,4 @@ pub mod instructions; pub mod programs; pub mod types; -pub use programs::*; +pub(crate) use programs::*; diff --git a/test/packages/rust/src/generated/types/candy_machine_data.rs b/test/packages/rust/src/generated/types/candy_machine_data.rs index c91ae4f05..a9769731b 100644 --- a/test/packages/rust/src/generated/types/candy_machine_data.rs +++ b/test/packages/rust/src/generated/types/candy_machine_data.rs @@ -12,7 +12,6 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; /// Candy machine configuration data. - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] pub struct CandyMachineData { /// Number of assets available diff --git a/test/packages/rust/src/generated/types/config_line.rs b/test/packages/rust/src/generated/types/config_line.rs index d7478780c..0ab814821 100644 --- a/test/packages/rust/src/generated/types/config_line.rs +++ b/test/packages/rust/src/generated/types/config_line.rs @@ -9,7 +9,6 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; /// Config line struct for storing asset (NFT) data pre-mint. - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] pub struct ConfigLine { /// Name of the asset. diff --git a/test/packages/rust/src/generated/types/config_line_settings.rs b/test/packages/rust/src/generated/types/config_line_settings.rs index 5c2a5e469..43f002f6e 100644 --- a/test/packages/rust/src/generated/types/config_line_settings.rs +++ b/test/packages/rust/src/generated/types/config_line_settings.rs @@ -9,7 +9,6 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; /// Config line settings to allocate space for individual name + URI. - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] pub struct ConfigLineSettings { /// Common name prefix diff --git a/test/packages/rust/src/generated/types/dummy_lines.rs b/test/packages/rust/src/generated/types/dummy_lines.rs new file mode 100644 index 000000000..72e84b875 --- /dev/null +++ b/test/packages/rust/src/generated/types/dummy_lines.rs @@ -0,0 +1,18 @@ +//! 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::ConfigLine; +use borsh::BorshDeserialize; +use borsh::BorshSerialize; +use kaigan::types::RemainderVec; + +/// Dummy lines. +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +pub struct DummyLines { + /// The dummy lines. + pub lines: RemainderVec, +} diff --git a/test/packages/rust/src/generated/types/helper/mod.rs b/test/packages/rust/src/generated/types/helper/mod.rs deleted file mode 100644 index 1cf7bfa8e..000000000 --- a/test/packages/rust/src/generated/types/helper/mod.rs +++ /dev/null @@ -1,96 +0,0 @@ -//! This code was AUTOGENERATED using the kinobi library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun kinobi to update it. -//! -//! [https://github.com/metaplex-foundation/kinobi] -//! - -use std::fmt::Debug; -use std::io::Write; -use std::ops::{Deref, DerefMut}; - -use borsh::maybestd::io::Read; -use borsh::{BorshDeserialize, BorshSerialize}; - -/// A vector that deserializes from a stream of bytes. -/// -/// This is useful for deserializing a vector that does not have -/// a length prefix. In order to determine how many elements to deserialize, -/// the type of the elements must implement the trait `Sized`. -pub struct RemainderVec(Vec); - -/// Deferences the inner `Vec` type. -impl Deref for RemainderVec -where - T: BorshSerialize + BorshDeserialize, -{ - type Target = Vec; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -/// Deferences the inner `Vec` type as mutable. -impl DerefMut for RemainderVec -where - T: BorshSerialize + BorshDeserialize, -{ - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - -/// `Debug` implementation for `RemainderVec`. -/// -/// This implementation simply forwards to the inner `Vec` type. -impl Debug for RemainderVec -where - T: BorshSerialize + BorshDeserialize + Debug, -{ - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_fmt(format_args!("{:?}", self.0)) - } -} - -impl BorshDeserialize for RemainderVec -where - T: BorshSerialize + BorshDeserialize, -{ - fn deserialize_reader(reader: &mut R) -> borsh::maybestd::io::Result { - let length = std::mem::size_of::(); - // buffer to read the data - let mut buffer = vec![0u8; length]; - // vec to store the items - let mut items: Vec = Vec::new(); - - loop { - match reader.read(&mut buffer)? { - 0 => break, - n if n == length => items.push(T::deserialize(&mut buffer.as_slice())?), - e => { - return Err(borsh::maybestd::io::Error::new( - borsh::maybestd::io::ErrorKind::InvalidData, - format!("unexpected number of bytes (read {e}, expected {length})"), - )) - } - } - } - - Ok(Self(items)) - } -} - -impl BorshSerialize for RemainderVec -where - T: BorshSerialize + BorshDeserialize, -{ - fn serialize(&self, writer: &mut W) -> borsh::maybestd::io::Result<()> { - // serialize each item without adding a prefix for the length - for item in self.0.iter() { - item.serialize(writer)?; - } - - Ok(()) - } -} diff --git a/test/packages/rust/src/generated/types/hidden_settings.rs b/test/packages/rust/src/generated/types/hidden_settings.rs index 6c53a8194..ce6f51667 100644 --- a/test/packages/rust/src/generated/types/hidden_settings.rs +++ b/test/packages/rust/src/generated/types/hidden_settings.rs @@ -9,7 +9,6 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; /// Hidden settings for large mints used with off-chain data. - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] pub struct HiddenSettings { /// Asset prefix name diff --git a/test/packages/rust/src/generated/types/mod.rs b/test/packages/rust/src/generated/types/mod.rs index 5d5d65778..b0b5813d1 100644 --- a/test/packages/rust/src/generated/types/mod.rs +++ b/test/packages/rust/src/generated/types/mod.rs @@ -5,90 +5,92 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -mod asset_data; -mod authority_type; -mod authorization_data; -mod burn_args; -mod candy_machine_data; -mod cm_creator; -mod collection; -mod collection_details; -mod config_line; -mod config_line_settings; -mod create_master_edition_args; -mod creator; -mod data_v2; -mod delegate_args; -mod delegate_role; -mod delegate_state; -mod escrow_authority; -mod extended_payload; -mod hidden_settings; -mod migrate_args; -mod mint_args; -mod mint_new_edition_from_master_edition_via_token_args; -mod mint_printing_tokens_via_token_args; -mod operation; -mod payload; -mod payload_key; -mod payload_type; -mod programmable_config; -mod reservation; -mod reservation_v1; -mod revoke_args; -mod set_collection_size_args; -mod ta_create_args; -mod ta_key; -mod tm_create_args; -mod tm_key; -mod token_standard; -mod transfer_args; -mod update_args; -mod use_asset_args; -mod use_method; -mod uses; -mod verify_args; +pub mod asset_data; +pub mod authority_type; +pub mod authorization_data; +pub mod burn_args; +pub mod candy_machine_data; +pub mod cm_creator; +pub mod collection; +pub mod collection_details; +pub mod config_line; +pub mod config_line_settings; +pub mod create_master_edition_args; +pub mod creator; +pub mod data_v2; +pub mod delegate_args; +pub mod delegate_role; +pub mod delegate_state; +pub mod dummy_lines; +pub mod escrow_authority; +pub mod extended_payload; +pub mod hidden_settings; +pub mod migrate_args; +pub mod mint_args; +pub mod mint_new_edition_from_master_edition_via_token_args; +pub mod mint_printing_tokens_via_token_args; +pub mod operation; +pub mod payload; +pub mod payload_key; +pub mod payload_type; +pub mod programmable_config; +pub mod reservation; +pub mod reservation_v1; +pub mod revoke_args; +pub mod set_collection_size_args; +pub mod ta_create_args; +pub mod ta_key; +pub mod tm_create_args; +pub mod tm_key; +pub mod token_standard; +pub mod transfer_args; +pub mod update_args; +pub mod use_asset_args; +pub mod use_method; +pub mod uses; +pub mod verify_args; -pub use asset_data::*; -pub use authority_type::*; -pub use authorization_data::*; -pub use burn_args::*; -pub use candy_machine_data::*; -pub use cm_creator::*; -pub use collection::*; -pub use collection_details::*; -pub use config_line::*; -pub use config_line_settings::*; -pub use create_master_edition_args::*; -pub use creator::*; -pub use data_v2::*; -pub use delegate_args::*; -pub use delegate_role::*; -pub use delegate_state::*; -pub use escrow_authority::*; -pub use extended_payload::*; -pub use hidden_settings::*; -pub use migrate_args::*; -pub use mint_args::*; -pub use mint_new_edition_from_master_edition_via_token_args::*; -pub use mint_printing_tokens_via_token_args::*; -pub use operation::*; -pub use payload::*; -pub use payload_key::*; -pub use payload_type::*; -pub use programmable_config::*; -pub use reservation::*; -pub use reservation_v1::*; -pub use revoke_args::*; -pub use set_collection_size_args::*; -pub use ta_create_args::*; -pub use ta_key::*; -pub use tm_create_args::*; -pub use tm_key::*; -pub use token_standard::*; -pub use transfer_args::*; -pub use update_args::*; -pub use use_asset_args::*; -pub use use_method::*; -pub use uses::*; -pub use verify_args::*; +pub use self::asset_data::*; +pub use self::authority_type::*; +pub use self::authorization_data::*; +pub use self::burn_args::*; +pub use self::candy_machine_data::*; +pub use self::cm_creator::*; +pub use self::collection::*; +pub use self::collection_details::*; +pub use self::config_line::*; +pub use self::config_line_settings::*; +pub use self::create_master_edition_args::*; +pub use self::creator::*; +pub use self::data_v2::*; +pub use self::delegate_args::*; +pub use self::delegate_role::*; +pub use self::delegate_state::*; +pub use self::dummy_lines::*; +pub use self::escrow_authority::*; +pub use self::extended_payload::*; +pub use self::hidden_settings::*; +pub use self::migrate_args::*; +pub use self::mint_args::*; +pub use self::mint_new_edition_from_master_edition_via_token_args::*; +pub use self::mint_printing_tokens_via_token_args::*; +pub use self::operation::*; +pub use self::payload::*; +pub use self::payload_key::*; +pub use self::payload_type::*; +pub use self::programmable_config::*; +pub use self::reservation::*; +pub use self::reservation_v1::*; +pub use self::revoke_args::*; +pub use self::set_collection_size_args::*; +pub use self::ta_create_args::*; +pub use self::ta_key::*; +pub use self::tm_create_args::*; +pub use self::tm_key::*; +pub use self::token_standard::*; +pub use self::transfer_args::*; +pub use self::update_args::*; +pub use self::use_asset_args::*; +pub use self::use_method::*; +pub use self::uses::*; +pub use self::verify_args::*; diff --git a/test/packages/rust/src/generated/types/payload_type.rs b/test/packages/rust/src/generated/types/payload_type.rs index c23fcda10..17ac75ff5 100644 --- a/test/packages/rust/src/generated/types/payload_type.rs +++ b/test/packages/rust/src/generated/types/payload_type.rs @@ -10,7 +10,6 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; /// This is a union of all the possible payload types. - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] pub enum PayloadType { Pubkey(Pubkey), diff --git a/test/packages/rust/src/generated/types/reservation_list_v1_account_data.rs b/test/packages/rust/src/generated/types/reservation_list_v1_account_data.rs index 109750710..d6e2855c3 100644 --- a/test/packages/rust/src/generated/types/reservation_list_v1_account_data.rs +++ b/test/packages/rust/src/generated/types/reservation_list_v1_account_data.rs @@ -11,7 +11,6 @@ use crate::generated::types::ReservationV1; use borsh::BorshSerialize; use borsh::BorshDeserialize; - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] pub struct ReservationListV1AccountData { pub key: TmKey, @@ -20,3 +19,4 @@ pub supply_snapshot: Option, pub reservations: Vec, } +