diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index db681182..14c97ee0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,7 @@ env: RUST_PACKAGES: "['clients-rust', 'interface', 'program']" SBPF_PROGRAM_PACKAGES: "['program']" WASM_PACKAGES: "['interface', 'program']" + IDL_PACKAGES: "['interface']" jobs: set_env: @@ -20,6 +21,7 @@ jobs: SBPF_PROGRAM_PACKAGES: ${{ steps.compute.outputs.SBPF_PROGRAM_PACKAGES }} RUST_PACKAGES: ${{ steps.compute.outputs.RUST_PACKAGES }} WASM_PACKAGES: ${{ steps.compute.outputs.WASM_PACKAGES }} + IDL_PACKAGES: ${{ steps.compute.outputs.IDL_PACKAGES }} RUST_TOOLCHAIN_NIGHTLY: ${{ steps.compute.outputs.RUST_TOOLCHAIN_NIGHTLY }} SOLANA_CLI_VERSION: ${{ steps.compute.outputs.SOLANA_CLI_VERSION }} steps: @@ -34,6 +36,7 @@ jobs: echo "SBPF_PROGRAM_PACKAGES=${{ env.SBPF_PROGRAM_PACKAGES }}" >> $GITHUB_OUTPUT echo "RUST_PACKAGES=${{ env.RUST_PACKAGES }}" >> $GITHUB_OUTPUT echo "WASM_PACKAGES=${{ env.WASM_PACKAGES }}" >> $GITHUB_OUTPUT + echo "IDL_PACKAGES=${{ env.IDL_PACKAGES }}" >> $GITHUB_OUTPUT echo "RUST_TOOLCHAIN_NIGHTLY=$(make rust-toolchain-nightly)" >> "$GITHUB_OUTPUT" echo "SOLANA_CLI_VERSION=$(make solana-cli-version)" >> "$GITHUB_OUTPUT" @@ -45,6 +48,7 @@ jobs: sbpf-program-packages: ${{ needs.set_env.outputs.SBPF_PROGRAM_PACKAGES }} rust-packages: ${{ needs.set_env.outputs.RUST_PACKAGES }} wasm-packages: ${{ needs.set_env.outputs.WASM_PACKAGES }} + idl-packages: ${{ needs.set_env.outputs.IDL_PACKAGES }} wasm-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }} rustfmt-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }} clippy-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }} diff --git a/Cargo.lock b/Cargo.lock index 80310871..d3ec163c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,10 +60,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be80c9787c7f30819e2999987cc6208c1ec6f775d7ed2b70f61a00a6e8acc0c8" dependencies = [ "ahash 0.8.11", - "solana-epoch-schedule 3.0.0", + "solana-epoch-schedule", "solana-hash 3.1.0", - "solana-pubkey 3.0.0", - "solana-sha256-hasher 3.0.0", + "solana-pubkey", + "solana-sha256-hasher", "solana-svm-feature-set", ] @@ -94,10 +94,10 @@ dependencies = [ "openssl", "sha3", "solana-ed25519-program", - "solana-message 3.0.0", + "solana-message", "solana-precompile-error", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-sdk-ids", "solana-secp256k1-program", "solana-secp256r1-program", ] @@ -109,8 +109,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efb2704410f79989956488f49d6f48fcc4f66e2e6c11d8b5f40e0e01bfbd6b91" dependencies = [ "agave-feature-set", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-sdk-ids", ] [[package]] @@ -122,27 +122,27 @@ dependencies = [ "bincode", "libsecp256k1", "num-traits", - "solana-account 3.2.0", - "solana-account-info 3.0.0", - "solana-big-mod-exp 3.0.0", - "solana-blake3-hasher 3.0.0", + "solana-account", + "solana-account-info", + "solana-big-mod-exp", + "solana-blake3-hasher", "solana-bn254", - "solana-clock 3.0.0", - "solana-cpi 3.0.0", + "solana-clock", + "solana-cpi", "solana-curve25519", "solana-hash 3.1.0", - "solana-instruction 3.0.0", - "solana-keccak-hasher 3.0.0", - "solana-loader-v3-interface 6.1.0", + "solana-instruction", + "solana-keccak-hasher", + "solana-loader-v3-interface", "solana-poseidon", - "solana-program-entrypoint 3.1.0", + "solana-program-entrypoint", "solana-program-runtime", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-sbpf", - "solana-sdk-ids 3.0.0", - "solana-secp256k1-recover 3.0.0", - "solana-sha256-hasher 3.0.0", - "solana-stable-layout 3.0.0", + "solana-sdk-ids", + "solana-secp256k1-recover", + "solana-sha256-hasher", + "solana-stable-layout", "solana-stake-interface 2.0.1", "solana-svm-callback", "solana-svm-feature-set", @@ -150,8 +150,8 @@ dependencies = [ "solana-svm-measure", "solana-svm-timings", "solana-svm-type-overrides", - "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sysvar", + "solana-sysvar-id", "solana-transaction-context", "thiserror 2.0.17", ] @@ -163,11 +163,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d04daeab9de8d1098156d2a73ec5e8dd019b628884c201e5af3f1e8baeffd1b0" dependencies = [ "solana-hash 3.1.0", - "solana-message 3.0.0", + "solana-message", "solana-packet", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-short-vec 3.0.0", + "solana-pubkey", + "solana-sdk-ids", + "solana-short-vec", "solana-signature", "solana-svm-transaction", ] @@ -672,39 +672,16 @@ dependencies = [ "generic-array", ] -[[package]] -name = "borsh" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115e54d64eb62cdebad391c19efc9dce4981c690c85a33a12199d99bb9546fee" -dependencies = [ - "borsh-derive 0.10.4", - "hashbrown 0.13.2", -] - [[package]] name = "borsh" version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce" dependencies = [ - "borsh-derive 1.5.7", + "borsh-derive", "cfg_aliases", ] -[[package]] -name = "borsh-derive" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831213f80d9423998dd696e2c5345aba6be7a0bd8cd19e31c5243e13df1cef89" -dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn 1.0.109", -] - [[package]] name = "borsh-derive" version = "1.5.7" @@ -712,34 +689,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3" dependencies = [ "once_cell", - "proc-macro-crate 3.2.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.98", ] -[[package]] -name = "borsh-derive-internal" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d6ba50644c98714aa2a70d13d7df3cd75cd2b523a2b452bf010443800976b3" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276691d96f063427be83e6692b86148e488ebba9f48f77788724ca027ba3b6d4" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "boxcar" version = "0.2.13" @@ -858,6 +813,16 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "cargo_toml" +version = "0.20.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88da5a13c620b4ca0078845707ea9c3faf11edbc3ffd8497d11d686211cd1ac0" +dependencies = [ + "serde", + "toml", +] + [[package]] name = "cc" version = "1.2.13" @@ -930,6 +895,160 @@ dependencies = [ "inout", ] +[[package]] +name = "codama" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38d4539ffa72fa0aa0bda4991d0daced19765d6a8fa1c14d9b5a725b240339a" +dependencies = [ + "codama-errors", + "codama-korok-plugins", + "codama-korok-visitors", + "codama-koroks", + "codama-macros", + "codama-nodes", + "codama-stores", + "proc-macro2", +] + +[[package]] +name = "codama-attributes" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0894101e7163dd7510afd9703dc0f9aa86f25aa99bd8e74ae6dc0730545cabc3" +dependencies = [ + "codama-errors", + "codama-nodes", + "codama-syn-helpers", + "derive_more", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "codama-errors" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96011c6fc3cb7886b45e598102f38a7784537650267b200452e4466cf7e6a62c" +dependencies = [ + "cargo_toml", + "proc-macro2", + "serde_json", + "syn 2.0.98", + "thiserror 2.0.17", +] + +[[package]] +name = "codama-korok-plugins" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fa24cc9925ad3c003279e71c755fe67259e2320b663a9744e466744ed428b5e" +dependencies = [ + "codama-errors", + "codama-korok-visitors", + "codama-koroks", +] + +[[package]] +name = "codama-korok-visitors" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31ea4e39e9034b2366b66b6f1e8fcd346bfa20263d99c9ae495e4063de41b932" +dependencies = [ + "cargo_toml", + "codama-attributes", + "codama-errors", + "codama-koroks", + "codama-nodes", + "codama-syn-helpers", + "serde_json", + "syn 2.0.98", +] + +[[package]] +name = "codama-koroks" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70b0cfebacf52d93889def37547dbd8907a69ce709605909b31ecd65f62f7ced" +dependencies = [ + "codama-attributes", + "codama-errors", + "codama-nodes", + "codama-stores", + "codama-syn-helpers", + "derive_more", + "proc-macro2", + "syn 2.0.98", +] + +[[package]] +name = "codama-macros" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0e04ddfb9305b43e6c196c555ca6086ed8ea822ed28c2626779f8c48a92d63" +dependencies = [ + "codama-attributes", + "codama-errors", + "codama-koroks", + "codama-stores", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "codama-nodes" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d36390bf96aac5ac885897ae17c5ae83f0de335cf4b79fcf8d9f0c60fc4308" +dependencies = [ + "codama-errors", + "codama-nodes-derive", + "derive_more", + "serde", + "serde_json", +] + +[[package]] +name = "codama-nodes-derive" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a190e56519e03786b59545ce04e1354d166fc24dd45085269b357d71a43c51f1" +dependencies = [ + "codama-errors", + "codama-syn-helpers", + "derive_more", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "codama-stores" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "566a3d466aa3548d5bd67ecd3bbf5efbd5920d1eb5cbc19129c9639c8ccd12fd" +dependencies = [ + "cargo_toml", + "codama-errors", + "proc-macro2", + "syn 2.0.98", +] + +[[package]] +name = "codama-syn-helpers" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d99b22a6395a0da3728e049da5d13e22f9897ad085170d8116f69327ea064" +dependencies = [ + "codama-errors", + "derive_more", + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "colorchoice" version = "1.0.4" @@ -981,26 +1100,6 @@ dependencies = [ "windows-sys 0.61.1", ] -[[package]] -name = "console_error_panic_hook" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" -dependencies = [ - "cfg-if", - "wasm-bindgen", -] - -[[package]] -name = "console_log" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89f72f65e8501878b8a004d5a1afb780987e2ce2b4532c562e367a72c57499f" -dependencies = [ - "log", - "web-sys", -] - [[package]] name = "const-oid" version = "0.9.6" @@ -1289,6 +1388,26 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "difflib" version = "0.4.0" @@ -2829,34 +2948,34 @@ dependencies = [ "mollusk-svm-error", "mollusk-svm-keys", "mollusk-svm-result", - "solana-account 3.2.0", + "solana-account", "solana-bpf-loader-program", - "solana-clock 3.0.0", + "solana-clock", "solana-compute-budget", - "solana-epoch-rewards 3.0.0", - "solana-epoch-schedule 3.0.0", + "solana-epoch-rewards", + "solana-epoch-schedule", "solana-hash 3.1.0", - "solana-instruction 3.0.0", + "solana-instruction", "solana-instruction-error", - "solana-loader-v3-interface 6.1.0", - "solana-loader-v4-interface 3.1.0", + "solana-loader-v3-interface", + "solana-loader-v4-interface", "solana-loader-v4-program", "solana-logger", "solana-precompile-error", - "solana-program-error 3.0.0", + "solana-program-error", "solana-program-runtime", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-slot-hashes 3.0.0", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-slot-hashes", "solana-stake-interface 2.0.1", "solana-stake-program 3.0.10", "solana-svm-callback", "solana-svm-log-collector", "solana-svm-timings", "solana-system-program", - "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sysvar", + "solana-sysvar-id", "solana-transaction-context", ] @@ -2866,7 +2985,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea155b60511338a5a39c077a457baa8268c229629f091e3281f499b0ab3a96b4" dependencies = [ - "solana-pubkey 3.0.0", + "solana-pubkey", "thiserror 1.0.69", ] @@ -2877,9 +2996,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7849281d0ce4f3894742cf508a98b33c3bb284eb7df9d66476ab2168945f128" dependencies = [ "mollusk-svm-error", - "solana-account 3.2.0", - "solana-instruction 3.0.0", - "solana-pubkey 3.0.0", + "solana-account", + "solana-instruction", + "solana-pubkey", "solana-transaction-context", ] @@ -2889,11 +3008,11 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f50b90812979ca5bb440f0a86e970355853d0e9466b939f88ad30af188e20525" dependencies = [ - "solana-account 3.2.0", - "solana-instruction 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", + "solana-account", + "solana-instruction", + "solana-program-error", + "solana-pubkey", + "solana-rent", ] [[package]] @@ -3066,7 +3185,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.98", @@ -3369,15 +3488,6 @@ dependencies = [ "termtree", ] -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml", -] - [[package]] name = "proc-macro-crate" version = "3.2.0" @@ -4200,6 +4310,15 @@ dependencies = [ "serde_core", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -4417,19 +4536,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "solana-account" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f949fe4edaeaea78c844023bfc1c898e0b1f5a100f8a8d2d0f85d0a7b090258" -dependencies = [ - "solana-account-info 2.2.1", - "solana-clock 2.2.2", - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", -] - [[package]] name = "solana-account" version = "3.2.0" @@ -4441,12 +4547,12 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-account-info 3.0.0", - "solana-clock 3.0.0", + "solana-account-info", + "solana-clock", "solana-instruction-error", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-sysvar 3.0.0", + "solana-pubkey", + "solana-sdk-ids", + "solana-sysvar", ] [[package]] @@ -4460,24 +4566,11 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "solana-account 3.2.0", - "solana-pubkey 3.0.0", + "solana-account", + "solana-pubkey", "zstd", ] -[[package]] -name = "solana-account-info" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c17d606a298a205fae325489fbed88ee6dc4463c111672172327e741c8905d" -dependencies = [ - "bincode", - "serde", - "solana-program-error 2.2.1", - "solana-program-memory 2.2.1", - "solana-pubkey 2.4.0", -] - [[package]] name = "solana-account-info" version = "3.0.0" @@ -4486,9 +4579,9 @@ checksum = "82f4691b69b172c687d218dd2f1f23fc7ea5e9aa79df9ac26dab3d8dd829ce48" dependencies = [ "bincode", "serde", - "solana-program-error 3.0.0", - "solana-program-memory 3.0.0", - "solana-pubkey 3.0.0", + "solana-program-error", + "solana-program-memory", + "solana-pubkey", ] [[package]] @@ -4524,31 +4617,31 @@ dependencies = [ "serde_derive", "slab", "smallvec", - "solana-account 3.2.0", - "solana-address-lookup-table-interface 3.0.0", + "solana-account", + "solana-address-lookup-table-interface", "solana-bucket-map", - "solana-clock 3.0.0", - "solana-epoch-schedule 3.0.0", - "solana-fee-calculator 3.0.0", + "solana-clock", + "solana-epoch-schedule", + "solana-fee-calculator", "solana-genesis-config", "solana-hash 3.1.0", "solana-lattice-hash", "solana-measure", - "solana-message 3.0.0", + "solana-message", "solana-metrics", "solana-nohash-hasher", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-rayon-threadlimit", "solana-reward-info", - "solana-sha256-hasher 3.0.0", - "solana-slot-hashes 3.0.0", + "solana-sha256-hasher", + "solana-slot-hashes", "solana-svm-transaction", - "solana-system-interface 2.0.0", - "solana-sysvar 3.0.0", + "solana-system-interface", + "solana-sysvar", "solana-time-utils", "solana-transaction", "solana-transaction-context", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "spl-generic-token", "static_assertions", "tar", @@ -4562,7 +4655,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a7a457086457ea9db9a5199d719dc8734dc2d0342fad0d8f77633c31eb62f19" dependencies = [ - "borsh 1.5.7", + "borsh", "bytemuck", "bytemuck_derive", "curve25519-dalek 4.1.3", @@ -4571,30 +4664,13 @@ dependencies = [ "rand 0.8.5", "serde", "serde_derive", - "solana-atomic-u64 3.0.0", - "solana-define-syscall 3.0.0", + "solana-atomic-u64", + "solana-define-syscall", "solana-frozen-abi", "solana-frozen-abi-macro", - "solana-program-error 3.0.0", - "solana-sanitize 3.0.0", - "solana-sha256-hasher 3.0.0", -] - -[[package]] -name = "solana-address-lookup-table-interface" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1673f67efe870b64a65cb39e6194be5b26527691ce5922909939961a6e6b395" -dependencies = [ - "bincode", - "bytemuck", - "serde", - "serde_derive", - "solana-clock 2.2.2", - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", - "solana-slot-hashes 2.2.1", + "solana-program-error", + "solana-sanitize", + "solana-sha256-hasher", ] [[package]] @@ -4607,21 +4683,12 @@ dependencies = [ "bytemuck", "serde", "serde_derive", - "solana-clock 3.0.0", - "solana-instruction 3.0.0", + "solana-clock", + "solana-instruction", "solana-instruction-error", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-slot-hashes 3.0.0", -] - -[[package]] -name = "solana-atomic-u64" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52e52720efe60465b052b9e7445a01c17550666beec855cce66f44766697bc2" -dependencies = [ - "parking_lot", + "solana-pubkey", + "solana-sdk-ids", + "solana-slot-hashes", ] [[package]] @@ -4639,22 +4706,22 @@ version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac0c8780d1c4216925f72d28d809b172ab83466b687e8110154f39066e228c3d" dependencies = [ - "borsh 1.5.7", + "borsh", "futures", - "solana-account 3.2.0", + "solana-account", "solana-banks-interface", - "solana-clock 3.0.0", + "solana-clock", "solana-commitment-config", "solana-hash 3.1.0", - "solana-message 3.0.0", - "solana-program-pack 3.0.0", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", + "solana-message", + "solana-program-pack", + "solana-pubkey", + "solana-rent", "solana-signature", - "solana-sysvar 3.0.0", + "solana-sysvar", "solana-transaction", "solana-transaction-context", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "tarpc", "thiserror 2.0.17", "tokio", @@ -4669,16 +4736,16 @@ checksum = "0114282a0c18cdca6beae1d5cd9c92be7b8a2140aa92e3f0a2536f86303b05d8" dependencies = [ "serde", "serde_derive", - "solana-account 3.2.0", - "solana-clock 3.0.0", + "solana-account", + "solana-clock", "solana-commitment-config", "solana-hash 3.1.0", - "solana-message 3.0.0", - "solana-pubkey 3.0.0", + "solana-message", + "solana-pubkey", "solana-signature", "solana-transaction", "solana-transaction-context", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "tarpc", ] @@ -4692,37 +4759,26 @@ dependencies = [ "bincode", "crossbeam-channel", "futures", - "solana-account 3.2.0", + "solana-account", "solana-banks-interface", "solana-client", - "solana-clock 3.0.0", + "solana-clock", "solana-commitment-config", "solana-hash 3.1.0", - "solana-message 3.0.0", - "solana-pubkey 3.0.0", + "solana-message", + "solana-pubkey", "solana-runtime", "solana-runtime-transaction", "solana-send-transaction-service", "solana-signature", "solana-svm", "solana-transaction", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "tarpc", "tokio", "tokio-serde", ] -[[package]] -name = "solana-big-mod-exp" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75db7f2bbac3e62cfd139065d15bcda9e2428883ba61fc8d27ccb251081e7567" -dependencies = [ - "num-bigint 0.4.6", - "num-traits", - "solana-define-syscall 2.3.0", -] - [[package]] name = "solana-big-mod-exp" version = "3.0.0" @@ -4731,18 +4787,7 @@ checksum = "30c80fb6d791b3925d5ec4bf23a7c169ef5090c013059ec3ed7d0b2c04efa085" dependencies = [ "num-bigint 0.4.6", "num-traits", - "solana-define-syscall 3.0.0", -] - -[[package]] -name = "solana-bincode" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19a3787b8cf9c9fe3dd360800e8b70982b9e5a8af9e11c354b6665dd4a003adc" -dependencies = [ - "bincode", - "serde", - "solana-instruction 2.3.0", + "solana-define-syscall", ] [[package]] @@ -4756,18 +4801,6 @@ dependencies = [ "solana-instruction-error", ] -[[package]] -name = "solana-blake3-hasher" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0801e25a1b31a14494fc80882a036be0ffd290efc4c2d640bfcca120a4672" -dependencies = [ - "blake3", - "solana-define-syscall 2.3.0", - "solana-hash 2.3.0", - "solana-sanitize 2.2.1", -] - [[package]] name = "solana-blake3-hasher" version = "3.0.0" @@ -4775,7 +4808,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffa2e3bdac3339c6d0423275e45dafc5ac25f4d43bf344d026a3cc9a85e244a6" dependencies = [ "blake3", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "solana-hash 3.1.0", ] @@ -4790,27 +4823,17 @@ dependencies = [ "ark-ff", "ark-serialize", "bytemuck", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "thiserror 2.0.17", ] -[[package]] -name = "solana-borsh" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718333bcd0a1a7aed6655aa66bef8d7fb047944922b2d3a18f49cbc13e73d004" -dependencies = [ - "borsh 0.10.4", - "borsh 1.5.7", -] - [[package]] name = "solana-borsh" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc402b16657abbfa9991cd5cbfac5a11d809f7e7d28d3bb291baeb088b39060e" dependencies = [ - "borsh 1.5.7", + "borsh", ] [[package]] @@ -4822,23 +4845,23 @@ dependencies = [ "agave-syscalls", "bincode", "qualifier_attr", - "solana-account 3.2.0", - "solana-bincode 3.0.0", - "solana-clock 3.0.0", - "solana-instruction 3.0.0", - "solana-loader-v3-interface 6.1.0", - "solana-loader-v4-interface 3.1.0", + "solana-account", + "solana-bincode", + "solana-clock", + "solana-instruction", + "solana-loader-v3-interface", + "solana-loader-v4-interface", "solana-packet", - "solana-program-entrypoint 3.1.0", + "solana-program-entrypoint", "solana-program-runtime", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-sbpf", - "solana-sdk-ids 3.0.0", + "solana-sdk-ids", "solana-svm-feature-set", "solana-svm-log-collector", "solana-svm-measure", "solana-svm-type-overrides", - "solana-system-interface 2.0.0", + "solana-system-interface", "solana-transaction-context", ] @@ -4855,9 +4878,9 @@ dependencies = [ "modular-bitfield", "num_enum", "rand 0.8.5", - "solana-clock 3.0.0", + "solana-clock", "solana-measure", - "solana-pubkey 3.0.0", + "solana-pubkey", "tempfile", ] @@ -4873,8 +4896,8 @@ dependencies = [ "solana-hash 3.1.0", "solana-loader-v4-program", "solana-program-runtime", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-sdk-ids", "solana-stake-program 3.0.10", "solana-system-program", "solana-vote-program", @@ -4894,8 +4917,8 @@ dependencies = [ "solana-bpf-loader-program", "solana-compute-budget-program", "solana-loader-v4-program", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-sdk-ids", "solana-stake-program 3.0.10", "solana-system-program", "solana-vote-program", @@ -4917,17 +4940,17 @@ dependencies = [ "log", "quinn", "rayon", - "solana-account 3.2.0", + "solana-account", "solana-client-traits", "solana-commitment-config", "solana-connection-cache", "solana-epoch-info", "solana-hash 3.1.0", - "solana-instruction 3.0.0", + "solana-instruction", "solana-keypair", "solana-measure", - "solana-message 3.0.0", - "solana-pubkey 3.0.0", + "solana-message", + "solana-pubkey", "solana-pubsub-client", "solana-quic-client", "solana-quic-definitions", @@ -4940,7 +4963,7 @@ dependencies = [ "solana-time-utils", "solana-tpu-client", "solana-transaction", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "solana-transaction-status-client-types", "solana-udp-client", "thiserror 2.0.17", @@ -4953,32 +4976,19 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08618ed587e128105510c54ae3e456b9a06d674d8640db75afe66dad65cb4e02" dependencies = [ - "solana-account 3.2.0", + "solana-account", "solana-commitment-config", "solana-epoch-info", "solana-hash 3.1.0", - "solana-instruction 3.0.0", + "solana-instruction", "solana-keypair", - "solana-message 3.0.0", - "solana-pubkey 3.0.0", + "solana-message", + "solana-pubkey", "solana-signature", "solana-signer", - "solana-system-interface 2.0.0", + "solana-system-interface", "solana-transaction", - "solana-transaction-error 3.0.0", -] - -[[package]] -name = "solana-clock" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bb482ab70fced82ad3d7d3d87be33d466a3498eb8aa856434ff3c0dfc2e2e31" -dependencies = [ - "serde", - "serde_derive", - "solana-sdk-ids 2.2.1", - "solana-sdk-macro 2.2.1", - "solana-sysvar-id 2.2.1", + "solana-transaction-error", ] [[package]] @@ -4989,9 +4999,9 @@ checksum = "fb62e9381182459a4520b5fe7fb22d423cae736239a6427fc398a88743d0ed59" dependencies = [ "serde", "serde_derive", - "solana-sdk-ids 3.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -5033,16 +5043,16 @@ checksum = "0ac29452169f23259fa6c60ff4be6dd389d45458256a1d74efa62e22cc169f05" dependencies = [ "agave-feature-set", "log", - "solana-borsh 3.0.0", + "solana-borsh", "solana-builtins-default-costs", "solana-compute-budget", "solana-compute-budget-interface", - "solana-instruction 3.0.0", + "solana-instruction", "solana-packet", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-sdk-ids", "solana-svm-transaction", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", ] @@ -5052,9 +5062,9 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8292c436b269ad23cecc8b24f7da3ab07ca111661e25e00ce0e1d22771951ab9" dependencies = [ - "borsh 1.5.7", - "solana-instruction 3.0.0", - "solana-sdk-ids 3.0.0", + "borsh", + "solana-instruction", + "solana-sdk-ids", ] [[package]] @@ -5075,12 +5085,12 @@ dependencies = [ "bincode", "serde", "serde_derive", - "solana-account 3.2.0", - "solana-instruction 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-short-vec 3.0.0", - "solana-system-interface 2.0.0", + "solana-account", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", + "solana-short-vec", + "solana-system-interface", ] [[package]] @@ -5101,7 +5111,7 @@ dependencies = [ "solana-measure", "solana-metrics", "solana-time-utils", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", "tokio", ] @@ -5115,51 +5125,37 @@ dependencies = [ "agave-feature-set", "ahash 0.8.11", "log", - "solana-bincode 3.0.0", - "solana-borsh 3.0.0", + "solana-bincode", + "solana-borsh", "solana-builtins-default-costs", - "solana-clock 3.0.0", + "solana-clock", "solana-compute-budget", "solana-compute-budget-instruction", "solana-compute-budget-interface", "solana-fee-structure", "solana-metrics", "solana-packet", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-runtime-transaction", - "solana-sdk-ids 3.0.0", + "solana-sdk-ids", "solana-svm-transaction", - "solana-system-interface 2.0.0", - "solana-transaction-error 3.0.0", + "solana-system-interface", + "solana-transaction-error", "solana-vote-program", ] [[package]] name = "solana-cpi" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dc71126edddc2ba014622fc32d0f5e2e78ec6c5a1e0eb511b85618c09e9ea11" -dependencies = [ - "solana-account-info 2.2.1", - "solana-define-syscall 2.3.0", - "solana-instruction 2.3.0", - "solana-program-error 2.2.1", - "solana-pubkey 2.4.0", - "solana-stable-layout 2.2.1", -] - -[[package]] -name = "solana-cpi" -version = "3.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16238feb63d1cbdf915fb287f29ef7a7ebf81469bd6214f8b72a53866b593f8f" dependencies = [ - "solana-account-info 3.0.0", - "solana-define-syscall 3.0.0", - "solana-instruction 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", - "solana-stable-layout 3.0.0", + "solana-account-info", + "solana-define-syscall", + "solana-instruction", + "solana-program-error", + "solana-pubkey", + "solana-stable-layout", ] [[package]] @@ -5171,26 +5167,11 @@ dependencies = [ "bytemuck", "bytemuck_derive", "curve25519-dalek 4.1.3", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "subtle", "thiserror 2.0.17", ] -[[package]] -name = "solana-decode-error" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a6a6383af236708048f8bd8d03db8ca4ff7baf4a48e5d580f4cce545925470" -dependencies = [ - "num-traits", -] - -[[package]] -name = "solana-define-syscall" -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" @@ -5216,8 +5197,8 @@ checksum = "e1419197f1c06abf760043f6d64ba9d79a03ad5a43f18c7586471937122094da" dependencies = [ "bytemuck", "bytemuck_derive", - "solana-instruction 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-instruction", + "solana-sdk-ids", ] [[package]] @@ -5230,20 +5211,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "solana-epoch-rewards" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b575d3dd323b9ea10bb6fe89bf6bf93e249b215ba8ed7f68f1a3633f384db7" -dependencies = [ - "serde", - "serde_derive", - "solana-hash 2.3.0", - "solana-sdk-ids 2.2.1", - "solana-sdk-macro 2.2.1", - "solana-sysvar-id 2.2.1", -] - [[package]] name = "solana-epoch-rewards" version = "3.0.0" @@ -5253,9 +5220,9 @@ dependencies = [ "serde", "serde_derive", "solana-hash 3.1.0", - "solana-sdk-ids 3.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -5266,20 +5233,7 @@ checksum = "e507099d0c2c5d7870c9b1848281ea67bbeee80d171ca85003ee5767994c9c38" dependencies = [ "siphasher 0.3.11", "solana-hash 3.1.0", - "solana-pubkey 3.0.0", -] - -[[package]] -name = "solana-epoch-schedule" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fce071fbddecc55d727b1d7ed16a629afe4f6e4c217bc8d00af3b785f6f67ed" -dependencies = [ - "serde", - "serde_derive", - "solana-sdk-ids 2.2.1", - "solana-sdk-macro 2.2.1", - "solana-sysvar-id 2.2.1", + "solana-pubkey", ] [[package]] @@ -5290,30 +5244,9 @@ checksum = "6e5481e72cc4d52c169db73e4c0cd16de8bc943078aac587ec4817a75cc6388f" dependencies = [ "serde", "serde_derive", - "solana-sdk-ids 3.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.0", -] - -[[package]] -name = "solana-example-mocks" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84461d56cbb8bb8d539347151e0525b53910102e4bced875d49d5139708e39d3" -dependencies = [ - "serde", - "serde_derive", - "solana-address-lookup-table-interface 2.2.2", - "solana-clock 2.2.2", - "solana-hash 2.3.0", - "solana-instruction 2.3.0", - "solana-keccak-hasher 2.2.1", - "solana-message 2.4.0", - "solana-nonce 2.2.1", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", - "solana-system-interface 1.0.0", - "thiserror 2.0.17", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -5324,38 +5257,19 @@ checksum = "978855d164845c1b0235d4b4d101cadc55373fffaf0b5b6cfa2194d25b2ed658" dependencies = [ "serde", "serde_derive", - "solana-address-lookup-table-interface 3.0.0", - "solana-clock 3.0.0", + "solana-address-lookup-table-interface", + "solana-clock", "solana-hash 3.1.0", - "solana-instruction 3.0.0", - "solana-keccak-hasher 3.0.0", - "solana-message 3.0.0", - "solana-nonce 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-system-interface 2.0.0", + "solana-instruction", + "solana-keccak-hasher", + "solana-message", + "solana-nonce", + "solana-pubkey", + "solana-sdk-ids", + "solana-system-interface", "thiserror 2.0.17", ] -[[package]] -name = "solana-feature-gate-interface" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f5c5382b449e8e4e3016fb05e418c53d57782d8b5c30aa372fc265654b956d" -dependencies = [ - "bincode", - "serde", - "serde_derive", - "solana-account 2.2.1", - "solana-account-info 2.2.1", - "solana-instruction 2.3.0", - "solana-program-error 2.2.1", - "solana-pubkey 2.4.0", - "solana-rent 2.2.1", - "solana-sdk-ids 2.2.1", - "solana-system-interface 1.0.0", -] - [[package]] name = "solana-feature-gate-interface" version = "3.0.0" @@ -5365,14 +5279,14 @@ dependencies = [ "bincode", "serde", "serde_derive", - "solana-account 3.2.0", - "solana-account-info 3.0.0", - "solana-instruction 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-system-interface 2.0.0", + "solana-account", + "solana-account-info", + "solana-instruction", + "solana-program-error", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-system-interface", ] [[package]] @@ -5386,17 +5300,6 @@ dependencies = [ "solana-svm-transaction", ] -[[package]] -name = "solana-fee-calculator" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89bc408da0fb3812bc3008189d148b4d3e08252c79ad810b245482a3f70cd8d" -dependencies = [ - "log", - "serde", - "serde_derive", -] - [[package]] name = "solana-fee-calculator" version = "3.0.0" @@ -5462,19 +5365,19 @@ dependencies = [ "memmap2 0.5.10", "serde", "serde_derive", - "solana-account 3.2.0", - "solana-clock 3.0.0", + "solana-account", + "solana-clock", "solana-cluster-type", - "solana-epoch-schedule 3.0.0", - "solana-fee-calculator 3.0.0", + "solana-epoch-schedule", + "solana-fee-calculator", "solana-hash 3.1.0", "solana-inflation", "solana-keypair", "solana-poh-config", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-sha256-hasher 3.0.0", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-sha256-hasher", "solana-shred-version", "solana-signer", "solana-time-utils", @@ -5490,24 +5393,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "solana-hash" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b96e9f0300fa287b545613f007dfe20043d7812bee255f418c1eb649c93b63" -dependencies = [ - "borsh 1.5.7", - "bytemuck", - "bytemuck_derive", - "five8 0.2.1", - "js-sys", - "serde", - "serde_derive", - "solana-atomic-u64 2.2.1", - "solana-sanitize 2.2.1", - "wasm-bindgen", -] - [[package]] name = "solana-hash" version = "3.1.0" @@ -5523,14 +5408,14 @@ version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a5d48a6ee7b91fc7b998944ab026ed7b3e2fc8ee3bc58452644a86c2648152f" dependencies = [ - "borsh 1.5.7", + "borsh", "bytemuck", "bytemuck_derive", "five8 1.0.0", "serde", "serde_derive", - "solana-atomic-u64 3.0.0", - "solana-sanitize 3.0.0", + "solana-atomic-u64", + "solana-sanitize", ] [[package]] @@ -5543,24 +5428,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "solana-instruction" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47298e2ce82876b64f71e9d13a46bc4b9056194e7f9937ad3084385befa50885" -dependencies = [ - "bincode", - "borsh 1.5.7", - "getrandom 0.2.15", - "js-sys", - "num-traits", - "serde", - "serde_derive", - "solana-define-syscall 2.3.0", - "solana-pubkey 2.4.0", - "wasm-bindgen", -] - [[package]] name = "solana-instruction" version = "3.0.0" @@ -5568,14 +5435,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8df4e8fcba01d7efa647ed20a081c234475df5e11a93acb4393cc2c9a7b99bab" dependencies = [ "bincode", - "borsh 1.5.7", + "borsh", "serde", "serde_derive", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-instruction-error", - "solana-pubkey 3.0.0", + "solana-pubkey", ] [[package]] @@ -5587,24 +5454,7 @@ dependencies = [ "num-traits", "serde", "serde_derive", - "solana-program-error 3.0.0", -] - -[[package]] -name = "solana-instructions-sysvar" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0e85a6fad5c2d0c4f5b91d34b8ca47118fc593af706e523cdbedf846a954f57" -dependencies = [ - "bitflags", - "solana-account-info 2.2.1", - "solana-instruction 2.3.0", - "solana-program-error 2.2.1", - "solana-pubkey 2.4.0", - "solana-sanitize 2.2.1", - "solana-sdk-ids 2.2.1", - "solana-serialize-utils 2.2.1", - "solana-sysvar-id 2.2.1", + "solana-program-error", ] [[package]] @@ -5614,27 +5464,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ddf67876c541aa1e21ee1acae35c95c6fbc61119814bfef70579317a5e26955" dependencies = [ "bitflags", - "solana-account-info 3.0.0", - "solana-instruction 3.0.0", + "solana-account-info", + "solana-instruction", "solana-instruction-error", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", - "solana-sanitize 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-serialize-utils 3.1.0", - "solana-sysvar-id 3.0.0", -] - -[[package]] -name = "solana-keccak-hasher" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7aeb957fbd42a451b99235df4942d96db7ef678e8d5061ef34c9b34cae12f79" -dependencies = [ - "sha3", - "solana-define-syscall 2.3.0", - "solana-hash 2.3.0", - "solana-sanitize 2.2.1", + "solana-program-error", + "solana-pubkey", + "solana-sanitize", + "solana-sdk-ids", + "solana-serialize-utils", + "solana-sysvar-id", ] [[package]] @@ -5644,7 +5482,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57eebd3012946913c8c1b8b43cdf8a6249edb09c0b6be3604ae910332a3acd97" dependencies = [ "sha3", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "solana-hash 3.1.0", ] @@ -5659,26 +5497,13 @@ dependencies = [ "five8 0.2.1", "rand 0.8.5", "solana-derivation-path", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-seed-derivable", "solana-seed-phrase", "solana-signature", "solana-signer", ] -[[package]] -name = "solana-last-restart-slot" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6360ac2fdc72e7463565cd256eedcf10d7ef0c28a1249d261ec168c1b55cdd" -dependencies = [ - "serde", - "serde_derive", - "solana-sdk-ids 2.2.1", - "solana-sdk-macro 2.2.1", - "solana-sysvar-id 2.2.1", -] - [[package]] name = "solana-last-restart-slot" version = "3.0.0" @@ -5687,9 +5512,9 @@ checksum = "dcda154ec827f5fc1e4da0af3417951b7e9b8157540f81f936c4a8b1156134d0" dependencies = [ "serde", "serde_derive", - "solana-sdk-ids 3.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -5704,35 +5529,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "solana-loader-v2-interface" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8ab08006dad78ae7cd30df8eea0539e207d08d91eaefb3e1d49a446e1c49654" -dependencies = [ - "serde", - "serde_bytes", - "serde_derive", - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", -] - -[[package]] -name = "solana-loader-v3-interface" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4be76cfa9afd84ca2f35ebc09f0da0f0092935ccdac0595d98447f259538c2" -dependencies = [ - "serde", - "serde_bytes", - "serde_derive", - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", - "solana-system-interface 1.0.0", -] - [[package]] name = "solana-loader-v3-interface" version = "6.1.0" @@ -5742,25 +5538,10 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-instruction 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-system-interface 2.0.0", -] - -[[package]] -name = "solana-loader-v4-interface" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "706a777242f1f39a83e2a96a2a6cb034cb41169c6ecbee2cf09cb873d9659e7e" -dependencies = [ - "serde", - "serde_bytes", - "serde_derive", - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", - "solana-system-interface 1.0.0", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", + "solana-system-interface", ] [[package]] @@ -5772,10 +5553,10 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-instruction 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-system-interface 2.0.0", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", + "solana-system-interface", ] [[package]] @@ -5786,17 +5567,17 @@ checksum = "4b4ce5ca27d4b16be527583738bac230fa0e62867e6c8b4bd6345cf09a3c941c" dependencies = [ "log", "qualifier_attr", - "solana-account 3.2.0", - "solana-bincode 3.0.0", + "solana-account", + "solana-bincode", "solana-bpf-loader-program", - "solana-instruction 3.0.0", - "solana-loader-v3-interface 6.1.0", - "solana-loader-v4-interface 3.1.0", + "solana-instruction", + "solana-loader-v3-interface", + "solana-loader-v4-interface", "solana-packet", "solana-program-runtime", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-sbpf", - "solana-sdk-ids 3.0.0", + "solana-sdk-ids", "solana-svm-log-collector", "solana-svm-measure", "solana-svm-type-overrides", @@ -5822,29 +5603,6 @@ version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec1c31d6a2213afe934a46f61a2f7512d32dab05247efca046d0713fdc0c8a9e" -[[package]] -name = "solana-message" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1796aabce376ff74bf89b78d268fa5e683d7d7a96a0a4e4813ec34de49d5314b" -dependencies = [ - "bincode", - "blake3", - "lazy_static", - "serde", - "serde_derive", - "solana-bincode 2.2.1", - "solana-hash 2.3.0", - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", - "solana-sanitize 2.2.1", - "solana-sdk-ids 2.2.1", - "solana-short-vec 2.2.1", - "solana-system-interface 1.0.0", - "solana-transaction-error 2.2.1", - "wasm-bindgen", -] - [[package]] name = "solana-message" version = "3.0.0" @@ -5857,12 +5615,12 @@ dependencies = [ "serde", "serde_derive", "solana-hash 3.1.0", - "solana-instruction 3.0.0", - "solana-pubkey 3.0.0", - "solana-sanitize 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-short-vec 3.0.0", - "solana-transaction-error 3.0.0", + "solana-instruction", + "solana-pubkey", + "solana-sanitize", + "solana-sdk-ids", + "solana-short-vec", + "solana-transaction-error", ] [[package]] @@ -5876,35 +5634,20 @@ dependencies = [ "log", "reqwest", "solana-cluster-type", - "solana-sha256-hasher 3.0.0", + "solana-sha256-hasher", "solana-time-utils", "thiserror 2.0.17", ] -[[package]] -name = "solana-msg" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36a1a14399afaabc2781a1db09cb14ee4cc4ee5c7a5a3cfcc601811379a8092" -dependencies = [ - "solana-define-syscall 2.3.0", -] - [[package]] name = "solana-msg" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "264275c556ea7e22b9d3f87d56305546a38d4eee8ec884f3b126236cb7dcbbb4" dependencies = [ - "solana-define-syscall 3.0.0", + "solana-define-syscall", ] -[[package]] -name = "solana-native-token" -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" @@ -5938,20 +5681,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b8a731ed60e89177c8a7ab05fe0f1511cedd3e70e773f288f9de33a9cfdc21e" -[[package]] -name = "solana-nonce" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703e22eb185537e06204a5bd9d509b948f0066f2d1d814a6f475dafb3ddf1325" -dependencies = [ - "serde", - "serde_derive", - "solana-fee-calculator 2.2.1", - "solana-hash 2.3.0", - "solana-pubkey 2.4.0", - "solana-sha256-hasher 2.2.1", -] - [[package]] name = "solana-nonce" version = "3.0.0" @@ -5960,10 +5689,10 @@ checksum = "abbdc6c8caf1c08db9f36a50967539d0f72b9f1d4aea04fec5430f532e5afadc" dependencies = [ "serde", "serde_derive", - "solana-fee-calculator 3.0.0", + "solana-fee-calculator", "solana-hash 3.1.0", - "solana-pubkey 3.0.0", - "solana-sha256-hasher 3.0.0", + "solana-pubkey", + "solana-sha256-hasher", ] [[package]] @@ -5972,10 +5701,10 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "805fd25b29e5a1a0e6c3dd6320c9da80f275fbe4ff6e392617c303a2085c435e" dependencies = [ - "solana-account 3.2.0", + "solana-account", "solana-hash 3.1.0", - "solana-nonce 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-nonce", + "solana-sdk-ids", ] [[package]] @@ -6013,13 +5742,13 @@ dependencies = [ "rayon", "serde", "solana-hash 3.1.0", - "solana-message 3.0.0", + "solana-message", "solana-metrics", "solana-packet", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-rayon-threadlimit", - "solana-sdk-ids 3.0.0", - "solana-short-vec 3.0.0", + "solana-sdk-ids", + "solana-short-vec", "solana-signature", "solana-time-utils", ] @@ -6042,7 +5771,7 @@ checksum = "794ff76c70d6f4c5d9c86c626069225c0066043405c0c9d6b96f00c8525dade5" dependencies = [ "ark-bn254", "light-poseidon", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "thiserror 2.0.17", ] @@ -6055,125 +5784,17 @@ dependencies = [ "num-traits", ] -[[package]] -name = "solana-program" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "586469467e93ceb79048f8d8e3a619bf61d05396ee7de95cb40280301a589d05" -dependencies = [ - "bincode", - "blake3", - "borsh 0.10.4", - "borsh 1.5.7", - "bs58", - "bytemuck", - "console_error_panic_hook", - "console_log", - "getrandom 0.2.15", - "lazy_static", - "log", - "memoffset", - "num-bigint 0.4.6", - "num-derive", - "num-traits", - "rand 0.8.5", - "serde", - "serde_bytes", - "serde_derive", - "solana-account-info 2.2.1", - "solana-address-lookup-table-interface 2.2.2", - "solana-atomic-u64 2.2.1", - "solana-big-mod-exp 2.2.1", - "solana-bincode 2.2.1", - "solana-blake3-hasher 2.2.1", - "solana-borsh 2.2.1", - "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-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-last-restart-slot 2.2.1", - "solana-loader-v2-interface", - "solana-loader-v3-interface 3.0.0", - "solana-loader-v4-interface 2.2.1", - "solana-message 2.4.0", - "solana-msg 2.2.1", - "solana-native-token 2.3.0", - "solana-nonce 2.2.1", - "solana-program-entrypoint 2.2.1", - "solana-program-error 2.2.1", - "solana-program-memory 2.2.1", - "solana-program-option", - "solana-program-pack 2.2.1", - "solana-pubkey 2.4.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-serde-varint 2.2.2", - "solana-serialize-utils 2.2.1", - "solana-sha256-hasher 2.2.1", - "solana-short-vec 2.2.1", - "solana-slot-hashes 2.2.1", - "solana-slot-history 2.2.1", - "solana-stable-layout 2.2.1", - "solana-stake-interface 1.2.1", - "solana-system-interface 1.0.0", - "solana-sysvar 2.2.2", - "solana-sysvar-id 2.2.1", - "solana-vote-interface 2.2.6", - "thiserror 2.0.17", - "wasm-bindgen", -] - -[[package]] -name = "solana-program-entrypoint" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473ffe73c68d93e9f2aa726ad2985fe52760052709aaab188100a42c618060ec" -dependencies = [ - "solana-account-info 2.2.1", - "solana-msg 2.2.1", - "solana-program-error 2.2.1", - "solana-pubkey 2.4.0", -] - [[package]] name = "solana-program-entrypoint" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6557cf5b5e91745d1667447438a1baa7823c6086e4ece67f8e6ebfa7a8f72660" dependencies = [ - "solana-account-info 3.0.0", - "solana-define-syscall 3.0.0", - "solana-msg 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", -] - -[[package]] -name = "solana-program-error" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8ae2c1a8d0d4ae865882d5770a7ebca92bab9c685e43f0461682c6c05a35bfa" -dependencies = [ - "borsh 1.5.7", - "num-traits", - "serde", - "serde_derive", - "solana-decode-error", - "solana-instruction 2.3.0", - "solana-msg 2.2.1", - "solana-pubkey 2.4.0", + "solana-account-info", + "solana-define-syscall", + "solana-msg", + "solana-program-error", + "solana-pubkey", ] [[package]] @@ -6182,17 +5803,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1af32c995a7b692a915bb7414d5f8e838450cf7c70414e763d8abcae7b51f28" dependencies = [ - "borsh 1.5.7", -] - -[[package]] -name = "solana-program-memory" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b0268f6c89825fb634a34bd0c3b8fdaeaecfc3728be1d622a8ee6dd577b60d4" -dependencies = [ - "num-traits", - "solana-define-syscall 2.3.0", + "borsh", ] [[package]] @@ -6201,22 +5812,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10e5660c60749c7bfb30b447542529758e4dbcecd31b1e8af1fdc92e2bdde90a" dependencies = [ - "solana-define-syscall 3.0.0", -] - -[[package]] -name = "solana-program-option" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc677a2e9bc616eda6dbdab834d463372b92848b2bfe4a1ed4e4b4adba3397d0" - -[[package]] -name = "solana-program-pack" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "319f0ef15e6e12dc37c597faccb7d62525a509fec5f6975ecb9419efddeb277b" -dependencies = [ - "solana-program-error 2.2.1", + "solana-define-syscall", ] [[package]] @@ -6225,7 +5821,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c169359de21f6034a63ebf96d6b380980307df17a8d371344ff04a883ec4e9d0" dependencies = [ - "solana-program-error 3.0.0", + "solana-program-error", ] [[package]] @@ -6241,20 +5837,20 @@ dependencies = [ "percentage", "rand 0.8.5", "serde", - "solana-account 3.2.0", - "solana-clock 3.0.0", - "solana-epoch-rewards 3.0.0", - "solana-epoch-schedule 3.0.0", + "solana-account", + "solana-clock", + "solana-epoch-rewards", + "solana-epoch-schedule", "solana-fee-structure", "solana-hash 3.1.0", - "solana-instruction 3.0.0", - "solana-last-restart-slot 3.0.0", - "solana-program-entrypoint 3.1.0", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", + "solana-instruction", + "solana-last-restart-slot", + "solana-program-entrypoint", + "solana-pubkey", + "solana-rent", "solana-sbpf", - "solana-sdk-ids 3.0.0", - "solana-slot-hashes 3.0.0", + "solana-sdk-ids", + "solana-slot-hashes", "solana-stake-interface 2.0.1", "solana-svm-callback", "solana-svm-feature-set", @@ -6263,9 +5859,9 @@ dependencies = [ "solana-svm-timings", "solana-svm-transaction", "solana-svm-type-overrides", - "solana-system-interface 2.0.0", - "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-system-interface", + "solana-sysvar", + "solana-sysvar-id", "solana-transaction-context", ] @@ -6284,81 +5880,55 @@ dependencies = [ "crossbeam-channel", "log", "serde", - "solana-account 3.2.0", - "solana-account-info 3.0.0", + "solana-account", + "solana-account-info", "solana-accounts-db", "solana-banks-client", "solana-banks-interface", "solana-banks-server", - "solana-clock 3.0.0", + "solana-clock", "solana-cluster-type", "solana-commitment-config", "solana-compute-budget", - "solana-epoch-rewards 3.0.0", - "solana-epoch-schedule 3.0.0", - "solana-fee-calculator 3.0.0", + "solana-epoch-rewards", + "solana-epoch-schedule", + "solana-fee-calculator", "solana-genesis-config", "solana-hash 3.1.0", - "solana-instruction 3.0.0", + "solana-instruction", "solana-keypair", - "solana-loader-v3-interface 6.1.0", + "solana-loader-v3-interface", "solana-logger", - "solana-message 3.0.0", - "solana-msg 3.0.0", - "solana-native-token 3.0.0", + "solana-message", + "solana-msg", + "solana-native-token", "solana-poh-config", - "solana-program-entrypoint 3.1.0", - "solana-program-error 3.0.0", + "solana-program-entrypoint", + "solana-program-error", "solana-program-runtime", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", + "solana-pubkey", + "solana-rent", "solana-runtime", "solana-sbpf", - "solana-sdk-ids 3.0.0", + "solana-sdk-ids", "solana-signer", - "solana-stable-layout 3.0.0", + "solana-stable-layout", "solana-stake-interface 2.0.1", "solana-svm", "solana-svm-log-collector", "solana-svm-timings", - "solana-system-interface 2.0.0", - "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-system-interface", + "solana-sysvar", + "solana-sysvar-id", "solana-transaction", "solana-transaction-context", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "solana-vote-program", "spl-generic-token", "thiserror 2.0.17", "tokio", ] -[[package]] -name = "solana-pubkey" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b62adb9c3261a052ca1f999398c388f1daf558a1b492f60a6d9e64857db4ff1" -dependencies = [ - "borsh 0.10.4", - "borsh 1.5.7", - "bytemuck", - "bytemuck_derive", - "curve25519-dalek 4.1.3", - "five8 0.2.1", - "five8_const", - "getrandom 0.2.15", - "js-sys", - "num-traits", - "serde", - "serde_derive", - "solana-atomic-u64 2.2.1", - "solana-decode-error", - "solana-define-syscall 2.3.0", - "solana-sanitize 2.2.1", - "solana-sha256-hasher 2.2.1", - "wasm-bindgen", -] - [[package]] name = "solana-pubkey" version = "3.0.0" @@ -6384,8 +5954,8 @@ dependencies = [ "serde_derive", "serde_json", "solana-account-decoder-client-types", - "solana-clock 3.0.0", - "solana-pubkey 3.0.0", + "solana-clock", + "solana-pubkey", "solana-rpc-client-types", "solana-signature", "thiserror 2.0.17", @@ -6415,13 +5985,13 @@ dependencies = [ "solana-measure", "solana-metrics", "solana-net-utils", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-quic-definitions", "solana-rpc-client-api", "solana-signer", "solana-streamer", "solana-tls-utils", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", "tokio", ] @@ -6445,19 +6015,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "solana-rent" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1aea8fdea9de98ca6e8c2da5827707fb3842833521b528a713810ca685d2480" -dependencies = [ - "serde", - "serde_derive", - "solana-sdk-ids 2.2.1", - "solana-sdk-macro 2.2.1", - "solana-sysvar-id 2.2.1", -] - [[package]] name = "solana-rent" version = "3.0.0" @@ -6466,9 +6023,9 @@ checksum = "b702d8c43711e3c8a9284a4f1bbc6a3de2553deb25b0c8142f9a44ef0ce5ddc1" dependencies = [ "serde", "serde_derive", - "solana-sdk-ids 3.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -6500,21 +6057,21 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "solana-account 3.2.0", + "solana-account", "solana-account-decoder-client-types", - "solana-clock 3.0.0", + "solana-clock", "solana-commitment-config", "solana-epoch-info", - "solana-epoch-schedule 3.0.0", - "solana-feature-gate-interface 3.0.0", + "solana-epoch-schedule", + "solana-feature-gate-interface", "solana-hash 3.1.0", - "solana-instruction 3.0.0", - "solana-message 3.0.0", - "solana-pubkey 3.0.0", + "solana-instruction", + "solana-message", + "solana-pubkey", "solana-rpc-client-api", "solana-signature", "solana-transaction", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "solana-transaction-status-client-types", "solana-version", "solana-vote-interface 3.0.0", @@ -6535,10 +6092,10 @@ dependencies = [ "serde_derive", "serde_json", "solana-account-decoder-client-types", - "solana-clock 3.0.0", + "solana-clock", "solana-rpc-client-types", "solana-signer", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "solana-transaction-status-client-types", "thiserror 2.0.17", ] @@ -6549,14 +6106,14 @@ version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9902af67012d1e92b4a737e26329ae17c4678b5322ed841aa0018bfcfd7a033" dependencies = [ - "solana-account 3.2.0", + "solana-account", "solana-commitment-config", "solana-hash 3.1.0", - "solana-message 3.0.0", - "solana-nonce 3.0.0", - "solana-pubkey 3.0.0", + "solana-message", + "solana-nonce", + "solana-pubkey", "solana-rpc-client", - "solana-sdk-ids 3.0.0", + "solana-sdk-ids", "thiserror 2.0.17", ] @@ -6572,14 +6129,14 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "solana-account 3.2.0", + "solana-account", "solana-account-decoder-client-types", - "solana-clock 3.0.0", + "solana-clock", "solana-commitment-config", - "solana-fee-calculator 3.0.0", + "solana-fee-calculator", "solana-inflation", - "solana-pubkey 3.0.0", - "solana-transaction-error 3.0.0", + "solana-pubkey", + "solana-transaction-error", "solana-transaction-status-client-types", "solana-version", "spl-generic-token", @@ -6631,79 +6188,79 @@ dependencies = [ "serde_derive", "serde_json", "serde_with", - "solana-account 3.2.0", - "solana-account-info 3.0.0", + "solana-account", + "solana-account-info", "solana-accounts-db", - "solana-address-lookup-table-interface 3.0.0", + "solana-address-lookup-table-interface", "solana-bpf-loader-program", "solana-bucket-map", "solana-builtins", "solana-client-traits", - "solana-clock 3.0.0", + "solana-clock", "solana-cluster-type", "solana-commitment-config", "solana-compute-budget", "solana-compute-budget-instruction", "solana-compute-budget-interface", "solana-cost-model", - "solana-cpi 3.0.0", + "solana-cpi", "solana-ed25519-program", "solana-epoch-info", "solana-epoch-rewards-hasher", - "solana-epoch-schedule 3.0.0", - "solana-feature-gate-interface 3.0.0", + "solana-epoch-schedule", + "solana-feature-gate-interface", "solana-fee", - "solana-fee-calculator 3.0.0", + "solana-fee-calculator", "solana-fee-structure", "solana-genesis-config", "solana-hard-forks", "solana-hash 3.1.0", "solana-inflation", - "solana-instruction 3.0.0", + "solana-instruction", "solana-keypair", "solana-lattice-hash", - "solana-loader-v3-interface 6.1.0", - "solana-loader-v4-interface 3.1.0", + "solana-loader-v3-interface", + "solana-loader-v4-interface", "solana-measure", - "solana-message 3.0.0", + "solana-message", "solana-metrics", - "solana-native-token 3.0.0", + "solana-native-token", "solana-nohash-hasher", - "solana-nonce 3.0.0", + "solana-nonce", "solana-nonce-account", "solana-packet", "solana-perf", "solana-poh-config", "solana-precompile-error", "solana-program-runtime", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-rayon-threadlimit", - "solana-rent 3.0.0", + "solana-rent", "solana-reward-info", "solana-runtime-transaction", - "solana-sdk-ids 3.0.0", + "solana-sdk-ids", "solana-secp256k1-program", "solana-seed-derivable", "solana-serde", - "solana-sha256-hasher 3.0.0", + "solana-sha256-hasher", "solana-signature", "solana-signer", - "solana-slot-hashes 3.0.0", - "solana-slot-history 3.0.0", + "solana-slot-hashes", + "solana-slot-history", "solana-stake-interface 2.0.1", "solana-stake-program 3.0.10", "solana-svm", "solana-svm-callback", "solana-svm-timings", "solana-svm-transaction", - "solana-system-interface 2.0.0", + "solana-system-interface", "solana-system-transaction", - "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sysvar", + "solana-sysvar-id", "solana-time-utils", "solana-transaction", "solana-transaction-context", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "solana-transaction-status-client-types", "solana-unified-scheduler-logic", "solana-version", @@ -6732,22 +6289,16 @@ dependencies = [ "solana-compute-budget", "solana-compute-budget-instruction", "solana-hash 3.1.0", - "solana-message 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-message", + "solana-pubkey", + "solana-sdk-ids", "solana-signature", "solana-svm-transaction", "solana-transaction", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", ] -[[package]] -name = "solana-sanitize" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61f1bc1357b8188d9c4a3af3fc55276e56987265eb7ad073ae6f8180ee54cecf" - [[package]] name = "solana-sanitize" version = "3.0.0" @@ -6771,34 +6322,13 @@ dependencies = [ "winapi", ] -[[package]] -name = "solana-sdk-ids" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5d8b9cc68d5c88b062a33e23a6466722467dde0035152d8fb1afbcdf350a5f" -dependencies = [ - "solana-pubkey 2.4.0", -] - [[package]] name = "solana-sdk-ids" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1b6d6aaf60669c592838d382266b173881c65fb1cdec83b37cb8ce7cb89f9ad" dependencies = [ - "solana-pubkey 3.0.0", -] - -[[package]] -name = "solana-sdk-macro" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86280da8b99d03560f6ab5aca9de2e38805681df34e0bb8f238e69b29433b9df" -dependencies = [ - "bs58", - "proc-macro2", - "quote", - "syn 2.0.98", + "solana-pubkey", ] [[package]] @@ -6827,17 +6357,6 @@ dependencies = [ "solana-signature", ] -[[package]] -name = "solana-secp256k1-recover" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa3120b6cdaa270f39444f5093a90a7b03d296d362878f7a6991d6de3bbe496" -dependencies = [ - "libsecp256k1", - "solana-define-syscall 2.3.0", - "thiserror 2.0.17", -] - [[package]] name = "solana-secp256k1-recover" version = "3.0.0" @@ -6845,7 +6364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "394a4470477d66296af5217970a905b1c5569032a7732c367fb69e5666c8607e" dependencies = [ "k256", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "thiserror 2.0.17", ] @@ -6857,8 +6376,8 @@ checksum = "445d8e12592631d76fc4dc57858bae66c9fd7cc838c306c62a472547fc9d0ce6" dependencies = [ "bytemuck", "openssl", - "solana-instruction 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-instruction", + "solana-sdk-ids", ] [[package]] @@ -6892,14 +6411,14 @@ dependencies = [ "itertools 0.12.1", "log", "solana-client", - "solana-clock 3.0.0", + "solana-clock", "solana-connection-cache", "solana-hash 3.1.0", "solana-keypair", "solana-measure", "solana-metrics", "solana-nonce-account", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-quic-definitions", "solana-runtime", "solana-signature", @@ -6918,15 +6437,6 @@ dependencies = [ "serde", ] -[[package]] -name = "solana-serde-varint" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a7e155eba458ecfb0107b98236088c3764a09ddf0201ec29e52a0be40857113" -dependencies = [ - "serde", -] - [[package]] name = "solana-serde-varint" version = "3.0.0" @@ -6936,17 +6446,6 @@ dependencies = [ "serde", ] -[[package]] -name = "solana-serialize-utils" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "817a284b63197d2b27afdba829c5ab34231da4a9b4e763466a003c40ca4f535e" -dependencies = [ - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", - "solana-sanitize 2.2.1", -] - [[package]] name = "solana-serialize-utils" version = "3.1.0" @@ -6954,19 +6453,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56e41dd8feea239516c623a02f0a81c2367f4b604d7965237fed0751aeec33ed" dependencies = [ "solana-instruction-error", - "solana-pubkey 3.0.0", - "solana-sanitize 3.0.0", -] - -[[package]] -name = "solana-sha256-hasher" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0037386961c0d633421f53560ad7c80675c0447cba4d1bb66d60974dd486c7ea" -dependencies = [ - "sha2 0.10.8", - "solana-define-syscall 2.3.0", - "solana-hash 2.3.0", + "solana-pubkey", + "solana-sanitize", ] [[package]] @@ -6976,19 +6464,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9b912ba6f71cb202c0c3773ec77bf898fa9fe0c78691a2d6859b3b5b8954719" dependencies = [ "sha2 0.10.8", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "solana-hash 3.1.0", ] -[[package]] -name = "solana-short-vec" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c54c66f19b9766a56fa0057d060de8378676cb64987533fa088861858fc5a69" -dependencies = [ - "serde", -] - [[package]] name = "solana-short-vec" version = "3.0.0" @@ -7006,7 +6485,7 @@ checksum = "94953e22ca28fe4541a3447d6baeaf519cc4ddc063253bfa673b721f34c136bb" dependencies = [ "solana-hard-forks", "solana-hash 3.1.0", - "solana-sha256-hasher 3.0.0", + "solana-sha256-hasher", ] [[package]] @@ -7020,7 +6499,7 @@ dependencies = [ "serde", "serde-big-array", "serde_derive", - "solana-sanitize 3.0.0", + "solana-sanitize", ] [[package]] @@ -7029,22 +6508,9 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bfea97951fee8bae0d6038f39a5efcb6230ecdfe33425ac75196d1a1e3e3235" dependencies = [ - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-signature", - "solana-transaction-error 3.0.0", -] - -[[package]] -name = "solana-slot-hashes" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c8691982114513763e88d04094c9caa0376b867a29577939011331134c301ce" -dependencies = [ - "serde", - "serde_derive", - "solana-hash 2.3.0", - "solana-sdk-ids 2.2.1", - "solana-sysvar-id 2.2.1", + "solana-transaction-error", ] [[package]] @@ -7056,21 +6522,8 @@ dependencies = [ "serde", "serde_derive", "solana-hash 3.1.0", - "solana-sdk-ids 3.0.0", - "solana-sysvar-id 3.0.0", -] - -[[package]] -name = "solana-slot-history" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ccc1b2067ca22754d5283afb2b0126d61eae734fc616d23871b0943b0d935e" -dependencies = [ - "bv", - "serde", - "serde_derive", - "solana-sdk-ids 2.2.1", - "solana-sysvar-id 2.2.1", + "solana-sdk-ids", + "solana-sysvar-id", ] [[package]] @@ -7082,18 +6535,8 @@ dependencies = [ "bv", "serde", "serde_derive", - "solana-sdk-ids 3.0.0", - "solana-sysvar-id 3.0.0", -] - -[[package]] -name = "solana-stable-layout" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f14f7d02af8f2bc1b5efeeae71bc1c2b7f0f65cd75bcc7d8180f2c762a57f54" -dependencies = [ - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", + "solana-sdk-ids", + "solana-sysvar-id", ] [[package]] @@ -7102,8 +6545,8 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1da74507795b6e8fb60b7c7306c0c36e2c315805d16eaaf479452661234685ac" dependencies = [ - "solana-instruction 3.0.0", - "solana-pubkey 3.0.0", + "solana-instruction", + "solana-pubkey", ] [[package]] @@ -7111,54 +6554,37 @@ name = "solana-stake-client" version = "0.0.0" dependencies = [ "assert_matches", - "borsh 1.5.7", + "borsh", "num-derive", "num-traits", "serde", "serde_with", - "solana-program", + "solana-account-info", + "solana-cpi", + "solana-instruction", + "solana-program-error", + "solana-pubkey", "thiserror 2.0.17", ] -[[package]] -name = "solana-stake-interface" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5269e89fde216b4d7e1d1739cf5303f8398a1ff372a81232abbee80e554a838c" -dependencies = [ - "borsh 0.10.4", - "borsh 1.5.7", - "num-traits", - "serde", - "serde_derive", - "solana-clock 2.2.2", - "solana-cpi 2.2.1", - "solana-decode-error", - "solana-instruction 2.3.0", - "solana-program-error 2.2.1", - "solana-pubkey 2.4.0", - "solana-system-interface 1.0.0", - "solana-sysvar-id 2.2.1", -] - [[package]] name = "solana-stake-interface" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f912ae679b683365348dea482dbd9468d22ff258b554fd36e3d3683c2122e3" dependencies = [ - "borsh 1.5.7", + "borsh", "num-traits", "serde", "serde_derive", - "solana-clock 3.0.0", - "solana-cpi 3.0.0", - "solana-instruction 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", - "solana-system-interface 2.0.0", - "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-clock", + "solana-cpi", + "solana-instruction", + "solana-program-error", + "solana-pubkey", + "solana-system-interface", + "solana-sysvar", + "solana-sysvar-id", ] [[package]] @@ -7168,26 +6594,29 @@ dependencies = [ "anyhow", "assert_matches", "bincode", - "borsh 1.5.7", + "borsh", + "codama", + "codama-macros", "num-traits", "serde", "serde_derive", + "serde_json", "serial_test", - "solana-account 3.2.0", - "solana-borsh 3.0.0", - "solana-clock 3.0.0", - "solana-cpi 3.0.0", - "solana-example-mocks 3.0.0", + "solana-account", + "solana-borsh", + "solana-clock", + "solana-cpi", + "solana-example-mocks", "solana-frozen-abi", "solana-frozen-abi-macro", - "solana-instruction 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-instruction", + "solana-program-error", + "solana-pubkey", + "solana-sdk-ids", "solana-stake-interface 2.0.2", - "solana-system-interface 2.0.0", - "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-system-interface", + "solana-sysvar", + "solana-sysvar-id", "static_assertions", "strum 0.27.2", "strum_macros 0.27.2", @@ -7203,22 +6632,22 @@ dependencies = [ "agave-feature-set", "bincode", "log", - "solana-account 3.2.0", - "solana-bincode 3.0.0", - "solana-clock 3.0.0", + "solana-account", + "solana-bincode", + "solana-clock", "solana-config-interface", "solana-genesis-config", - "solana-instruction 3.0.0", - "solana-native-token 3.0.0", + "solana-instruction", + "solana-native-token", "solana-packet", "solana-program-runtime", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", "solana-stake-interface 2.0.1", "solana-svm-log-collector", "solana-svm-type-overrides", - "solana-sysvar 3.0.0", + "solana-sysvar", "solana-transaction-context", "solana-vote-interface 3.0.0", ] @@ -7234,32 +6663,32 @@ dependencies = [ "mollusk-svm", "proptest", "rand 0.9.2", - "solana-account 3.2.0", - "solana-account-info 3.0.0", - "solana-clock 3.0.0", + "solana-account", + "solana-account-info", + "solana-clock", "solana-config-interface", - "solana-cpi 3.0.0", - "solana-epoch-rewards 3.0.0", - "solana-epoch-schedule 3.0.0", - "solana-instruction 3.0.0", + "solana-cpi", + "solana-epoch-rewards", + "solana-epoch-schedule", + "solana-instruction", "solana-instruction-error", "solana-keypair", "solana-logger", - "solana-msg 3.0.0", - "solana-native-token 3.0.0", - "solana-program-entrypoint 3.1.0", - "solana-program-error 3.0.0", + "solana-msg", + "solana-native-token", + "solana-program-entrypoint", + "solana-program-error", "solana-program-test", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", "solana-signature", "solana-signer", "solana-stake-interface 2.0.1", "solana-svm-log-collector", - "solana-system-interface 2.0.0", - "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-system-interface", + "solana-sysvar", + "solana-sysvar-id", "solana-transaction", "solana-vote-interface 4.0.4", "test-case", @@ -7300,13 +6729,13 @@ dependencies = [ "solana-net-utils", "solana-packet", "solana-perf", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-quic-definitions", "solana-signature", "solana-signer", "solana-time-utils", "solana-tls-utils", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "solana-transaction-metrics-tracker", "thiserror 2.0.17", "tokio", @@ -7325,24 +6754,24 @@ dependencies = [ "percentage", "serde", "serde_derive", - "solana-account 3.2.0", - "solana-clock 3.0.0", + "solana-account", + "solana-clock", "solana-fee-structure", "solana-hash 3.1.0", - "solana-instruction 3.0.0", - "solana-instructions-sysvar 3.0.0", - "solana-loader-v3-interface 6.1.0", - "solana-loader-v4-interface 3.1.0", + "solana-instruction", + "solana-instructions-sysvar", + "solana-loader-v3-interface", + "solana-loader-v4-interface", "solana-loader-v4-program", - "solana-message 3.0.0", - "solana-nonce 3.0.0", + "solana-message", + "solana-nonce", "solana-nonce-account", - "solana-program-entrypoint 3.1.0", - "solana-program-pack 3.0.0", + "solana-program-entrypoint", + "solana-program-pack", "solana-program-runtime", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", "solana-svm-callback", "solana-svm-feature-set", "solana-svm-log-collector", @@ -7350,10 +6779,10 @@ dependencies = [ "solana-svm-timings", "solana-svm-transaction", "solana-svm-type-overrides", - "solana-system-interface 2.0.0", - "solana-sysvar-id 3.0.0", + "solana-system-interface", + "solana-sysvar-id", "solana-transaction-context", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "spl-generic-token", "thiserror 2.0.17", ] @@ -7364,10 +6793,10 @@ version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d2211ecefc92a3d6db1206eca32aa579bb112eb1a2823ac227d8cbd5cdb0465" dependencies = [ - "solana-account 3.2.0", - "solana-clock 3.0.0", + "solana-account", + "solana-clock", "solana-precompile-error", - "solana-pubkey 3.0.0", + "solana-pubkey", ] [[package]] @@ -7399,7 +6828,7 @@ checksum = "62606f820fe99b72ee8e26b8e20eed3c2ccc2f6e3146f537c4cb22a442c69170" dependencies = [ "eager", "enum-iterator", - "solana-pubkey 3.0.0", + "solana-pubkey", ] [[package]] @@ -7409,9 +6838,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "336583f8418964f7050b98996e13151857995604fe057c0d8f2f3512a16d3a8b" dependencies = [ "solana-hash 3.1.0", - "solana-message 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-message", + "solana-pubkey", + "solana-sdk-ids", "solana-signature", "solana-transaction", ] @@ -7425,22 +6854,6 @@ dependencies = [ "rand 0.8.5", ] -[[package]] -name = "solana-system-interface" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d7c18cb1a91c6be5f5a8ac9276a1d7c737e39a21beba9ea710ab4b9c63bc90" -dependencies = [ - "js-sys", - "num-traits", - "serde", - "serde_derive", - "solana-decode-error", - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", - "wasm-bindgen", -] - [[package]] name = "solana-system-interface" version = "2.0.0" @@ -7450,10 +6863,10 @@ dependencies = [ "num-traits", "serde", "serde_derive", - "solana-instruction 3.0.0", - "solana-msg 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", + "solana-instruction", + "solana-msg", + "solana-program-error", + "solana-pubkey", ] [[package]] @@ -7466,20 +6879,20 @@ dependencies = [ "log", "serde", "serde_derive", - "solana-account 3.2.0", - "solana-bincode 3.0.0", - "solana-fee-calculator 3.0.0", - "solana-instruction 3.0.0", - "solana-nonce 3.0.0", + "solana-account", + "solana-bincode", + "solana-fee-calculator", + "solana-instruction", + "solana-nonce", "solana-nonce-account", "solana-packet", "solana-program-runtime", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-sdk-ids", "solana-svm-log-collector", "solana-svm-type-overrides", - "solana-system-interface 2.0.0", - "solana-sysvar 3.0.0", + "solana-system-interface", + "solana-sysvar", "solana-transaction-context", ] @@ -7491,50 +6904,13 @@ checksum = "a31b5699ec533621515e714f1533ee6b3b0e71c463301d919eb59b8c1e249d30" dependencies = [ "solana-hash 3.1.0", "solana-keypair", - "solana-message 3.0.0", - "solana-pubkey 3.0.0", + "solana-message", + "solana-pubkey", "solana-signer", - "solana-system-interface 2.0.0", + "solana-system-interface", "solana-transaction", ] -[[package]] -name = "solana-sysvar" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50c92bc019c590f5e42c61939676e18d14809ed00b2a59695dd5c67ae72c097" -dependencies = [ - "base64 0.22.1", - "bincode", - "bytemuck", - "bytemuck_derive", - "lazy_static", - "serde", - "serde_derive", - "solana-account-info 2.2.1", - "solana-clock 2.2.2", - "solana-define-syscall 2.3.0", - "solana-epoch-rewards 2.2.1", - "solana-epoch-schedule 2.2.1", - "solana-fee-calculator 2.2.1", - "solana-hash 2.3.0", - "solana-instruction 2.3.0", - "solana-instructions-sysvar 2.2.2", - "solana-last-restart-slot 2.2.1", - "solana-program-entrypoint 2.2.1", - "solana-program-error 2.2.1", - "solana-program-memory 2.2.1", - "solana-pubkey 2.4.0", - "solana-rent 2.2.1", - "solana-sanitize 2.2.1", - "solana-sdk-ids 2.2.1", - "solana-sdk-macro 2.2.1", - "solana-slot-hashes 2.2.1", - "solana-slot-history 2.2.1", - "solana-stake-interface 1.2.1", - "solana-sysvar-id 2.2.1", -] - [[package]] name = "solana-sysvar" version = "3.0.0" @@ -7546,37 +6922,27 @@ dependencies = [ "lazy_static", "serde", "serde_derive", - "solana-account-info 3.0.0", - "solana-clock 3.0.0", - "solana-define-syscall 3.0.0", - "solana-epoch-rewards 3.0.0", - "solana-epoch-schedule 3.0.0", - "solana-fee-calculator 3.0.0", + "solana-account-info", + "solana-clock", + "solana-define-syscall", + "solana-epoch-rewards", + "solana-epoch-schedule", + "solana-fee-calculator", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-hash 3.1.0", - "solana-instruction 3.0.0", - "solana-last-restart-slot 3.0.0", - "solana-program-entrypoint 3.1.0", - "solana-program-error 3.0.0", - "solana-program-memory 3.0.0", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-sdk-macro 3.0.0", - "solana-slot-hashes 3.0.0", - "solana-slot-history 3.0.0", - "solana-sysvar-id 3.0.0", -] - -[[package]] -name = "solana-sysvar-id" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5762b273d3325b047cfda250787f8d796d781746860d5d0a746ee29f3e8812c1" -dependencies = [ - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", + "solana-instruction", + "solana-last-restart-slot", + "solana-program-entrypoint", + "solana-program-error", + "solana-program-memory", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-slot-hashes", + "solana-slot-history", + "solana-sysvar-id", ] [[package]] @@ -7585,8 +6951,8 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5051bc1a16d5d96a96bc33b5b2ec707495c48fe978097bdaba68d3c47987eb32" dependencies = [ - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-sdk-ids", ] [[package]] @@ -7603,7 +6969,7 @@ checksum = "213b0b783dc59c113821478ab18da70b7b143ef69b194b7975fcdda20372130c" dependencies = [ "rustls 0.23.32", "solana-keypair", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-signer", "x509-parser", ] @@ -7622,14 +6988,14 @@ dependencies = [ "log", "rayon", "solana-client-traits", - "solana-clock 3.0.0", + "solana-clock", "solana-commitment-config", "solana-connection-cache", - "solana-epoch-schedule 3.0.0", + "solana-epoch-schedule", "solana-measure", - "solana-message 3.0.0", + "solana-message", "solana-net-utils", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-pubsub-client", "solana-quic-definitions", "solana-rpc-client", @@ -7637,7 +7003,7 @@ dependencies = [ "solana-signature", "solana-signer", "solana-transaction", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", "tokio", ] @@ -7653,7 +7019,7 @@ dependencies = [ "lru", "quinn", "rustls 0.23.32", - "solana-clock 3.0.0", + "solana-clock", "solana-connection-cache", "solana-keypair", "solana-measure", @@ -7680,15 +7046,15 @@ dependencies = [ "serde_derive", "solana-address", "solana-hash 3.1.0", - "solana-instruction 3.0.0", + "solana-instruction", "solana-instruction-error", - "solana-message 3.0.0", - "solana-sanitize 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-short-vec 3.0.0", + "solana-message", + "solana-sanitize", + "solana-sdk-ids", + "solana-short-vec", "solana-signature", "solana-signer", - "solana-transaction-error 3.0.0", + "solana-transaction-error", ] [[package]] @@ -7701,23 +7067,13 @@ dependencies = [ "qualifier_attr", "serde", "serde_derive", - "solana-account 3.2.0", - "solana-instruction 3.0.0", - "solana-instructions-sysvar 3.0.0", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", + "solana-account", + "solana-instruction", + "solana-instructions-sysvar", + "solana-pubkey", + "solana-rent", "solana-sbpf", - "solana-sdk-ids 3.0.0", -] - -[[package]] -name = "solana-transaction-error" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a9dc8fdb61c6088baab34fc3a8b8473a03a7a5fd404ed8dd502fa79b67cb1" -dependencies = [ - "solana-instruction 2.3.0", - "solana-sanitize 2.2.1", + "solana-sdk-ids", ] [[package]] @@ -7729,7 +7085,7 @@ dependencies = [ "serde", "serde_derive", "solana-instruction-error", - "solana-sanitize 3.0.0", + "solana-sanitize", ] [[package]] @@ -7744,7 +7100,7 @@ dependencies = [ "rand 0.8.5", "solana-packet", "solana-perf", - "solana-short-vec 3.0.0", + "solana-short-vec", "solana-signature", ] @@ -7762,14 +7118,14 @@ dependencies = [ "serde_json", "solana-account-decoder-client-types", "solana-commitment-config", - "solana-instruction 3.0.0", - "solana-message 3.0.0", - "solana-pubkey 3.0.0", + "solana-instruction", + "solana-message", + "solana-pubkey", "solana-reward-info", "solana-signature", "solana-transaction", "solana-transaction-context", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", ] @@ -7784,7 +7140,7 @@ dependencies = [ "solana-keypair", "solana-net-utils", "solana-streamer", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", "tokio", ] @@ -7796,7 +7152,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9151a3f80cb570d848fe8ff2985d2e8f84df49b832a9434ed255065c5e670e9c" dependencies = [ "assert_matches", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-runtime-transaction", "solana-transaction", "static_assertions", @@ -7814,8 +7170,8 @@ dependencies = [ "semver", "serde", "serde_derive", - "solana-sanitize 3.0.0", - "solana-serde-varint 3.0.0", + "solana-sanitize", + "solana-serde-varint", ] [[package]] @@ -7828,16 +7184,16 @@ dependencies = [ "log", "serde", "serde_derive", - "solana-account 3.2.0", - "solana-bincode 3.0.0", - "solana-clock 3.0.0", + "solana-account", + "solana-bincode", + "solana-clock", "solana-hash 3.1.0", - "solana-instruction 3.0.0", + "solana-instruction", "solana-keypair", "solana-packet", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-serialize-utils 3.1.0", + "solana-pubkey", + "solana-sdk-ids", + "solana-serialize-utils", "solana-signature", "solana-signer", "solana-svm-transaction", @@ -7846,30 +7202,6 @@ dependencies = [ "thiserror 2.0.17", ] -[[package]] -name = "solana-vote-interface" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b80d57478d6599d30acc31cc5ae7f93ec2361a06aefe8ea79bc81739a08af4c3" -dependencies = [ - "bincode", - "num-derive", - "num-traits", - "serde", - "serde_derive", - "solana-clock 2.2.2", - "solana-decode-error", - "solana-hash 2.3.0", - "solana-instruction 2.3.0", - "solana-pubkey 2.4.0", - "solana-rent 2.2.1", - "solana-sdk-ids 2.2.1", - "solana-serde-varint 2.2.2", - "solana-serialize-utils 2.2.1", - "solana-short-vec 2.2.1", - "solana-system-interface 1.0.0", -] - [[package]] name = "solana-vote-interface" version = "3.0.0" @@ -7883,17 +7215,17 @@ dependencies = [ "serde", "serde_derive", "serde_with", - "solana-clock 3.0.0", + "solana-clock", "solana-hash 3.1.0", - "solana-instruction 3.0.0", + "solana-instruction", "solana-instruction-error", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-serde-varint 3.0.0", - "solana-serialize-utils 3.1.0", - "solana-short-vec 3.0.0", - "solana-system-interface 2.0.0", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-serde-varint", + "solana-serialize-utils", + "solana-short-vec", + "solana-system-interface", ] [[package]] @@ -7909,17 +7241,17 @@ dependencies = [ "serde", "serde_derive", "serde_with", - "solana-clock 3.0.0", + "solana-clock", "solana-hash 3.1.0", - "solana-instruction 3.0.0", + "solana-instruction", "solana-instruction-error", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-serde-varint 3.0.0", - "solana-serialize-utils 3.1.0", - "solana-short-vec 3.0.0", - "solana-system-interface 2.0.0", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-serde-varint", + "solana-serialize-utils", + "solana-short-vec", + "solana-system-interface", ] [[package]] @@ -7935,20 +7267,20 @@ dependencies = [ "num-traits", "serde", "serde_derive", - "solana-account 3.2.0", - "solana-bincode 3.0.0", - "solana-clock 3.0.0", - "solana-epoch-schedule 3.0.0", + "solana-account", + "solana-bincode", + "solana-clock", + "solana-epoch-schedule", "solana-hash 3.1.0", - "solana-instruction 3.0.0", + "solana-instruction", "solana-keypair", "solana-packet", "solana-program-runtime", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", "solana-signer", - "solana-slot-hashes 3.0.0", + "solana-slot-hashes", "solana-transaction", "solana-transaction-context", "solana-vote-interface 3.0.0", @@ -7965,9 +7297,9 @@ dependencies = [ "bytemuck", "num-derive", "num-traits", - "solana-instruction 3.0.0", + "solana-instruction", "solana-program-runtime", - "solana-sdk-ids 3.0.0", + "solana-sdk-ids", "solana-svm-log-collector", "solana-zk-sdk", ] @@ -7996,9 +7328,9 @@ dependencies = [ "serde_json", "sha3", "solana-derivation-path", - "solana-instruction 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", "solana-seed-derivable", "solana-seed-phrase", "solana-signature", @@ -8019,9 +7351,9 @@ dependencies = [ "bytemuck", "num-derive", "num-traits", - "solana-instruction 3.0.0", + "solana-instruction", "solana-program-runtime", - "solana-sdk-ids 3.0.0", + "solana-sdk-ids", "solana-svm-log-collector", "solana-zk-token-sdk", ] @@ -8049,9 +7381,9 @@ dependencies = [ "sha3", "solana-curve25519", "solana-derivation-path", - "solana-instruction 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", "solana-seed-derivable", "solana-seed-phrase", "solana-signature", @@ -8087,7 +7419,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "233df81b75ab99b42f002b5cdd6e65a7505ffa930624f7096a7580a56765e9cf" dependencies = [ "bytemuck", - "solana-pubkey 3.0.0", + "solana-pubkey", ] [[package]] @@ -8541,11 +7873,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.11" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", ] [[package]] @@ -8553,6 +7888,9 @@ name = "toml_datetime" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -8561,6 +7899,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap 2.10.0", + "serde", + "serde_spanned", "toml_datetime", "winnow", ] diff --git a/Cargo.toml b/Cargo.toml index 6b8cd32a..ac4fc77c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,11 +20,11 @@ solana = "3.0.0" level = "warn" check-cfg = [ 'cfg(target_os, values("solana"))', - 'cfg(feature, values("custom-heap", "custom-panic", "frozen-abi", "no-entrypoint"))', + 'cfg(feature, values("codama", "custom-heap", "custom-panic", "frozen-abi", "no-entrypoint"))', ] [workspace.metadata.toolchains] -build = "1.86.0" +build = "1.90.0" format = "nightly-2025-02-16" lint = "nightly-2025-02-16" test = "nightly-2025-02-16" diff --git a/Makefile b/Makefile index 0fd1d3c9..047d2ffa 100644 --- a/Makefile +++ b/Makefile @@ -84,6 +84,9 @@ stop-test-validator: generate-clients: pnpm generate:clients $(ARGS) +generate-idl-%: + cargo run --manifest-path $(call make-path,$*)/Cargo.toml --features codama --bin generate-idl $(ARGS) + # Helpers for publishing tag-name = $(lastword $(subst /, ,$(call make-path,$1))) preid-arg = $(subst pre,--preid $2,$(findstring pre,$1)) diff --git a/clients/js/src/generated/instructions/authorize.ts b/clients/js/src/generated/instructions/authorize.ts index fd9c0d12..4411210b 100644 --- a/clients/js/src/generated/instructions/authorize.ts +++ b/clients/js/src/generated/instructions/authorize.ts @@ -133,9 +133,9 @@ export type AuthorizeInput< stake: Address; /** Clock sysvar */ clockSysvar?: Address; - /** Stake or withdraw authority */ + /** The stake or withdraw authority */ authority: TransactionSigner; - /** Lockup authority */ + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; arg0: AuthorizeInstructionDataArgs['arg0']; arg1: AuthorizeInstructionDataArgs['arg1']; @@ -220,9 +220,9 @@ export type ParsedAuthorizeInstruction< stake: TAccountMetas[0]; /** Clock sysvar */ clockSysvar: TAccountMetas[1]; - /** Stake or withdraw authority */ + /** The stake or withdraw authority */ authority: TAccountMetas[2]; - /** Lockup authority */ + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TAccountMetas[3] | undefined; }; data: AuthorizeInstructionData; diff --git a/clients/js/src/generated/instructions/authorizeChecked.ts b/clients/js/src/generated/instructions/authorizeChecked.ts index eafcaf60..b230f69f 100644 --- a/clients/js/src/generated/instructions/authorizeChecked.ts +++ b/clients/js/src/generated/instructions/authorizeChecked.ts @@ -137,7 +137,7 @@ export type AuthorizeCheckedInput< authority: TransactionSigner; /** The new stake or withdraw authority */ newAuthority: TransactionSigner; - /** Lockup authority */ + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; stakeAuthorize: AuthorizeCheckedInstructionDataArgs['stakeAuthorize']; }; @@ -231,7 +231,7 @@ export type ParsedAuthorizeCheckedInstruction< authority: TAccountMetas[2]; /** The new stake or withdraw authority */ newAuthority: TAccountMetas[3]; - /** Lockup authority */ + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TAccountMetas[4] | undefined; }; data: AuthorizeCheckedInstructionData; diff --git a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts index 66a5519c..317277e1 100644 --- a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts @@ -156,7 +156,7 @@ export type AuthorizeCheckedWithSeedInput< clockSysvar?: Address; /** The new stake or withdraw authority */ newAuthority: TransactionSigner; - /** Lockup authority */ + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; stakeAuthorize: AuthorizeCheckedWithSeedInstructionDataArgs['stakeAuthorize']; authoritySeed: AuthorizeCheckedWithSeedInstructionDataArgs['authoritySeed']; @@ -252,7 +252,7 @@ export type ParsedAuthorizeCheckedWithSeedInstruction< clockSysvar: TAccountMetas[2]; /** The new stake or withdraw authority */ newAuthority: TAccountMetas[3]; - /** Lockup authority */ + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TAccountMetas[4] | undefined; }; data: AuthorizeCheckedWithSeedInstructionData; diff --git a/clients/js/src/generated/instructions/authorizeWithSeed.ts b/clients/js/src/generated/instructions/authorizeWithSeed.ts index 0f103252..0007b5b7 100644 --- a/clients/js/src/generated/instructions/authorizeWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeWithSeed.ts @@ -149,7 +149,7 @@ export type AuthorizeWithSeedInput< base: TransactionSigner; /** Clock sysvar */ clockSysvar?: Address; - /** Lockup authority */ + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; newAuthorizedPubkey: AuthorizeWithSeedInstructionDataArgs['newAuthorizedPubkey']; stakeAuthorize: AuthorizeWithSeedInstructionDataArgs['stakeAuthorize']; @@ -238,7 +238,7 @@ export type ParsedAuthorizeWithSeedInstruction< base: TAccountMetas[1]; /** Clock sysvar */ clockSysvar: TAccountMetas[2]; - /** Lockup authority */ + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TAccountMetas[3] | undefined; }; data: AuthorizeWithSeedInstructionData; diff --git a/clients/js/src/generated/instructions/deactivate.ts b/clients/js/src/generated/instructions/deactivate.ts index c6d73b86..7bbce5a8 100644 --- a/clients/js/src/generated/instructions/deactivate.ts +++ b/clients/js/src/generated/instructions/deactivate.ts @@ -93,7 +93,7 @@ export type DeactivateInput< TAccountClockSysvar extends string = string, TAccountStakeAuthority extends string = string, > = { - /** Delegated stake account */ + /** Delegated stake account to be deactivated */ stake: Address; /** Clock sysvar */ clockSysvar?: Address; @@ -162,7 +162,7 @@ export type ParsedDeactivateInstruction< > = { programAddress: Address; accounts: { - /** Delegated stake account */ + /** Delegated stake account to be deactivated */ stake: TAccountMetas[0]; /** Clock sysvar */ clockSysvar: TAccountMetas[1]; diff --git a/clients/js/src/generated/instructions/deactivateDelinquent.ts b/clients/js/src/generated/instructions/deactivateDelinquent.ts index b1df56cb..88ecf8ad 100644 --- a/clients/js/src/generated/instructions/deactivateDelinquent.ts +++ b/clients/js/src/generated/instructions/deactivateDelinquent.ts @@ -92,9 +92,9 @@ export type DeactivateDelinquentInput< > = { /** Delegated stake account */ stake: Address; - /** Delinquent vote account */ + /** Delinquent vote account for the delegated stake account */ delinquentVote: Address; - /** Reference vote account */ + /** Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs */ referenceVote: Address; }; @@ -155,9 +155,9 @@ export type ParsedDeactivateDelinquentInstruction< accounts: { /** Delegated stake account */ stake: TAccountMetas[0]; - /** Delinquent vote account */ + /** Delinquent vote account for the delegated stake account */ delinquentVote: TAccountMetas[1]; - /** Reference vote account */ + /** Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs */ referenceVote: TAccountMetas[2]; }; data: DeactivateDelinquentInstructionData; diff --git a/clients/js/src/generated/instructions/delegateStake.ts b/clients/js/src/generated/instructions/delegateStake.ts index 0b712b93..1797f2fe 100644 --- a/clients/js/src/generated/instructions/delegateStake.ts +++ b/clients/js/src/generated/instructions/delegateStake.ts @@ -44,7 +44,9 @@ export type DelegateStakeInstruction< TAccountClockSysvar extends | string | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', - TAccountStakeHistory extends string | AccountMeta = string, + TAccountStakeHistory extends + | string + | AccountMeta = 'SysvarStakeHistory1111111111111111111111111', TAccountUnused extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], @@ -114,8 +116,8 @@ export type DelegateStakeInput< vote: Address; /** Clock sysvar */ clockSysvar?: Address; - /** Stake history sysvar */ - stakeHistory: Address; + /** Stake history sysvar that carries stake warmup/cooldown history */ + stakeHistory?: Address; /** Unused account, formerly the stake config */ unused: Address; /** Stake authority */ @@ -171,6 +173,10 @@ export function getDelegateStakeInstruction< accounts.clockSysvar.value = 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; } + if (!accounts.stakeHistory.value) { + accounts.stakeHistory.value = + 'SysvarStakeHistory1111111111111111111111111' as Address<'SysvarStakeHistory1111111111111111111111111'>; + } const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ @@ -207,7 +213,7 @@ export type ParsedDelegateStakeInstruction< vote: TAccountMetas[1]; /** Clock sysvar */ clockSysvar: TAccountMetas[2]; - /** Stake history sysvar */ + /** Stake history sysvar that carries stake warmup/cooldown history */ stakeHistory: TAccountMetas[3]; /** Unused account, formerly the stake config */ unused: TAccountMetas[4]; diff --git a/clients/js/src/generated/instructions/merge.ts b/clients/js/src/generated/instructions/merge.ts index 502cfd33..f792d606 100644 --- a/clients/js/src/generated/instructions/merge.ts +++ b/clients/js/src/generated/instructions/merge.ts @@ -44,7 +44,9 @@ export type MergeInstruction< TAccountClockSysvar extends | string | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', - TAccountStakeHistory extends string | AccountMeta = string, + TAccountStakeHistory extends + | string + | AccountMeta = 'SysvarStakeHistory1111111111111111111111111', TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & @@ -103,14 +105,14 @@ export type MergeInput< TAccountStakeHistory extends string = string, TAccountStakeAuthority extends string = string, > = { - /** Destination stake account */ + /** Destination stake account for the merge */ destinationStake: Address; - /** Source stake account */ + /** Source stake account for to merge. This account will be drained */ sourceStake: Address; /** Clock sysvar */ clockSysvar?: Address; - /** Stake history sysvar */ - stakeHistory: Address; + /** Stake history sysvar that carries stake warmup/cooldown history */ + stakeHistory?: Address; /** Stake authority */ stakeAuthority: TransactionSigner; }; @@ -163,6 +165,10 @@ export function getMergeInstruction< accounts.clockSysvar.value = 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; } + if (!accounts.stakeHistory.value) { + accounts.stakeHistory.value = + 'SysvarStakeHistory1111111111111111111111111' as Address<'SysvarStakeHistory1111111111111111111111111'>; + } const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ @@ -191,13 +197,13 @@ export type ParsedMergeInstruction< > = { programAddress: Address; accounts: { - /** Destination stake account */ + /** Destination stake account for the merge */ destinationStake: TAccountMetas[0]; - /** Source stake account */ + /** Source stake account for to merge. This account will be drained */ sourceStake: TAccountMetas[1]; /** Clock sysvar */ clockSysvar: TAccountMetas[2]; - /** Stake history sysvar */ + /** Stake history sysvar that carries stake warmup/cooldown history */ stakeHistory: TAccountMetas[3]; /** Stake authority */ stakeAuthority: TAccountMetas[4]; diff --git a/clients/js/src/generated/instructions/setLockup.ts b/clients/js/src/generated/instructions/setLockup.ts index 1e082f68..18dc14b1 100644 --- a/clients/js/src/generated/instructions/setLockup.ts +++ b/clients/js/src/generated/instructions/setLockup.ts @@ -10,16 +10,12 @@ import { combineCodec, getAddressDecoder, getAddressEncoder, - getI64Decoder, - getI64Encoder, getOptionDecoder, getOptionEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, - getU64Decoder, - getU64Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -39,6 +35,16 @@ import { } from '@solana/kit'; import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getEpochDecoder, + getEpochEncoder, + getUnixTimestampDecoder, + getUnixTimestampEncoder, + type Epoch, + type EpochArgs, + type UnixTimestamp, + type UnixTimestampArgs, +} from '../types'; export const SET_LOCKUP_DISCRIMINATOR = 6; @@ -68,14 +74,14 @@ export type SetLockupInstruction< export type SetLockupInstructionData = { discriminator: number; - unixTimestamp: Option; - epoch: Option; + unixTimestamp: Option; + epoch: Option; custodian: Option
; }; export type SetLockupInstructionDataArgs = { - unixTimestamp: OptionOrNullable; - epoch: OptionOrNullable; + unixTimestamp: OptionOrNullable; + epoch: OptionOrNullable; custodian: OptionOrNullable
; }; @@ -83,8 +89,8 @@ export function getSetLockupInstructionDataEncoder(): Encoder ({ ...value, discriminator: SET_LOCKUP_DISCRIMINATOR }) @@ -94,8 +100,8 @@ export function getSetLockupInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['unixTimestamp', getOptionDecoder(getI64Decoder())], - ['epoch', getOptionDecoder(getU64Decoder())], + ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], + ['epoch', getOptionDecoder(getEpochDecoder())], ['custodian', getOptionDecoder(getAddressDecoder())], ]); } diff --git a/clients/js/src/generated/instructions/setLockupChecked.ts b/clients/js/src/generated/instructions/setLockupChecked.ts index 12aea9b8..7256b7ad 100644 --- a/clients/js/src/generated/instructions/setLockupChecked.ts +++ b/clients/js/src/generated/instructions/setLockupChecked.ts @@ -8,16 +8,12 @@ import { combineCodec, - getI64Decoder, - getI64Encoder, getOptionDecoder, getOptionEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, - getU64Decoder, - getU64Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -37,6 +33,16 @@ import { } from '@solana/kit'; import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getEpochDecoder, + getEpochEncoder, + getUnixTimestampDecoder, + getUnixTimestampEncoder, + type Epoch, + type EpochArgs, + type UnixTimestamp, + type UnixTimestampArgs, +} from '../types'; export const SET_LOCKUP_CHECKED_DISCRIMINATOR = 12; @@ -78,21 +84,21 @@ export type SetLockupCheckedInstruction< export type SetLockupCheckedInstructionData = { discriminator: number; - unixTimestamp: Option; - epoch: Option; + unixTimestamp: Option; + epoch: Option; }; export type SetLockupCheckedInstructionDataArgs = { - unixTimestamp: OptionOrNullable; - epoch: OptionOrNullable; + unixTimestamp: OptionOrNullable; + epoch: OptionOrNullable; }; export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['unixTimestamp', getOptionEncoder(getI64Encoder())], - ['epoch', getOptionEncoder(getU64Encoder())], + ['unixTimestamp', getOptionEncoder(getUnixTimestampEncoder())], + ['epoch', getOptionEncoder(getEpochEncoder())], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_CHECKED_DISCRIMINATOR }) ); @@ -101,8 +107,8 @@ export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['unixTimestamp', getOptionDecoder(getI64Decoder())], - ['epoch', getOptionDecoder(getU64Decoder())], + ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], + ['epoch', getOptionDecoder(getEpochDecoder())], ]); } diff --git a/clients/js/src/generated/instructions/split.ts b/clients/js/src/generated/instructions/split.ts index a01549bf..7095c7a3 100644 --- a/clients/js/src/generated/instructions/split.ts +++ b/clients/js/src/generated/instructions/split.ts @@ -98,9 +98,9 @@ export type SplitInput< TAccountSplitStake extends string = string, TAccountStakeAuthority extends string = string, > = { - /** Stake account to be split */ + /** Stake account to be split; must be in the Initialized or Stake state */ stake: Address; - /** Uninitialized stake account */ + /** Uninitialized stake account that will take the split-off amount */ splitStake: Address; /** Stake authority */ stakeAuthority: TransactionSigner; @@ -163,9 +163,9 @@ export type ParsedSplitInstruction< > = { programAddress: Address; accounts: { - /** Stake account to be split */ + /** Stake account to be split; must be in the Initialized or Stake state */ stake: TAccountMetas[0]; - /** Uninitialized stake account */ + /** Uninitialized stake account that will take the split-off amount */ splitStake: TAccountMetas[1]; /** Stake authority */ stakeAuthority: TAccountMetas[2]; diff --git a/clients/js/src/generated/instructions/withdraw.ts b/clients/js/src/generated/instructions/withdraw.ts index f48b433a..e19c0b77 100644 --- a/clients/js/src/generated/instructions/withdraw.ts +++ b/clients/js/src/generated/instructions/withdraw.ts @@ -46,7 +46,9 @@ export type WithdrawInstruction< TAccountClockSysvar extends | string | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', - TAccountStakeHistory extends string | AccountMeta = string, + TAccountStakeHistory extends + | string + | AccountMeta = 'SysvarStakeHistory1111111111111111111111111', TAccountWithdrawAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends | string @@ -130,11 +132,11 @@ export type WithdrawInput< recipient: Address; /** Clock sysvar */ clockSysvar?: Address; - /** Stake history sysvar */ - stakeHistory: Address; + /** Stake history sysvar that carries stake warmup/cooldown history */ + stakeHistory?: Address; /** Withdraw authority */ withdrawAuthority: TransactionSigner; - /** Lockup authority */ + /** Lockup authority, if before lockup expiration */ lockupAuthority?: TransactionSigner; args: WithdrawInstructionDataArgs['args']; }; @@ -197,6 +199,10 @@ export function getWithdrawInstruction< accounts.clockSysvar.value = 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; } + if (!accounts.stakeHistory.value) { + accounts.stakeHistory.value = + 'SysvarStakeHistory1111111111111111111111111' as Address<'SysvarStakeHistory1111111111111111111111111'>; + } const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ @@ -235,11 +241,11 @@ export type ParsedWithdrawInstruction< recipient: TAccountMetas[1]; /** Clock sysvar */ clockSysvar: TAccountMetas[2]; - /** Stake history sysvar */ + /** Stake history sysvar that carries stake warmup/cooldown history */ stakeHistory: TAccountMetas[3]; /** Withdraw authority */ withdrawAuthority: TAccountMetas[4]; - /** Lockup authority */ + /** Lockup authority, if before lockup expiration */ lockupAuthority?: TAccountMetas[5] | undefined; }; data: WithdrawInstructionData; diff --git a/clients/js/src/generated/types/delegation.ts b/clients/js/src/generated/types/delegation.ts index 0e50a564..f9c7acbf 100644 --- a/clients/js/src/generated/types/delegation.ts +++ b/clients/js/src/generated/types/delegation.ts @@ -21,20 +21,26 @@ import { type FixedSizeDecoder, type FixedSizeEncoder, } from '@solana/kit'; +import { + getEpochDecoder, + getEpochEncoder, + type Epoch, + type EpochArgs, +} from '.'; export type Delegation = { voterPubkey: Address; stake: bigint; - activationEpoch: bigint; - deactivationEpoch: bigint; + activationEpoch: Epoch; + deactivationEpoch: Epoch; warmupCooldownRate: number; }; export type DelegationArgs = { voterPubkey: Address; stake: number | bigint; - activationEpoch: number | bigint; - deactivationEpoch: number | bigint; + activationEpoch: EpochArgs; + deactivationEpoch: EpochArgs; warmupCooldownRate: number; }; @@ -42,8 +48,8 @@ export function getDelegationEncoder(): FixedSizeEncoder { return getStructEncoder([ ['voterPubkey', getAddressEncoder()], ['stake', getU64Encoder()], - ['activationEpoch', getU64Encoder()], - ['deactivationEpoch', getU64Encoder()], + ['activationEpoch', getEpochEncoder()], + ['deactivationEpoch', getEpochEncoder()], ['warmupCooldownRate', getF64Encoder()], ]); } @@ -52,8 +58,8 @@ export function getDelegationDecoder(): FixedSizeDecoder { return getStructDecoder([ ['voterPubkey', getAddressDecoder()], ['stake', getU64Decoder()], - ['activationEpoch', getU64Decoder()], - ['deactivationEpoch', getU64Decoder()], + ['activationEpoch', getEpochDecoder()], + ['deactivationEpoch', getEpochDecoder()], ['warmupCooldownRate', getF64Decoder()], ]); } diff --git a/clients/js/src/generated/types/epoch.ts b/clients/js/src/generated/types/epoch.ts new file mode 100644 index 00000000..5ab8fd61 --- /dev/null +++ b/clients/js/src/generated/types/epoch.ts @@ -0,0 +1,32 @@ +/** + * This code was AUTOGENERATED using the Codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun Codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getU64Decoder, + getU64Encoder, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, +} from '@solana/kit'; + +export type Epoch = bigint; + +export type EpochArgs = number | bigint; + +export function getEpochEncoder(): FixedSizeEncoder { + return getU64Encoder(); +} + +export function getEpochDecoder(): FixedSizeDecoder { + return getU64Decoder(); +} + +export function getEpochCodec(): FixedSizeCodec { + return combineCodec(getEpochEncoder(), getEpochDecoder()); +} diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index edb794d1..7fd6869d 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -8,6 +8,7 @@ export * from './authorized'; export * from './delegation'; +export * from './epoch'; export * from './lockup'; export * from './meta'; export * from './stake'; @@ -15,3 +16,4 @@ export * from './stakeAuthorize'; export * from './stakeFlags'; export * from './stakeState'; export * from './stakeStateV2'; +export * from './unixTimestamp'; diff --git a/clients/js/src/generated/types/lockup.ts b/clients/js/src/generated/types/lockup.ts index 3d3a5343..debab244 100644 --- a/clients/js/src/generated/types/lockup.ts +++ b/clients/js/src/generated/types/lockup.ts @@ -10,42 +10,48 @@ import { combineCodec, getAddressDecoder, getAddressEncoder, - getI64Decoder, - getI64Encoder, getStructDecoder, getStructEncoder, - getU64Decoder, - getU64Encoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, } from '@solana/kit'; +import { + getEpochDecoder, + getEpochEncoder, + getUnixTimestampDecoder, + getUnixTimestampEncoder, + type Epoch, + type EpochArgs, + type UnixTimestamp, + type UnixTimestampArgs, +} from '.'; export type Lockup = { - unixTimestamp: bigint; - epoch: bigint; + unixTimestamp: UnixTimestamp; + epoch: Epoch; custodian: Address; }; export type LockupArgs = { - unixTimestamp: number | bigint; - epoch: number | bigint; + unixTimestamp: UnixTimestampArgs; + epoch: EpochArgs; custodian: Address; }; export function getLockupEncoder(): FixedSizeEncoder { return getStructEncoder([ - ['unixTimestamp', getI64Encoder()], - ['epoch', getU64Encoder()], + ['unixTimestamp', getUnixTimestampEncoder()], + ['epoch', getEpochEncoder()], ['custodian', getAddressEncoder()], ]); } export function getLockupDecoder(): FixedSizeDecoder { return getStructDecoder([ - ['unixTimestamp', getI64Decoder()], - ['epoch', getU64Decoder()], + ['unixTimestamp', getUnixTimestampDecoder()], + ['epoch', getEpochDecoder()], ['custodian', getAddressDecoder()], ]); } diff --git a/clients/js/src/generated/types/unixTimestamp.ts b/clients/js/src/generated/types/unixTimestamp.ts new file mode 100644 index 00000000..7b9daeb5 --- /dev/null +++ b/clients/js/src/generated/types/unixTimestamp.ts @@ -0,0 +1,35 @@ +/** + * This code was AUTOGENERATED using the Codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun Codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getI64Decoder, + getI64Encoder, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, +} from '@solana/kit'; + +export type UnixTimestamp = bigint; + +export type UnixTimestampArgs = number | bigint; + +export function getUnixTimestampEncoder(): FixedSizeEncoder { + return getI64Encoder(); +} + +export function getUnixTimestampDecoder(): FixedSizeDecoder { + return getI64Decoder(); +} + +export function getUnixTimestampCodec(): FixedSizeCodec< + UnixTimestampArgs, + UnixTimestamp +> { + return combineCodec(getUnixTimestampEncoder(), getUnixTimestampDecoder()); +} diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index debc9be8..2419fefa 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -11,12 +11,16 @@ license-file = "../../LICENSE" serde = ["dep:serde", "dep:serde_with"] [dependencies] -borsh = "1.5" +borsh = { version = "1.5", features = ["derive"] } num-derive = "0.4" num-traits = "0.2" serde = { version = "1.0", features = ["derive"], optional = true } serde_with = { version = "3.15", optional = true } -solana-program = "2.2.1" +solana-account-info = "^3.0" +solana-cpi = "^3.0" +solana-instruction = "^3.0" +solana-program-error = "^3.0" +solana-pubkey = { version = "^3.0", features = ["borsh", "serde"] } thiserror = "2.0" [dev-dependencies] diff --git a/clients/rust/src/generated/errors/stake.rs b/clients/rust/src/generated/errors/stake.rs index cae66e42..068f5267 100644 --- a/clients/rust/src/generated/errors/stake.rs +++ b/clients/rust/src/generated/errors/stake.rs @@ -64,14 +64,8 @@ pub enum StakeError { EpochRewardsActive = 0x10, } -impl solana_program::program_error::PrintProgramError for StakeError { - fn print(&self) { - solana_program::msg!(&self.to_string()); - } -} - -impl solana_program::decode_error::DecodeError for StakeError { - fn type_of() -> &'static str { - "StakeError" +impl From for solana_program_error::ProgramError { + fn from(e: StakeError) -> Self { + solana_program_error::ProgramError::Custom(e as u32) } } diff --git a/clients/rust/src/generated/instructions/authorize.rs b/clients/rust/src/generated/instructions/authorize.rs index 2231c750..2ad2add7 100644 --- a/clients/rust/src/generated/instructions/authorize.rs +++ b/clients/rust/src/generated/instructions/authorize.rs @@ -8,59 +8,57 @@ use { crate::generated::types::StakeAuthorize, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, + solana_pubkey::Pubkey, }; +pub const AUTHORIZE_DISCRIMINATOR: u32 = 1; + /// Accounts. #[derive(Debug)] pub struct Authorize { /// Stake account to be updated - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake or withdraw authority - pub authority: solana_program::pubkey::Pubkey, - /// Lockup authority - pub lockup_authority: Option, + pub clock_sysvar: solana_pubkey::Pubkey, + /// The stake or withdraw authority + pub authority: solana_pubkey::Pubkey, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option, } impl Authorize { - pub fn instruction( - &self, - args: AuthorizeInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: AuthorizeInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: AuthorizeInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.clock_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( lockup_authority, true, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AuthorizeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AuthorizeInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -78,6 +76,10 @@ impl AuthorizeInstructionData { pub fn new() -> Self { Self { discriminator: 1 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AuthorizeInstructionData { @@ -93,6 +95,12 @@ pub struct AuthorizeInstructionArgs { pub arg1: StakeAuthorize, } +impl AuthorizeInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Authorize`. /// /// ### Accounts: @@ -103,13 +111,13 @@ pub struct AuthorizeInstructionArgs { /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeBuilder { - stake: Option, - clock_sysvar: Option, - authority: Option, - lockup_authority: Option, + stake: Option, + clock_sysvar: Option, + authority: Option, + lockup_authority: Option, arg0: Option, arg1: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AuthorizeBuilder { @@ -118,29 +126,29 @@ impl AuthorizeBuilder { } /// Stake account to be updated #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn clock_sysvar(&mut self, clock_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } - /// Stake or withdraw authority + /// The stake or withdraw authority #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option, + lockup_authority: Option, ) -> &mut Self { self.lockup_authority = lockup_authority; self @@ -157,10 +165,7 @@ impl AuthorizeBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -168,16 +173,16 @@ impl AuthorizeBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Authorize { stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + clock_sysvar: self.clock_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), authority: self.authority.expect("authority is not set"), @@ -195,34 +200,34 @@ impl AuthorizeBuilder { /// `authorize` CPI accounts. pub struct AuthorizeCpiAccounts<'a, 'b> { /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// The stake or withdraw authority + pub authority: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `authorize` CPI instruction. pub struct AuthorizeCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// The stake or withdraw authority + pub authority: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeInstructionArgs, } impl<'a, 'b> AuthorizeCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AuthorizeCpiAccounts<'a, 'b>, args: AuthorizeInstructionArgs, ) -> Self { @@ -236,69 +241,56 @@ impl<'a, 'b> AuthorizeCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *lockup_authority.key, true, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AuthorizeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AuthorizeInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -316,9 +308,9 @@ impl<'a, 'b> AuthorizeCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -337,7 +329,7 @@ pub struct AuthorizeCpiBuilder<'a, 'b> { } impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AuthorizeCpiBuilderInstruction { __program: program, stake: None, @@ -352,7 +344,7 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { } /// Stake account to be updated #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } @@ -360,26 +352,23 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { #[inline(always)] pub fn clock_sysvar( &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + clock_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Stake or withdraw authority + /// The stake or withdraw authority #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.lockup_authority = lockup_authority; self @@ -398,7 +387,7 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -414,11 +403,7 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -426,15 +411,12 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AuthorizeInstructionArgs { arg0: self.instruction.arg0.clone().expect("arg0 is not set"), arg1: self.instruction.arg1.clone().expect("arg1 is not set"), @@ -463,17 +445,13 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AuthorizeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, arg0: Option, arg1: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/authorize_checked.rs b/clients/rust/src/generated/instructions/authorize_checked.rs index 62476187..70873adf 100644 --- a/clients/rust/src/generated/instructions/authorize_checked.rs +++ b/clients/rust/src/generated/instructions/authorize_checked.rs @@ -10,62 +10,63 @@ use { borsh::{BorshDeserialize, BorshSerialize}, }; +pub const AUTHORIZE_CHECKED_DISCRIMINATOR: u32 = 10; + /// Accounts. #[derive(Debug)] pub struct AuthorizeChecked { /// Stake account to be updated - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_pubkey::Pubkey, /// The stake or withdraw authority - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// The new stake or withdraw authority - pub new_authority: solana_program::pubkey::Pubkey, - /// Lockup authority - pub lockup_authority: Option, + pub new_authority: solana_pubkey::Pubkey, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option, } impl AuthorizeChecked { pub fn instruction( &self, args: AuthorizeCheckedInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: AuthorizeCheckedInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.clock_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.new_authority, true, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( lockup_authority, true, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AuthorizeCheckedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AuthorizeCheckedInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -83,6 +84,10 @@ impl AuthorizeCheckedInstructionData { pub fn new() -> Self { Self { discriminator: 10 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AuthorizeCheckedInstructionData { @@ -97,6 +102,12 @@ pub struct AuthorizeCheckedInstructionArgs { pub stake_authorize: StakeAuthorize, } +impl AuthorizeCheckedInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `AuthorizeChecked`. /// /// ### Accounts: @@ -108,13 +119,13 @@ pub struct AuthorizeCheckedInstructionArgs { /// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeCheckedBuilder { - stake: Option, - clock_sysvar: Option, - authority: Option, - new_authority: Option, - lockup_authority: Option, + stake: Option, + clock_sysvar: Option, + authority: Option, + new_authority: Option, + lockup_authority: Option, stake_authorize: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AuthorizeCheckedBuilder { @@ -123,35 +134,35 @@ impl AuthorizeCheckedBuilder { } /// Stake account to be updated #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn clock_sysvar(&mut self, clock_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } /// The stake or withdraw authority #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// The new stake or withdraw authority #[inline(always)] - pub fn new_authority(&mut self, new_authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn new_authority(&mut self, new_authority: solana_pubkey::Pubkey) -> &mut Self { self.new_authority = Some(new_authority); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option, + lockup_authority: Option, ) -> &mut Self { self.lockup_authority = lockup_authority; self @@ -163,10 +174,7 @@ impl AuthorizeCheckedBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -174,16 +182,16 @@ impl AuthorizeCheckedBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = AuthorizeChecked { stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + clock_sysvar: self.clock_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), authority: self.authority.expect("authority is not set"), @@ -204,38 +212,38 @@ impl AuthorizeCheckedBuilder { /// `authorize_checked` CPI accounts. pub struct AuthorizeCheckedCpiAccounts<'a, 'b> { /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// The stake or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// The new stake or withdraw authority - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub new_authority: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `authorize_checked` CPI instruction. pub struct AuthorizeCheckedCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// The stake or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// The new stake or withdraw authority - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub new_authority: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeCheckedInstructionArgs, } impl<'a, 'b> AuthorizeCheckedCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AuthorizeCheckedCpiAccounts<'a, 'b>, args: AuthorizeCheckedInstructionArgs, ) -> Self { @@ -250,73 +258,60 @@ impl<'a, 'b> AuthorizeCheckedCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.new_authority.key, true, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *lockup_authority.key, true, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AuthorizeCheckedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AuthorizeCheckedInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -335,9 +330,9 @@ impl<'a, 'b> AuthorizeCheckedCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -357,7 +352,7 @@ pub struct AuthorizeCheckedCpiBuilder<'a, 'b> { } impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AuthorizeCheckedCpiBuilderInstruction { __program: program, stake: None, @@ -372,7 +367,7 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { } /// Stake account to be updated #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } @@ -380,17 +375,14 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn clock_sysvar( &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + clock_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.clock_sysvar = Some(clock_sysvar); self } /// The stake or withdraw authority #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -398,17 +390,17 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn new_authority( &mut self, - new_authority: &'b solana_program::account_info::AccountInfo<'a>, + new_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.new_authority = Some(new_authority); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.lockup_authority = lockup_authority; self @@ -422,7 +414,7 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -438,11 +430,7 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -450,15 +438,12 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AuthorizeCheckedInstructionArgs { stake_authorize: self .instruction @@ -495,17 +480,13 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AuthorizeCheckedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + new_authority: Option<&'b solana_account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, stake_authorize: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs index d408063d..bdb7629c 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -8,64 +8,67 @@ use { crate::generated::types::StakeAuthorize, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, + solana_pubkey::Pubkey, }; +pub const AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR: u32 = 11; + /// Accounts. #[derive(Debug)] pub struct AuthorizeCheckedWithSeed { /// Stake account to be updated - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Base key of stake or withdraw authority - pub base: solana_program::pubkey::Pubkey, + pub base: solana_pubkey::Pubkey, /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_pubkey::Pubkey, /// The new stake or withdraw authority - pub new_authority: solana_program::pubkey::Pubkey, - /// Lockup authority - pub lockup_authority: Option, + pub new_authority: solana_pubkey::Pubkey, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option, } impl AuthorizeCheckedWithSeed { pub fn instruction( &self, args: AuthorizeCheckedWithSeedInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: AuthorizeCheckedWithSeedInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.base, true, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.clock_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.new_authority, true, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( lockup_authority, true, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AuthorizeCheckedWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AuthorizeCheckedWithSeedInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -83,6 +86,10 @@ impl AuthorizeCheckedWithSeedInstructionData { pub fn new() -> Self { Self { discriminator: 11 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AuthorizeCheckedWithSeedInstructionData { @@ -99,6 +106,12 @@ pub struct AuthorizeCheckedWithSeedInstructionArgs { pub authority_owner: Pubkey, } +impl AuthorizeCheckedWithSeedInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `AuthorizeCheckedWithSeed`. /// /// ### Accounts: @@ -110,15 +123,15 @@ pub struct AuthorizeCheckedWithSeedInstructionArgs { /// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeCheckedWithSeedBuilder { - stake: Option, - base: Option, - clock_sysvar: Option, - new_authority: Option, - lockup_authority: Option, + stake: Option, + base: Option, + clock_sysvar: Option, + new_authority: Option, + lockup_authority: Option, stake_authorize: Option, authority_seed: Option, authority_owner: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AuthorizeCheckedWithSeedBuilder { @@ -127,35 +140,35 @@ impl AuthorizeCheckedWithSeedBuilder { } /// Stake account to be updated #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// Base key of stake or withdraw authority #[inline(always)] - pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn base(&mut self, base: solana_pubkey::Pubkey) -> &mut Self { self.base = Some(base); self } /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn clock_sysvar(&mut self, clock_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } /// The new stake or withdraw authority #[inline(always)] - pub fn new_authority(&mut self, new_authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn new_authority(&mut self, new_authority: solana_pubkey::Pubkey) -> &mut Self { self.new_authority = Some(new_authority); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option, + lockup_authority: Option, ) -> &mut Self { self.lockup_authority = lockup_authority; self @@ -177,10 +190,7 @@ impl AuthorizeCheckedWithSeedBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -188,17 +198,17 @@ impl AuthorizeCheckedWithSeedBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = AuthorizeCheckedWithSeed { stake: self.stake.expect("stake is not set"), base: self.base.expect("base is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + clock_sysvar: self.clock_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), new_authority: self.new_authority.expect("new_authority is not set"), @@ -226,38 +236,38 @@ impl AuthorizeCheckedWithSeedBuilder { /// `authorize_checked_with_seed` CPI accounts. pub struct AuthorizeCheckedWithSeedCpiAccounts<'a, 'b> { /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, + pub base: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// The new stake or withdraw authority - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub new_authority: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `authorize_checked_with_seed` CPI instruction. pub struct AuthorizeCheckedWithSeedCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, + pub base: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// The new stake or withdraw authority - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub new_authority: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeCheckedWithSeedInstructionArgs, } impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AuthorizeCheckedWithSeedCpiAccounts<'a, 'b>, args: AuthorizeCheckedWithSeedInstructionArgs, ) -> Self { @@ -272,73 +282,62 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.base.key, true, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.new_authority.key, true, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *lockup_authority.key, true, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AuthorizeCheckedWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AuthorizeCheckedWithSeedInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -357,9 +356,9 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -379,7 +378,7 @@ pub struct AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { } impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AuthorizeCheckedWithSeedCpiBuilderInstruction { __program: program, stake: None, @@ -396,13 +395,13 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { } /// Stake account to be updated #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } /// Base key of stake or withdraw authority #[inline(always)] - pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn base(&mut self, base: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.base = Some(base); self } @@ -410,7 +409,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn clock_sysvar( &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + clock_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.clock_sysvar = Some(clock_sysvar); self @@ -419,17 +418,17 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn new_authority( &mut self, - new_authority: &'b solana_program::account_info::AccountInfo<'a>, + new_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.new_authority = Some(new_authority); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.lockup_authority = lockup_authority; self @@ -453,7 +452,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -469,11 +468,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -481,15 +476,12 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AuthorizeCheckedWithSeedInstructionArgs { stake_authorize: self .instruction @@ -536,19 +528,15 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AuthorizeCheckedWithSeedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - base: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + base: Option<&'b solana_account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + new_authority: Option<&'b solana_account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, stake_authorize: Option, authority_seed: Option, authority_owner: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index 86b83f62..45e2eab7 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -8,58 +8,61 @@ use { crate::generated::types::StakeAuthorize, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, + solana_pubkey::Pubkey, }; +pub const AUTHORIZE_WITH_SEED_DISCRIMINATOR: u32 = 8; + /// Accounts. #[derive(Debug)] pub struct AuthorizeWithSeed { /// Stake account to be updated - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Base key of stake or withdraw authority - pub base: solana_program::pubkey::Pubkey, + pub base: solana_pubkey::Pubkey, /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Lockup authority - pub lockup_authority: Option, + pub clock_sysvar: solana_pubkey::Pubkey, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option, } impl AuthorizeWithSeed { pub fn instruction( &self, args: AuthorizeWithSeedInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: AuthorizeWithSeedInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.base, true, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.clock_sysvar, false, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( lockup_authority, true, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AuthorizeWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AuthorizeWithSeedInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -77,6 +80,10 @@ impl AuthorizeWithSeedInstructionData { pub fn new() -> Self { Self { discriminator: 8 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AuthorizeWithSeedInstructionData { @@ -94,6 +101,12 @@ pub struct AuthorizeWithSeedInstructionArgs { pub authority_owner: Pubkey, } +impl AuthorizeWithSeedInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `AuthorizeWithSeed`. /// /// ### Accounts: @@ -104,15 +117,15 @@ pub struct AuthorizeWithSeedInstructionArgs { /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeWithSeedBuilder { - stake: Option, - base: Option, - clock_sysvar: Option, - lockup_authority: Option, + stake: Option, + base: Option, + clock_sysvar: Option, + lockup_authority: Option, new_authorized_pubkey: Option, stake_authorize: Option, authority_seed: Option, authority_owner: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AuthorizeWithSeedBuilder { @@ -121,29 +134,29 @@ impl AuthorizeWithSeedBuilder { } /// Stake account to be updated #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// Base key of stake or withdraw authority #[inline(always)] - pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn base(&mut self, base: solana_pubkey::Pubkey) -> &mut Self { self.base = Some(base); self } /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn clock_sysvar(&mut self, clock_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option, + lockup_authority: Option, ) -> &mut Self { self.lockup_authority = lockup_authority; self @@ -170,10 +183,7 @@ impl AuthorizeWithSeedBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -181,17 +191,17 @@ impl AuthorizeWithSeedBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = AuthorizeWithSeed { stake: self.stake.expect("stake is not set"), base: self.base.expect("base is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + clock_sysvar: self.clock_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), lockup_authority: self.lockup_authority, @@ -222,34 +232,34 @@ impl AuthorizeWithSeedBuilder { /// `authorize_with_seed` CPI accounts. pub struct AuthorizeWithSeedCpiAccounts<'a, 'b> { /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, + pub base: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `authorize_with_seed` CPI instruction. pub struct AuthorizeWithSeedCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, + pub base: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeWithSeedInstructionArgs, } impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AuthorizeWithSeedCpiAccounts<'a, 'b>, args: AuthorizeWithSeedInstructionArgs, ) -> Self { @@ -263,69 +273,58 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.base.key, true, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, false, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *lockup_authority.key, true, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AuthorizeWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AuthorizeWithSeedInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -343,9 +342,9 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -364,7 +363,7 @@ pub struct AuthorizeWithSeedCpiBuilder<'a, 'b> { } impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AuthorizeWithSeedCpiBuilderInstruction { __program: program, stake: None, @@ -381,13 +380,13 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { } /// Stake account to be updated #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } /// Base key of stake or withdraw authority #[inline(always)] - pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn base(&mut self, base: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.base = Some(base); self } @@ -395,17 +394,17 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn clock_sysvar( &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + clock_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.clock_sysvar = Some(clock_sysvar); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.lockup_authority = lockup_authority; self @@ -434,7 +433,7 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -450,11 +449,7 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -462,15 +457,12 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AuthorizeWithSeedInstructionArgs { new_authorized_pubkey: self .instruction @@ -517,19 +509,15 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AuthorizeWithSeedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - base: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + base: Option<&'b solana_account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, new_authorized_pubkey: Option, stake_authorize: Option, authority_seed: Option, authority_owner: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/deactivate.rs b/clients/rust/src/generated/instructions/deactivate.rs index 468e458b..67a76ba2 100644 --- a/clients/rust/src/generated/instructions/deactivate.rs +++ b/clients/rust/src/generated/instructions/deactivate.rs @@ -7,42 +7,43 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const DEACTIVATE_DISCRIMINATOR: u32 = 5; + /// Accounts. #[derive(Debug)] pub struct Deactivate { - /// Delegated stake account - pub stake: solana_program::pubkey::Pubkey, + /// Delegated stake account to be deactivated + pub stake: solana_pubkey::Pubkey, /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_pubkey::Pubkey, /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, + pub stake_authority: solana_pubkey::Pubkey, } impl Deactivate { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.clock_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DeactivateInstructionData::new()).unwrap(); + let data = DeactivateInstructionData::new().try_to_vec().unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -60,6 +61,10 @@ impl DeactivateInstructionData { pub fn new() -> Self { Self { discriminator: 5 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for DeactivateInstructionData { @@ -77,44 +82,38 @@ impl Default for DeactivateInstructionData { /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct DeactivateBuilder { - stake: Option, - clock_sysvar: Option, - stake_authority: Option, - __remaining_accounts: Vec, + stake: Option, + clock_sysvar: Option, + stake_authority: Option, + __remaining_accounts: Vec, } impl DeactivateBuilder { pub fn new() -> Self { Self::default() } - /// Delegated stake account + /// Delegated stake account to be deactivated #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn clock_sysvar(&mut self, clock_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } /// Stake authority #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn stake_authority(&mut self, stake_authority: solana_pubkey::Pubkey) -> &mut Self { self.stake_authority = Some(stake_authority); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -122,16 +121,16 @@ impl DeactivateBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Deactivate { stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + clock_sysvar: self.clock_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), stake_authority: self.stake_authority.expect("stake_authority is not set"), @@ -143,29 +142,29 @@ impl DeactivateBuilder { /// `deactivate` CPI accounts. pub struct DeactivateCpiAccounts<'a, 'b> { - /// Delegated stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Delegated stake account to be deactivated + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, } /// `deactivate` CPI instruction. pub struct DeactivateCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Delegated stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, + /// Delegated stake account to be deactivated + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> DeactivateCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: DeactivateCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -176,61 +175,48 @@ impl<'a, 'b> DeactivateCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&DeactivateInstructionData::new()).unwrap(); + let data = DeactivateInstructionData::new().try_to_vec().unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -245,9 +231,9 @@ impl<'a, 'b> DeactivateCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -265,7 +251,7 @@ pub struct DeactivateCpiBuilder<'a, 'b> { } impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(DeactivateCpiBuilderInstruction { __program: program, stake: None, @@ -275,9 +261,9 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { }); Self { instruction } } - /// Delegated stake account + /// Delegated stake account to be deactivated #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } @@ -285,7 +271,7 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { #[inline(always)] pub fn clock_sysvar( &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + clock_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.clock_sysvar = Some(clock_sysvar); self @@ -294,7 +280,7 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { #[inline(always)] pub fn stake_authority( &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + stake_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_authority = Some(stake_authority); self @@ -303,7 +289,7 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -319,11 +305,7 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -331,15 +313,12 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = DeactivateCpi { __program: self.instruction.__program, @@ -364,14 +343,10 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct DeactivateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/deactivate_delinquent.rs b/clients/rust/src/generated/instructions/deactivate_delinquent.rs index 3ccc5ffe..6a2ec350 100644 --- a/clients/rust/src/generated/instructions/deactivate_delinquent.rs +++ b/clients/rust/src/generated/instructions/deactivate_delinquent.rs @@ -7,42 +7,45 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const DEACTIVATE_DELINQUENT_DISCRIMINATOR: u32 = 14; + /// Accounts. #[derive(Debug)] pub struct DeactivateDelinquent { /// Delegated stake account - pub stake: solana_program::pubkey::Pubkey, - /// Delinquent vote account - pub delinquent_vote: solana_program::pubkey::Pubkey, - /// Reference vote account - pub reference_vote: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, + /// Delinquent vote account for the delegated stake account + pub delinquent_vote: solana_pubkey::Pubkey, + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs + pub reference_vote: solana_pubkey::Pubkey, } impl DeactivateDelinquent { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.delinquent_vote, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.reference_vote, false, )); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DeactivateDelinquentInstructionData::new()).unwrap(); + let data = DeactivateDelinquentInstructionData::new() + .try_to_vec() + .unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -60,6 +63,10 @@ impl DeactivateDelinquentInstructionData { pub fn new() -> Self { Self { discriminator: 14 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for DeactivateDelinquentInstructionData { @@ -77,10 +84,10 @@ impl Default for DeactivateDelinquentInstructionData { /// 2. `[]` reference_vote #[derive(Clone, Debug, Default)] pub struct DeactivateDelinquentBuilder { - stake: Option, - delinquent_vote: Option, - reference_vote: Option, - __remaining_accounts: Vec, + stake: Option, + delinquent_vote: Option, + reference_vote: Option, + __remaining_accounts: Vec, } impl DeactivateDelinquentBuilder { @@ -89,31 +96,25 @@ impl DeactivateDelinquentBuilder { } /// Delegated stake account #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// Delinquent vote account + /// Delinquent vote account for the delegated stake account #[inline(always)] - pub fn delinquent_vote( - &mut self, - delinquent_vote: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn delinquent_vote(&mut self, delinquent_vote: solana_pubkey::Pubkey) -> &mut Self { self.delinquent_vote = Some(delinquent_vote); self } - /// Reference vote account + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs #[inline(always)] - pub fn reference_vote(&mut self, reference_vote: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn reference_vote(&mut self, reference_vote: solana_pubkey::Pubkey) -> &mut Self { self.reference_vote = Some(reference_vote); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -121,13 +122,13 @@ impl DeactivateDelinquentBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = DeactivateDelinquent { stake: self.stake.expect("stake is not set"), delinquent_vote: self.delinquent_vote.expect("delinquent_vote is not set"), @@ -141,28 +142,28 @@ impl DeactivateDelinquentBuilder { /// `deactivate_delinquent` CPI accounts. pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { /// Delegated stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Delinquent vote account - pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Reference vote account - pub reference_vote: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, + /// Delinquent vote account for the delegated stake account + pub delinquent_vote: &'b solana_account_info::AccountInfo<'a>, + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs + pub reference_vote: &'b solana_account_info::AccountInfo<'a>, } /// `deactivate_delinquent` CPI instruction. pub struct DeactivateDelinquentCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Delegated stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Delinquent vote account - pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Reference vote account - pub reference_vote: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, + /// Delinquent vote account for the delegated stake account + pub delinquent_vote: &'b solana_account_info::AccountInfo<'a>, + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs + pub reference_vote: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: DeactivateDelinquentCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -173,61 +174,50 @@ impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.delinquent_vote.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.reference_vote.key, false, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&DeactivateDelinquentInstructionData::new()).unwrap(); + let data = DeactivateDelinquentInstructionData::new() + .try_to_vec() + .unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -242,9 +232,9 @@ impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -262,7 +252,7 @@ pub struct DeactivateDelinquentCpiBuilder<'a, 'b> { } impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(DeactivateDelinquentCpiBuilderInstruction { __program: program, stake: None, @@ -274,24 +264,24 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { } /// Delegated stake account #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Delinquent vote account + /// Delinquent vote account for the delegated stake account #[inline(always)] pub fn delinquent_vote( &mut self, - delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, + delinquent_vote: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.delinquent_vote = Some(delinquent_vote); self } - /// Reference vote account + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs #[inline(always)] pub fn reference_vote( &mut self, - reference_vote: &'b solana_program::account_info::AccountInfo<'a>, + reference_vote: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.reference_vote = Some(reference_vote); self @@ -300,7 +290,7 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -316,11 +306,7 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -328,15 +314,12 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = DeactivateDelinquentCpi { __program: self.instruction.__program, @@ -361,14 +344,10 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct DeactivateDelinquentCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - delinquent_vote: Option<&'b solana_program::account_info::AccountInfo<'a>>, - reference_vote: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + delinquent_vote: Option<&'b solana_account_info::AccountInfo<'a>>, + reference_vote: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/delegate_stake.rs b/clients/rust/src/generated/instructions/delegate_stake.rs index 617f2ca8..00fe1591 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -7,59 +7,60 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const DELEGATE_STAKE_DISCRIMINATOR: u32 = 2; + /// Accounts. #[derive(Debug)] pub struct DelegateStake { /// Initialized stake account to be delegated - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Vote account to which this stake will be delegated - pub vote: solana_program::pubkey::Pubkey, + pub vote: solana_pubkey::Pubkey, /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar - pub stake_history: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_pubkey::Pubkey, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: solana_pubkey::Pubkey, /// Unused account, formerly the stake config - pub unused: solana_program::pubkey::Pubkey, + pub unused: solana_pubkey::Pubkey, /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, + pub stake_authority: solana_pubkey::Pubkey, } impl DelegateStake { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.vote, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.clock_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_history, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.unused, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DelegateStakeInstructionData::new()).unwrap(); + let data = DelegateStakeInstructionData::new().try_to_vec().unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -77,6 +78,10 @@ impl DelegateStakeInstructionData { pub fn new() -> Self { Self { discriminator: 2 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for DelegateStakeInstructionData { @@ -92,18 +97,18 @@ impl Default for DelegateStakeInstructionData { /// 0. `[writable]` stake /// 1. `[]` vote /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[]` stake_history +/// 3. `[optional]` stake_history (default to `SysvarStakeHistory1111111111111111111111111`) /// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct DelegateStakeBuilder { - stake: Option, - vote: Option, - clock_sysvar: Option, - stake_history: Option, - unused: Option, - stake_authority: Option, - __remaining_accounts: Vec, + stake: Option, + vote: Option, + clock_sysvar: Option, + stake_history: Option, + unused: Option, + stake_authority: Option, + __remaining_accounts: Vec, } impl DelegateStakeBuilder { @@ -112,50 +117,45 @@ impl DelegateStakeBuilder { } /// Initialized stake account to be delegated #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// Vote account to which this stake will be delegated #[inline(always)] - pub fn vote(&mut self, vote: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn vote(&mut self, vote: solana_pubkey::Pubkey) -> &mut Self { self.vote = Some(vote); self } /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn clock_sysvar(&mut self, clock_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar + /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] - pub fn stake_history(&mut self, stake_history: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake_history(&mut self, stake_history: solana_pubkey::Pubkey) -> &mut Self { self.stake_history = Some(stake_history); self } /// Unused account, formerly the stake config #[inline(always)] - pub fn unused(&mut self, unused: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn unused(&mut self, unused: solana_pubkey::Pubkey) -> &mut Self { self.unused = Some(unused); self } /// Stake authority #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn stake_authority(&mut self, stake_authority: solana_pubkey::Pubkey) -> &mut Self { self.stake_authority = Some(stake_authority); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -163,20 +163,22 @@ impl DelegateStakeBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = DelegateStake { stake: self.stake.expect("stake is not set"), vote: self.vote.expect("vote is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + clock_sysvar: self.clock_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), - stake_history: self.stake_history.expect("stake_history is not set"), + stake_history: self.stake_history.unwrap_or(solana_pubkey::pubkey!( + "SysvarStakeHistory1111111111111111111111111" + )), unused: self.unused.expect("unused is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -188,40 +190,40 @@ impl DelegateStakeBuilder { /// `delegate_stake` CPI accounts. pub struct DelegateStakeCpiAccounts<'a, 'b> { /// Initialized stake account to be delegated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Vote account to which this stake will be delegated - pub vote: &'b solana_program::account_info::AccountInfo<'a>, + pub vote: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: &'b solana_account_info::AccountInfo<'a>, /// Unused account, formerly the stake config - pub unused: &'b solana_program::account_info::AccountInfo<'a>, + pub unused: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, } /// `delegate_stake` CPI instruction. pub struct DelegateStakeCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Initialized stake account to be delegated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Vote account to which this stake will be delegated - pub vote: &'b solana_program::account_info::AccountInfo<'a>, + pub vote: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: &'b solana_account_info::AccountInfo<'a>, /// Unused account, formerly the stake config - pub unused: &'b solana_program::account_info::AccountInfo<'a>, + pub unused: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> DelegateStakeCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: DelegateStakeCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -235,73 +237,60 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.vote.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_history.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.unused.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&DelegateStakeInstructionData::new()).unwrap(); + let data = DelegateStakeInstructionData::new().try_to_vec().unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -319,9 +308,9 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -342,7 +331,7 @@ pub struct DelegateStakeCpiBuilder<'a, 'b> { } impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(DelegateStakeCpiBuilderInstruction { __program: program, stake: None, @@ -357,13 +346,13 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { } /// Initialized stake account to be delegated #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } /// Vote account to which this stake will be delegated #[inline(always)] - pub fn vote(&mut self, vote: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn vote(&mut self, vote: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.vote = Some(vote); self } @@ -371,26 +360,23 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { #[inline(always)] pub fn clock_sysvar( &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + clock_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history( &mut self, - stake_history: &'b solana_program::account_info::AccountInfo<'a>, + stake_history: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_history = Some(stake_history); self } /// Unused account, formerly the stake config #[inline(always)] - pub fn unused( - &mut self, - unused: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn unused(&mut self, unused: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.unused = Some(unused); self } @@ -398,7 +384,7 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { #[inline(always)] pub fn stake_authority( &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + stake_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_authority = Some(stake_authority); self @@ -407,7 +393,7 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -423,11 +409,7 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -435,15 +417,12 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = DelegateStakeCpi { __program: self.instruction.__program, @@ -477,17 +456,13 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct DelegateStakeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - vote: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_history: Option<&'b solana_program::account_info::AccountInfo<'a>>, - unused: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + vote: Option<&'b solana_account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_history: Option<&'b solana_account_info::AccountInfo<'a>>, + unused: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/get_minimum_delegation.rs b/clients/rust/src/generated/instructions/get_minimum_delegation.rs index d510e2cb..4a211159 100644 --- a/clients/rust/src/generated/instructions/get_minimum_delegation.rs +++ b/clients/rust/src/generated/instructions/get_minimum_delegation.rs @@ -7,24 +7,29 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const GET_MINIMUM_DELEGATION_DISCRIMINATOR: u32 = 13; + /// Accounts. #[derive(Debug)] pub struct GetMinimumDelegation {} impl GetMinimumDelegation { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(remaining_accounts.len()); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&GetMinimumDelegationInstructionData::new()).unwrap(); + let data = GetMinimumDelegationInstructionData::new() + .try_to_vec() + .unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -42,6 +47,10 @@ impl GetMinimumDelegationInstructionData { pub fn new() -> Self { Self { discriminator: 13 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for GetMinimumDelegationInstructionData { @@ -56,7 +65,7 @@ impl Default for GetMinimumDelegationInstructionData { /// #[derive(Clone, Debug, Default)] pub struct GetMinimumDelegationBuilder { - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl GetMinimumDelegationBuilder { @@ -65,10 +74,7 @@ impl GetMinimumDelegationBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -76,13 +82,13 @@ impl GetMinimumDelegationBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = GetMinimumDelegation {}; accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) @@ -92,57 +98,49 @@ impl GetMinimumDelegationBuilder { /// `get_minimum_delegation` CPI instruction. pub struct GetMinimumDelegationCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> GetMinimumDelegationCpi<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { Self { __program: program } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(remaining_accounts.len()); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&GetMinimumDelegationInstructionData::new()).unwrap(); + let data = GetMinimumDelegationInstructionData::new() + .try_to_vec() + .unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -154,9 +152,9 @@ impl<'a, 'b> GetMinimumDelegationCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -171,7 +169,7 @@ pub struct GetMinimumDelegationCpiBuilder<'a, 'b> { } impl<'a, 'b> GetMinimumDelegationCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(GetMinimumDelegationCpiBuilderInstruction { __program: program, __remaining_accounts: Vec::new(), @@ -182,7 +180,7 @@ impl<'a, 'b> GetMinimumDelegationCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -198,11 +196,7 @@ impl<'a, 'b> GetMinimumDelegationCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -210,15 +204,12 @@ impl<'a, 'b> GetMinimumDelegationCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = GetMinimumDelegationCpi { __program: self.instruction.__program, }; @@ -231,11 +222,7 @@ impl<'a, 'b> GetMinimumDelegationCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct GetMinimumDelegationCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, + __program: &'b solana_account_info::AccountInfo<'a>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/initialize.rs b/clients/rust/src/generated/instructions/initialize.rs index 24bc81f5..e8df55af 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -10,42 +10,40 @@ use { borsh::{BorshDeserialize, BorshSerialize}, }; +pub const INITIALIZE_DISCRIMINATOR: u32 = 0; + /// Accounts. #[derive(Debug)] pub struct Initialize { /// Uninitialized stake account - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Rent sysvar - pub rent_sysvar: solana_program::pubkey::Pubkey, + pub rent_sysvar: solana_pubkey::Pubkey, } impl Initialize { - pub fn instruction( - &self, - args: InitializeInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: InitializeInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: InitializeInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.rent_sysvar, false, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = InitializeInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -63,6 +61,10 @@ impl InitializeInstructionData { pub fn new() -> Self { Self { discriminator: 0 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for InitializeInstructionData { @@ -78,6 +80,12 @@ pub struct InitializeInstructionArgs { pub arg1: Lockup, } +impl InitializeInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Initialize`. /// /// ### Accounts: @@ -86,11 +94,11 @@ pub struct InitializeInstructionArgs { /// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct InitializeBuilder { - stake: Option, - rent_sysvar: Option, + stake: Option, + rent_sysvar: Option, arg0: Option, arg1: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl InitializeBuilder { @@ -99,14 +107,14 @@ impl InitializeBuilder { } /// Uninitialized stake account #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` /// Rent sysvar #[inline(always)] - pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn rent_sysvar(&mut self, rent_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.rent_sysvar = Some(rent_sysvar); self } @@ -122,10 +130,7 @@ impl InitializeBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -133,16 +138,16 @@ impl InitializeBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Initialize { stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( + rent_sysvar: self.rent_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarRent111111111111111111111111111111111" )), }; @@ -158,26 +163,26 @@ impl InitializeBuilder { /// `initialize` CPI accounts. pub struct InitializeCpiAccounts<'a, 'b> { /// Uninitialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Rent sysvar - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_account_info::AccountInfo<'a>, } /// `initialize` CPI instruction. pub struct InitializeCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Uninitialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Rent sysvar - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: InitializeInstructionArgs, } impl<'a, 'b> InitializeCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: InitializeCpiAccounts<'a, 'b>, args: InitializeInstructionArgs, ) -> Self { @@ -189,59 +194,46 @@ impl<'a, 'b> InitializeCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.rent_sysvar.key, false, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = InitializeInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -255,9 +247,9 @@ impl<'a, 'b> InitializeCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -274,7 +266,7 @@ pub struct InitializeCpiBuilder<'a, 'b> { } impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(InitializeCpiBuilderInstruction { __program: program, stake: None, @@ -287,7 +279,7 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { } /// Uninitialized stake account #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } @@ -295,7 +287,7 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { #[inline(always)] pub fn rent_sysvar( &mut self, - rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + rent_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.rent_sysvar = Some(rent_sysvar); self @@ -314,7 +306,7 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -330,11 +322,7 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -342,15 +330,12 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = InitializeInstructionArgs { arg0: self.instruction.arg0.clone().expect("arg0 is not set"), arg1: self.instruction.arg1.clone().expect("arg1 is not set"), @@ -375,15 +360,11 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct InitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - rent_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + rent_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, arg0: Option, arg1: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/initialize_checked.rs b/clients/rust/src/generated/instructions/initialize_checked.rs index 929046f7..6d563ada 100644 --- a/clients/rust/src/generated/instructions/initialize_checked.rs +++ b/clients/rust/src/generated/instructions/initialize_checked.rs @@ -7,48 +7,51 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const INITIALIZE_CHECKED_DISCRIMINATOR: u32 = 9; + /// Accounts. #[derive(Debug)] pub struct InitializeChecked { /// Uninitialized stake account - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Rent sysvar - pub rent_sysvar: solana_program::pubkey::Pubkey, + pub rent_sysvar: solana_pubkey::Pubkey, /// The stake authority - pub stake_authority: solana_program::pubkey::Pubkey, + pub stake_authority: solana_pubkey::Pubkey, /// The withdraw authority - pub withdraw_authority: solana_program::pubkey::Pubkey, + pub withdraw_authority: solana_pubkey::Pubkey, } impl InitializeChecked { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.rent_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_authority, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.withdraw_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeCheckedInstructionData::new()).unwrap(); + let data = InitializeCheckedInstructionData::new() + .try_to_vec() + .unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -66,6 +69,10 @@ impl InitializeCheckedInstructionData { pub fn new() -> Self { Self { discriminator: 9 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for InitializeCheckedInstructionData { @@ -84,11 +91,11 @@ impl Default for InitializeCheckedInstructionData { /// 3. `[signer]` withdraw_authority #[derive(Clone, Debug, Default)] pub struct InitializeCheckedBuilder { - stake: Option, - rent_sysvar: Option, - stake_authority: Option, - withdraw_authority: Option, - __remaining_accounts: Vec, + stake: Option, + rent_sysvar: Option, + stake_authority: Option, + withdraw_authority: Option, + __remaining_accounts: Vec, } impl InitializeCheckedBuilder { @@ -97,41 +104,32 @@ impl InitializeCheckedBuilder { } /// Uninitialized stake account #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` /// Rent sysvar #[inline(always)] - pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn rent_sysvar(&mut self, rent_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.rent_sysvar = Some(rent_sysvar); self } /// The stake authority #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn stake_authority(&mut self, stake_authority: solana_pubkey::Pubkey) -> &mut Self { self.stake_authority = Some(stake_authority); self } /// The withdraw authority #[inline(always)] - pub fn withdraw_authority( - &mut self, - withdraw_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn withdraw_authority(&mut self, withdraw_authority: solana_pubkey::Pubkey) -> &mut Self { self.withdraw_authority = Some(withdraw_authority); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -139,16 +137,16 @@ impl InitializeCheckedBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = InitializeChecked { stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( + rent_sysvar: self.rent_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarRent111111111111111111111111111111111" )), stake_authority: self.stake_authority.expect("stake_authority is not set"), @@ -164,32 +162,32 @@ impl InitializeCheckedBuilder { /// `initialize_checked` CPI accounts. pub struct InitializeCheckedCpiAccounts<'a, 'b> { /// Uninitialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Rent sysvar - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_account_info::AccountInfo<'a>, /// The stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, /// The withdraw authority - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub withdraw_authority: &'b solana_account_info::AccountInfo<'a>, } /// `initialize_checked` CPI instruction. pub struct InitializeCheckedCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Uninitialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Rent sysvar - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_account_info::AccountInfo<'a>, /// The stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, /// The withdraw authority - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub withdraw_authority: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: InitializeCheckedCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -201,65 +199,54 @@ impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.rent_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_authority.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.withdraw_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&InitializeCheckedInstructionData::new()).unwrap(); + let data = InitializeCheckedInstructionData::new() + .try_to_vec() + .unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -275,9 +262,9 @@ impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -296,7 +283,7 @@ pub struct InitializeCheckedCpiBuilder<'a, 'b> { } impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(InitializeCheckedCpiBuilderInstruction { __program: program, stake: None, @@ -309,7 +296,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { } /// Uninitialized stake account #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } @@ -317,7 +304,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn rent_sysvar( &mut self, - rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + rent_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.rent_sysvar = Some(rent_sysvar); self @@ -326,7 +313,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn stake_authority( &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + stake_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_authority = Some(stake_authority); self @@ -335,7 +322,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn withdraw_authority( &mut self, - withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + withdraw_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.withdraw_authority = Some(withdraw_authority); self @@ -344,7 +331,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -360,11 +347,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -372,15 +355,12 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = InitializeCheckedCpi { __program: self.instruction.__program, @@ -410,15 +390,11 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct InitializeCheckedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - rent_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - withdraw_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + rent_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_account_info::AccountInfo<'a>>, + withdraw_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/merge.rs b/clients/rust/src/generated/instructions/merge.rs index e56caa51..47a2d4a6 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -7,55 +7,58 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const MERGE_DISCRIMINATOR: u32 = 7; + /// Accounts. #[derive(Debug)] pub struct Merge { - /// Destination stake account - pub destination_stake: solana_program::pubkey::Pubkey, - /// Source stake account - pub source_stake: solana_program::pubkey::Pubkey, + /// Destination stake account for the merge + pub destination_stake: solana_pubkey::Pubkey, + /// Source stake account for to merge. This account will be drained + pub source_stake: solana_pubkey::Pubkey, /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar - pub stake_history: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_pubkey::Pubkey, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: solana_pubkey::Pubkey, /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, + pub stake_authority: solana_pubkey::Pubkey, } impl Merge { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.destination_stake, false, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.source_stake, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.clock_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_history, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MergeInstructionData::new()).unwrap(); + let data = MergeInstructionData::new().try_to_vec().unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -73,6 +76,10 @@ impl MergeInstructionData { pub fn new() -> Self { Self { discriminator: 7 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for MergeInstructionData { @@ -88,65 +95,57 @@ impl Default for MergeInstructionData { /// 0. `[writable]` destination_stake /// 1. `[writable]` source_stake /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[]` stake_history +/// 3. `[optional]` stake_history (default to `SysvarStakeHistory1111111111111111111111111`) /// 4. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MergeBuilder { - destination_stake: Option, - source_stake: Option, - clock_sysvar: Option, - stake_history: Option, - stake_authority: Option, - __remaining_accounts: Vec, + destination_stake: Option, + source_stake: Option, + clock_sysvar: Option, + stake_history: Option, + stake_authority: Option, + __remaining_accounts: Vec, } impl MergeBuilder { pub fn new() -> Self { Self::default() } - /// Destination stake account + /// Destination stake account for the merge #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn destination_stake(&mut self, destination_stake: solana_pubkey::Pubkey) -> &mut Self { self.destination_stake = Some(destination_stake); self } - /// Source stake account + /// Source stake account for to merge. This account will be drained #[inline(always)] - pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn source_stake(&mut self, source_stake: solana_pubkey::Pubkey) -> &mut Self { self.source_stake = Some(source_stake); self } /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn clock_sysvar(&mut self, clock_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar + /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] - pub fn stake_history(&mut self, stake_history: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake_history(&mut self, stake_history: solana_pubkey::Pubkey) -> &mut Self { self.stake_history = Some(stake_history); self } /// Stake authority #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn stake_authority(&mut self, stake_authority: solana_pubkey::Pubkey) -> &mut Self { self.stake_authority = Some(stake_authority); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -154,22 +153,24 @@ impl MergeBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Merge { destination_stake: self .destination_stake .expect("destination_stake is not set"), source_stake: self.source_stake.expect("source_stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + clock_sysvar: self.clock_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), - stake_history: self.stake_history.expect("stake_history is not set"), + stake_history: self.stake_history.unwrap_or(solana_pubkey::pubkey!( + "SysvarStakeHistory1111111111111111111111111" + )), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -179,37 +180,37 @@ impl MergeBuilder { /// `merge` CPI accounts. pub struct MergeCpiAccounts<'a, 'b> { - /// Destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Destination stake account for the merge + pub destination_stake: &'b solana_account_info::AccountInfo<'a>, + /// Source stake account for to merge. This account will be drained + pub source_stake: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, } /// `merge` CPI instruction. pub struct MergeCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, + /// Destination stake account for the merge + pub destination_stake: &'b solana_account_info::AccountInfo<'a>, + /// Source stake account for to merge. This account will be drained + pub source_stake: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> MergeCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: MergeCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -222,69 +223,59 @@ impl<'a, 'b> MergeCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.destination_stake.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.source_stake.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_history.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&MergeInstructionData::new()).unwrap(); + let data = MergeInstructionData::new().try_to_vec().unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -301,9 +292,9 @@ impl<'a, 'b> MergeCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -323,7 +314,7 @@ pub struct MergeCpiBuilder<'a, 'b> { } impl<'a, 'b> MergeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MergeCpiBuilderInstruction { __program: program, destination_stake: None, @@ -335,20 +326,20 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { }); Self { instruction } } - /// Destination stake account + /// Destination stake account for the merge #[inline(always)] pub fn destination_stake( &mut self, - destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + destination_stake: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.destination_stake = Some(destination_stake); self } - /// Source stake account + /// Source stake account for to merge. This account will be drained #[inline(always)] pub fn source_stake( &mut self, - source_stake: &'b solana_program::account_info::AccountInfo<'a>, + source_stake: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.source_stake = Some(source_stake); self @@ -357,16 +348,16 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { #[inline(always)] pub fn clock_sysvar( &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + clock_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history( &mut self, - stake_history: &'b solana_program::account_info::AccountInfo<'a>, + stake_history: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_history = Some(stake_history); self @@ -375,7 +366,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { #[inline(always)] pub fn stake_authority( &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + stake_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_authority = Some(stake_authority); self @@ -384,7 +375,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -400,11 +391,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -412,15 +399,12 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = MergeCpi { __program: self.instruction.__program, @@ -458,16 +442,12 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct MergeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - destination_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - source_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_history: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + destination_stake: Option<&'b solana_account_info::AccountInfo<'a>>, + source_stake: Option<&'b solana_account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_history: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs index cc30b72c..68e75247 100644 --- a/clients/rust/src/generated/instructions/move_lamports.rs +++ b/clients/rust/src/generated/instructions/move_lamports.rs @@ -7,49 +7,52 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const MOVE_LAMPORTS_DISCRIMINATOR: u32 = 17; + /// Accounts. #[derive(Debug)] pub struct MoveLamports { /// Active or inactive source stake account - pub source_stake: solana_program::pubkey::Pubkey, + pub source_stake: solana_pubkey::Pubkey, /// Mergeable destination stake account - pub destination_stake: solana_program::pubkey::Pubkey, + pub destination_stake: solana_pubkey::Pubkey, /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, + pub stake_authority: solana_pubkey::Pubkey, } impl MoveLamports { pub fn instruction( &self, args: MoveLamportsInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: MoveLamportsInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.source_stake, false, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.destination_stake, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&MoveLamportsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = MoveLamportsInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -67,6 +70,10 @@ impl MoveLamportsInstructionData { pub fn new() -> Self { Self { discriminator: 17 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for MoveLamportsInstructionData { @@ -81,6 +88,12 @@ pub struct MoveLamportsInstructionArgs { pub args: u64, } +impl MoveLamportsInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `MoveLamports`. /// /// ### Accounts: @@ -90,11 +103,11 @@ pub struct MoveLamportsInstructionArgs { /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveLamportsBuilder { - source_stake: Option, - destination_stake: Option, - stake_authority: Option, + source_stake: Option, + destination_stake: Option, + stake_authority: Option, args: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl MoveLamportsBuilder { @@ -103,25 +116,19 @@ impl MoveLamportsBuilder { } /// Active or inactive source stake account #[inline(always)] - pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn source_stake(&mut self, source_stake: solana_pubkey::Pubkey) -> &mut Self { self.source_stake = Some(source_stake); self } /// Mergeable destination stake account #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn destination_stake(&mut self, destination_stake: solana_pubkey::Pubkey) -> &mut Self { self.destination_stake = Some(destination_stake); self } /// Stake authority #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn stake_authority(&mut self, stake_authority: solana_pubkey::Pubkey) -> &mut Self { self.stake_authority = Some(stake_authority); self } @@ -132,10 +139,7 @@ impl MoveLamportsBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -143,13 +147,13 @@ impl MoveLamportsBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = MoveLamports { source_stake: self.source_stake.expect("source_stake is not set"), destination_stake: self @@ -168,30 +172,30 @@ impl MoveLamportsBuilder { /// `move_lamports` CPI accounts. pub struct MoveLamportsCpiAccounts<'a, 'b> { /// Active or inactive source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_account_info::AccountInfo<'a>, /// Mergeable destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, } /// `move_lamports` CPI instruction. pub struct MoveLamportsCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Active or inactive source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_account_info::AccountInfo<'a>, /// Mergeable destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: MoveLamportsInstructionArgs, } impl<'a, 'b> MoveLamportsCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: MoveLamportsCpiAccounts<'a, 'b>, args: MoveLamportsInstructionArgs, ) -> Self { @@ -204,63 +208,53 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.source_stake.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.destination_stake.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&MoveLamportsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = MoveLamportsInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -275,9 +269,9 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -295,7 +289,7 @@ pub struct MoveLamportsCpiBuilder<'a, 'b> { } impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MoveLamportsCpiBuilderInstruction { __program: program, source_stake: None, @@ -310,7 +304,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { #[inline(always)] pub fn source_stake( &mut self, - source_stake: &'b solana_program::account_info::AccountInfo<'a>, + source_stake: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.source_stake = Some(source_stake); self @@ -319,7 +313,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { #[inline(always)] pub fn destination_stake( &mut self, - destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + destination_stake: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.destination_stake = Some(destination_stake); self @@ -328,7 +322,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { #[inline(always)] pub fn stake_authority( &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + stake_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_authority = Some(stake_authority); self @@ -342,7 +336,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -358,11 +352,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -370,15 +360,12 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = MoveLamportsInstructionArgs { args: self.instruction.args.clone().expect("args is not set"), }; @@ -410,15 +397,11 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct MoveLamportsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - source_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - destination_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + source_stake: Option<&'b solana_account_info::AccountInfo<'a>>, + destination_stake: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_account_info::AccountInfo<'a>>, args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/move_stake.rs b/clients/rust/src/generated/instructions/move_stake.rs index c8953253..9e6dfbde 100644 --- a/clients/rust/src/generated/instructions/move_stake.rs +++ b/clients/rust/src/generated/instructions/move_stake.rs @@ -7,49 +7,49 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const MOVE_STAKE_DISCRIMINATOR: u32 = 16; + /// Accounts. #[derive(Debug)] pub struct MoveStake { /// Active source stake account - pub source_stake: solana_program::pubkey::Pubkey, + pub source_stake: solana_pubkey::Pubkey, /// Active or inactive destination stake account - pub destination_stake: solana_program::pubkey::Pubkey, + pub destination_stake: solana_pubkey::Pubkey, /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, + pub stake_authority: solana_pubkey::Pubkey, } impl MoveStake { - pub fn instruction( - &self, - args: MoveStakeInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: MoveStakeInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: MoveStakeInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.source_stake, false, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.destination_stake, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&MoveStakeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = MoveStakeInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -67,6 +67,10 @@ impl MoveStakeInstructionData { pub fn new() -> Self { Self { discriminator: 16 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for MoveStakeInstructionData { @@ -81,6 +85,12 @@ pub struct MoveStakeInstructionArgs { pub args: u64, } +impl MoveStakeInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `MoveStake`. /// /// ### Accounts: @@ -90,11 +100,11 @@ pub struct MoveStakeInstructionArgs { /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveStakeBuilder { - source_stake: Option, - destination_stake: Option, - stake_authority: Option, + source_stake: Option, + destination_stake: Option, + stake_authority: Option, args: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl MoveStakeBuilder { @@ -103,25 +113,19 @@ impl MoveStakeBuilder { } /// Active source stake account #[inline(always)] - pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn source_stake(&mut self, source_stake: solana_pubkey::Pubkey) -> &mut Self { self.source_stake = Some(source_stake); self } /// Active or inactive destination stake account #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn destination_stake(&mut self, destination_stake: solana_pubkey::Pubkey) -> &mut Self { self.destination_stake = Some(destination_stake); self } /// Stake authority #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn stake_authority(&mut self, stake_authority: solana_pubkey::Pubkey) -> &mut Self { self.stake_authority = Some(stake_authority); self } @@ -132,10 +136,7 @@ impl MoveStakeBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -143,13 +144,13 @@ impl MoveStakeBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = MoveStake { source_stake: self.source_stake.expect("source_stake is not set"), destination_stake: self @@ -168,30 +169,30 @@ impl MoveStakeBuilder { /// `move_stake` CPI accounts. pub struct MoveStakeCpiAccounts<'a, 'b> { /// Active source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_account_info::AccountInfo<'a>, /// Active or inactive destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, } /// `move_stake` CPI instruction. pub struct MoveStakeCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Active source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_account_info::AccountInfo<'a>, /// Active or inactive destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: MoveStakeInstructionArgs, } impl<'a, 'b> MoveStakeCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: MoveStakeCpiAccounts<'a, 'b>, args: MoveStakeInstructionArgs, ) -> Self { @@ -204,63 +205,53 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.source_stake.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.destination_stake.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&MoveStakeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = MoveStakeInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -275,9 +266,9 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -295,7 +286,7 @@ pub struct MoveStakeCpiBuilder<'a, 'b> { } impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MoveStakeCpiBuilderInstruction { __program: program, source_stake: None, @@ -310,7 +301,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { #[inline(always)] pub fn source_stake( &mut self, - source_stake: &'b solana_program::account_info::AccountInfo<'a>, + source_stake: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.source_stake = Some(source_stake); self @@ -319,7 +310,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { #[inline(always)] pub fn destination_stake( &mut self, - destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + destination_stake: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.destination_stake = Some(destination_stake); self @@ -328,7 +319,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { #[inline(always)] pub fn stake_authority( &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + stake_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_authority = Some(stake_authority); self @@ -342,7 +333,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -358,11 +349,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -370,15 +357,12 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = MoveStakeInstructionArgs { args: self.instruction.args.clone().expect("args is not set"), }; @@ -410,15 +394,11 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct MoveStakeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - source_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - destination_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + source_stake: Option<&'b solana_account_info::AccountInfo<'a>>, + destination_stake: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_account_info::AccountInfo<'a>>, args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/set_lockup.rs b/clients/rust/src/generated/instructions/set_lockup.rs index f92de1e9..2d03c567 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -6,46 +6,45 @@ //! use { + crate::generated::types::{Epoch, UnixTimestamp}, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, + solana_pubkey::Pubkey, }; +pub const SET_LOCKUP_DISCRIMINATOR: u32 = 6; + /// Accounts. #[derive(Debug)] pub struct SetLockup { /// Initialized stake account - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Lockup authority or withdraw authority - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, } impl SetLockup { - pub fn instruction( - &self, - args: SetLockupInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: SetLockupInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: SetLockupInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetLockupInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = SetLockupInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -63,6 +62,10 @@ impl SetLockupInstructionData { pub fn new() -> Self { Self { discriminator: 6 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for SetLockupInstructionData { @@ -74,11 +77,17 @@ impl Default for SetLockupInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupInstructionArgs { - pub unix_timestamp: Option, - pub epoch: Option, + pub unix_timestamp: Option, + pub epoch: Option, pub custodian: Option, } +impl SetLockupInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `SetLockup`. /// /// ### Accounts: @@ -87,12 +96,12 @@ pub struct SetLockupInstructionArgs { /// 1. `[signer]` authority #[derive(Clone, Debug, Default)] pub struct SetLockupBuilder { - stake: Option, - authority: Option, - unix_timestamp: Option, - epoch: Option, + stake: Option, + authority: Option, + unix_timestamp: Option, + epoch: Option, custodian: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl SetLockupBuilder { @@ -101,25 +110,25 @@ impl SetLockupBuilder { } /// Initialized stake account #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// Lockup authority or withdraw authority #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional argument]` #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { + pub fn unix_timestamp(&mut self, unix_timestamp: UnixTimestamp) -> &mut Self { self.unix_timestamp = Some(unix_timestamp); self } /// `[optional argument]` #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.epoch = Some(epoch); self } @@ -131,10 +140,7 @@ impl SetLockupBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -142,13 +148,13 @@ impl SetLockupBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = SetLockup { stake: self.stake.expect("stake is not set"), authority: self.authority.expect("authority is not set"), @@ -166,26 +172,26 @@ impl SetLockupBuilder { /// `set_lockup` CPI accounts. pub struct SetLockupCpiAccounts<'a, 'b> { /// Initialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, } /// `set_lockup` CPI instruction. pub struct SetLockupCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Initialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: SetLockupInstructionArgs, } impl<'a, 'b> SetLockupCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: SetLockupCpiAccounts<'a, 'b>, args: SetLockupInstructionArgs, ) -> Self { @@ -197,59 +203,46 @@ impl<'a, 'b> SetLockupCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&SetLockupInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = SetLockupInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -263,9 +256,9 @@ impl<'a, 'b> SetLockupCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -282,7 +275,7 @@ pub struct SetLockupCpiBuilder<'a, 'b> { } impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(SetLockupCpiBuilderInstruction { __program: program, stake: None, @@ -296,28 +289,25 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { } /// Initialized stake account #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } /// Lockup authority or withdraw authority #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } /// `[optional argument]` #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { + pub fn unix_timestamp(&mut self, unix_timestamp: UnixTimestamp) -> &mut Self { self.instruction.unix_timestamp = Some(unix_timestamp); self } /// `[optional argument]` #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.instruction.epoch = Some(epoch); self } @@ -331,7 +321,7 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -347,11 +337,7 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -359,15 +345,12 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = SetLockupInstructionArgs { unix_timestamp: self.instruction.unix_timestamp.clone(), epoch: self.instruction.epoch.clone(), @@ -390,16 +373,12 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct SetLockupCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - unix_timestamp: Option, - epoch: Option, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + unix_timestamp: Option, + epoch: Option, custodian: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/set_lockup_checked.rs b/clients/rust/src/generated/instructions/set_lockup_checked.rs index fbfb6125..90e33a22 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -5,52 +5,56 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use { + crate::generated::types::{Epoch, UnixTimestamp}, + borsh::{BorshDeserialize, BorshSerialize}, +}; + +pub const SET_LOCKUP_CHECKED_DISCRIMINATOR: u32 = 12; /// Accounts. #[derive(Debug)] pub struct SetLockupChecked { /// Initialized stake account - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Lockup authority or withdraw authority - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// New lockup authority - pub new_authority: Option, + pub new_authority: Option, } impl SetLockupChecked { pub fn instruction( &self, args: SetLockupCheckedInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: SetLockupCheckedInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(new_authority) = self.new_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( new_authority, true, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetLockupCheckedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = SetLockupCheckedInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -68,6 +72,10 @@ impl SetLockupCheckedInstructionData { pub fn new() -> Self { Self { discriminator: 12 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for SetLockupCheckedInstructionData { @@ -79,8 +87,14 @@ impl Default for SetLockupCheckedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupCheckedInstructionArgs { - pub unix_timestamp: Option, - pub epoch: Option, + pub unix_timestamp: Option, + pub epoch: Option, +} + +impl SetLockupCheckedInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } /// Instruction builder for `SetLockupChecked`. @@ -92,12 +106,12 @@ pub struct SetLockupCheckedInstructionArgs { /// 2. `[signer, optional]` new_authority #[derive(Clone, Debug, Default)] pub struct SetLockupCheckedBuilder { - stake: Option, - authority: Option, - new_authority: Option, - unix_timestamp: Option, - epoch: Option, - __remaining_accounts: Vec, + stake: Option, + authority: Option, + new_authority: Option, + unix_timestamp: Option, + epoch: Option, + __remaining_accounts: Vec, } impl SetLockupCheckedBuilder { @@ -106,44 +120,38 @@ impl SetLockupCheckedBuilder { } /// Initialized stake account #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// Lockup authority or withdraw authority #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` /// New lockup authority #[inline(always)] - pub fn new_authority( - &mut self, - new_authority: Option, - ) -> &mut Self { + pub fn new_authority(&mut self, new_authority: Option) -> &mut Self { self.new_authority = new_authority; self } /// `[optional argument]` #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { + pub fn unix_timestamp(&mut self, unix_timestamp: UnixTimestamp) -> &mut Self { self.unix_timestamp = Some(unix_timestamp); self } /// `[optional argument]` #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.epoch = Some(epoch); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -151,13 +159,13 @@ impl SetLockupCheckedBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = SetLockupChecked { stake: self.stake.expect("stake is not set"), authority: self.authority.expect("authority is not set"), @@ -175,30 +183,30 @@ impl SetLockupCheckedBuilder { /// `set_lockup_checked` CPI accounts. pub struct SetLockupCheckedCpiAccounts<'a, 'b> { /// Initialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// New lockup authority - pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub new_authority: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `set_lockup_checked` CPI instruction. pub struct SetLockupCheckedCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Initialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// New lockup authority - pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub new_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: SetLockupCheckedInstructionArgs, } impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: SetLockupCheckedCpiAccounts<'a, 'b>, args: SetLockupCheckedInstructionArgs, ) -> Self { @@ -211,65 +219,52 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(new_authority) = self.new_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *new_authority.key, true, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&SetLockupCheckedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = SetLockupCheckedInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -286,9 +281,9 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -306,7 +301,7 @@ pub struct SetLockupCheckedCpiBuilder<'a, 'b> { } impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(SetLockupCheckedCpiBuilderInstruction { __program: program, stake: None, @@ -320,16 +315,13 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { } /// Initialized stake account #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } /// Lockup authority or withdraw authority #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -338,20 +330,20 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn new_authority( &mut self, - new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + new_authority: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.new_authority = new_authority; self } /// `[optional argument]` #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { + pub fn unix_timestamp(&mut self, unix_timestamp: UnixTimestamp) -> &mut Self { self.instruction.unix_timestamp = Some(unix_timestamp); self } /// `[optional argument]` #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.instruction.epoch = Some(epoch); self } @@ -359,7 +351,7 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -375,11 +367,7 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -387,15 +375,12 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = SetLockupCheckedInstructionArgs { unix_timestamp: self.instruction.unix_timestamp.clone(), epoch: self.instruction.epoch.clone(), @@ -419,16 +404,12 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct SetLockupCheckedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - unix_timestamp: Option, - epoch: Option, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + new_authority: Option<&'b solana_account_info::AccountInfo<'a>>, + unix_timestamp: Option, + epoch: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/split.rs b/clients/rust/src/generated/instructions/split.rs index e17198a1..4b646d0f 100644 --- a/clients/rust/src/generated/instructions/split.rs +++ b/clients/rust/src/generated/instructions/split.rs @@ -7,48 +7,46 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const SPLIT_DISCRIMINATOR: u32 = 3; + /// Accounts. #[derive(Debug)] pub struct Split { - /// Stake account to be split - pub stake: solana_program::pubkey::Pubkey, - /// Uninitialized stake account - pub split_stake: solana_program::pubkey::Pubkey, + /// Stake account to be split; must be in the Initialized or Stake state + pub stake: solana_pubkey::Pubkey, + /// Uninitialized stake account that will take the split-off amount + pub split_stake: solana_pubkey::Pubkey, /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, + pub stake_authority: solana_pubkey::Pubkey, } impl Split { - pub fn instruction( - &self, - args: SplitInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: SplitInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: SplitInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new( self.split_stake, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SplitInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = SplitInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -66,6 +64,10 @@ impl SplitInstructionData { pub fn new() -> Self { Self { discriminator: 3 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for SplitInstructionData { @@ -80,6 +82,12 @@ pub struct SplitInstructionArgs { pub args: u64, } +impl SplitInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Split`. /// /// ### Accounts: @@ -89,35 +97,32 @@ pub struct SplitInstructionArgs { /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct SplitBuilder { - stake: Option, - split_stake: Option, - stake_authority: Option, + stake: Option, + split_stake: Option, + stake_authority: Option, args: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl SplitBuilder { pub fn new() -> Self { Self::default() } - /// Stake account to be split + /// Stake account to be split; must be in the Initialized or Stake state #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// Uninitialized stake account + /// Uninitialized stake account that will take the split-off amount #[inline(always)] - pub fn split_stake(&mut self, split_stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn split_stake(&mut self, split_stake: solana_pubkey::Pubkey) -> &mut Self { self.split_stake = Some(split_stake); self } /// Stake authority #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn stake_authority(&mut self, stake_authority: solana_pubkey::Pubkey) -> &mut Self { self.stake_authority = Some(stake_authority); self } @@ -128,10 +133,7 @@ impl SplitBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -139,13 +141,13 @@ impl SplitBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Split { stake: self.stake.expect("stake is not set"), split_stake: self.split_stake.expect("split_stake is not set"), @@ -161,31 +163,31 @@ impl SplitBuilder { /// `split` CPI accounts. pub struct SplitCpiAccounts<'a, 'b> { - /// Stake account to be split - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Uninitialized stake account - pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be split; must be in the Initialized or Stake state + pub stake: &'b solana_account_info::AccountInfo<'a>, + /// Uninitialized stake account that will take the split-off amount + pub split_stake: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, } /// `split` CPI instruction. pub struct SplitCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake account to be split - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Uninitialized stake account - pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, + /// Stake account to be split; must be in the Initialized or Stake state + pub stake: &'b solana_account_info::AccountInfo<'a>, + /// Uninitialized stake account that will take the split-off amount + pub split_stake: &'b solana_account_info::AccountInfo<'a>, /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: SplitInstructionArgs, } impl<'a, 'b> SplitCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: SplitCpiAccounts<'a, 'b>, args: SplitInstructionArgs, ) -> Self { @@ -198,63 +200,50 @@ impl<'a, 'b> SplitCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new( *self.split_stake.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&SplitInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = SplitInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -269,9 +258,9 @@ impl<'a, 'b> SplitCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -289,7 +278,7 @@ pub struct SplitCpiBuilder<'a, 'b> { } impl<'a, 'b> SplitCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(SplitCpiBuilderInstruction { __program: program, stake: None, @@ -300,17 +289,17 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { }); Self { instruction } } - /// Stake account to be split + /// Stake account to be split; must be in the Initialized or Stake state #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Uninitialized stake account + /// Uninitialized stake account that will take the split-off amount #[inline(always)] pub fn split_stake( &mut self, - split_stake: &'b solana_program::account_info::AccountInfo<'a>, + split_stake: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.split_stake = Some(split_stake); self @@ -319,7 +308,7 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { #[inline(always)] pub fn stake_authority( &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + stake_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_authority = Some(stake_authority); self @@ -333,7 +322,7 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -349,11 +338,7 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -361,15 +346,12 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = SplitInstructionArgs { args: self.instruction.args.clone().expect("args is not set"), }; @@ -398,15 +380,11 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct SplitCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - split_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + split_stake: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_account_info::AccountInfo<'a>>, args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/withdraw.rs b/clients/rust/src/generated/instructions/withdraw.rs index 7d21b1c2..edb35253 100644 --- a/clients/rust/src/generated/instructions/withdraw.rs +++ b/clients/rust/src/generated/instructions/withdraw.rs @@ -7,68 +7,63 @@ use borsh::{BorshDeserialize, BorshSerialize}; +pub const WITHDRAW_DISCRIMINATOR: u32 = 4; + /// Accounts. #[derive(Debug)] pub struct Withdraw { /// Stake account from which to withdraw - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Recipient account - pub recipient: solana_program::pubkey::Pubkey, + pub recipient: solana_pubkey::Pubkey, /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar - pub stake_history: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_pubkey::Pubkey, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: solana_pubkey::Pubkey, /// Withdraw authority - pub withdraw_authority: solana_program::pubkey::Pubkey, - /// Lockup authority - pub lockup_authority: Option, + pub withdraw_authority: solana_pubkey::Pubkey, + /// Lockup authority, if before lockup expiration + pub lockup_authority: Option, } impl Withdraw { - pub fn instruction( - &self, - args: WithdrawInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: WithdrawInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, args: WithdrawInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.stake, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - self.recipient, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.stake, false)); + accounts.push(solana_instruction::AccountMeta::new(self.recipient, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.clock_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.stake_history, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.withdraw_authority, true, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( lockup_authority, true, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = WithdrawInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -86,6 +81,10 @@ impl WithdrawInstructionData { pub fn new() -> Self { Self { discriminator: 4 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for WithdrawInstructionData { @@ -100,6 +99,12 @@ pub struct WithdrawInstructionArgs { pub args: u64, } +impl WithdrawInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Withdraw`. /// /// ### Accounts: @@ -107,19 +112,19 @@ pub struct WithdrawInstructionArgs { /// 0. `[writable]` stake /// 1. `[writable]` recipient /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[]` stake_history +/// 3. `[optional]` stake_history (default to `SysvarStakeHistory1111111111111111111111111`) /// 4. `[signer]` withdraw_authority /// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct WithdrawBuilder { - stake: Option, - recipient: Option, - clock_sysvar: Option, - stake_history: Option, - withdraw_authority: Option, - lockup_authority: Option, + stake: Option, + recipient: Option, + clock_sysvar: Option, + stake_history: Option, + withdraw_authority: Option, + lockup_authority: Option, args: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl WithdrawBuilder { @@ -128,44 +133,42 @@ impl WithdrawBuilder { } /// Stake account from which to withdraw #[inline(always)] - pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake(&mut self, stake: solana_pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } /// Recipient account #[inline(always)] - pub fn recipient(&mut self, recipient: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn recipient(&mut self, recipient: solana_pubkey::Pubkey) -> &mut Self { self.recipient = Some(recipient); self } /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn clock_sysvar(&mut self, clock_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar + /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] - pub fn stake_history(&mut self, stake_history: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn stake_history(&mut self, stake_history: solana_pubkey::Pubkey) -> &mut Self { self.stake_history = Some(stake_history); self } /// Withdraw authority #[inline(always)] - pub fn withdraw_authority( - &mut self, - withdraw_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn withdraw_authority(&mut self, withdraw_authority: solana_pubkey::Pubkey) -> &mut Self { self.withdraw_authority = Some(withdraw_authority); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option, + lockup_authority: Option, ) -> &mut Self { self.lockup_authority = lockup_authority; self @@ -177,10 +180,7 @@ impl WithdrawBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -188,20 +188,22 @@ impl WithdrawBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Withdraw { stake: self.stake.expect("stake is not set"), recipient: self.recipient.expect("recipient is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + clock_sysvar: self.clock_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), - stake_history: self.stake_history.expect("stake_history is not set"), + stake_history: self.stake_history.unwrap_or(solana_pubkey::pubkey!( + "SysvarStakeHistory1111111111111111111111111" + )), withdraw_authority: self .withdraw_authority .expect("withdraw_authority is not set"), @@ -218,42 +220,42 @@ impl WithdrawBuilder { /// `withdraw` CPI accounts. pub struct WithdrawCpiAccounts<'a, 'b> { /// Stake account from which to withdraw - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Recipient account - pub recipient: &'b solana_program::account_info::AccountInfo<'a>, + pub recipient: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: &'b solana_account_info::AccountInfo<'a>, /// Withdraw authority - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub withdraw_authority: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `withdraw` CPI instruction. pub struct WithdrawCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Stake account from which to withdraw - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Recipient account - pub recipient: &'b solana_program::account_info::AccountInfo<'a>, + pub recipient: &'b solana_account_info::AccountInfo<'a>, /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: &'b solana_account_info::AccountInfo<'a>, /// Withdraw authority - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub withdraw_authority: &'b solana_account_info::AccountInfo<'a>, + /// Lockup authority, if before lockup expiration + pub lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: WithdrawInstructionArgs, } impl<'a, 'b> WithdrawCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: WithdrawCpiAccounts<'a, 'b>, args: WithdrawInstructionArgs, ) -> Self { @@ -269,77 +271,64 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } + #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new(*self.stake.key, false)); + accounts.push(solana_instruction::AccountMeta::new( *self.recipient.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.stake_history.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.withdraw_authority.key, true, )); if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *lockup_authority.key, true, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = WithdrawInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::STAKE_ID, accounts, data, @@ -359,9 +348,9 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -382,7 +371,7 @@ pub struct WithdrawCpiBuilder<'a, 'b> { } impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(WithdrawCpiBuilderInstruction { __program: program, stake: None, @@ -398,16 +387,13 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { } /// Stake account from which to withdraw #[inline(always)] - pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn stake(&mut self, stake: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } /// Recipient account #[inline(always)] - pub fn recipient( - &mut self, - recipient: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn recipient(&mut self, recipient: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.recipient = Some(recipient); self } @@ -415,16 +401,16 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { #[inline(always)] pub fn clock_sysvar( &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + clock_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history( &mut self, - stake_history: &'b solana_program::account_info::AccountInfo<'a>, + stake_history: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.stake_history = Some(stake_history); self @@ -433,17 +419,17 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { #[inline(always)] pub fn withdraw_authority( &mut self, - withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + withdraw_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.withdraw_authority = Some(withdraw_authority); self } /// `[optional account]` - /// Lockup authority + /// Lockup authority, if before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.lockup_authority = lockup_authority; self @@ -457,7 +443,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -473,11 +459,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -485,15 +467,12 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = WithdrawInstructionArgs { args: self.instruction.args.clone().expect("args is not set"), }; @@ -531,18 +510,14 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct WithdrawCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - recipient: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_history: Option<&'b solana_program::account_info::AccountInfo<'a>>, - withdraw_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + stake: Option<&'b solana_account_info::AccountInfo<'a>>, + recipient: Option<&'b solana_account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + stake_history: Option<&'b solana_account_info::AccountInfo<'a>>, + withdraw_authority: Option<&'b solana_account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>, args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/programs.rs b/clients/rust/src/generated/programs.rs index e3286ac3..f9d1f59f 100644 --- a/clients/rust/src/generated/programs.rs +++ b/clients/rust/src/generated/programs.rs @@ -5,7 +5,7 @@ //! //! -use solana_program::{pubkey, pubkey::Pubkey}; +use solana_pubkey::{pubkey, Pubkey}; /// `stake` program ID. pub const STAKE_ID: Pubkey = pubkey!("Stake11111111111111111111111111111111111111"); diff --git a/clients/rust/src/generated/types/authorized.rs b/clients/rust/src/generated/types/authorized.rs index e6406ae9..03d3bfbe 100644 --- a/clients/rust/src/generated/types/authorized.rs +++ b/clients/rust/src/generated/types/authorized.rs @@ -7,7 +7,7 @@ use { borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, + solana_pubkey::Pubkey, }; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] diff --git a/clients/rust/src/generated/types/delegation.rs b/clients/rust/src/generated/types/delegation.rs index a9066b51..67195f5d 100644 --- a/clients/rust/src/generated/types/delegation.rs +++ b/clients/rust/src/generated/types/delegation.rs @@ -6,8 +6,9 @@ //! use { + crate::generated::types::Epoch, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, + solana_pubkey::Pubkey, }; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] @@ -19,7 +20,7 @@ pub struct Delegation { )] pub voter_pubkey: Pubkey, pub stake: u64, - pub activation_epoch: u64, - pub deactivation_epoch: u64, + pub activation_epoch: Epoch, + pub deactivation_epoch: Epoch, pub warmup_cooldown_rate: f64, } diff --git a/clients/rust/src/generated/types/epoch.rs b/clients/rust/src/generated/types/epoch.rs new file mode 100644 index 00000000..0060ad16 --- /dev/null +++ b/clients/rust/src/generated/types/epoch.rs @@ -0,0 +1,8 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +pub type Epoch = u64; diff --git a/clients/rust/src/generated/types/lockup.rs b/clients/rust/src/generated/types/lockup.rs index c25a723f..906b9fa7 100644 --- a/clients/rust/src/generated/types/lockup.rs +++ b/clients/rust/src/generated/types/lockup.rs @@ -6,15 +6,16 @@ //! use { + crate::generated::types::{Epoch, UnixTimestamp}, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, + solana_pubkey::Pubkey, }; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Lockup { - pub unix_timestamp: i64, - pub epoch: u64, + pub unix_timestamp: UnixTimestamp, + pub epoch: Epoch, #[cfg_attr( feature = "serde", serde(with = "serde_with::As::") diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index 41560dee..052ebd93 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -7,6 +7,7 @@ pub(crate) mod r#authorized; pub(crate) mod r#delegation; +pub(crate) mod r#epoch; pub(crate) mod r#lockup; pub(crate) mod r#meta; pub(crate) mod r#stake; @@ -14,8 +15,10 @@ pub(crate) mod r#stake_authorize; pub(crate) mod r#stake_flags; pub(crate) mod r#stake_state; pub(crate) mod r#stake_state_v2; +pub(crate) mod r#unix_timestamp; pub use self::{ - r#authorized::*, r#delegation::*, r#lockup::*, r#meta::*, r#stake::*, r#stake_authorize::*, - r#stake_flags::*, r#stake_state::*, r#stake_state_v2::*, + r#authorized::*, r#delegation::*, r#epoch::*, r#lockup::*, r#meta::*, r#stake::*, + r#stake_authorize::*, r#stake_flags::*, r#stake_state::*, r#stake_state_v2::*, + r#unix_timestamp::*, }; diff --git a/clients/rust/src/generated/types/unix_timestamp.rs b/clients/rust/src/generated/types/unix_timestamp.rs new file mode 100644 index 00000000..62d0860b --- /dev/null +++ b/clients/rust/src/generated/types/unix_timestamp.rs @@ -0,0 +1,8 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +pub type UnixTimestamp = i64; diff --git a/clients/rust/src/hooked/stake_state_account.rs b/clients/rust/src/hooked/stake_state_account.rs index 640ef03b..360b3c54 100644 --- a/clients/rust/src/hooked/stake_state_account.rs +++ b/clients/rust/src/hooked/stake_state_account.rs @@ -106,12 +106,10 @@ impl StakeStateAccount { } } -impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for StakeStateAccount { +impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for StakeStateAccount { type Error = std::io::Error; - fn try_from( - account_info: &solana_program::account_info::AccountInfo<'a>, - ) -> Result { + fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { let mut data: &[u8] = &(*account_info.data).borrow(); Self::deserialize(&mut data) } diff --git a/codama.json b/codama.json new file mode 100644 index 00000000..ca9ea06e --- /dev/null +++ b/codama.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://codama.gg/schemas/codama.json", + "idls": [ + { + "path": "interface/idl.json", + "format": "codama" + } + ], + "generators": [ + { + "generator": "@codama/renderers-js", + "path": "clients/js/src/generated" + }, + { + "generator": "@codama/renderers-rust", + "path": "clients/rust/src/generated" + } + ] +} + diff --git a/interface/Cargo.toml b/interface/Cargo.toml index f91d225d..9f8f0a2a 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -18,6 +18,8 @@ program-id = "Stake11111111111111111111111111111111111111" [dependencies] borsh = { version = "1.5.7", features = ["derive", "unstable__schema"], optional = true } +codama = { version = "0.7.1", optional = true } +codama-macros = { version = "0.7.1", optional = true } num-traits = "0.2" serde = { version = "1.0.210", optional = true } serde_derive = { version = "1.0.210", optional = true } @@ -32,6 +34,9 @@ solana-system-interface = "2.0.0" solana-sysvar = { version = "3.0.0", optional = true } solana-sysvar-id = { version = "3.0.0", optional = true } +[target.'cfg(not(target_os = "solana"))'.dependencies] +serde_json = { version = "1.0", optional = true } + [dev-dependencies] anyhow = "1" assert_matches = "1.5.0" @@ -67,6 +72,7 @@ borsh = [ "solana-program-error/borsh", "solana-pubkey/borsh" ] +codama = ["dep:codama", "dep:codama-macros", "dep:serde_json"] frozen-abi = [ "dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", diff --git a/interface/idl.json b/interface/idl.json index 87cf2042..b329bed8 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -1,1078 +1,1853 @@ { - "version": "0.1.0", - "name": "solana_stake_interface", - "instructions": [ - { - "name": "Initialize", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Uninitialized stake account" - ] - }, - { - "name": "rentSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Rent sysvar" - ] + "additionalPrograms": [], + "kind": "rootNode", + "program": { + "accounts": [], + "definedTypes": [ + { + "kind": "definedTypeNode", + "name": "lockupParams", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "unixTimestamp", + "type": { + "item": { + "kind": "definedTypeLinkNode", + "name": "unixTimestamp" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "epoch", + "type": { + "item": { + "kind": "definedTypeLinkNode", + "name": "epoch" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "custodian", + "type": { + "item": { + "kind": "publicKeyTypeNode" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + } + ], + "kind": "structTypeNode" } - ], - "args": [ - { - "name": "arg0", - "type": { - "defined": "Authorized" - } - }, - { - "name": "arg1", - "type": { - "defined": "Lockup" - } + }, + { + "kind": "definedTypeNode", + "name": "lockupCheckedParams", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "unixTimestamp", + "type": { + "item": { + "kind": "definedTypeLinkNode", + "name": "unixTimestamp" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "epoch", + "type": { + "item": { + "kind": "definedTypeLinkNode", + "name": "epoch" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + } + ], + "kind": "structTypeNode" } - ], - "discriminant": { - "type": "u32", - "value": 0 - } - }, - { - "name": "Authorize", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account to be updated" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake or withdraw authority" - ] - }, - { - "name": "lockupAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "Lockup authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "authorizeWithSeedParams", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "newAuthorizedPubkey", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "stakeAuthorize", + "type": { + "kind": "definedTypeLinkNode", + "name": "stakeAuthorize" + } + }, + { + "kind": "structFieldTypeNode", + "name": "authoritySeed", + "type": { + "kind": "sizePrefixTypeNode", + "prefix": { + "endian": "le", + "format": "u32", + "kind": "numberTypeNode" + }, + "type": { + "encoding": "utf8", + "kind": "stringTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "authorityOwner", + "type": { + "kind": "publicKeyTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [ - { - "name": "arg0", - "type": "publicKey" - }, - { - "name": "arg1", - "type": { - "defined": "StakeAuthorize" - } + }, + { + "kind": "definedTypeNode", + "name": "authorizeCheckedWithSeedParams", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "stakeAuthorize", + "type": { + "kind": "definedTypeLinkNode", + "name": "stakeAuthorize" + } + }, + { + "kind": "structFieldTypeNode", + "name": "authoritySeed", + "type": { + "kind": "sizePrefixTypeNode", + "prefix": { + "endian": "le", + "format": "u32", + "kind": "numberTypeNode" + }, + "type": { + "encoding": "utf8", + "kind": "stringTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "authorityOwner", + "type": { + "kind": "publicKeyTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "discriminant": { - "type": "u32", - "value": 1 - } - }, - { - "name": "DelegateStake", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Initialized stake account to be delegated" - ] - }, - { - "name": "vote", - "isMut": false, - "isSigner": false, - "docs": [ - "Vote account to which this stake will be delegated" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "stakeHistory", - "isMut": false, - "isSigner": false, - "docs": [ - "Stake history sysvar" - ] - }, - { - "name": "unused", - "isMut": false, - "isSigner": false, - "docs": [ - "Unused account, formerly the stake config" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "stakeFlags", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "bits", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 2 - } - }, - { - "name": "Split", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account to be split" - ] - }, - { - "name": "splitStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Uninitialized stake account" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" + }, + { + "kind": "definedTypeNode", + "name": "stakeState", + "type": { + "kind": "enumTypeNode", + "size": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + }, + "variants": [ + { + "kind": "enumEmptyVariantTypeNode", + "name": "uninitialized" + }, + { + "kind": "enumTupleVariantTypeNode", + "name": "initialized", + "tuple": { + "items": [ + { + "kind": "definedTypeLinkNode", + "name": "meta" + } + ], + "kind": "tupleTypeNode" + } + }, + { + "kind": "enumTupleVariantTypeNode", + "name": "stake", + "tuple": { + "items": [ + { + "kind": "definedTypeLinkNode", + "name": "meta" + }, + { + "kind": "definedTypeLinkNode", + "name": "stake" + } + ], + "kind": "tupleTypeNode" + } + }, + { + "kind": "enumEmptyVariantTypeNode", + "name": "rewardsPool" + } ] } - ], - "args": [ - { - "name": "args", - "type": "u64" - } - ], - "discriminant": { - "type": "u32", - "value": 3 - } - }, - { - "name": "Withdraw", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account from which to withdraw" - ] - }, - { - "name": "recipient", - "isMut": true, - "isSigner": false, - "docs": [ - "Recipient account" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "stakeHistory", - "isMut": false, - "isSigner": false, - "docs": [ - "Stake history sysvar" - ] - }, - { - "name": "withdrawAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Withdraw authority" - ] - }, - { - "name": "lockupAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "Lockup authority" + }, + { + "kind": "definedTypeNode", + "name": "stakeStateV2", + "type": { + "kind": "enumTypeNode", + "size": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + }, + "variants": [ + { + "kind": "enumEmptyVariantTypeNode", + "name": "uninitialized" + }, + { + "kind": "enumTupleVariantTypeNode", + "name": "initialized", + "tuple": { + "items": [ + { + "kind": "definedTypeLinkNode", + "name": "meta" + } + ], + "kind": "tupleTypeNode" + } + }, + { + "kind": "enumTupleVariantTypeNode", + "name": "stake", + "tuple": { + "items": [ + { + "kind": "definedTypeLinkNode", + "name": "meta" + }, + { + "kind": "definedTypeLinkNode", + "name": "stake" + }, + { + "kind": "definedTypeLinkNode", + "name": "stakeFlags" + } + ], + "kind": "tupleTypeNode" + } + }, + { + "kind": "enumEmptyVariantTypeNode", + "name": "rewardsPool" + } ] } - ], - "args": [ - { - "name": "args", - "type": "u64" - } - ], - "discriminant": { - "type": "u32", - "value": 4 - } - }, - { - "name": "Deactivate", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Delegated stake account" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" + }, + { + "kind": "definedTypeNode", + "name": "stakeAuthorize", + "type": { + "kind": "enumTypeNode", + "size": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + }, + "variants": [ + { + "kind": "enumEmptyVariantTypeNode", + "name": "staker" + }, + { + "kind": "enumEmptyVariantTypeNode", + "name": "withdrawer" + } ] } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 5 - } - }, - { - "name": "SetLockup", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Initialized stake account" - ] - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "docs": [ - "Lockup authority or withdraw authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "lockup", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "unixTimestamp", + "type": { + "kind": "definedTypeLinkNode", + "name": "unixTimestamp" + } + }, + { + "kind": "structFieldTypeNode", + "name": "epoch", + "type": { + "kind": "definedTypeLinkNode", + "name": "epoch" + } + }, + { + "kind": "structFieldTypeNode", + "name": "custodian", + "type": { + "kind": "publicKeyTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [ - { - "name": "lockupArgs", - "type": { - "defined": "LockupArgs" - } + }, + { + "kind": "definedTypeNode", + "name": "authorized", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "staker", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "withdrawer", + "type": { + "kind": "publicKeyTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "discriminant": { - "type": "u32", - "value": 6 - } - }, - { - "name": "Merge", - "accounts": [ - { - "name": "destinationStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Destination stake account" - ] - }, - { - "name": "sourceStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Source stake account" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "stakeHistory", - "isMut": false, - "isSigner": false, - "docs": [ - "Stake history sysvar" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "meta", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "rentExemptReserve", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "authorized", + "type": { + "kind": "definedTypeLinkNode", + "name": "authorized" + } + }, + { + "kind": "structFieldTypeNode", + "name": "lockup", + "type": { + "kind": "definedTypeLinkNode", + "name": "lockup" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 7 - } - }, - { - "name": "AuthorizeWithSeed", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account to be updated" - ] - }, - { - "name": "base", - "isMut": false, - "isSigner": true, - "docs": [ - "Base key of stake or withdraw authority" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "lockupAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "Lockup authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "delegation", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "voterPubkey", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "stake", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "activationEpoch", + "type": { + "kind": "definedTypeLinkNode", + "name": "epoch" + } + }, + { + "kind": "structFieldTypeNode", + "name": "deactivationEpoch", + "type": { + "kind": "definedTypeLinkNode", + "name": "epoch" + } + }, + { + "kind": "structFieldTypeNode", + "name": "warmupCooldownRate", + "type": { + "endian": "le", + "format": "f64", + "kind": "numberTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [ - { - "name": "authorizeWithSeedArgs", - "type": { - "defined": "AuthorizeWithSeedArgs" - } + }, + { + "kind": "definedTypeNode", + "name": "stake", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "delegation", + "type": { + "kind": "definedTypeLinkNode", + "name": "delegation" + } + }, + { + "kind": "structFieldTypeNode", + "name": "creditsObserved", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "discriminant": { - "type": "u32", - "value": 8 } - }, - { - "name": "InitializeChecked", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Uninitialized stake account" - ] - }, - { - "name": "rentSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Rent sysvar" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": false, - "docs": [ - "The stake authority" - ] - }, - { - "name": "withdrawAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "The withdraw authority" - ] - } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 9 + ], + "errors": [ + { + "code": 0, + "kind": "errorNode", + "message": "Not enough credits to redeem", + "name": "noCreditsToRedeem" + }, + { + "code": 1, + "kind": "errorNode", + "message": "Lockup has not yet expired", + "name": "lockupInForce" + }, + { + "code": 2, + "kind": "errorNode", + "message": "Stake already deactivated", + "name": "alreadyDeactivated" + }, + { + "code": 3, + "kind": "errorNode", + "message": "One re-delegation permitted per epoch", + "name": "tooSoonToRedelegate" + }, + { + "code": 4, + "kind": "errorNode", + "message": "Split amount is more than is staked", + "name": "insufficientStake" + }, + { + "code": 5, + "kind": "errorNode", + "message": "Stake account with transient stake cannot be merged", + "name": "mergeTransientStake" + }, + { + "code": 6, + "kind": "errorNode", + "message": "Stake account merge failed due to different authority, lockups or state", + "name": "mergeMismatch" + }, + { + "code": 7, + "kind": "errorNode", + "message": "Custodian address not present", + "name": "custodianMissing" + }, + { + "code": 8, + "kind": "errorNode", + "message": "Custodian signature not present", + "name": "custodianSignatureMissing" + }, + { + "code": 9, + "kind": "errorNode", + "message": "Insufficient voting activity in the reference vote account", + "name": "insufficientReferenceVotes" + }, + { + "code": 10, + "kind": "errorNode", + "message": "Stake account is not delegated to the provided vote account", + "name": "voteAddressMismatch" + }, + { + "code": 11, + "kind": "errorNode", + "message": "Stake account has not been delinquent for the minimum epochs required for deactivation", + "name": "minimumDelinquentEpochsForDeactivationNotMet" + }, + { + "code": 12, + "kind": "errorNode", + "message": "Delegation amount is less than the minimum", + "name": "insufficientDelegation" + }, + { + "code": 13, + "kind": "errorNode", + "message": "Stake account with transient or inactive stake cannot be redelegated", + "name": "redelegateTransientOrInactiveStake" + }, + { + "code": 14, + "kind": "errorNode", + "message": "Stake redelegation to the same vote account is not permitted", + "name": "redelegateToSameVoteAccount" + }, + { + "code": 15, + "kind": "errorNode", + "message": "Redelegated stake must be fully activated before deactivation", + "name": "redelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted" + }, + { + "code": 16, + "kind": "errorNode", + "message": "Stake action is not permitted while the epoch rewards period is active", + "name": "epochRewardsActive" } - }, - { - "name": "AuthorizeChecked", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account to be updated" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "docs": [ - "The stake or withdraw authority" - ] - }, - { - "name": "newAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "The new stake or withdraw authority" - ] - }, - { - "name": "lockupAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "Lockup authority" - ] - } - ], - "args": [ - { - "name": "stakeAuthorize", - "type": { - "defined": "StakeAuthorize" + ], + "instructions": [ + { + "accounts": [ + { + "docs": [ + "Uninitialized stake account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarRent111111111111111111111111111111111" + }, + "docs": [ + "Rent sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "rentSysvar" } - } - ], - "discriminant": { - "type": "u32", - "value": 10 - } - }, - { - "name": "AuthorizeCheckedWithSeed", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account to be updated" - ] - }, - { - "name": "base", - "isMut": false, - "isSigner": true, - "docs": [ - "Base key of stake or withdraw authority" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "newAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "The new stake or withdraw authority" - ] - }, - { - "name": "lockupAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "Lockup authority" - ] - } - ], - "args": [ - { - "name": "authorizeCheckedWithSeedArgs", - "type": { - "defined": "AuthorizeCheckedWithSeedArgs" + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 0 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + }, + { + "kind": "instructionArgumentNode", + "name": "arg0", + "type": { + "kind": "definedTypeLinkNode", + "name": "authorized" + } + }, + { + "kind": "instructionArgumentNode", + "name": "arg1", + "type": { + "kind": "definedTypeLinkNode", + "name": "lockup" + } } - } - ], - "discriminant": { - "type": "u32", - "value": 11 - } - }, - { - "name": "SetLockupChecked", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Initialized stake account" - ] - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "docs": [ - "Lockup authority or withdraw authority" - ] - }, - { - "name": "newAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "New lockup authority" - ] - } - ], - "args": [ - { - "name": "lockupCheckedArgs", - "type": { - "defined": "LockupCheckedArgs" + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 } - } - ], - "discriminant": { - "type": "u32", - "value": 12 - } - }, - { - "name": "GetMinimumDelegation", - "accounts": [], - "args": [], - "discriminant": { - "type": "u32", - "value": 13 - } - }, - { - "name": "DeactivateDelinquent", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Delegated stake account" - ] - }, - { - "name": "delinquentVote", - "isMut": false, - "isSigner": false, - "docs": [ - "Delinquent vote account" - ] - }, - { - "name": "referenceVote", - "isMut": false, - "isSigner": false, - "docs": [ - "Reference vote account" - ] - } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 14 - } - }, - { - "name": "Redelegate", - "accounts": [], - "args": [], - "discriminant": { - "type": "u32", - "value": 15 - } - }, - { - "name": "MoveStake", - "accounts": [ - { - "name": "sourceStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Active source stake account" - ] - }, - { - "name": "destinationStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Active or inactive destination stake account" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" - ] - } - ], - "args": [ - { - "name": "args", - "type": "u64" - } - ], - "discriminant": { - "type": "u32", - "value": 16 - } - }, - { - "name": "MoveLamports", - "accounts": [ - { - "name": "sourceStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Active or inactive source stake account" - ] - }, - { - "name": "destinationStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Mergeable destination stake account" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" - ] - } - ], - "args": [ - { - "name": "args", - "type": "u64" - } - ], - "discriminant": { - "type": "u32", - "value": 17 - } - } - ], - "types": [ - { - "name": "LockupArgs", - "type": { - "kind": "struct", - "fields": [ - { - "name": "unixTimestamp", + ], + "kind": "instructionNode", + "name": "initialize" + }, + { + "accounts": [ + { + "docs": [ + "Stake account to be updated" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, + "docs": [ + "Clock sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "docs": [ + "The stake or withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authority" + }, + { + "docs": [ + "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + ], + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "lockupAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 1 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "option": { - "defined": "UnixTimestamp" - } + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } }, { - "name": "epoch", + "kind": "instructionArgumentNode", + "name": "arg0", "type": { - "option": { - "defined": "Epoch" - } + "kind": "publicKeyTypeNode" } }, { - "name": "custodian", + "kind": "instructionArgumentNode", + "name": "arg1", "type": { - "option": "publicKey" + "kind": "definedTypeLinkNode", + "name": "stakeAuthorize" } } - ] - } - }, - { - "name": "LockupCheckedArgs", - "type": { - "kind": "struct", - "fields": [ - { - "name": "unixTimestamp", + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "authorize" + }, + { + "accounts": [ + { + "docs": [ + "Initialized stake account to be delegated" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "docs": [ + "Vote account to which this stake will be delegated" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "vote" + }, + { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, + "docs": [ + "Clock sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarStakeHistory1111111111111111111111111" + }, + "docs": [ + "Stake history sysvar that carries stake warmup/cooldown history" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeHistory" + }, + { + "docs": [ + "Unused account, formerly the stake config" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "unused" + }, + { + "docs": [ + "Stake authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 2 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "option": { - "defined": "UnixTimestamp" - } + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "delegateStake" + }, + { + "accounts": [ + { + "docs": [ + "Stake account to be split; must be in the Initialized or Stake state" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "docs": [ + "Uninitialized stake account that will take the split-off amount" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "splitStake" }, { - "name": "epoch", + "docs": [ + "Stake authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 3 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "option": { - "defined": "Epoch" - } + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } - } - ] - } - }, - { - "name": "AuthorizeWithSeedArgs", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAuthorizedPubkey", - "type": "publicKey" }, { - "name": "stakeAuthorize", + "kind": "instructionArgumentNode", + "name": "args", "type": { - "defined": "StakeAuthorize" + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "split" + }, + { + "accounts": [ + { + "docs": [ + "Stake account from which to withdraw" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "docs": [ + "Recipient account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "recipient" + }, + { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, + "docs": [ + "Clock sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" }, { - "name": "authoritySeed", - "type": "string" + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarStakeHistory1111111111111111111111111" + }, + "docs": [ + "Stake history sysvar that carries stake warmup/cooldown history" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeHistory" }, { - "name": "authorityOwner", - "type": "publicKey" + "docs": [ + "Withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "withdrawAuthority" + }, + { + "docs": [ + "Lockup authority, if before lockup expiration" + ], + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "lockupAuthority" } - ] - } - }, - { - "name": "AuthorizeCheckedWithSeedArgs", - "type": { - "kind": "struct", - "fields": [ + ], + "arguments": [ { - "name": "stakeAuthorize", + "defaultValue": { + "kind": "numberValueNode", + "number": 4 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + }, + { + "kind": "instructionArgumentNode", + "name": "args", "type": { - "defined": "StakeAuthorize" + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "withdraw" + }, + { + "accounts": [ + { + "docs": [ + "Delegated stake account to be deactivated" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" }, { - "name": "authoritySeed", - "type": "string" + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, + "docs": [ + "Clock sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" }, { - "name": "authorityOwner", - "type": "publicKey" + "docs": [ + "Stake authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeAuthority" } - ] - } - }, - { - "name": "StakeFlags", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bits", - "type": "u8" + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 5 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } } - ] - } - }, - { - "name": "Lockup", - "type": { - "kind": "struct", - "fields": [ - { - "name": "unixTimestamp", + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "deactivate" + }, + { + "accounts": [ + { + "docs": [ + "Initialized stake account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "docs": [ + "Lockup authority or withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 6 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "defined": "UnixTimestamp" + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } }, { - "name": "epoch", + "kind": "instructionArgumentNode", + "name": "arg0", "type": { - "defined": "Epoch" + "kind": "definedTypeLinkNode", + "name": "lockupArgs" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "setLockup" + }, + { + "accounts": [ + { + "docs": [ + "Destination stake account for the merge" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "destinationStake" + }, + { + "docs": [ + "Source stake account for to merge. This account will be drained" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "sourceStake" }, { - "name": "custodian", - "type": "publicKey" + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, + "docs": [ + "Clock sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarStakeHistory1111111111111111111111111" + }, + "docs": [ + "Stake history sysvar that carries stake warmup/cooldown history" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeHistory" + }, + { + "docs": [ + "Stake authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeAuthority" } - ] - } - }, - { - "name": "Authorized", - "type": { - "kind": "struct", - "fields": [ - { - "name": "staker", - "type": "publicKey" + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 7 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "merge" + }, + { + "accounts": [ + { + "docs": [ + "Stake account to be updated" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "docs": [ + "Base key of stake or withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "base" }, { - "name": "withdrawer", - "type": "publicKey" + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, + "docs": [ + "Clock sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "docs": [ + "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + ], + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "lockupAuthority" } - ] - } - }, - { - "name": "Meta", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rentExemptReserve", - "type": "u64" + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 8 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } }, { - "name": "authorized", + "kind": "instructionArgumentNode", + "name": "arg0", "type": { - "defined": "Authorized" + "kind": "definedTypeLinkNode", + "name": "authorizeWithSeedArgs" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "authorizeWithSeed" + }, + { + "accounts": [ + { + "docs": [ + "Uninitialized stake account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" }, { - "name": "lockup", + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarRent111111111111111111111111111111111" + }, + "docs": [ + "Rent sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "rentSysvar" + }, + { + "docs": [ + "The stake authority" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeAuthority" + }, + { + "docs": [ + "The withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "withdrawAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 9 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "defined": "Lockup" + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } } - ] - } - }, - { - "name": "Delegation", - "type": { - "kind": "struct", - "fields": [ - { - "name": "voterPubkey", - "type": "publicKey" + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "initializeChecked" + }, + { + "accounts": [ + { + "docs": [ + "Stake account to be updated" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, + "docs": [ + "Clock sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" }, { - "name": "stake", - "type": "u64" + "docs": [ + "The stake or withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authority" + }, + { + "docs": [ + "The new stake or withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "newAuthority" + }, + { + "docs": [ + "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + ], + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "lockupAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 10 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } }, { - "name": "activationEpoch", + "kind": "instructionArgumentNode", + "name": "stakeAuthorize", "type": { - "defined": "Epoch" + "kind": "definedTypeLinkNode", + "name": "stakeAuthorize" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "authorizeChecked" + }, + { + "accounts": [ + { + "docs": [ + "Stake account to be updated" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "docs": [ + "Base key of stake or withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "base" + }, + { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, + "docs": [ + "Clock sysvar" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "docs": [ + "The new stake or withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "newAuthority" }, { - "name": "deactivationEpoch", + "docs": [ + "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + ], + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "lockupAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 11 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "defined": "Epoch" + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } }, { - "name": "warmupCooldownRate", + "kind": "instructionArgumentNode", + "name": "arg0", "type": { - "defined": "f64" + "kind": "definedTypeLinkNode", + "name": "authorizeCheckedWithSeedArgs" } } - ] - } - }, - { - "name": "Stake", - "type": { - "kind": "struct", - "fields": [ - { - "name": "delegation", + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "authorizeCheckedWithSeed" + }, + { + "accounts": [ + { + "docs": [ + "Initialized stake account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "docs": [ + "Lockup authority or withdraw authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authority" + }, + { + "docs": [ + "New lockup authority" + ], + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "newAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 12 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "defined": "Delegation" + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } }, { - "name": "creditsObserved", - "type": "u64" + "kind": "instructionArgumentNode", + "name": "arg0", + "type": { + "kind": "definedTypeLinkNode", + "name": "lockupCheckedArgs" + } } - ] - } - }, - { - "name": "StakeState", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Uninitialized" + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "setLockupChecked" + }, + { + "accounts": [], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 13 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "getMinimumDelegation" + }, + { + "accounts": [ + { + "docs": [ + "Delegated stake account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" }, { - "name": "Initialized", - "fields": [ - { - "defined": "Meta" - } - ] + "docs": [ + "Delinquent vote account for the delegated stake account" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "delinquentVote" }, { - "name": "Stake", - "fields": [ - { - "defined": "Meta" - }, - { - "defined": "Stake" - } - ] + "docs": [ + "Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs" + ], + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "referenceVote" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 14 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "deactivateDelinquent" + }, + { + "accounts": [], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 15 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "redelegate" + }, + { + "accounts": [ + { + "docs": [ + "Active source stake account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "sourceStake" }, { - "name": "RewardsPool" + "docs": [ + "Active or inactive destination stake account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "destinationStake" + }, + { + "docs": [ + "Stake authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeAuthority" } - ] - } - }, - { - "name": "StakeStateV2", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Uninitialized" + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 16 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } }, { - "name": "Initialized", - "fields": [ - { - "defined": "Meta" - } - ] + "kind": "instructionArgumentNode", + "name": "args", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "moveStake" + }, + { + "accounts": [ + { + "docs": [ + "Active or inactive source stake account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "sourceStake" }, { - "name": "Stake", - "fields": [ - { - "defined": "Meta" - }, - { - "defined": "Stake" - }, - { - "defined": "StakeFlags" - } - ] + "docs": [ + "Mergeable destination stake account" + ], + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "destinationStake" }, { - "name": "RewardsPool" + "docs": [ + "Stake authority" + ], + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeAuthority" } - ] - } - }, - { - "name": "StakeAuthorize", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Staker" + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 17 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } }, { - "name": "Withdrawer" + "kind": "instructionArgumentNode", + "name": "args", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 } - ] + ], + "kind": "instructionNode", + "name": "moveLamports" } - } - ], - "metadata": { - "origin": "shank", - "address": "Stake11111111111111111111111111111111111111", - "binaryVersion": "0.4.2", - "libVersion": "0.4.2" - } + ], + "kind": "programNode", + "name": "solanaStakeInterface", + "pdas": [], + "publicKey": "Stake11111111111111111111111111111111111111", + "version": "2.0.2" + }, + "standard": "codama", + "version": "1.0.0" } diff --git a/interface/src/bin/generate-idl.rs b/interface/src/bin/generate-idl.rs new file mode 100644 index 00000000..f1df8977 --- /dev/null +++ b/interface/src/bin/generate-idl.rs @@ -0,0 +1,32 @@ +//! Codama IDL generation binary. +#[cfg(feature = "codama")] +use { + codama::Codama, + std::{env, fs, path::Path}, +}; + +#[cfg(feature = "codama")] +fn main() -> Result<(), Box> { + // Generate IDL. + let manifest_dir = env::var("CARGO_MANIFEST_DIR")?; + let crate_path = Path::new(&manifest_dir); + let codama = Codama::load(crate_path)?; + let idl_json = codama.get_json_idl()?; + + // Parse and format the JSON with pretty printing. + let parsed: serde_json::Value = serde_json::from_str(&idl_json)?; + let mut formatted_json = serde_json::to_string_pretty(&parsed)?; + formatted_json.push('\n'); + + // Write IDL file. + let idl_path = Path::new(&manifest_dir).join("idl.json"); + fs::write(&idl_path, formatted_json)?; + + println!("IDL written to: {}", idl_path.display()); + Ok(()) +} + +#[cfg(not(feature = "codama"))] +fn main() { + println!("Codama is not enabled"); +} diff --git a/interface/src/error.rs b/interface/src/error.rs index 29923230..d965b340 100644 --- a/interface/src/error.rs +++ b/interface/src/error.rs @@ -1,70 +1,145 @@ +#[cfg(feature = "codama")] +use codama_macros::CodamaErrors; use { num_traits::{FromPrimitive, ToPrimitive}, solana_program_error::ProgramError, }; /// Reasons the Stake might have had an error. +#[cfg_attr(feature = "codama", derive(CodamaErrors))] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(test, derive(strum_macros::FromRepr, strum_macros::EnumIter))] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Clone, Debug, PartialEq, Eq)] pub enum StakeError { - // 0 /// Not enough credits to redeem. + #[cfg_attr( + feature = "codama", + codama(error(message = "Not enough credits to redeem")) + )] NoCreditsToRedeem, /// Lockup has not yet expired. + #[cfg_attr( + feature = "codama", + codama(error(message = "Lockup has not yet expired")) + )] LockupInForce, /// Stake already deactivated. + #[cfg_attr( + feature = "codama", + codama(error(message = "Stake already deactivated")) + )] AlreadyDeactivated, /// One re-delegation permitted per epoch. + #[cfg_attr( + feature = "codama", + codama(error(message = "One re-delegation permitted per epoch")) + )] TooSoonToRedelegate, /// Split amount is more than is staked. + #[cfg_attr( + feature = "codama", + codama(error(message = "Split amount is more than is staked")) + )] InsufficientStake, - // 5 /// Stake account with transient stake cannot be merged. + #[cfg_attr( + feature = "codama", + codama(error(message = "Stake account with transient stake cannot be merged")) + )] MergeTransientStake, /// Stake account merge failed due to different authority, lockups or state. + #[cfg_attr( + feature = "codama", + codama(error( + message = "Stake account merge failed due to different authority, lockups or state" + )) + )] MergeMismatch, /// Custodian address not present. + #[cfg_attr( + feature = "codama", + codama(error(message = "Custodian address not present")) + )] CustodianMissing, /// Custodian signature not present. + #[cfg_attr( + feature = "codama", + codama(error(message = "Custodian signature not present")) + )] CustodianSignatureMissing, /// Insufficient voting activity in the reference vote account. + #[cfg_attr( + feature = "codama", + codama(error(message = "Insufficient voting activity in the reference vote account")) + )] InsufficientReferenceVotes, - // 10 /// Stake account is not delegated to the provided vote account. + #[cfg_attr( + feature = "codama", + codama(error(message = "Stake account is not delegated to the provided vote account")) + )] VoteAddressMismatch, /// Stake account has not been delinquent for the minimum epochs required /// for deactivation. + #[cfg_attr( + feature = "codama", + codama(error( + message = "Stake account has not been delinquent for the minimum epochs required for deactivation" + )) + )] MinimumDelinquentEpochsForDeactivationNotMet, /// Delegation amount is less than the minimum. + #[cfg_attr( + feature = "codama", + codama(error(message = "Delegation amount is less than the minimum")) + )] InsufficientDelegation, /// Stake account with transient or inactive stake cannot be redelegated. + #[cfg_attr( + feature = "codama", + codama(error( + message = "Stake account with transient or inactive stake cannot be redelegated" + )) + )] RedelegateTransientOrInactiveStake, /// Stake redelegation to the same vote account is not permitted. + #[cfg_attr( + feature = "codama", + codama(error(message = "Stake redelegation to the same vote account is not permitted")) + )] RedelegateToSameVoteAccount, - // 15 /// Redelegated stake must be fully activated before deactivation. + #[cfg_attr( + feature = "codama", + codama(error(message = "Redelegated stake must be fully activated before deactivation")) + )] RedelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted, /// Stake action is not permitted while the epoch rewards period is active. + #[cfg_attr( + feature = "codama", + codama(error( + message = "Stake action is not permitted while the epoch rewards period is active" + )) + )] EpochRewardsActive, } diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 7bbb5033..373212c1 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -3,6 +3,8 @@ // Required to avoid warnings from uses of deprecated types during trait derivations. #![allow(deprecated)] +#[cfg(feature = "codama")] +use codama_macros::{codama, CodamaInstructions, CodamaType}; use { crate::state::{Authorized, Lockup, StakeAuthorize}, solana_clock::{Epoch, UnixTimestamp}, @@ -37,6 +39,7 @@ const STAKE_HISTORY_ID: Pubkey = feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] +#[cfg_attr(feature = "codama", derive(CodamaInstructions))] #[derive(Debug, PartialEq, Eq, Clone)] pub enum StakeInstruction { /// Initialize a stake with lockup and authorization information @@ -48,6 +51,12 @@ pub enum StakeInstruction { /// [`Authorized`] carries pubkeys that must sign staker transactions /// and withdrawer transactions; [`Lockup`] carries information about /// withdrawal restrictions. + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Uninitialized stake account")), + codama(account(name = "rent_sysvar", docs = "Rent sysvar", default_value = sysvar("rent"))) + )] + // backwards compatibility with old IDL demands auto `arg0` and `arg1` names Initialize(Authorized, Lockup), /// Authorize a key to manage stake or withdrawal @@ -58,6 +67,19 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` The stake or withdraw authority /// 3. Optional: `[SIGNER]` Lockup authority, if updating `StakeAuthorize::Withdrawer` before /// lockup expiration + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Stake account to be updated")), + codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))), + codama(account(name = "authority", signer, docs = "The stake or withdraw authority")), + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + )) + )] + // backwards compatibility with old IDL demands auto `arg0` and `arg1` names Authorize(Pubkey, StakeAuthorize), /// Delegate a stake to a particular vote account @@ -72,6 +94,26 @@ pub enum StakeInstruction { /// /// The entire balance of the staking account is staked. `DelegateStake` /// can be called multiple times, but re-delegation is delayed by one epoch. + #[cfg_attr( + feature = "codama", + codama(account( + name = "stake", + writable, + docs = "Initialized stake account to be delegated" + )), + codama(account( + name = "vote", + docs = "Vote account to which this stake will be delegated" + )), + codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))), + codama(account( + name = "stake_history", + docs = "Stake history sysvar that carries stake warmup/cooldown history", + default_value = sysvar("stake_history") + )), + codama(account(name = "unused", docs = "Unused account, formerly the stake config")), + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] DelegateStake, /// Split `u64` tokens and stake off a stake account into another stake account. @@ -80,7 +122,22 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Stake account to be split; must be in the Initialized or Stake state /// 1. `[WRITE]` Uninitialized stake account that will take the split-off amount /// 2. `[SIGNER]` Stake authority - Split(u64), + #[cfg_attr( + feature = "codama", + codama(account( + name = "stake", + writable, + docs = "Stake account to be split; must be in the Initialized or Stake state" + )), + codama(account( + name = "split_stake", + writable, + docs = "Uninitialized stake account that will take the split-off amount" + )), + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] + // backwards compatibility with old IDL demands old `args` name + Split(#[cfg_attr(feature = "codama", codama(name = "args"))] u64), /// Withdraw unstaked lamports from the stake account /// @@ -94,7 +151,30 @@ pub enum StakeInstruction { /// /// The `u64` is the portion of the stake account balance to be withdrawn, /// must be `<= StakeAccount.lamports - staked_lamports`. - Withdraw(u64), + #[cfg_attr( + feature = "codama", + codama(account( + name = "stake", + writable, + docs = "Stake account from which to withdraw" + )), + codama(account(name = "recipient", writable, docs = "Recipient account")), + codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))), + codama(account( + name = "stake_history", + docs = "Stake history sysvar that carries stake warmup/cooldown history", + default_value = sysvar("stake_history") + )), + codama(account(name = "withdraw_authority", signer, docs = "Withdraw authority")), + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if before lockup expiration" + )) + )] + // backwards compatibility with old IDL demands old `args` name + Withdraw(#[cfg_attr(feature = "codama", codama(name = "args"))] u64), /// Deactivates the stake in the account /// @@ -102,6 +182,16 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Delegated stake account /// 1. `[]` Clock sysvar /// 2. `[SIGNER]` Stake authority + #[cfg_attr( + feature = "codama", + codama(account( + name = "stake", + writable, + docs = "Delegated stake account to be deactivated" + )), + codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))), + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] Deactivate, /// Set stake lockup @@ -112,6 +202,15 @@ pub enum StakeInstruction { /// # Account references /// 0. `[WRITE]` Initialized stake account /// 1. `[SIGNER]` Lockup authority or withdraw authority + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Initialized stake account")), + codama(account( + name = "authority", + signer, + docs = "Lockup authority or withdraw authority" + )) + )] SetLockup(LockupArgs), /// Merge two stake accounts. @@ -138,6 +237,26 @@ pub enum StakeInstruction { /// 2. `[]` Clock sysvar /// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history /// 4. `[SIGNER]` Stake authority + #[cfg_attr( + feature = "codama", + codama(account( + name = "destination_stake", + writable, + docs = "Destination stake account for the merge" + )), + codama(account( + name = "source_stake", + writable, + docs = "Source stake account for to merge. This account will be drained" + )), + codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))), + codama(account( + name = "stake_history", + docs = "Stake history sysvar that carries stake warmup/cooldown history", + default_value = sysvar("stake_history") + )), + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] Merge, /// Authorize a key to manage stake or withdrawal with a derived key @@ -148,6 +267,22 @@ pub enum StakeInstruction { /// 2. `[]` Clock sysvar /// 3. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Stake account to be updated")), + codama(account( + name = "base", + signer, + docs = "Base key of stake or withdraw authority" + )), + codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))), + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + )) + )] AuthorizeWithSeed(AuthorizeWithSeedArgs), /// Initialize a stake with authorization information @@ -160,6 +295,13 @@ pub enum StakeInstruction { /// 1. `[]` Rent sysvar /// 2. `[]` The stake authority /// 3. `[SIGNER]` The withdraw authority + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Uninitialized stake account")), + codama(account(name = "rent_sysvar", docs = "Rent sysvar", default_value = sysvar("rent"))), + codama(account(name = "stake_authority", docs = "The stake authority")), + codama(account(name = "withdraw_authority", signer, docs = "The withdraw authority")) + )] InitializeChecked, /// Authorize a key to manage stake or withdrawal @@ -174,7 +316,26 @@ pub enum StakeInstruction { /// 3. `[SIGNER]` The new stake or withdraw authority /// 4. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration - AuthorizeChecked(StakeAuthorize), + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Stake account to be updated")), + codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))), + codama(account(name = "authority", signer, docs = "The stake or withdraw authority")), + codama(account( + name = "new_authority", + signer, + docs = "The new stake or withdraw authority" + )), + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + )) + )] + AuthorizeChecked( + #[cfg_attr(feature = "codama", codama(name = "stakeAuthorize"))] StakeAuthorize, + ), /// Authorize a key to manage stake or withdrawal with a derived key /// @@ -188,6 +349,27 @@ pub enum StakeInstruction { /// 3. `[SIGNER]` The new stake or withdraw authority /// 4. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Stake account to be updated")), + codama(account( + name = "base", + signer, + docs = "Base key of stake or withdraw authority" + )), + codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))), + codama(account( + name = "new_authority", + signer, + docs = "The new stake or withdraw authority" + )), + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + )) + )] AuthorizeCheckedWithSeed(AuthorizeCheckedWithSeedArgs), /// Set stake lockup @@ -202,6 +384,21 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Initialized stake account /// 1. `[SIGNER]` Lockup authority or withdraw authority /// 2. Optional: `[SIGNER]` New lockup authority + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Initialized stake account")), + codama(account( + name = "authority", + signer, + docs = "Lockup authority or withdraw authority" + )), + codama(account( + name = "new_authority", + optional, + signer, + docs = "New lockup authority" + )) + )] SetLockupChecked(LockupCheckedArgs), /// Get the minimum stake delegation, in lamports @@ -217,7 +414,7 @@ pub enum StakeInstruction { GetMinimumDelegation, /// Deactivate stake delegated to a vote account that has been delinquent for at least - /// [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs. + /// `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs. /// /// No signer is required for this instruction as it is a common good to deactivate abandoned /// stake. @@ -226,7 +423,19 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Delegated stake account /// 1. `[]` Delinquent vote account for the delegated stake account /// 2. `[]` Reference vote account that has voted at least once in the last - /// [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs + /// `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Delegated stake account")), + codama(account( + name = "delinquent_vote", + docs = "Delinquent vote account for the delegated stake account" + )), + codama(account( + name = "reference_vote", + docs = "Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs" + )) + )] DeactivateDelinquent, /// Redelegate activated stake to another vote account. @@ -250,6 +459,7 @@ pub enum StakeInstruction { /// 4. `[SIGNER]` Stake authority /// #[deprecated(since = "2.1.0", note = "Redelegate will not be enabled")] + // NOTE: No codama attributes - this instruction is disabled and excluded from IDL Redelegate, /// Move stake between accounts with the same authorities and lockups, using Staker authority. @@ -271,7 +481,18 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of the stake to move, which may be the entire delegation - MoveStake(u64), + #[cfg_attr( + feature = "codama", + codama(account(name = "sourceStake", writable, docs = "Active source stake account")), + codama(account( + name = "destinationStake", + writable, + docs = "Active or inactive destination stake account" + )), + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] + // sadly named `args` to avoid breaking users of old IDL + MoveStake(#[cfg_attr(feature = "codama", codama(name = "args"))] u64), /// Move unstaked lamports between accounts with the same authorities and lockups, using Staker /// authority. @@ -286,35 +507,61 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of available lamports to move - MoveLamports(u64), + #[cfg_attr( + feature = "codama", + codama(account( + name = "source_stake", + writable, + docs = "Active or inactive source stake account" + )), + codama(account( + name = "destination_stake", + writable, + docs = "Mergeable destination stake account" + )), + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] + // sadly named `args` to avoid breaking users of old IDL + MoveLamports(#[cfg_attr(feature = "codama", codama(name = "args"))] u64), } +#[cfg_attr(feature = "codama", derive(CodamaType), codama(name = "lockupParams"))] +#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] pub struct LockupArgs { pub unix_timestamp: Option, pub epoch: Option, pub custodian: Option, } +#[cfg_attr( + feature = "codama", + derive(CodamaType), + codama(name = "lockupCheckedParams") +)] +#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] pub struct LockupCheckedArgs { pub unix_timestamp: Option, pub epoch: Option, } +#[cfg_attr( + feature = "codama", + derive(CodamaType), + codama(name = "authorizeWithSeedParams") +)] +#[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Debug, PartialEq, Eq, Clone)] pub struct AuthorizeWithSeedArgs { pub new_authorized_pubkey: Pubkey, pub stake_authorize: StakeAuthorize, @@ -322,11 +569,16 @@ pub struct AuthorizeWithSeedArgs { pub authority_owner: Pubkey, } +#[cfg_attr( + feature = "codama", + derive(CodamaType), + codama(name = "authorizeCheckedWithSeedParams") +)] +#[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Debug, PartialEq, Eq, Clone)] pub struct AuthorizeCheckedWithSeedArgs { pub stake_authorize: StakeAuthorize, pub authority_seed: String, diff --git a/interface/src/lib.rs b/interface/src/lib.rs index d82a9532..edfd08b3 100644 --- a/interface/src/lib.rs +++ b/interface/src/lib.rs @@ -14,6 +14,9 @@ pub mod state; pub mod sysvar; pub mod tools; +#[cfg(feature = "codama")] +use codama_macros::codama; +#[cfg_attr(feature = "codama", codama(name = "stake"))] pub mod program { solana_pubkey::declare_id!("Stake11111111111111111111111111111111111111"); } diff --git a/interface/src/stake_flags.rs b/interface/src/stake_flags.rs index 790925d8..05ad9053 100644 --- a/interface/src/stake_flags.rs +++ b/interface/src/stake_flags.rs @@ -2,6 +2,8 @@ use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; /// Additional flags for stake state. +#[cfg_attr(feature = "codama", derive(codama_macros::CodamaType))] +#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Debug)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -12,7 +14,6 @@ use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Debug)] pub struct StakeFlags { bits: u8, } diff --git a/interface/src/state.rs b/interface/src/state.rs index f473eac8..6b8e827b 100644 --- a/interface/src/state.rs +++ b/interface/src/state.rs @@ -6,6 +6,8 @@ #[cfg(feature = "borsh")] use borsh::{io, BorshDeserialize, BorshSchema, BorshSerialize}; +#[cfg(feature = "codama")] +use codama_macros::{codama, CodamaType}; use { crate::{ error::StakeError, @@ -79,12 +81,17 @@ macro_rules! impl_borsh_stake_state { } }; } +#[cfg_attr( + feature = "codama", + derive(CodamaType), + codama(enum_discriminator(size = number(u32))) +)] +#[derive(Debug, Default, PartialEq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Debug, Default, PartialEq, Clone, Copy)] #[allow(clippy::large_enum_variant)] #[deprecated( since = "1.17.0", @@ -140,12 +147,17 @@ impl StakeState { } } +#[cfg_attr( + feature = "codama", + derive(CodamaType), + codama(enum_discriminator(size = number(u32))) +)] +#[derive(Debug, Default, PartialEq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Debug, Default, PartialEq, Clone, Copy)] #[allow(clippy::large_enum_variant)] pub enum StakeStateV2 { #[default] @@ -259,17 +271,24 @@ impl StakeStateV2 { } } +#[cfg_attr( + feature = "codama", + derive(CodamaType), + codama(enum_discriminator(size = number(u32))) +)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum StakeAuthorize { Staker, Withdrawer, } +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -280,7 +299,6 @@ pub enum StakeAuthorize { feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] pub struct Lockup { /// `UnixTimestamp` at which this stake will allow withdrawal, unless the /// transaction is signed by the custodian @@ -301,6 +319,8 @@ impl Lockup { } } +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -311,7 +331,6 @@ impl Lockup { feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] pub struct Authorized { pub staker: Pubkey, pub withdrawer: Pubkey, @@ -383,6 +402,8 @@ impl Authorized { } } +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -393,7 +414,6 @@ impl Authorized { feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] pub struct Meta { pub rent_exempt_reserve: u64, pub authorized: Authorized, @@ -437,6 +457,8 @@ impl Meta { } } +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[derive(Debug, PartialEq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -447,7 +469,6 @@ impl Meta { feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Debug, PartialEq, Clone, Copy)] pub struct Delegation { /// to whom the stake is delegated pub voter_pubkey: Pubkey, @@ -676,6 +697,8 @@ impl Delegation { } } +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[derive(Debug, Default, PartialEq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -686,7 +709,6 @@ impl Delegation { feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Debug, Default, PartialEq, Clone, Copy)] pub struct Stake { pub delegation: Delegation, /// credits observed is credits from vote account state when delegated or redeemed diff --git a/package.json b/package.json index ac65323b..790cc4dd 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,8 @@ "generate:clients": "tsx ./scripts/generate-clients.mts && (cd clients/js && pnpm format:fix)" }, "devDependencies": { - "@codama/nodes-from-anchor": "^1.3.7", "@codama/renderers-js": "^1.4", - "@codama/renderers-rust": "~1.0", + "@codama/renderers-rust": "^1.2.9", "@iarna/toml": "^2.2.5", "codama": "^1.5", "tsx": "^4.21.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 75dd91c7..e1fec7e5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,15 +8,12 @@ importers: .: devDependencies: - '@codama/nodes-from-anchor': - specifier: ^1.3.7 - version: 1.3.7(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) '@codama/renderers-js': specifier: ^1.4 version: 1.4.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) '@codama/renderers-rust': - specifier: ~1.0 - version: 1.0.16(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) + specifier: ^1.2.9 + version: 1.2.9(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) '@iarna/toml': specifier: ^2.2.5 version: 2.2.5 @@ -39,61 +36,59 @@ packages: resolution: {integrity: sha512-0uLecW/RZC2c1wx3j/eiRAYvilvNY+2DoyEYu/hV0OfM1/uIgIyuy5U+wolV+LY4wLFYdApjYdy+5D32lngCHg==} hasBin: true - '@codama/errors@1.2.8': - resolution: {integrity: sha512-TVPf7oJpbHtxdu52ruftJX+DlTNWi7D65tasysqs7mfRKoiZKzmkatr5hqidBz/M9WzCddUeFAHL9ZiW6g9Ccg==} - hasBin: true - '@codama/errors@1.3.7': resolution: {integrity: sha512-96BF8agDVc2vAgL4qw1lZZfuJ7XBefdzTBk2VOUnOhdMQiLb0QhJCC4BH88OcL+rZXQdet4pk7Qwarj1I1GFKg==} hasBin: true + '@codama/errors@1.4.4': + resolution: {integrity: sha512-XC86H5X+zGTi0cSRKLc+wFkeXNsvnh+ttOgVnVHIljmXOJWbUt9wXhKding3UftipLWwlHPuoswERJ0vS0mO2A==} + hasBin: true + '@codama/errors@1.5.0': resolution: {integrity: sha512-i4cS+S7JaZXhofQHFY3cwzt8rqxUVPNaeJND5VOyKUbtcOi933YXJXk52gDG4mc+CpGqHJijsJjfSpr1lJGxzg==} hasBin: true - '@codama/node-types@1.2.8': - resolution: {integrity: sha512-PEvPLMN3QGJvkwsQ7R9DmAtdazQXN0RD9WYlmHyeiR4nathV0qy9nZGFDoRh5nbNfPkbeLTgL5o3zAoeeRP6GQ==} - '@codama/node-types@1.3.7': resolution: {integrity: sha512-L9UTFfoeki5t+BYJAa4OMsqBPpbMbx8YJQar+55mYcjwGlJsKJW7mRfLYvwEFkCUYyLdNva40OVmTf88jccZCA==} + '@codama/node-types@1.4.4': + resolution: {integrity: sha512-uUeIz34Id/TTAMi4k5OVl9FByM/PawnlNIIVqgpooH9AS0UlniICZ+KJ/mdHZidJs/AGo6bSRoOPS1BLtMajyw==} + '@codama/node-types@1.5.0': resolution: {integrity: sha512-Ebz2vOUukmNaFXWdkni1ZihXkAIUnPYtqIMXYxKXOxjMP+TGz2q0lGtRo7sqw1pc2ksFBIkfBp5pZsl5p6gwXA==} - '@codama/nodes-from-anchor@1.3.7': - resolution: {integrity: sha512-MJbTVfyCAmRilJ6wDqk8dT2kMU3nvUnImaiLLOagAG9aKlKeBcjDvqNp0XM6qhb49jogXgfK7x1q9ERaQQnacQ==} - - '@codama/nodes@1.2.8': - resolution: {integrity: sha512-tCi7KErG2ChQr5n3Nj3dwciFmUo3O8RQ+S4Qv23w1zvYLaGwhEvdg3KRtgCGEI0wr9uvm2QtTBM670kdLntZiQ==} - '@codama/nodes@1.3.7': resolution: {integrity: sha512-3OV6SIBcqsIDARyzZVGdfnffNlnKSYcb0aGp/9Liz5/EID0oBTIyuh/Cmj5Ww6RX4WPb+GNAxABAGW94zbcfQg==} + '@codama/nodes@1.4.4': + resolution: {integrity: sha512-JzlY5qLk3rhsnu0nerC/Vkc9/2HjdsLtEpBtST0dxC1j9kpfHvIc2uyIj+5hlB1YIBRJIDNo+UOHGla8hidkaA==} + '@codama/nodes@1.5.0': resolution: {integrity: sha512-yg+xmorWiMNjS3n19CGIt/FZ/ZCuDIu+HEY45bq6gHu1MN3RtJZY+Q3v0ErnBPA60D8mNWkvkKoeSZXfzcAvfw==} - '@codama/renderers-core@1.0.10': - resolution: {integrity: sha512-7NwoyP2j1cZKgHCrd1RRn891gtxpZeiXNSP3aCFdVsRPW8dDNUL1sJ1SNOF9ILHfNP77clCBtL3eoZIFdeNQAg==} - '@codama/renderers-core@1.2.2': resolution: {integrity: sha512-dPyHgn5L45G+tWP17ITvOlpX3+s2FcJHMjAhFZlmUHAJpH/wl+UsUwuWg698iSb56Er2jUwqX7srw5iZf7XHjQ==} + '@codama/renderers-core@1.3.4': + resolution: {integrity: sha512-+qEPsvpCjUElohgJTcVNsjy6u1LjoCcwo72NbcffLF9QU5mUjNwL8EhFouEq2K60H/QKmNaiVKLQfJcQ/xCT9A==} + '@codama/renderers-js@1.4.3': resolution: {integrity: sha512-FC/wba6IZayKeWk710XP0OJN50kf9B6cVQGo6uXb8M8hMw9qjSJLDPwpou57Y0V7tja3kjTFPBb3I9zHheeDtQ==} engines: {node: '>=20.18.0'} - '@codama/renderers-rust@1.0.16': - resolution: {integrity: sha512-pFHwHN6X4Yuk26Yfh+VT9Ps1i/QEjuK3EoT8BpsCTATOk6ntJNqyD5aQngG2lE4KWx3uQrCYYbQEAN4vG6v+EA==} + '@codama/renderers-rust@1.2.9': + resolution: {integrity: sha512-6sc/g8LYHEa3MFqakEBRJito/1liv1jE1b6P1gGRz7z84YiGscPKh0pbcELlLPxyLraNTBYSA6V9EXrj2LLvIA==} + engines: {node: '>=20.18.0'} '@codama/validators@1.5.0': resolution: {integrity: sha512-p3ufDxnCH1jiuHGzcBv4/d+ctzUcKD2K3gX/W8169tC41o9DggjlEpNy1Z6YAAhVb3wHnmXVGA2qmp32rWSfWw==} - '@codama/visitors-core@1.2.8': - resolution: {integrity: sha512-sYmZT2Z6Goacgr/HrAhjLSGtu2Udcal10tEfYN8ZJBXs34PGPu0oWOC8kFx7CxvmAvt/6mw8NhKIPtg/UaIKHw==} - '@codama/visitors-core@1.3.7': resolution: {integrity: sha512-B1JnzhRDJiLxewha/F3YzeEp8Zrtd7eKiGNJFJHSPufAnIVm2lQUDaKS+OrAOHnSRmRKIAVdzfpFpdz6EM0N6Q==} + '@codama/visitors-core@1.4.4': + resolution: {integrity: sha512-vk/4tczViAUHa7c8PF7FxN+JWbuTcDB0pIdrDbbO6eBPKDPQGZCUCEp6rXIYBVxfO129jWrNf2+CuyYre/c/vA==} + '@codama/visitors-core@1.5.0': resolution: {integrity: sha512-3PIAlBX0a06hIxzyPtQMfQcqWGFBgfbwysSwcXBbvHUYbemwhD6xwlBKJuqTwm9DyFj3faStp5fpvcp03Rjxtw==} @@ -259,16 +254,6 @@ packages: '@iarna/toml@2.2.5': resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} - '@noble/hashes@2.0.1': - resolution: {integrity: sha512-XlOlEbQcE9fmuXxrVTXCTlG2nlRXa9Rj3rr5Ue/+tX+nmkgbX720YHh0VR3hBF9xDvwnb8D2shVGOwNx+ulArw==} - engines: {node: '>= 20.19.0'} - - '@solana/codecs-core@2.0.0-rc.4': - resolution: {integrity: sha512-JIrTSps032mSE3wBxW3bXOqWfoy4CMy1CX/XeVCijyh5kLVxZTSDIdRTYdePdL1yzaOZF1Xysvt1DhOUgBdM+A==} - engines: {node: '>=20.18.0'} - peerDependencies: - typescript: '>=5' - '@solana/codecs-core@4.0.0': resolution: {integrity: sha512-28kNUsyIlhU3MO3/7ZLDqeJf2YAm32B4tnTjl5A9HrbBqsTZ+upT/RzxZGP1MMm7jnPuIKCMwmTpsyqyR6IUpw==} engines: {node: '>=20.18.0'} @@ -281,18 +266,6 @@ packages: peerDependencies: typescript: '>=5.3.3' - '@solana/codecs-data-structures@5.0.0': - resolution: {integrity: sha512-y503Pqmv0LHcfcf0vQJGaxDvydQJbyCo8nK3nxn56EhFj5lBQ1NWb3WvTd83epigwuZurW2MhJARrpikfhQglQ==} - engines: {node: '>=20.18.0'} - peerDependencies: - typescript: '>=5.3.3' - - '@solana/codecs-numbers@2.0.0-rc.4': - resolution: {integrity: sha512-ZJR7TaUO65+3Hzo3YOOUCS0wlzh17IW+j0MZC2LCk1R0woaypRpHKj4iSMYeQOZkMxsd9QT3WNvjFrPC2qA6Sw==} - engines: {node: '>=20.18.0'} - peerDependencies: - typescript: '>=5' - '@solana/codecs-numbers@4.0.0': resolution: {integrity: sha512-z9zpjtcwzqT9rbkKVZpkWB5/0V7+6YRKs6BccHkGJlaDx8Pe/+XOvPi2rEdXPqrPd9QWb5Xp1iBfcgaDMyiOiA==} engines: {node: '>=20.18.0'} @@ -305,13 +278,6 @@ packages: peerDependencies: typescript: '>=5.3.3' - '@solana/codecs-strings@2.0.0-rc.4': - resolution: {integrity: sha512-LGfK2RL0BKjYYUfzu2FG/gTgCsYOMz9FKVs2ntji6WneZygPxJTV5W98K3J8Rl0JewpCSCFQH3xjLSHBJUS0fA==} - engines: {node: '>=20.18.0'} - peerDependencies: - fastestsmallesttextencoderdecoder: ^1.0.22 - typescript: '>=5' - '@solana/codecs-strings@4.0.0': resolution: {integrity: sha512-XvyD+sQ1zyA0amfxbpoFZsucLoe+yASQtDiLUGMDg5TZ82IHE3B7n82jE8d8cTAqi0HgqQiwU13snPhvg1O0Ow==} engines: {node: '>=20.18.0'} @@ -326,19 +292,6 @@ packages: fastestsmallesttextencoderdecoder: ^1.0.22 typescript: '>=5.3.3' - '@solana/codecs@5.0.0': - resolution: {integrity: sha512-KOw0gFUSBxIMDWLJ3AkVFkEci91dw0Rpx3C6y83Our7fSW+SEP8vRZklCElieYR85LHVB1QIEhoeHR7rc+Ifkw==} - engines: {node: '>=20.18.0'} - peerDependencies: - typescript: '>=5.3.3' - - '@solana/errors@2.0.0-rc.4': - resolution: {integrity: sha512-0PPaMyB81keEHG/1pnyEuiBVKctbXO641M2w3CIOrYT/wzjunfF0FTxsqq9wYJeYo0AyiefCKGgSPs6wiY2PpQ==} - engines: {node: '>=20.18.0'} - hasBin: true - peerDependencies: - typescript: '>=5' - '@solana/errors@4.0.0': resolution: {integrity: sha512-3YEtvcMvtcnTl4HahqLt0VnaGVf7vVWOnt6/uPky5e0qV6BlxDSbGkbBzttNjxLXHognV0AQi3pjvrtfUnZmbg==} engines: {node: '>=20.18.0'} @@ -353,12 +306,6 @@ packages: peerDependencies: typescript: '>=5.3.3' - '@solana/options@5.0.0': - resolution: {integrity: sha512-ezHVBFb9FXVSn8LUVRD2tLb6fejU0x8KtGEYyCYh0J0pQuXSITV0IQCjcEopvu/ZxWdXOJyzjvmymnhz90on5A==} - engines: {node: '>=20.18.0'} - peerDependencies: - typescript: '>=5.3.3' - a-sync-waterfall@1.0.1: resolution: {integrity: sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA==} @@ -377,18 +324,10 @@ packages: resolution: {integrity: sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==} engines: {node: '>= 0.4'} - call-bound@1.0.3: - resolution: {integrity: sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==} - engines: {node: '>= 0.4'} - call-bound@1.0.4: resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==} engines: {node: '>= 0.4'} - chalk@5.4.1: - resolution: {integrity: sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==} - engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} - chalk@5.6.2: resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} @@ -397,14 +336,6 @@ packages: resolution: {integrity: sha512-hhfSzrOiDX3bV7QmJneEBsBk3ln4gIcMJs6P8BlEJ3EFI+P0QZaTT5W61o8Tq0/79hTZeyj0gP65HZ/LYJil+w==} hasBin: true - commander@12.1.0: - resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} - engines: {node: '>=18'} - - commander@13.1.0: - resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==} - engines: {node: '>=18'} - commander@14.0.1: resolution: {integrity: sha512-2JkV3gUZUVrbNA+1sjBOYLsMZ5cEEl8GTFP2a4AVz5hvasAMCQ1D2l2le/cX+pV4N6ZU17zjUahLpIXRrnWL8A==} engines: {node: '>=20'} @@ -486,10 +417,6 @@ packages: isarray@2.0.5: resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} - json-stable-stringify@1.2.1: - resolution: {integrity: sha512-Lp6HbbBgosLmJbjx0pBLbgvx68FaFU1sdkmBuckmhhJ88kL13OA51CDtR2yJB50eCNMH9wRqtQNNiAqQH4YXnA==} - engines: {node: '>= 0.4'} - json-stable-stringify@1.3.0: resolution: {integrity: sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg==} engines: {node: '>= 0.4'} @@ -567,68 +494,57 @@ snapshots: picocolors: 1.1.1 prompts: 2.4.2 - '@codama/errors@1.2.8': - dependencies: - '@codama/node-types': 1.2.8 - chalk: 5.4.1 - commander: 13.1.0 - '@codama/errors@1.3.7': dependencies: '@codama/node-types': 1.3.7 commander: 14.0.1 picocolors: 1.1.1 + '@codama/errors@1.4.4': + dependencies: + '@codama/node-types': 1.4.4 + commander: 14.0.2 + picocolors: 1.1.1 + '@codama/errors@1.5.0': dependencies: '@codama/node-types': 1.5.0 commander: 14.0.2 picocolors: 1.1.1 - '@codama/node-types@1.2.8': {} - '@codama/node-types@1.3.7': {} - '@codama/node-types@1.5.0': {} - - '@codama/nodes-from-anchor@1.3.7(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': - dependencies: - '@codama/errors': 1.5.0 - '@codama/nodes': 1.5.0 - '@codama/visitors': 1.5.0 - '@noble/hashes': 2.0.1 - '@solana/codecs': 5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - transitivePeerDependencies: - - fastestsmallesttextencoderdecoder - - typescript + '@codama/node-types@1.4.4': {} - '@codama/nodes@1.2.8': - dependencies: - '@codama/errors': 1.2.8 - '@codama/node-types': 1.2.8 + '@codama/node-types@1.5.0': {} '@codama/nodes@1.3.7': dependencies: '@codama/errors': 1.3.7 '@codama/node-types': 1.3.7 + '@codama/nodes@1.4.4': + dependencies: + '@codama/errors': 1.4.4 + '@codama/node-types': 1.4.4 + '@codama/nodes@1.5.0': dependencies: '@codama/errors': 1.5.0 '@codama/node-types': 1.5.0 - '@codama/renderers-core@1.0.10': - dependencies: - '@codama/errors': 1.2.8 - '@codama/nodes': 1.2.8 - '@codama/visitors-core': 1.2.8 - '@codama/renderers-core@1.2.2': dependencies: '@codama/errors': 1.3.7 '@codama/nodes': 1.3.7 '@codama/visitors-core': 1.3.7 + '@codama/renderers-core@1.3.4': + dependencies: + '@codama/errors': 1.4.4 + '@codama/nodes': 1.4.4 + '@codama/visitors-core': 1.4.4 + '@codama/renderers-js@1.4.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': dependencies: '@codama/errors': 1.3.7 @@ -641,13 +557,13 @@ snapshots: - fastestsmallesttextencoderdecoder - typescript - '@codama/renderers-rust@1.0.16(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': + '@codama/renderers-rust@1.2.9(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': dependencies: - '@codama/errors': 1.2.8 - '@codama/nodes': 1.2.8 - '@codama/renderers-core': 1.0.10 - '@codama/visitors-core': 1.2.8 - '@solana/codecs-strings': 2.0.0-rc.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) + '@codama/errors': 1.4.4 + '@codama/nodes': 1.4.4 + '@codama/renderers-core': 1.3.4 + '@codama/visitors-core': 1.4.4 + '@solana/codecs-strings': 5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) nunjucks: 3.2.4 transitivePeerDependencies: - chokidar @@ -660,18 +576,18 @@ snapshots: '@codama/nodes': 1.5.0 '@codama/visitors-core': 1.5.0 - '@codama/visitors-core@1.2.8': - dependencies: - '@codama/errors': 1.2.8 - '@codama/nodes': 1.2.8 - json-stable-stringify: 1.2.1 - '@codama/visitors-core@1.3.7': dependencies: '@codama/errors': 1.3.7 '@codama/nodes': 1.3.7 json-stable-stringify: 1.3.0 + '@codama/visitors-core@1.4.4': + dependencies: + '@codama/errors': 1.4.4 + '@codama/nodes': 1.4.4 + json-stable-stringify: 1.3.0 + '@codama/visitors-core@1.5.0': dependencies: '@codama/errors': 1.5.0 @@ -764,13 +680,6 @@ snapshots: '@iarna/toml@2.2.5': {} - '@noble/hashes@2.0.1': {} - - '@solana/codecs-core@2.0.0-rc.4(typescript@5.9.3)': - dependencies: - '@solana/errors': 2.0.0-rc.4(typescript@5.9.3) - typescript: 5.9.3 - '@solana/codecs-core@4.0.0(typescript@5.9.3)': dependencies: '@solana/errors': 4.0.0(typescript@5.9.3) @@ -781,19 +690,6 @@ snapshots: '@solana/errors': 5.0.0(typescript@5.9.3) typescript: 5.9.3 - '@solana/codecs-data-structures@5.0.0(typescript@5.9.3)': - dependencies: - '@solana/codecs-core': 5.0.0(typescript@5.9.3) - '@solana/codecs-numbers': 5.0.0(typescript@5.9.3) - '@solana/errors': 5.0.0(typescript@5.9.3) - typescript: 5.9.3 - - '@solana/codecs-numbers@2.0.0-rc.4(typescript@5.9.3)': - dependencies: - '@solana/codecs-core': 2.0.0-rc.4(typescript@5.9.3) - '@solana/errors': 2.0.0-rc.4(typescript@5.9.3) - typescript: 5.9.3 - '@solana/codecs-numbers@4.0.0(typescript@5.9.3)': dependencies: '@solana/codecs-core': 4.0.0(typescript@5.9.3) @@ -806,14 +702,6 @@ snapshots: '@solana/errors': 5.0.0(typescript@5.9.3) typescript: 5.9.3 - '@solana/codecs-strings@2.0.0-rc.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': - dependencies: - '@solana/codecs-core': 2.0.0-rc.4(typescript@5.9.3) - '@solana/codecs-numbers': 2.0.0-rc.4(typescript@5.9.3) - '@solana/errors': 2.0.0-rc.4(typescript@5.9.3) - fastestsmallesttextencoderdecoder: 1.0.22 - typescript: 5.9.3 - '@solana/codecs-strings@4.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': dependencies: '@solana/codecs-core': 4.0.0(typescript@5.9.3) @@ -830,23 +718,6 @@ snapshots: fastestsmallesttextencoderdecoder: 1.0.22 typescript: 5.9.3 - '@solana/codecs@5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': - dependencies: - '@solana/codecs-core': 5.0.0(typescript@5.9.3) - '@solana/codecs-data-structures': 5.0.0(typescript@5.9.3) - '@solana/codecs-numbers': 5.0.0(typescript@5.9.3) - '@solana/codecs-strings': 5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - '@solana/options': 5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - typescript: 5.9.3 - transitivePeerDependencies: - - fastestsmallesttextencoderdecoder - - '@solana/errors@2.0.0-rc.4(typescript@5.9.3)': - dependencies: - chalk: 5.6.2 - commander: 12.1.0 - typescript: 5.9.3 - '@solana/errors@4.0.0(typescript@5.9.3)': dependencies: chalk: 5.6.2 @@ -859,17 +730,6 @@ snapshots: commander: 14.0.1 typescript: 5.9.3 - '@solana/options@5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': - dependencies: - '@solana/codecs-core': 5.0.0(typescript@5.9.3) - '@solana/codecs-data-structures': 5.0.0(typescript@5.9.3) - '@solana/codecs-numbers': 5.0.0(typescript@5.9.3) - '@solana/codecs-strings': 5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - '@solana/errors': 5.0.0(typescript@5.9.3) - typescript: 5.9.3 - transitivePeerDependencies: - - fastestsmallesttextencoderdecoder - a-sync-waterfall@1.0.1: {} asap@2.0.6: {} @@ -891,18 +751,11 @@ snapshots: get-intrinsic: 1.2.7 set-function-length: 1.2.2 - call-bound@1.0.3: - dependencies: - call-bind-apply-helpers: 1.0.1 - get-intrinsic: 1.2.7 - call-bound@1.0.4: dependencies: call-bind-apply-helpers: 1.0.2 get-intrinsic: 1.3.0 - chalk@5.4.1: {} - chalk@5.6.2: {} codama@1.5.0: @@ -913,10 +766,6 @@ snapshots: '@codama/validators': 1.5.0 '@codama/visitors': 1.5.0 - commander@12.1.0: {} - - commander@13.1.0: {} - commander@14.0.1: {} commander@14.0.2: {} @@ -1028,14 +877,6 @@ snapshots: isarray@2.0.5: {} - json-stable-stringify@1.2.1: - dependencies: - call-bind: 1.0.8 - call-bound: 1.0.3 - isarray: 2.0.5 - jsonify: 0.0.1 - object-keys: 1.1.1 - json-stable-stringify@1.3.0: dependencies: call-bind: 1.0.8 diff --git a/program/idl.json b/program/idl.json deleted file mode 100644 index ce6876e9..00000000 --- a/program/idl.json +++ /dev/null @@ -1,502 +0,0 @@ -{ - "version": "1.17.13", - "name": "stake_program", - "instructions": [ - { - "name": "Initialize", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to initialize" - }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "desc": "Rent sysvar" - } - ], - "args": [ - { - "name": "authorized", - "type": { - "defined": "Authorized" - } - }, - { - "name": "lockup", - "type": { - "defined": "Lockup" - } - } - ] - }, - { - "name": "Authorize", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to be updated" - }, - { - "name": "clock", - "isMut": false, - "isSigner": false, - "desc": "Clock sysvar" - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "desc": "stake's current stake or withdraw authority to change away from. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer" - } - ], - "args": [ - { - "name": "newAuthority", - "type": "publicKey" - }, - { - "name": "stakeAuthorize", - "type": { - "defined": "StakeAuthorize" - } - } - ] - }, - { - "name": "DelegateStake", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to be delegated" - }, - { - "name": "vote", - "isMut": false, - "isSigner": false, - "desc": "Vote account to which stake will be delegated" - }, - { - "name": "clock", - "isMut": false, - "isSigner": false, - "desc": "Clock sysvar" - }, - { - "name": "stakeHistory", - "isMut": false, - "isSigner": false, - "desc": "Stake history sysvar" - }, - { - "name": "stakeConfig", - "isMut": false, - "isSigner": false, - "desc": "Stake config native program" - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "desc": "stake's stake authority" - } - ] - }, - { - "name": "Split", - "accounts": [ - { - "name": "from", - "isMut": true, - "isSigner": false, - "desc": "The stake account to split. Must be in the Initialized or Stake state" - }, - { - "name": "to", - "isMut": true, - "isSigner": false, - "desc": "The uninitialized stake account to split to. Must be rent-exempt starting from solana 1.17." - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "desc": "from's stake authority" - } - ], - "args": [{ "name": "lamports", "type": "u64" }] - }, - { - "name": "Withdraw", - "accounts": [ - { - "name": "from", - "isMut": true, - "isSigner": false, - "desc": "The stake account to withdraw from" - }, - { - "name": "to", - "isMut": true, - "isSigner": false, - "desc": "Recipient account" - }, - { - "name": "clock", - "isMut": false, - "isSigner": false, - "desc": "Clock sysvar" - }, - { - "name": "stakeHistory", - "isMut": false, - "isSigner": false, - "desc": "Stake history sysvar" - }, - { - "name": "withdrawAuthority", - "isMut": false, - "isSigner": true, - "desc": "from's withdraw authority. If stake Lockup is active, the signing lockup authority must follow." - } - ], - "args": [{ "name": "lamports", "type": "u64" }] - }, - { - "name": "Deactivate", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to deactivate" - }, - { - "name": "clock", - "isMut": false, - "isSigner": false, - "desc": "Clock sysvar" - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "desc": "stake's stake authority" - } - ] - }, - { - "name": "SetLockup", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to set the lockup of" - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "desc": "stake's withdraw authority or lockup authority if lockup is active" - } - ], - "args": [ - { - "name": "unixTimestamp", - "type": { "option": "i64" } - }, - { - "name": "epoch", - "type": { "option": "u64" } - }, - { - "name": "custodian", - "type": { "option": "publicKey" } - } - ] - }, - { - "name": "Merge", - "accounts": [ - { - "name": "to", - "isMut": true, - "isSigner": false, - "desc": "The destination stake account to merge into" - }, - { - "name": "from", - "isMut": true, - "isSigner": false, - "desc": "The stake account to merge from. Must have exact same lockup and authority as to. This account will be drained." - }, - { - "name": "clock", - "isMut": false, - "isSigner": false, - "desc": "Clock sysvar" - }, - { - "name": "stakeHistory", - "isMut": false, - "isSigner": false, - "desc": "Stake history sysvar" - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "desc": "Both from and to's stake authority" - } - ] - }, - { - "name": "AuthorizeWithSeed", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to be updated, with the authority to be updated being an account created with Pubkey::create_with_seed()" - }, - { - "name": "authorityBase", - "isMut": false, - "isSigner": true, - "desc": "Base account of stake's authority to be updated" - }, - { - "name": "clock", - "isMut": false, - "isSigner": false, - "desc": "Clock sysvar. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer." - } - ], - "args": [ - { - "name": "newAuthority", - "type": "publicKey" - }, - { - "name": "stakeAuthorize", - "type": { "defined": "StakeAuthorize" } - }, - { - "name": "authoritySeed", - "type": "string" - }, - { - "name": "authorityOwner", - "type": "publicKey" - } - ] - }, - { - "name": "InitializeChecked", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to initialize" - }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "desc": "Rent sysvar" - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": false, - "desc": "stake's new stake authority" - }, - { - "name": "withdrawAuthority", - "isMut": false, - "isSigner": true, - "desc": "stake's new withdraw authority" - } - ] - }, - { - "name": "AuthorizeChecked", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to be updated" - }, - { - "name": "clock", - "isMut": false, - "isSigner": false, - "desc": "Clock sysvar" - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "desc": "stake's current stake or withdraw authority to change away from" - }, - { - "name": "newAuthority", - "isMut": false, - "isSigner": true, - "desc": "stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer." - } - ], - "args": [ - { "name": "stakeAuthorize", "type": { "defined": "StakeAuthorize" } } - ] - }, - { - "name": "AuthorizeCheckedWithSeed", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to be updated" - }, - { - "name": "authorityBase", - "isMut": false, - "isSigner": true, - "desc": "Base account of stake's authority to be updated" - }, - { - "name": "clock", - "isMut": false, - "isSigner": false, - "desc": "Clock sysvar" - }, - { - "name": "newAuthority", - "isMut": false, - "isSigner": true, - "desc": "stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer." - } - ], - "args": [ - { "name": "stakeAuthorize", "type": { "defined": "StakeAuthorize" } }, - { "name": "authoritySeed", "type": "string" }, - { "name": "authorityOwner", "type": "publicKey" } - ] - }, - { - "name": "SetLockupChecked", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The stake account to set the lockup of" - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "desc": "stake's withdraw authority or lockup authority if lockup is active. If setting a new lockup authority, the signing new lockup authority must follow." - } - ], - "args": [ - { "name": "unixTimestamp", "type": { "option": "i64" } }, - { "name": "epoch", "type": { "option": "u64" } } - ] - }, - { - "name": "GetMinimumDelegation" - }, - { - "name": "DeactivateDelinquent", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "desc": "The delinquent stake account to deactivate" - }, - { - "name": "vote", - "isMut": false, - "isSigner": false, - "desc": "stake's delinquent vote account" - }, - { - "name": "referenceVote", - "isMut": false, - "isSigner": false, - "desc": "Reference vote account that has voted at least once in the last MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION epochs" - } - ] - } - ], - "types": [ - { - "name": "Authorized", - "type": { - "kind": "struct", - "fields": [ - { - "name": "staker", - "type": "publicKey" - }, - { - "name": "withdrawer", - "type": "publicKey" - } - ] - } - }, - { - "name": "Lockup", - "type": { - "kind": "struct", - "fields": [ - { - "name": "unixTimestamp", - "type": "i64" - }, - { - "name": "epoch", - "type": "u64" - }, - { - "name": "custodian", - "type": "publicKey" - } - ] - } - }, - { - "name": "StakeAuthorize", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Staker" - }, - { - "name": "Withdrawer" - } - ] - } - } - ], - "metadata": { - "origin": "anchor", - "address": "Stake11111111111111111111111111111111111111" - } - } - \ No newline at end of file diff --git a/program/tests/stake_instruction.rs b/program/tests/stake_instruction.rs index 58df8118..df5136ef 100644 --- a/program/tests/stake_instruction.rs +++ b/program/tests/stake_instruction.rs @@ -1037,6 +1037,7 @@ fn test_stake_checked_instructions() { } #[test] +#[allow(deprecated)] // TODO: remove need for this fn test_stake_initialize() { let mollusk = mollusk_bpf(); @@ -2207,6 +2208,7 @@ fn test_redelegate_consider_balance_changes() { } #[test] +#[allow(deprecated)] // TODO: remove need for this fn test_split() { let mollusk = mollusk_bpf(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index cf6d0f55..ff100edc 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.86.0" +channel = "1.90.0" diff --git a/scripts/generate-clients.mts b/scripts/generate-clients.mts index 03fb7c28..15714949 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -1,16 +1,15 @@ #!/usr/bin/env zx import 'zx/globals'; import * as c from 'codama'; -import { rootNodeFromAnchor } from '@codama/nodes-from-anchor'; import { renderVisitor as renderJavaScriptVisitor } from '@codama/renderers-js'; import { renderVisitor as renderRustVisitor } from '@codama/renderers-rust'; import { getToolchainArgument, workingDirectory } from './utils.mts'; -// Instanciate Codama from the IDL. +// Load the auto-generated IDL from Codama macros const idl = JSON.parse( fs.readFileSync(path.join(workingDirectory, 'interface', 'idl.json'), 'utf-8') ); -const codama = c.createFromRoot(rootNodeFromAnchor(idl)); +const codama = c.createFromRoot(idl); // Rename the program. codama.update( @@ -26,18 +25,60 @@ codama.update( }) ); -// Add missing types from the IDL. +// Rename instruction argument types to avoid collisions with encoder arg types +codama.update( + c.updateDefinedTypesVisitor({ + lockupArgs: { name: 'lockupParams' }, + lockupCheckedArgs: { name: 'lockupCheckedParams' }, + authorizeWithSeedArgs: { name: 'authorizeWithSeedParams' }, + authorizeCheckedWithSeedArgs: { name: 'authorizeCheckedWithSeedParams' }, + }) +); + +// Unwrap defined type links used only as instruction args, then flatten them +codama.update(c.unwrapInstructionArgsDefinedTypesVisitor()); +codama.update(c.flattenInstructionDataArgumentsVisitor()); + +// Add type aliases for semantic external types codama.update( c.bottomUpTransformerVisitor([ { - select: '[programNode]stake', + select: '[programNode]', + transform: (node) => { + c.assertIsNode(node, 'programNode'); + return { + ...node, + definedTypes: [ + // Add Epoch type alias + c.definedTypeNode({ + name: 'epoch', + type: c.numberTypeNode('u64'), + }), + // Add UnixTimestamp type alias + c.definedTypeNode({ + name: 'unixTimestamp', + type: c.numberTypeNode('i64'), + }), + ...node.definedTypes, + ], + }; + }, + }, + ]) +); + +// Apply transformations to the IDL +codama.update( + c.bottomUpTransformerVisitor([ + { + select: '[programNode]', transform: (node) => { c.assertIsNode(node, 'programNode'); return { ...node, accounts: [ ...node.accounts, - // stake account + // Stake account wrapper for client convenience c.accountNode({ name: 'stakeStateAccount', data: c.structTypeNode([ @@ -48,125 +89,9 @@ codama.update( ]), }), ], - errors: [ - c.errorNode({ - code: 0, - name: 'NoCreditsToRedeem', - message: 'Not enough credits to redeem', - }), - c.errorNode({ - code: 1, - name: 'LockupInForce', - message: 'Lockup has not yet expired', - }), - c.errorNode({ - code: 2, - name: 'AlreadyDeactivated', - message: 'Stake already deactivated', - }), - c.errorNode({ - code: 3, - name: 'TooSoonToRedelegate', - message: 'One re-delegation permitted per epoch', - }), - c.errorNode({ - code: 4, - name: 'InsufficientStake', - message: 'Split amount is more than is staked', - }), - c.errorNode({ - code: 5, - name: 'MergeTransientStake', - message: 'Stake account with transient stake cannot be merged', - }), - c.errorNode({ - code: 6, - name: 'MergeMismatch', - message: - 'Stake account merge failed due to different authority, lockups or state', - }), - c.errorNode({ - code: 7, - name: 'CustodianMissing', - message: 'Custodian address not present', - }), - c.errorNode({ - code: 8, - name: 'CustodianSignatureMissing', - message: 'Custodian signature not present', - }), - c.errorNode({ - code: 9, - name: 'InsufficientReferenceVotes', - message: - 'Insufficient voting activity in the reference vote account', - }), - c.errorNode({ - code: 10, - name: 'VoteAddressMismatch', - message: - 'Stake account is not delegated to the provided vote account', - }), - c.errorNode({ - code: 11, - name: 'MinimumDelinquentEpochsForDeactivationNotMet', - message: - 'Stake account has not been delinquent for the minimum epochs required for deactivation', - }), - c.errorNode({ - code: 12, - name: 'InsufficientDelegation', - message: 'Delegation amount is less than the minimum', - }), - c.errorNode({ - code: 13, - name: 'RedelegateTransientOrInactiveStake', - message: - 'Stake account with transient or inactive stake cannot be redelegated', - }), - c.errorNode({ - code: 14, - name: 'RedelegateToSameVoteAccount', - message: - 'Stake redelegation to the same vote account is not permitted', - }), - c.errorNode({ - code: 15, - name: 'RedelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted', - message: - 'Redelegated stake must be fully activated before deactivation', - }), - c.errorNode({ - code: 16, - name: 'EpochRewardsActive', - message: - 'Stake action is not permitted while the epoch rewards period is active', - }), - ], }; }, }, - { - // Epoch -> u64 - select: '[definedTypeLinkNode]epoch', - transform: () => { - return c.numberTypeNode('u64'); - }, - }, - { - // UnixTimestamp -> i64 - select: '[definedTypeLinkNode]unixTimestamp', - transform: () => { - return c.numberTypeNode('i64'); - }, - }, - { - // [definedType]f64 -> [numberType]f64 - select: '[definedTypeLinkNode]f64', - transform: () => { - return c.numberTypeNode('f64'); - }, - }, { // enum discriminator -> u32 select: '[definedTypeNode]stakeState.[enumTypeNode]', @@ -194,7 +119,15 @@ codama.update( select: '[instructionNode]', transform: (node) => { c.assertIsNode(node, 'instructionNode'); - return { ...node, optionalAccountStrategy: 'omitted' }; + return { + ...node, + optionalAccountStrategy: 'omitted', + arguments: node.arguments.map((arg) => + arg.name === 'discriminator' + ? { ...arg, type: c.numberTypeNode('u32') } + : arg + ), + }; }, }, ]) @@ -240,3 +173,4 @@ codama.accept( }, }) ); + diff --git a/scripts/solana.dic b/scripts/solana.dic index 7c3905d1..6c0dd4f2 100644 --- a/scripts/solana.dic +++ b/scripts/solana.dic @@ -7,6 +7,7 @@ cooldown deallocated entrypoint fn +IDL lamports mergeable pubkey