From 01a69166cfee5171a4584443067ebfa8f2637802 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Fri, 14 Nov 2025 17:48:48 +0000 Subject: [PATCH 01/27] update to use codama macros --- codama.json | 20 + interface/Cargo.toml | 6 + interface/build.rs | 36 + interface/idl.json | 2462 +++++++++++++++++++++------------- interface/src/error.rs | 20 +- interface/src/instruction.rs | 149 +- interface/src/lib.rs | 2 + interface/src/stake_flags.rs | 2 +- interface/src/state.rs | 19 +- scripts/generate-clients.mts | 190 +-- 10 files changed, 1754 insertions(+), 1152 deletions(-) create mode 100644 codama.json create mode 100644 interface/build.rs diff --git a/codama.json b/codama.json new file mode 100644 index 00000000..c1b017a2 --- /dev/null +++ b/codama.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://codama.gg/schemas/codama.json", + "idls": [ + { + "path": "interface/idl.json", + "format": "anchor" + } + ], + "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 0dca2cdc..79263d17 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -18,6 +18,8 @@ program-id = "Stake11111111111111111111111111111111111111" [dependencies] borsh = { version = "1.5.1", features = ["derive", "unstable__schema"], optional = true } +codama = "0.6.2" +codama-macros = "0.6.2" num-traits = "0.2" serde = { version = "1.0.210", optional = true } serde_derive = { version = "1.0.210", optional = true } @@ -32,6 +34,10 @@ solana-system-interface = "2.0.0" solana-sysvar = { version = "3.0.0", optional = true } solana-sysvar-id = { version = "3.0.0", optional = true } +[build-dependencies] +codama = "0.6.2" +serde_json = "1.0" + [dev-dependencies] anyhow = "1" assert_matches = "1.5.0" diff --git a/interface/build.rs b/interface/build.rs new file mode 100644 index 00000000..27dbc48c --- /dev/null +++ b/interface/build.rs @@ -0,0 +1,36 @@ +//! Codama IDL build script. + +use { + codama::Codama, + std::{env, fs, path::Path}, +}; + +fn main() { + println!("cargo:rerun-if-changed=src/"); + println!("cargo:rerun-if-env-changed=GENERATE_IDL"); + + if let Err(e) = generate_idl() { + println!("cargo:warning=Failed to generate IDL: {}", e) + } +} + +fn generate_idl() -> 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!("cargo:warning=IDL written to: {}", idl_path.display()); + Ok(()) +} + diff --git a/interface/idl.json b/interface/idl.json index 87cf2042..ee8a6ecc 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -1,1078 +1,1618 @@ { - "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": "lockupArgs", + "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": "lockupCheckedArgs", + "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": "authorizeWithSeedArgs", + "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": "authorizeCheckedWithSeedArgs", + "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "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": "authorized", + "type": { + "kind": "definedTypeLinkNode", + "name": "authorized" + } + }, + { + "kind": "instructionArgumentNode", + "name": "lockup", + "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authority" + }, + { + "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": "pubkey", "type": { - "option": { - "defined": "Epoch" - } + "kind": "publicKeyTypeNode" } }, { - "name": "custodian", + "kind": "instructionArgumentNode", + "name": "stakeAuthorize", "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "vote" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeHistorySysvar" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "config" + }, + { + "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" }, { - "name": "epoch", + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "splitStake" + }, + { + "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": "lamports", "type": { - "defined": "StakeAuthorize" + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "split" + }, + { + "accounts": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "recipient" }, { - "name": "authoritySeed", - "type": "string" + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" }, { - "name": "authorityOwner", - "type": "publicKey" + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeHistorySysvar" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "withdrawAuthority" + }, + { + "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": "lamports", "type": { - "defined": "StakeAuthorize" + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "withdraw" + }, + { + "accounts": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" }, { - "name": "authoritySeed", - "type": "string" + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" }, { - "name": "authorityOwner", - "type": "publicKey" + "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "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": "lockup", "type": { - "defined": "Epoch" + "kind": "definedTypeLinkNode", + "name": "lockupArgs" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "setLockup" + }, + { + "accounts": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "destination" }, { - "name": "custodian", - "type": "publicKey" + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "source" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeHistorySysvar" + }, + { + "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" }, { - "name": "withdrawer", - "type": "publicKey" + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authorityBase" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "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": "args", "type": { - "defined": "Authorized" + "kind": "definedTypeLinkNode", + "name": "authorizeWithSeedArgs" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "authorizeWithSeed" + }, + { + "accounts": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" }, { - "name": "lockup", + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "rentSysvar" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeAuthority" + }, + { + "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authority" }, { - "name": "stake", - "type": "u64" + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "newAuthority" }, { - "name": "activationEpoch", + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "lockupAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 10 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "defined": "Epoch" + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } }, { - "name": "deactivationEpoch", + "kind": "instructionArgumentNode", + "name": "stakeAuthorize", "type": { - "defined": "Epoch" + "kind": "definedTypeLinkNode", + "name": "stakeAuthorize" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "authorizeChecked" + }, + { + "accounts": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authorityBase" }, { - "name": "warmupCooldownRate", + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "newAuthority" + }, + { + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "lockupAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 11 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + }, + { + "kind": "instructionArgumentNode", + "name": "args", "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authority" + }, + { + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "newLockupAuthority" + } + ], + "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": "lockup", + "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" }, { - "name": "Initialized", - "fields": [ - { - "defined": "Meta" - } - ] + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "delinquentVote" }, { - "name": "Stake", - "fields": [ - { - "defined": "Meta" - }, - { - "defined": "Stake" - } - ] + "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": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "source" }, { - "name": "RewardsPool" + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "destination" + }, + { + "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": "lamports", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "moveStake" + }, + { + "accounts": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "source" }, { - "name": "Stake", - "fields": [ - { - "defined": "Meta" - }, - { - "defined": "Stake" - }, - { - "defined": "StakeFlags" - } - ] + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "destination" }, { - "name": "RewardsPool" + "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": "lamports", + "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.1" + }, + "standard": "codama", + "version": "1.0.0" } diff --git a/interface/src/error.rs b/interface/src/error.rs index 29923230..07f82864 100644 --- a/interface/src/error.rs +++ b/interface/src/error.rs @@ -1,70 +1,88 @@ use { + codama_macros::CodamaErrors, num_traits::{FromPrimitive, ToPrimitive}, solana_program_error::ProgramError, }; /// Reasons the Stake might have had an error. +#[derive(CodamaErrors, 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. + #[codama(error(code = 0, message = "Not enough credits to redeem"))] NoCreditsToRedeem, /// Lockup has not yet expired. + #[codama(error(code = 1, message = "Lockup has not yet expired"))] LockupInForce, /// Stake already deactivated. + #[codama(error(code = 2, message = "Stake already deactivated"))] AlreadyDeactivated, /// One re-delegation permitted per epoch. + #[codama(error(code = 3, message = "One re-delegation permitted per epoch"))] TooSoonToRedelegate, /// Split amount is more than is staked. + #[codama(error(code = 4, message = "Split amount is more than is staked"))] InsufficientStake, // 5 /// Stake account with transient stake cannot be merged. + #[codama(error(code = 5, message = "Stake account with transient stake cannot be merged"))] MergeTransientStake, /// Stake account merge failed due to different authority, lockups or state. + #[codama(error(code = 6, message = "Stake account merge failed due to different authority, lockups or state"))] MergeMismatch, /// Custodian address not present. + #[codama(error(code = 7, message = "Custodian address not present"))] CustodianMissing, /// Custodian signature not present. + #[codama(error(code = 8, message = "Custodian signature not present"))] CustodianSignatureMissing, /// Insufficient voting activity in the reference vote account. + #[codama(error(code = 9, message = "Insufficient voting activity in the reference vote account"))] InsufficientReferenceVotes, // 10 /// Stake account is not delegated to the provided vote account. + #[codama(error(code = 10, 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. + #[codama(error(code = 11, message = "Stake account has not been delinquent for the minimum epochs required for deactivation"))] MinimumDelinquentEpochsForDeactivationNotMet, /// Delegation amount is less than the minimum. + #[codama(error(code = 12, message = "Delegation amount is less than the minimum"))] InsufficientDelegation, /// Stake account with transient or inactive stake cannot be redelegated. + #[codama(error(code = 13, message = "Stake account with transient or inactive stake cannot be redelegated"))] RedelegateTransientOrInactiveStake, /// Stake redelegation to the same vote account is not permitted. + #[codama(error(code = 14, message = "Stake redelegation to the same vote account is not permitted"))] RedelegateToSameVoteAccount, // 15 /// Redelegated stake must be fully activated before deactivation. + #[codama(error(code = 15, message = "Redelegated stake must be fully activated before deactivation"))] RedelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted, /// Stake action is not permitted while the epoch rewards period is active. + #[codama(error(code = 16, 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 e8751c11..c529c7e9 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -5,6 +5,7 @@ use { crate::state::{Authorized, Lockup, StakeAuthorize}, + codama_macros::{codama, CodamaInstructions, CodamaType}, solana_clock::{Epoch, UnixTimestamp}, solana_pubkey::Pubkey, }; @@ -29,11 +30,11 @@ const RENT_ID: Pubkey = Pubkey::from_str_const("SysvarRent1111111111111111111111 const STAKE_HISTORY_ID: Pubkey = Pubkey::from_str_const("SysvarStakeHistory1111111111111111111111111"); +#[derive(CodamaInstructions, Debug, PartialEq, Eq, Clone)] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] -#[derive(Debug, PartialEq, Eq, Clone)] pub enum StakeInstruction { /// Initialize a stake with lockup and authorization information /// @@ -44,7 +45,12 @@ pub enum StakeInstruction { /// [`Authorized`] carries pubkeys that must sign staker transactions /// and withdrawer transactions; [`Lockup`] carries information about /// withdrawal restrictions. - Initialize(Authorized, Lockup), + #[codama(account(name = "stake", writable))] + #[codama(account(name = "rent_sysvar"))] + Initialize { + authorized: Authorized, + lockup: Lockup, + }, /// Authorize a key to manage stake or withdrawal /// @@ -54,7 +60,14 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` The stake or withdraw authority /// 3. Optional: `[SIGNER]` Lockup authority, if updating `StakeAuthorize::Withdrawer` before /// lockup expiration - Authorize(Pubkey, StakeAuthorize), + #[codama(account(name = "stake", writable))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "authority", signer))] + #[codama(account(name = "lockup_authority", optional, signer))] + Authorize { + pubkey: Pubkey, + stake_authorize: StakeAuthorize, + }, /// Delegate a stake to a particular vote account /// @@ -68,6 +81,12 @@ 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. + #[codama(account(name = "stake", writable))] + #[codama(account(name = "vote"))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "stake_history_sysvar"))] + #[codama(account(name = "config"))] + #[codama(account(name = "stake_authority", signer))] DelegateStake, /// Split `u64` tokens and stake off a stake account into another stake account. @@ -76,7 +95,12 @@ 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), + #[codama(account(name = "stake", writable))] + #[codama(account(name = "split_stake", writable))] + #[codama(account(name = "stake_authority", signer))] + Split { + lamports: u64, + }, /// Withdraw unstaked lamports from the stake account /// @@ -90,7 +114,15 @@ pub enum StakeInstruction { /// /// The `u64` is the portion of the stake account balance to be withdrawn, /// must be `<= StakeAccount.lamports - staked_lamports`. - Withdraw(u64), + #[codama(account(name = "stake", writable))] + #[codama(account(name = "recipient", writable))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "stake_history_sysvar"))] + #[codama(account(name = "withdraw_authority", signer))] + #[codama(account(name = "lockup_authority", optional, signer))] + Withdraw { + lamports: u64, + }, /// Deactivates the stake in the account /// @@ -98,6 +130,9 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Delegated stake account /// 1. `[]` Clock sysvar /// 2. `[SIGNER]` Stake authority + #[codama(account(name = "stake", writable))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "stake_authority", signer))] Deactivate, /// Set stake lockup @@ -108,7 +143,11 @@ pub enum StakeInstruction { /// # Account references /// 0. `[WRITE]` Initialized stake account /// 1. `[SIGNER]` Lockup authority or withdraw authority - SetLockup(LockupArgs), + #[codama(account(name = "stake", writable))] + #[codama(account(name = "authority", signer))] + SetLockup { + lockup: LockupArgs, + }, /// Merge two stake accounts. /// @@ -134,6 +173,11 @@ pub enum StakeInstruction { /// 2. `[]` Clock sysvar /// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history /// 4. `[SIGNER]` Stake authority + #[codama(account(name = "destination", writable))] + #[codama(account(name = "source", writable))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "stake_history_sysvar"))] + #[codama(account(name = "stake_authority", signer))] Merge, /// Authorize a key to manage stake or withdrawal with a derived key @@ -144,7 +188,13 @@ pub enum StakeInstruction { /// 2. `[]` Clock sysvar /// 3. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration - AuthorizeWithSeed(AuthorizeWithSeedArgs), + #[codama(account(name = "stake", writable))] + #[codama(account(name = "authority_base", signer))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "lockup_authority", optional, signer))] + AuthorizeWithSeed { + args: AuthorizeWithSeedArgs, + }, /// Initialize a stake with authorization information /// @@ -156,6 +206,10 @@ pub enum StakeInstruction { /// 1. `[]` Rent sysvar /// 2. `[]` The stake authority /// 3. `[SIGNER]` The withdraw authority + #[codama(account(name = "stake", writable))] + #[codama(account(name = "rent_sysvar"))] + #[codama(account(name = "stake_authority"))] + #[codama(account(name = "withdraw_authority", signer))] InitializeChecked, /// Authorize a key to manage stake or withdrawal @@ -170,7 +224,14 @@ 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), + #[codama(account(name = "stake", writable))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "authority", signer))] + #[codama(account(name = "new_authority", signer))] + #[codama(account(name = "lockup_authority", optional, signer))] + AuthorizeChecked { + stake_authorize: StakeAuthorize, + }, /// Authorize a key to manage stake or withdrawal with a derived key /// @@ -184,7 +245,14 @@ pub enum StakeInstruction { /// 3. `[SIGNER]` The new stake or withdraw authority /// 4. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration - AuthorizeCheckedWithSeed(AuthorizeCheckedWithSeedArgs), + #[codama(account(name = "stake", writable))] + #[codama(account(name = "authority_base", signer))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "new_authority", signer))] + #[codama(account(name = "lockup_authority", optional, signer))] + AuthorizeCheckedWithSeed { + args: AuthorizeCheckedWithSeedArgs, + }, /// Set stake lockup /// @@ -198,7 +266,12 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Initialized stake account /// 1. `[SIGNER]` Lockup authority or withdraw authority /// 2. Optional: `[SIGNER]` New lockup authority - SetLockupChecked(LockupCheckedArgs), + #[codama(account(name = "stake", writable))] + #[codama(account(name = "authority", signer))] + #[codama(account(name = "new_lockup_authority", optional, signer))] + SetLockupChecked { + lockup: LockupCheckedArgs, + }, /// Get the minimum stake delegation, in lamports /// @@ -223,6 +296,9 @@ pub enum StakeInstruction { /// 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 + #[codama(account(name = "stake", writable))] + #[codama(account(name = "delinquent_vote"))] + #[codama(account(name = "reference_vote"))] DeactivateDelinquent, /// Redelegate activated stake to another vote account. @@ -246,6 +322,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. @@ -267,7 +344,12 @@ 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), + #[codama(account(name = "source", writable))] + #[codama(account(name = "destination", writable))] + #[codama(account(name = "stake_authority", signer))] + MoveStake { + lamports: u64, + }, /// Move unstaked lamports between accounts with the same authorities and lockups, using Staker /// authority. @@ -282,35 +364,40 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of available lamports to move - MoveLamports(u64), + #[codama(account(name = "source", writable))] + #[codama(account(name = "destination", writable))] + #[codama(account(name = "stake_authority", signer))] + MoveLamports { + lamports: u64, + }, } +#[derive(CodamaType, 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, } +#[derive(CodamaType, 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, } +#[derive(CodamaType, 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, @@ -318,11 +405,11 @@ pub struct AuthorizeWithSeedArgs { pub authority_owner: Pubkey, } +#[derive(CodamaType, 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, @@ -333,7 +420,10 @@ pub struct AuthorizeCheckedWithSeedArgs { pub fn initialize(stake_pubkey: &Pubkey, authorized: &Authorized, lockup: &Lockup) -> Instruction { Instruction::new_with_bincode( ID, - &StakeInstruction::Initialize(*authorized, *lockup), + &StakeInstruction::Initialize { + authorized: *authorized, + lockup: *lockup, + }, vec![ AccountMeta::new(*stake_pubkey, false), AccountMeta::new_readonly(RENT_ID, false), @@ -454,7 +544,7 @@ fn _split( AccountMeta::new_readonly(*authorized_pubkey, true), ]; - Instruction::new_with_bincode(ID, &StakeInstruction::Split(lamports), account_metas) + Instruction::new_with_bincode(ID, &StakeInstruction::Split { lamports }, account_metas) } #[cfg(feature = "bincode")] @@ -593,7 +683,10 @@ pub fn authorize( Instruction::new_with_bincode( ID, - &StakeInstruction::Authorize(*new_authorized_pubkey, stake_authorize), + &StakeInstruction::Authorize { + pubkey: *new_authorized_pubkey, + stake_authorize, + }, account_metas, ) } @@ -619,7 +712,7 @@ pub fn authorize_checked( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeChecked(stake_authorize), + &StakeInstruction::AuthorizeChecked { stake_authorize }, account_metas, ) } @@ -653,7 +746,7 @@ pub fn authorize_with_seed( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeWithSeed(args), + &StakeInstruction::AuthorizeWithSeed { args }, account_metas, ) } @@ -687,7 +780,7 @@ pub fn authorize_checked_with_seed( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeCheckedWithSeed(args), + &StakeInstruction::AuthorizeCheckedWithSeed { args }, account_metas, ) } @@ -730,7 +823,7 @@ pub fn withdraw( account_metas.push(AccountMeta::new_readonly(*custodian_pubkey, true)); } - Instruction::new_with_bincode(ID, &StakeInstruction::Withdraw(lamports), account_metas) + Instruction::new_with_bincode(ID, &StakeInstruction::Withdraw { lamports }, account_metas) } #[cfg(feature = "bincode")] @@ -753,7 +846,7 @@ pub fn set_lockup( AccountMeta::new(*stake_pubkey, false), AccountMeta::new_readonly(*custodian_pubkey, true), ]; - Instruction::new_with_bincode(ID, &StakeInstruction::SetLockup(*lockup), account_metas) + Instruction::new_with_bincode(ID, &StakeInstruction::SetLockup { lockup: *lockup }, account_metas) } #[cfg(feature = "bincode")] @@ -776,7 +869,9 @@ pub fn set_lockup_checked( } Instruction::new_with_bincode( ID, - &StakeInstruction::SetLockupChecked(lockup_checked), + &StakeInstruction::SetLockupChecked { + lockup: lockup_checked, + }, account_metas, ) } @@ -881,7 +976,7 @@ pub fn move_stake( AccountMeta::new_readonly(*authorized_pubkey, true), ]; - Instruction::new_with_bincode(ID, &StakeInstruction::MoveStake(lamports), account_metas) + Instruction::new_with_bincode(ID, &StakeInstruction::MoveStake { lamports }, account_metas) } #[cfg(feature = "bincode")] @@ -897,7 +992,7 @@ pub fn move_lamports( AccountMeta::new_readonly(*authorized_pubkey, true), ]; - Instruction::new_with_bincode(ID, &StakeInstruction::MoveLamports(lamports), account_metas) + Instruction::new_with_bincode(ID, &StakeInstruction::MoveLamports { lamports }, account_metas) } #[cfg(feature = "bincode")] diff --git a/interface/src/lib.rs b/interface/src/lib.rs index d82a9532..76315784 100644 --- a/interface/src/lib.rs +++ b/interface/src/lib.rs @@ -14,6 +14,8 @@ pub mod state; pub mod sysvar; pub mod tools; +use codama_macros::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..daef514f 100644 --- a/interface/src/stake_flags.rs +++ b/interface/src/stake_flags.rs @@ -2,6 +2,7 @@ use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; /// Additional flags for stake state. +#[derive(codama_macros::CodamaType, 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 +13,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..6a038564 100644 --- a/interface/src/state.rs +++ b/interface/src/state.rs @@ -7,6 +7,7 @@ #[cfg(feature = "borsh")] use borsh::{io, BorshDeserialize, BorshSchema, BorshSerialize}; use { + codama_macros::{codama, CodamaType}, crate::{ error::StakeError, instruction::LockupArgs, @@ -79,17 +80,18 @@ macro_rules! impl_borsh_stake_state { } }; } +#[derive(CodamaType, 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", note = "Please use `StakeStateV2` instead, and match the third `StakeFlags` field when matching `StakeStateV2::Stake` to resolve any breakage. For example, `if let StakeState::Stake(meta, stake)` becomes `if let StakeStateV2::Stake(meta, stake, _stake_flags)`." )] +#[codama(enum_discriminator(size = number(u32)))] pub enum StakeState { #[default] Uninitialized, @@ -140,13 +142,14 @@ impl StakeState { } } +#[derive(CodamaType, 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)] +#[codama(enum_discriminator(size = number(u32)))] pub enum StakeStateV2 { #[default] Uninitialized, @@ -259,17 +262,18 @@ impl StakeStateV2 { } } +#[derive(CodamaType, 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, } +#[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -280,7 +284,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 +304,7 @@ impl Lockup { } } +#[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -311,7 +315,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 +386,7 @@ impl Authorized { } } +#[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -393,7 +397,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 +440,7 @@ impl Meta { } } +#[derive(CodamaType, Debug, PartialEq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -447,7 +451,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 +679,7 @@ impl Delegation { } } +#[derive(CodamaType, Debug, Default, PartialEq, Clone, Copy)] #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[cfg_attr( feature = "borsh", @@ -686,7 +690,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/scripts/generate-clients.mts b/scripts/generate-clients.mts index 03fb7c28..da2c673f 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -1,43 +1,63 @@ #!/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. +// Rename the program from solanaStakeInterface to stake codama.update( c.updateProgramsVisitor({ solanaStakeInterface: { name: 'stake' }, }) ); +// Add type aliases for semantic external types codama.update( - c.updateInstructionsVisitor({ - // Deprecated instruction. - redelegate: { delete: true }, - }) + c.bottomUpTransformerVisitor([ + { + 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, + ], + }; + }, + }, + ]) ); -// Add missing types from the IDL. +// Apply transformations to the IDL codama.update( c.bottomUpTransformerVisitor([ { - select: '[programNode]stake', + 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,149 +68,11 @@ 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]', - transform: (node) => { - c.assertIsNode(node, 'enumTypeNode'); - return { - ...node, - size: c.numberTypeNode('u32'), - }; - }, - }, - { - // enum discriminator -> u32 - select: '[definedTypeNode]stakeStateV2.[enumTypeNode]', - transform: (node) => { - c.assertIsNode(node, 'enumTypeNode'); - return { - ...node, - size: c.numberTypeNode('u32'), - }; - }, - }, - { - // Use omitted optional account strategy for all instructions. + // Use omitted optional account strategy for all instructions select: '[instructionNode]', transform: (node) => { c.assertIsNode(node, 'instructionNode'); @@ -200,7 +82,7 @@ codama.update( ]) ); -// Render JavaScript. +// Render JavaScript client const jsClient = path.join(workingDirectory, 'clients', 'js'); codama.accept( renderJavaScriptVisitor(path.join(jsClient, 'src', 'generated'), { @@ -211,14 +93,14 @@ codama.accept( ); // Remove the stake account from the accounts since the Rust client -// provides its own implementation. +// provides its own implementation in the hooked module codama.update( c.updateAccountsVisitor({ stakeStateAccount: { delete: true }, }) ); -// Render Rust. +// Render Rust client const rustClient = path.join(workingDirectory, 'clients', 'rust'); codama.accept( renderRustVisitor(path.join(rustClient, 'src', 'generated'), { @@ -234,9 +116,9 @@ codama.accept( 'serde::Deserialize', 'Clone', 'Debug', - // 'Eq', <- Remove 'Eq' from the default traits. 'PartialEq', ], }, }) ); + From fb1cc44f04f85cd5f1374ae88d1cd36394cf3e87 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Fri, 14 Nov 2025 17:52:35 +0000 Subject: [PATCH 02/27] fmt --- Cargo.lock | 215 ++++++++++++++++++++++++++++++++++- interface/build.rs | 1 - interface/src/error.rs | 45 ++++++-- interface/src/instruction.rs | 48 ++++---- interface/src/state.rs | 2 +- 5 files changed, 270 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68da0e9b..1efc35e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -858,6 +858,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 0.8.20", +] + [[package]] name = "cc" version = "1.2.13" @@ -930,6 +940,160 @@ dependencies = [ "inout", ] +[[package]] +name = "codama" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c48b3524aa7ad4c96e9efab8eebf6f1c48dbeac2d82945aa40c61824e958f2" +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.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c746407a3ad52c46bd790db787adc3cc45ce35941cfd766681dc30d76137127" +dependencies = [ + "codama-errors", + "codama-nodes", + "codama-syn-helpers", + "derive_more", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "codama-errors" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cc87d9486b8b0c55079667e3735d98efa3ce6304c9d5977a306e84f2fc7247c" +dependencies = [ + "cargo_toml", + "proc-macro2", + "serde_json", + "syn 2.0.98", + "thiserror 2.0.17", +] + +[[package]] +name = "codama-korok-plugins" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff0421200f8fedbc02a63741a0303f0c77dc4d1a7e07839995c696283bda955" +dependencies = [ + "codama-errors", + "codama-korok-visitors", + "codama-koroks", +] + +[[package]] +name = "codama-korok-visitors" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b04c22204928bbc5d7e513abcfaf9c94d0e289afe4d31c9873c171882979a" +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.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bb7056e426920bbb1ed7936eabf55cbcf100e05312e2e813bfcc3e02e6d6722" +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.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d81f04d181107665dde8c5ceaff7e12af0ea9e30125818994165541a58997c50" +dependencies = [ + "codama-attributes", + "codama-errors", + "codama-koroks", + "codama-stores", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "codama-nodes" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "943fc6ab9092c8bd6a417ea1df808e6ca4f6a940903c34cf6d06e1ee8e30b839" +dependencies = [ + "codama-errors", + "codama-nodes-derive", + "derive_more", + "serde", + "serde_json", +] + +[[package]] +name = "codama-nodes-derive" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e971fff8f456bc7cc2d95e33a9f64956ebf57df10e1e8094488c4c2f0b8f6a76" +dependencies = [ + "codama-errors", + "codama-syn-helpers", + "derive_more", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "codama-stores" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b656f6efc8fe614b913b4651321f48fa612f6c44edbcdb256fd3f216f45dc29" +dependencies = [ + "cargo_toml", + "codama-errors", + "proc-macro2", + "syn 2.0.98", +] + +[[package]] +name = "codama-syn-helpers" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30fb789956efa136fad8b509875e80f27659dcac0ad9872571de8369e0e9bc0f" +dependencies = [ + "codama-errors", + "derive_more", + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "colorchoice" version = "1.0.4" @@ -1289,6 +1453,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" @@ -3375,7 +3559,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" dependencies = [ - "toml", + "toml 0.5.11", ] [[package]] @@ -4200,6 +4384,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" @@ -7149,9 +7342,12 @@ dependencies = [ "assert_matches", "bincode", "borsh 1.5.7", + "codama", + "codama-macros", "num-traits", "serde", "serde_derive", + "serde_json", "serial_test", "solana-account 3.2.0", "solana-borsh 3.0.0", @@ -8548,11 +8744,26 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + [[package]] 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 +8772,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/interface/build.rs b/interface/build.rs index 27dbc48c..251381f3 100644 --- a/interface/build.rs +++ b/interface/build.rs @@ -33,4 +33,3 @@ fn generate_idl() -> Result<(), Box> { println!("cargo:warning=IDL written to: {}", idl_path.display()); Ok(()) } - diff --git a/interface/src/error.rs b/interface/src/error.rs index 07f82864..fb6a5354 100644 --- a/interface/src/error.rs +++ b/interface/src/error.rs @@ -35,11 +35,17 @@ pub enum StakeError { // 5 /// Stake account with transient stake cannot be merged. - #[codama(error(code = 5, message = "Stake account with transient stake cannot be merged"))] + #[codama(error( + code = 5, + message = "Stake account with transient stake cannot be merged" + ))] MergeTransientStake, /// Stake account merge failed due to different authority, lockups or state. - #[codama(error(code = 6, message = "Stake account merge failed due to different authority, lockups or state"))] + #[codama(error( + code = 6, + message = "Stake account merge failed due to different authority, lockups or state" + ))] MergeMismatch, /// Custodian address not present. @@ -51,17 +57,26 @@ pub enum StakeError { CustodianSignatureMissing, /// Insufficient voting activity in the reference vote account. - #[codama(error(code = 9, message = "Insufficient voting activity in the reference vote account"))] + #[codama(error( + code = 9, + message = "Insufficient voting activity in the reference vote account" + ))] InsufficientReferenceVotes, // 10 /// Stake account is not delegated to the provided vote account. - #[codama(error(code = 10, message = "Stake account is not delegated to the provided vote account"))] + #[codama(error( + code = 10, + 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. - #[codama(error(code = 11, message = "Stake account has not been delinquent for the minimum epochs required for deactivation"))] + #[codama(error( + code = 11, + message = "Stake account has not been delinquent for the minimum epochs required for deactivation" + ))] MinimumDelinquentEpochsForDeactivationNotMet, /// Delegation amount is less than the minimum. @@ -69,20 +84,32 @@ pub enum StakeError { InsufficientDelegation, /// Stake account with transient or inactive stake cannot be redelegated. - #[codama(error(code = 13, message = "Stake account with transient or inactive stake cannot be redelegated"))] + #[codama(error( + code = 13, + message = "Stake account with transient or inactive stake cannot be redelegated" + ))] RedelegateTransientOrInactiveStake, /// Stake redelegation to the same vote account is not permitted. - #[codama(error(code = 14, message = "Stake redelegation to the same vote account is not permitted"))] + #[codama(error( + code = 14, + message = "Stake redelegation to the same vote account is not permitted" + ))] RedelegateToSameVoteAccount, // 15 /// Redelegated stake must be fully activated before deactivation. - #[codama(error(code = 15, message = "Redelegated stake must be fully activated before deactivation"))] + #[codama(error( + code = 15, + message = "Redelegated stake must be fully activated before deactivation" + ))] RedelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted, /// Stake action is not permitted while the epoch rewards period is active. - #[codama(error(code = 16, message = "Stake action is not permitted while the epoch rewards period is active"))] + #[codama(error( + code = 16, + 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 c529c7e9..d0428c3b 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -98,9 +98,7 @@ pub enum StakeInstruction { #[codama(account(name = "stake", writable))] #[codama(account(name = "split_stake", writable))] #[codama(account(name = "stake_authority", signer))] - Split { - lamports: u64, - }, + Split { lamports: u64 }, /// Withdraw unstaked lamports from the stake account /// @@ -120,9 +118,7 @@ pub enum StakeInstruction { #[codama(account(name = "stake_history_sysvar"))] #[codama(account(name = "withdraw_authority", signer))] #[codama(account(name = "lockup_authority", optional, signer))] - Withdraw { - lamports: u64, - }, + Withdraw { lamports: u64 }, /// Deactivates the stake in the account /// @@ -145,9 +141,7 @@ pub enum StakeInstruction { /// 1. `[SIGNER]` Lockup authority or withdraw authority #[codama(account(name = "stake", writable))] #[codama(account(name = "authority", signer))] - SetLockup { - lockup: LockupArgs, - }, + SetLockup { lockup: LockupArgs }, /// Merge two stake accounts. /// @@ -192,9 +186,7 @@ pub enum StakeInstruction { #[codama(account(name = "authority_base", signer))] #[codama(account(name = "clock_sysvar"))] #[codama(account(name = "lockup_authority", optional, signer))] - AuthorizeWithSeed { - args: AuthorizeWithSeedArgs, - }, + AuthorizeWithSeed { args: AuthorizeWithSeedArgs }, /// Initialize a stake with authorization information /// @@ -229,9 +221,7 @@ pub enum StakeInstruction { #[codama(account(name = "authority", signer))] #[codama(account(name = "new_authority", signer))] #[codama(account(name = "lockup_authority", optional, signer))] - AuthorizeChecked { - stake_authorize: StakeAuthorize, - }, + AuthorizeChecked { stake_authorize: StakeAuthorize }, /// Authorize a key to manage stake or withdrawal with a derived key /// @@ -250,9 +240,7 @@ pub enum StakeInstruction { #[codama(account(name = "clock_sysvar"))] #[codama(account(name = "new_authority", signer))] #[codama(account(name = "lockup_authority", optional, signer))] - AuthorizeCheckedWithSeed { - args: AuthorizeCheckedWithSeedArgs, - }, + AuthorizeCheckedWithSeed { args: AuthorizeCheckedWithSeedArgs }, /// Set stake lockup /// @@ -269,9 +257,7 @@ pub enum StakeInstruction { #[codama(account(name = "stake", writable))] #[codama(account(name = "authority", signer))] #[codama(account(name = "new_lockup_authority", optional, signer))] - SetLockupChecked { - lockup: LockupCheckedArgs, - }, + SetLockupChecked { lockup: LockupCheckedArgs }, /// Get the minimum stake delegation, in lamports /// @@ -347,9 +333,7 @@ pub enum StakeInstruction { #[codama(account(name = "source", writable))] #[codama(account(name = "destination", writable))] #[codama(account(name = "stake_authority", signer))] - MoveStake { - lamports: u64, - }, + MoveStake { lamports: u64 }, /// Move unstaked lamports between accounts with the same authorities and lockups, using Staker /// authority. @@ -367,9 +351,7 @@ pub enum StakeInstruction { #[codama(account(name = "source", writable))] #[codama(account(name = "destination", writable))] #[codama(account(name = "stake_authority", signer))] - MoveLamports { - lamports: u64, - }, + MoveLamports { lamports: u64 }, } #[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] @@ -846,7 +828,11 @@ pub fn set_lockup( AccountMeta::new(*stake_pubkey, false), AccountMeta::new_readonly(*custodian_pubkey, true), ]; - Instruction::new_with_bincode(ID, &StakeInstruction::SetLockup { lockup: *lockup }, account_metas) + Instruction::new_with_bincode( + ID, + &StakeInstruction::SetLockup { lockup: *lockup }, + account_metas, + ) } #[cfg(feature = "bincode")] @@ -992,7 +978,11 @@ pub fn move_lamports( AccountMeta::new_readonly(*authorized_pubkey, true), ]; - Instruction::new_with_bincode(ID, &StakeInstruction::MoveLamports { lamports }, account_metas) + Instruction::new_with_bincode( + ID, + &StakeInstruction::MoveLamports { lamports }, + account_metas, + ) } #[cfg(feature = "bincode")] diff --git a/interface/src/state.rs b/interface/src/state.rs index 6a038564..79be1158 100644 --- a/interface/src/state.rs +++ b/interface/src/state.rs @@ -7,13 +7,13 @@ #[cfg(feature = "borsh")] use borsh::{io, BorshDeserialize, BorshSchema, BorshSerialize}; use { - codama_macros::{codama, CodamaType}, crate::{ error::StakeError, instruction::LockupArgs, stake_flags::StakeFlags, stake_history::{StakeHistoryEntry, StakeHistoryGetEntry}, }, + codama_macros::{codama, CodamaType}, solana_clock::{Clock, Epoch, UnixTimestamp}, solana_instruction::error::InstructionError, solana_pubkey::Pubkey, From 722f30b56411e8e033ab21e13d280aa1b96cd7cc Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Fri, 14 Nov 2025 17:55:18 +0000 Subject: [PATCH 03/27] generated clients --- .../src/generated/instructions/authorize.ts | 50 ++-- .../instructions/authorizeChecked.ts | 32 +-- .../instructions/authorizeCheckedWithSeed.ts | 98 +++---- .../instructions/authorizeWithSeed.ts | 101 +++----- .../src/generated/instructions/deactivate.ts | 28 +- .../instructions/deactivateDelinquent.ts | 16 +- .../generated/instructions/delegateStake.ts | 93 +++---- .../instructions/getMinimumDelegation.ts | 10 +- .../js/src/generated/instructions/index.ts | 1 + .../src/generated/instructions/initialize.ts | 46 ++-- .../instructions/initializeChecked.ts | 30 +-- .../js/src/generated/instructions/merge.ts | 122 ++++----- .../generated/instructions/moveLamports.ts | 85 +++--- .../src/generated/instructions/moveStake.ts | 88 +++---- .../src/generated/instructions/redelegate.ts | 93 +++++++ .../src/generated/instructions/setLockup.ts | 52 ++-- .../instructions/setLockupChecked.ts | 80 +++--- .../js/src/generated/instructions/split.ts | 26 +- .../js/src/generated/instructions/withdraw.ts | 78 +++--- clients/js/src/generated/programs/stake.ts | 44 ++-- .../types/authorizeCheckedWithSeedArgs.ts | 69 +++++ .../generated/types/authorizeWithSeedArgs.ts | 73 ++++++ clients/js/src/generated/types/delegation.ts | 22 +- clients/js/src/generated/types/epoch.ts | 32 +++ clients/js/src/generated/types/index.ts | 6 + clients/js/src/generated/types/lockup.ts | 30 ++- clients/js/src/generated/types/lockupArgs.ts | 65 +++++ .../src/generated/types/lockupCheckedArgs.ts | 64 +++++ clients/js/src/generated/types/stakeState.ts | 56 ++-- .../js/src/generated/types/stakeStateV2.ts | 84 +++--- .../js/src/generated/types/unixTimestamp.ts | 35 +++ .../src/generated/instructions/authorize.rs | 86 +++---- .../instructions/authorize_checked.rs | 47 ++-- .../authorize_checked_with_seed.rs | 166 ++++-------- .../instructions/authorize_with_seed.rs | 181 ++++--------- .../src/generated/instructions/deactivate.rs | 31 +-- .../instructions/deactivate_delinquent.rs | 24 +- .../generated/instructions/delegate_stake.rs | 140 +++++----- .../instructions/get_minimum_delegation.rs | 2 +- .../src/generated/instructions/initialize.rs | 67 +++-- .../instructions/initialize_checked.rs | 39 +-- .../rust/src/generated/instructions/merge.rs | 182 ++++++------- .../rust/src/generated/instructions/mod.rs | 5 +- .../generated/instructions/move_lamports.rs | 136 +++++----- .../src/generated/instructions/move_stake.rs | 136 +++++----- .../src/generated/instructions/redelegate.rs | 241 ++++++++++++++++++ .../src/generated/instructions/set_lockup.rs | 76 ++---- .../instructions/set_lockup_checked.rs | 115 ++++----- .../rust/src/generated/instructions/split.rs | 48 ++-- .../src/generated/instructions/withdraw.rs | 126 +++++---- .../types/authorize_checked_with_seed_args.rs | 24 ++ .../types/authorize_with_seed_args.rs | 29 +++ .../rust/src/generated/types/delegation.rs | 5 +- clients/rust/src/generated/types/epoch.rs | 8 + clients/rust/src/generated/types/lockup.rs | 5 +- .../rust/src/generated/types/lockup_args.rs | 20 ++ .../generated/types/lockup_checked_args.rs | 18 ++ clients/rust/src/generated/types/mod.rs | 12 +- .../src/generated/types/unix_timestamp.rs | 8 + 59 files changed, 1946 insertions(+), 1740 deletions(-) create mode 100644 clients/js/src/generated/instructions/redelegate.ts create mode 100644 clients/js/src/generated/types/authorizeCheckedWithSeedArgs.ts create mode 100644 clients/js/src/generated/types/authorizeWithSeedArgs.ts create mode 100644 clients/js/src/generated/types/epoch.ts create mode 100644 clients/js/src/generated/types/lockupArgs.ts create mode 100644 clients/js/src/generated/types/lockupCheckedArgs.ts create mode 100644 clients/js/src/generated/types/unixTimestamp.ts create mode 100644 clients/rust/src/generated/instructions/redelegate.rs create mode 100644 clients/rust/src/generated/types/authorize_checked_with_seed_args.rs create mode 100644 clients/rust/src/generated/types/authorize_with_seed_args.rs create mode 100644 clients/rust/src/generated/types/epoch.rs create mode 100644 clients/rust/src/generated/types/lockup_args.rs create mode 100644 clients/rust/src/generated/types/lockup_checked_args.rs create mode 100644 clients/rust/src/generated/types/unix_timestamp.rs diff --git a/clients/js/src/generated/instructions/authorize.ts b/clients/js/src/generated/instructions/authorize.ts index fd9c0d12..f73c2f59 100644 --- a/clients/js/src/generated/instructions/authorize.ts +++ b/clients/js/src/generated/instructions/authorize.ts @@ -12,8 +12,8 @@ import { getAddressEncoder, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -42,15 +42,13 @@ import { export const AUTHORIZE_DISCRIMINATOR = 1; export function getAuthorizeDiscriminatorBytes() { - return getU32Encoder().encode(AUTHORIZE_DISCRIMINATOR); + return getU8Encoder().encode(AUTHORIZE_DISCRIMINATOR); } export type AuthorizeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountClockSysvar extends - | string - | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', + TAccountClockSysvar extends string | AccountMeta = string, TAccountAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends | string @@ -85,21 +83,21 @@ export type AuthorizeInstruction< export type AuthorizeInstructionData = { discriminator: number; - arg0: Address; - arg1: StakeAuthorize; + pubkey: Address; + stakeAuthorize: StakeAuthorize; }; export type AuthorizeInstructionDataArgs = { - arg0: Address; - arg1: StakeAuthorizeArgs; + pubkey: Address; + stakeAuthorize: StakeAuthorizeArgs; }; export function getAuthorizeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['arg0', getAddressEncoder()], - ['arg1', getStakeAuthorizeEncoder()], + ['discriminator', getU8Encoder()], + ['pubkey', getAddressEncoder()], + ['stakeAuthorize', getStakeAuthorizeEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_DISCRIMINATOR }) ); @@ -107,9 +105,9 @@ export function getAuthorizeInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['arg0', getAddressDecoder()], - ['arg1', getStakeAuthorizeDecoder()], + ['discriminator', getU8Decoder()], + ['pubkey', getAddressDecoder()], + ['stakeAuthorize', getStakeAuthorizeDecoder()], ]); } @@ -129,16 +127,12 @@ export type AuthorizeInput< TAccountAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { - /** Stake account to be updated */ stake: Address; - /** Clock sysvar */ - clockSysvar?: Address; - /** Stake or withdraw authority */ + clockSysvar: Address; authority: TransactionSigner; - /** Lockup authority */ lockupAuthority?: TransactionSigner; - arg0: AuthorizeInstructionDataArgs['arg0']; - arg1: AuthorizeInstructionDataArgs['arg1']; + pubkey: AuthorizeInstructionDataArgs['pubkey']; + stakeAuthorize: AuthorizeInstructionDataArgs['stakeAuthorize']; }; export function getAuthorizeInstruction< @@ -183,12 +177,6 @@ export function getAuthorizeInstruction< // Original args. const args = { ...input }; - // Resolve default values. - if (!accounts.clockSysvar.value) { - accounts.clockSysvar.value = - 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ @@ -216,13 +204,9 @@ export type ParsedAuthorizeInstruction< > = { programAddress: Address; accounts: { - /** Stake account to be updated */ stake: TAccountMetas[0]; - /** Clock sysvar */ clockSysvar: TAccountMetas[1]; - /** Stake or withdraw authority */ authority: TAccountMetas[2]; - /** Lockup authority */ 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..36d289e4 100644 --- a/clients/js/src/generated/instructions/authorizeChecked.ts +++ b/clients/js/src/generated/instructions/authorizeChecked.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -40,15 +40,13 @@ import { export const AUTHORIZE_CHECKED_DISCRIMINATOR = 10; export function getAuthorizeCheckedDiscriminatorBytes() { - return getU32Encoder().encode(AUTHORIZE_CHECKED_DISCRIMINATOR); + return getU8Encoder().encode(AUTHORIZE_CHECKED_DISCRIMINATOR); } export type AuthorizeCheckedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountClockSysvar extends - | string - | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', + TAccountClockSysvar extends string | AccountMeta = string, TAccountAuthority extends string | AccountMeta = string, TAccountNewAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends @@ -98,7 +96,7 @@ export type AuthorizeCheckedInstructionDataArgs = { export function getAuthorizeCheckedInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], + ['discriminator', getU8Encoder()], ['stakeAuthorize', getStakeAuthorizeEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_CHECKED_DISCRIMINATOR }) @@ -107,7 +105,7 @@ export function getAuthorizeCheckedInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], + ['discriminator', getU8Decoder()], ['stakeAuthorize', getStakeAuthorizeDecoder()], ]); } @@ -129,15 +127,10 @@ export type AuthorizeCheckedInput< TAccountNewAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { - /** Stake account to be updated */ stake: Address; - /** Clock sysvar */ - clockSysvar?: Address; - /** The stake or withdraw authority */ + clockSysvar: Address; authority: TransactionSigner; - /** The new stake or withdraw authority */ newAuthority: TransactionSigner; - /** Lockup authority */ lockupAuthority?: TransactionSigner; stakeAuthorize: AuthorizeCheckedInstructionDataArgs['stakeAuthorize']; }; @@ -188,12 +181,6 @@ export function getAuthorizeCheckedInstruction< // Original args. const args = { ...input }; - // Resolve default values. - if (!accounts.clockSysvar.value) { - accounts.clockSysvar.value = - 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ @@ -223,15 +210,10 @@ export type ParsedAuthorizeCheckedInstruction< > = { programAddress: Address; accounts: { - /** Stake account to be updated */ stake: TAccountMetas[0]; - /** Clock sysvar */ clockSysvar: TAccountMetas[1]; - /** The stake or withdraw authority */ authority: TAccountMetas[2]; - /** The new stake or withdraw authority */ newAuthority: TAccountMetas[3]; - /** Lockup authority */ 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..34ffaf64 100644 --- a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts @@ -7,17 +7,11 @@ */ import { - addDecoderSizePrefix, - addEncoderSizePrefix, combineCodec, - getAddressDecoder, - getAddressEncoder, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, - getUtf8Decoder, - getUtf8Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -37,25 +31,23 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getStakeAuthorizeDecoder, - getStakeAuthorizeEncoder, - type StakeAuthorize, - type StakeAuthorizeArgs, + getAuthorizeCheckedWithSeedArgsDecoder, + getAuthorizeCheckedWithSeedArgsEncoder, + type AuthorizeCheckedWithSeedArgs, + type AuthorizeCheckedWithSeedArgsArgs, } from '../types'; export const AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR = 11; export function getAuthorizeCheckedWithSeedDiscriminatorBytes() { - return getU32Encoder().encode(AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR); + return getU8Encoder().encode(AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR); } export type AuthorizeCheckedWithSeedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountBase extends string | AccountMeta = string, - TAccountClockSysvar extends - | string - | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', + TAccountAuthorityBase extends string | AccountMeta = string, + TAccountClockSysvar extends string | AccountMeta = string, TAccountNewAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends | string @@ -69,9 +61,10 @@ export type AuthorizeCheckedWithSeedInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountBase extends string - ? ReadonlySignerAccount & AccountSignerMeta - : TAccountBase, + TAccountAuthorityBase extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthorityBase, TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, @@ -93,27 +86,18 @@ export type AuthorizeCheckedWithSeedInstruction< export type AuthorizeCheckedWithSeedInstructionData = { discriminator: number; - stakeAuthorize: StakeAuthorize; - authoritySeed: string; - authorityOwner: Address; + args: AuthorizeCheckedWithSeedArgs; }; export type AuthorizeCheckedWithSeedInstructionDataArgs = { - stakeAuthorize: StakeAuthorizeArgs; - authoritySeed: string; - authorityOwner: Address; + args: AuthorizeCheckedWithSeedArgsArgs; }; export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['stakeAuthorize', getStakeAuthorizeEncoder()], - [ - 'authoritySeed', - addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()), - ], - ['authorityOwner', getAddressEncoder()], + ['discriminator', getU8Encoder()], + ['args', getAuthorizeCheckedWithSeedArgsEncoder()], ]), (value) => ({ ...value, @@ -124,10 +108,8 @@ export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['stakeAuthorize', getStakeAuthorizeDecoder()], - ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], - ['authorityOwner', getAddressDecoder()], + ['discriminator', getU8Decoder()], + ['args', getAuthorizeCheckedWithSeedArgsDecoder()], ]); } @@ -143,29 +125,22 @@ export function getAuthorizeCheckedWithSeedInstructionDataCodec(): Codec< export type AuthorizeCheckedWithSeedInput< TAccountStake extends string = string, - TAccountBase extends string = string, + TAccountAuthorityBase extends string = string, TAccountClockSysvar extends string = string, TAccountNewAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { - /** Stake account to be updated */ stake: Address; - /** Base key of stake or withdraw authority */ - base: TransactionSigner; - /** Clock sysvar */ - clockSysvar?: Address; - /** The new stake or withdraw authority */ + authorityBase: TransactionSigner; + clockSysvar: Address; newAuthority: TransactionSigner; - /** Lockup authority */ lockupAuthority?: TransactionSigner; - stakeAuthorize: AuthorizeCheckedWithSeedInstructionDataArgs['stakeAuthorize']; - authoritySeed: AuthorizeCheckedWithSeedInstructionDataArgs['authoritySeed']; - authorityOwner: AuthorizeCheckedWithSeedInstructionDataArgs['authorityOwner']; + args: AuthorizeCheckedWithSeedInstructionDataArgs['args']; }; export function getAuthorizeCheckedWithSeedInstruction< TAccountStake extends string, - TAccountBase extends string, + TAccountAuthorityBase extends string, TAccountClockSysvar extends string, TAccountNewAuthority extends string, TAccountLockupAuthority extends string, @@ -173,7 +148,7 @@ export function getAuthorizeCheckedWithSeedInstruction< >( input: AuthorizeCheckedWithSeedInput< TAccountStake, - TAccountBase, + TAccountAuthorityBase, TAccountClockSysvar, TAccountNewAuthority, TAccountLockupAuthority @@ -182,7 +157,7 @@ export function getAuthorizeCheckedWithSeedInstruction< ): AuthorizeCheckedWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountBase, + TAccountAuthorityBase, TAccountClockSysvar, TAccountNewAuthority, TAccountLockupAuthority @@ -193,7 +168,7 @@ export function getAuthorizeCheckedWithSeedInstruction< // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - base: { value: input.base ?? null, isWritable: false }, + authorityBase: { value: input.authorityBase ?? null, isWritable: false }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, newAuthority: { value: input.newAuthority ?? null, isWritable: false }, lockupAuthority: { @@ -209,17 +184,11 @@ export function getAuthorizeCheckedWithSeedInstruction< // Original args. const args = { ...input }; - // Resolve default values. - if (!accounts.clockSysvar.value) { - accounts.clockSysvar.value = - 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.base), + getAccountMeta(accounts.authorityBase), getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.newAuthority), getAccountMeta(accounts.lockupAuthority), @@ -231,7 +200,7 @@ export function getAuthorizeCheckedWithSeedInstruction< } as AuthorizeCheckedWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountBase, + TAccountAuthorityBase, TAccountClockSysvar, TAccountNewAuthority, TAccountLockupAuthority @@ -244,15 +213,10 @@ export type ParsedAuthorizeCheckedWithSeedInstruction< > = { programAddress: Address; accounts: { - /** Stake account to be updated */ stake: TAccountMetas[0]; - /** Base key of stake or withdraw authority */ - base: TAccountMetas[1]; - /** Clock sysvar */ + authorityBase: TAccountMetas[1]; clockSysvar: TAccountMetas[2]; - /** The new stake or withdraw authority */ newAuthority: TAccountMetas[3]; - /** Lockup authority */ lockupAuthority?: TAccountMetas[4] | undefined; }; data: AuthorizeCheckedWithSeedInstructionData; @@ -286,7 +250,7 @@ export function parseAuthorizeCheckedWithSeedInstruction< programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - base: getNextAccount(), + authorityBase: getNextAccount(), clockSysvar: getNextAccount(), newAuthority: getNextAccount(), lockupAuthority: getNextOptionalAccount(), diff --git a/clients/js/src/generated/instructions/authorizeWithSeed.ts b/clients/js/src/generated/instructions/authorizeWithSeed.ts index 0f103252..809b0e76 100644 --- a/clients/js/src/generated/instructions/authorizeWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeWithSeed.ts @@ -7,17 +7,11 @@ */ import { - addDecoderSizePrefix, - addEncoderSizePrefix, combineCodec, - getAddressDecoder, - getAddressEncoder, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, - getUtf8Decoder, - getUtf8Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -37,25 +31,23 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getStakeAuthorizeDecoder, - getStakeAuthorizeEncoder, - type StakeAuthorize, - type StakeAuthorizeArgs, + getAuthorizeWithSeedArgsDecoder, + getAuthorizeWithSeedArgsEncoder, + type AuthorizeWithSeedArgs, + type AuthorizeWithSeedArgsArgs, } from '../types'; export const AUTHORIZE_WITH_SEED_DISCRIMINATOR = 8; export function getAuthorizeWithSeedDiscriminatorBytes() { - return getU32Encoder().encode(AUTHORIZE_WITH_SEED_DISCRIMINATOR); + return getU8Encoder().encode(AUTHORIZE_WITH_SEED_DISCRIMINATOR); } export type AuthorizeWithSeedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountBase extends string | AccountMeta = string, - TAccountClockSysvar extends - | string - | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', + TAccountAuthorityBase extends string | AccountMeta = string, + TAccountClockSysvar extends string | AccountMeta = string, TAccountLockupAuthority extends | string | AccountMeta @@ -68,9 +60,10 @@ export type AuthorizeWithSeedInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountBase extends string - ? ReadonlySignerAccount & AccountSignerMeta - : TAccountBase, + TAccountAuthorityBase extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthorityBase, TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, @@ -88,30 +81,18 @@ export type AuthorizeWithSeedInstruction< export type AuthorizeWithSeedInstructionData = { discriminator: number; - newAuthorizedPubkey: Address; - stakeAuthorize: StakeAuthorize; - authoritySeed: string; - authorityOwner: Address; + args: AuthorizeWithSeedArgs; }; export type AuthorizeWithSeedInstructionDataArgs = { - newAuthorizedPubkey: Address; - stakeAuthorize: StakeAuthorizeArgs; - authoritySeed: string; - authorityOwner: Address; + args: AuthorizeWithSeedArgsArgs; }; export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['newAuthorizedPubkey', getAddressEncoder()], - ['stakeAuthorize', getStakeAuthorizeEncoder()], - [ - 'authoritySeed', - addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()), - ], - ['authorityOwner', getAddressEncoder()], + ['discriminator', getU8Encoder()], + ['args', getAuthorizeWithSeedArgsEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_WITH_SEED_DISCRIMINATOR }) ); @@ -119,11 +100,8 @@ export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['newAuthorizedPubkey', getAddressDecoder()], - ['stakeAuthorize', getStakeAuthorizeDecoder()], - ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], - ['authorityOwner', getAddressDecoder()], + ['discriminator', getU8Decoder()], + ['args', getAuthorizeWithSeedArgsDecoder()], ]); } @@ -139,34 +117,27 @@ export function getAuthorizeWithSeedInstructionDataCodec(): Codec< export type AuthorizeWithSeedInput< TAccountStake extends string = string, - TAccountBase extends string = string, + TAccountAuthorityBase extends string = string, TAccountClockSysvar extends string = string, TAccountLockupAuthority extends string = string, > = { - /** Stake account to be updated */ stake: Address; - /** Base key of stake or withdraw authority */ - base: TransactionSigner; - /** Clock sysvar */ - clockSysvar?: Address; - /** Lockup authority */ + authorityBase: TransactionSigner; + clockSysvar: Address; lockupAuthority?: TransactionSigner; - newAuthorizedPubkey: AuthorizeWithSeedInstructionDataArgs['newAuthorizedPubkey']; - stakeAuthorize: AuthorizeWithSeedInstructionDataArgs['stakeAuthorize']; - authoritySeed: AuthorizeWithSeedInstructionDataArgs['authoritySeed']; - authorityOwner: AuthorizeWithSeedInstructionDataArgs['authorityOwner']; + args: AuthorizeWithSeedInstructionDataArgs['args']; }; export function getAuthorizeWithSeedInstruction< TAccountStake extends string, - TAccountBase extends string, + TAccountAuthorityBase extends string, TAccountClockSysvar extends string, TAccountLockupAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: AuthorizeWithSeedInput< TAccountStake, - TAccountBase, + TAccountAuthorityBase, TAccountClockSysvar, TAccountLockupAuthority >, @@ -174,7 +145,7 @@ export function getAuthorizeWithSeedInstruction< ): AuthorizeWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountBase, + TAccountAuthorityBase, TAccountClockSysvar, TAccountLockupAuthority > { @@ -184,7 +155,7 @@ export function getAuthorizeWithSeedInstruction< // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - base: { value: input.base ?? null, isWritable: false }, + authorityBase: { value: input.authorityBase ?? null, isWritable: false }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, lockupAuthority: { value: input.lockupAuthority ?? null, @@ -199,17 +170,11 @@ export function getAuthorizeWithSeedInstruction< // Original args. const args = { ...input }; - // Resolve default values. - if (!accounts.clockSysvar.value) { - accounts.clockSysvar.value = - 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.base), + getAccountMeta(accounts.authorityBase), getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.lockupAuthority), ].filter((x: T | undefined): x is T => x !== undefined), @@ -220,7 +185,7 @@ export function getAuthorizeWithSeedInstruction< } as AuthorizeWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountBase, + TAccountAuthorityBase, TAccountClockSysvar, TAccountLockupAuthority >); @@ -232,13 +197,9 @@ export type ParsedAuthorizeWithSeedInstruction< > = { programAddress: Address; accounts: { - /** Stake account to be updated */ stake: TAccountMetas[0]; - /** Base key of stake or withdraw authority */ - base: TAccountMetas[1]; - /** Clock sysvar */ + authorityBase: TAccountMetas[1]; clockSysvar: TAccountMetas[2]; - /** Lockup authority */ lockupAuthority?: TAccountMetas[3] | undefined; }; data: AuthorizeWithSeedInstructionData; @@ -272,7 +233,7 @@ export function parseAuthorizeWithSeedInstruction< programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - base: getNextAccount(), + authorityBase: getNextAccount(), clockSysvar: getNextAccount(), lockupAuthority: getNextOptionalAccount(), }, diff --git a/clients/js/src/generated/instructions/deactivate.ts b/clients/js/src/generated/instructions/deactivate.ts index c6d73b86..1b9a3d01 100644 --- a/clients/js/src/generated/instructions/deactivate.ts +++ b/clients/js/src/generated/instructions/deactivate.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -34,15 +34,13 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const DEACTIVATE_DISCRIMINATOR = 5; export function getDeactivateDiscriminatorBytes() { - return getU32Encoder().encode(DEACTIVATE_DISCRIMINATOR); + return getU8Encoder().encode(DEACTIVATE_DISCRIMINATOR); } export type DeactivateInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountClockSysvar extends - | string - | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', + TAccountClockSysvar extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & @@ -69,13 +67,13 @@ export type DeactivateInstructionDataArgs = {}; export function getDeactivateInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU32Encoder()]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: DEACTIVATE_DISCRIMINATOR }) ); } export function getDeactivateInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU32Decoder()]]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getDeactivateInstructionDataCodec(): FixedSizeCodec< @@ -93,11 +91,8 @@ export type DeactivateInput< TAccountClockSysvar extends string = string, TAccountStakeAuthority extends string = string, > = { - /** Delegated stake account */ stake: Address; - /** Clock sysvar */ - clockSysvar?: Address; - /** Stake authority */ + clockSysvar: Address; stakeAuthority: TransactionSigner; }; @@ -133,12 +128,6 @@ export function getDeactivateInstruction< ResolvedAccount >; - // Resolve default values. - if (!accounts.clockSysvar.value) { - accounts.clockSysvar.value = - 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ @@ -162,11 +151,8 @@ export type ParsedDeactivateInstruction< > = { programAddress: Address; accounts: { - /** Delegated stake account */ stake: TAccountMetas[0]; - /** Clock sysvar */ clockSysvar: TAccountMetas[1]; - /** Stake authority */ stakeAuthority: TAccountMetas[2]; }; data: DeactivateInstructionData; diff --git a/clients/js/src/generated/instructions/deactivateDelinquent.ts b/clients/js/src/generated/instructions/deactivateDelinquent.ts index b1df56cb..328bfc2b 100644 --- a/clients/js/src/generated/instructions/deactivateDelinquent.ts +++ b/clients/js/src/generated/instructions/deactivateDelinquent.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type Address, @@ -31,7 +31,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const DEACTIVATE_DELINQUENT_DISCRIMINATOR = 14; export function getDeactivateDelinquentDiscriminatorBytes() { - return getU32Encoder().encode(DEACTIVATE_DELINQUENT_DISCRIMINATOR); + return getU8Encoder().encode(DEACTIVATE_DELINQUENT_DISCRIMINATOR); } export type DeactivateDelinquentInstruction< @@ -63,7 +63,7 @@ export type DeactivateDelinquentInstructionDataArgs = {}; export function getDeactivateDelinquentInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU32Encoder()]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: DEACTIVATE_DELINQUENT_DISCRIMINATOR, @@ -72,7 +72,7 @@ export function getDeactivateDelinquentInstructionDataEncoder(): FixedSizeEncode } export function getDeactivateDelinquentInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU32Decoder()]]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getDeactivateDelinquentInstructionDataCodec(): FixedSizeCodec< @@ -90,11 +90,8 @@ export type DeactivateDelinquentInput< TAccountDelinquentVote extends string = string, TAccountReferenceVote extends string = string, > = { - /** Delegated stake account */ stake: Address; - /** Delinquent vote account */ delinquentVote: Address; - /** Reference vote account */ referenceVote: Address; }; @@ -153,11 +150,8 @@ export type ParsedDeactivateDelinquentInstruction< > = { programAddress: Address; accounts: { - /** Delegated stake account */ stake: TAccountMetas[0]; - /** Delinquent vote account */ delinquentVote: TAccountMetas[1]; - /** Reference vote account */ 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..85695b27 100644 --- a/clients/js/src/generated/instructions/delegateStake.ts +++ b/clients/js/src/generated/instructions/delegateStake.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -34,18 +34,16 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const DELEGATE_STAKE_DISCRIMINATOR = 2; export function getDelegateStakeDiscriminatorBytes() { - return getU32Encoder().encode(DELEGATE_STAKE_DISCRIMINATOR); + return getU8Encoder().encode(DELEGATE_STAKE_DISCRIMINATOR); } export type DelegateStakeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, TAccountVote extends string | AccountMeta = string, - TAccountClockSysvar extends - | string - | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', - TAccountStakeHistory extends string | AccountMeta = string, - TAccountUnused extends string | AccountMeta = string, + TAccountClockSysvar extends string | AccountMeta = string, + TAccountStakeHistorySysvar extends string | AccountMeta = string, + TAccountConfig extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & @@ -61,12 +59,12 @@ export type DelegateStakeInstruction< TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, - TAccountStakeHistory extends string - ? ReadonlyAccount - : TAccountStakeHistory, - TAccountUnused extends string - ? ReadonlyAccount - : TAccountUnused, + TAccountStakeHistorySysvar extends string + ? ReadonlyAccount + : TAccountStakeHistorySysvar, + TAccountConfig extends string + ? ReadonlyAccount + : TAccountConfig, TAccountStakeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -81,13 +79,13 @@ export type DelegateStakeInstructionDataArgs = {}; export function getDelegateStakeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU32Encoder()]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: DELEGATE_STAKE_DISCRIMINATOR }) ); } export function getDelegateStakeInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU32Decoder()]]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getDelegateStakeInstructionDataCodec(): FixedSizeCodec< @@ -104,21 +102,15 @@ export type DelegateStakeInput< TAccountStake extends string = string, TAccountVote extends string = string, TAccountClockSysvar extends string = string, - TAccountStakeHistory extends string = string, - TAccountUnused extends string = string, + TAccountStakeHistorySysvar extends string = string, + TAccountConfig extends string = string, TAccountStakeAuthority extends string = string, > = { - /** Initialized stake account to be delegated */ stake: Address; - /** Vote account to which this stake will be delegated */ vote: Address; - /** Clock sysvar */ - clockSysvar?: Address; - /** Stake history sysvar */ - stakeHistory: Address; - /** Unused account, formerly the stake config */ - unused: Address; - /** Stake authority */ + clockSysvar: Address; + stakeHistorySysvar: Address; + config: Address; stakeAuthority: TransactionSigner; }; @@ -126,8 +118,8 @@ export function getDelegateStakeInstruction< TAccountStake extends string, TAccountVote extends string, TAccountClockSysvar extends string, - TAccountStakeHistory extends string, - TAccountUnused extends string, + TAccountStakeHistorySysvar extends string, + TAccountConfig extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( @@ -135,8 +127,8 @@ export function getDelegateStakeInstruction< TAccountStake, TAccountVote, TAccountClockSysvar, - TAccountStakeHistory, - TAccountUnused, + TAccountStakeHistorySysvar, + TAccountConfig, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } @@ -145,8 +137,8 @@ export function getDelegateStakeInstruction< TAccountStake, TAccountVote, TAccountClockSysvar, - TAccountStakeHistory, - TAccountUnused, + TAccountStakeHistorySysvar, + TAccountConfig, TAccountStakeAuthority > { // Program address. @@ -157,8 +149,11 @@ export function getDelegateStakeInstruction< stake: { value: input.stake ?? null, isWritable: true }, vote: { value: input.vote ?? null, isWritable: false }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, - stakeHistory: { value: input.stakeHistory ?? null, isWritable: false }, - unused: { value: input.unused ?? null, isWritable: false }, + stakeHistorySysvar: { + value: input.stakeHistorySysvar ?? null, + isWritable: false, + }, + config: { value: input.config ?? null, isWritable: false }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -166,20 +161,14 @@ export function getDelegateStakeInstruction< ResolvedAccount >; - // Resolve default values. - if (!accounts.clockSysvar.value) { - accounts.clockSysvar.value = - 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ getAccountMeta(accounts.stake), getAccountMeta(accounts.vote), getAccountMeta(accounts.clockSysvar), - getAccountMeta(accounts.stakeHistory), - getAccountMeta(accounts.unused), + getAccountMeta(accounts.stakeHistorySysvar), + getAccountMeta(accounts.config), getAccountMeta(accounts.stakeAuthority), ], data: getDelegateStakeInstructionDataEncoder().encode({}), @@ -189,8 +178,8 @@ export function getDelegateStakeInstruction< TAccountStake, TAccountVote, TAccountClockSysvar, - TAccountStakeHistory, - TAccountUnused, + TAccountStakeHistorySysvar, + TAccountConfig, TAccountStakeAuthority >); } @@ -201,17 +190,11 @@ export type ParsedDelegateStakeInstruction< > = { programAddress: Address; accounts: { - /** Initialized stake account to be delegated */ stake: TAccountMetas[0]; - /** Vote account to which this stake will be delegated */ vote: TAccountMetas[1]; - /** Clock sysvar */ clockSysvar: TAccountMetas[2]; - /** Stake history sysvar */ - stakeHistory: TAccountMetas[3]; - /** Unused account, formerly the stake config */ - unused: TAccountMetas[4]; - /** Stake authority */ + stakeHistorySysvar: TAccountMetas[3]; + config: TAccountMetas[4]; stakeAuthority: TAccountMetas[5]; }; data: DelegateStakeInstructionData; @@ -241,8 +224,8 @@ export function parseDelegateStakeInstruction< stake: getNextAccount(), vote: getNextAccount(), clockSysvar: getNextAccount(), - stakeHistory: getNextAccount(), - unused: getNextAccount(), + stakeHistorySysvar: getNextAccount(), + config: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getDelegateStakeInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/getMinimumDelegation.ts b/clients/js/src/generated/instructions/getMinimumDelegation.ts index 6e1a2f5a..b7c4e3e4 100644 --- a/clients/js/src/generated/instructions/getMinimumDelegation.ts +++ b/clients/js/src/generated/instructions/getMinimumDelegation.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type Address, @@ -28,7 +28,7 @@ import { STAKE_PROGRAM_ADDRESS } from '../programs'; export const GET_MINIMUM_DELEGATION_DISCRIMINATOR = 13; export function getGetMinimumDelegationDiscriminatorBytes() { - return getU32Encoder().encode(GET_MINIMUM_DELEGATION_DISCRIMINATOR); + return getU8Encoder().encode(GET_MINIMUM_DELEGATION_DISCRIMINATOR); } export type GetMinimumDelegationInstruction< @@ -44,7 +44,7 @@ export type GetMinimumDelegationInstructionDataArgs = {}; export function getGetMinimumDelegationInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU32Encoder()]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: GET_MINIMUM_DELEGATION_DISCRIMINATOR, @@ -53,7 +53,7 @@ export function getGetMinimumDelegationInstructionDataEncoder(): FixedSizeEncode } export function getGetMinimumDelegationInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU32Decoder()]]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getGetMinimumDelegationInstructionDataCodec(): FixedSizeCodec< diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index 1eb46db5..1ccb4a45 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -19,6 +19,7 @@ export * from './initializeChecked'; export * from './merge'; export * from './moveLamports'; export * from './moveStake'; +export * from './redelegate'; export * from './setLockup'; export * from './setLockupChecked'; export * from './split'; diff --git a/clients/js/src/generated/instructions/initialize.ts b/clients/js/src/generated/instructions/initialize.ts index 0e22930a..c46e285b 100644 --- a/clients/js/src/generated/instructions/initialize.ts +++ b/clients/js/src/generated/instructions/initialize.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type Address, @@ -41,15 +41,13 @@ import { export const INITIALIZE_DISCRIMINATOR = 0; export function getInitializeDiscriminatorBytes() { - return getU32Encoder().encode(INITIALIZE_DISCRIMINATOR); + return getU8Encoder().encode(INITIALIZE_DISCRIMINATOR); } export type InitializeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountRentSysvar extends - | string - | AccountMeta = 'SysvarRent111111111111111111111111111111111', + TAccountRentSysvar extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & @@ -67,21 +65,21 @@ export type InitializeInstruction< export type InitializeInstructionData = { discriminator: number; - arg0: Authorized; - arg1: Lockup; + authorized: Authorized; + lockup: Lockup; }; export type InitializeInstructionDataArgs = { - arg0: AuthorizedArgs; - arg1: LockupArgs; + authorized: AuthorizedArgs; + lockup: LockupArgs; }; export function getInitializeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['arg0', getAuthorizedEncoder()], - ['arg1', getLockupEncoder()], + ['discriminator', getU8Encoder()], + ['authorized', getAuthorizedEncoder()], + ['lockup', getLockupEncoder()], ]), (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) ); @@ -89,9 +87,9 @@ export function getInitializeInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['arg0', getAuthorizedDecoder()], - ['arg1', getLockupDecoder()], + ['discriminator', getU8Decoder()], + ['authorized', getAuthorizedDecoder()], + ['lockup', getLockupDecoder()], ]); } @@ -109,12 +107,10 @@ export type InitializeInput< TAccountStake extends string = string, TAccountRentSysvar extends string = string, > = { - /** Uninitialized stake account */ stake: Address; - /** Rent sysvar */ - rentSysvar?: Address; - arg0: InitializeInstructionDataArgs['arg0']; - arg1: InitializeInstructionDataArgs['arg1']; + rentSysvar: Address; + authorized: InitializeInstructionDataArgs['authorized']; + lockup: InitializeInstructionDataArgs['lockup']; }; export function getInitializeInstruction< @@ -141,12 +137,6 @@ export function getInitializeInstruction< // Original args. const args = { ...input }; - // Resolve default values. - if (!accounts.rentSysvar.value) { - accounts.rentSysvar.value = - 'SysvarRent111111111111111111111111111111111' as Address<'SysvarRent111111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ @@ -170,9 +160,7 @@ export type ParsedInitializeInstruction< > = { programAddress: Address; accounts: { - /** Uninitialized stake account */ stake: TAccountMetas[0]; - /** Rent sysvar */ rentSysvar: TAccountMetas[1]; }; data: InitializeInstructionData; diff --git a/clients/js/src/generated/instructions/initializeChecked.ts b/clients/js/src/generated/instructions/initializeChecked.ts index 4b733d9e..fc2c95c8 100644 --- a/clients/js/src/generated/instructions/initializeChecked.ts +++ b/clients/js/src/generated/instructions/initializeChecked.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -34,15 +34,13 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const INITIALIZE_CHECKED_DISCRIMINATOR = 9; export function getInitializeCheckedDiscriminatorBytes() { - return getU32Encoder().encode(INITIALIZE_CHECKED_DISCRIMINATOR); + return getU8Encoder().encode(INITIALIZE_CHECKED_DISCRIMINATOR); } export type InitializeCheckedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountRentSysvar extends - | string - | AccountMeta = 'SysvarRent111111111111111111111111111111111', + TAccountRentSysvar extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TAccountWithdrawAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], @@ -73,13 +71,13 @@ export type InitializeCheckedInstructionDataArgs = {}; export function getInitializeCheckedInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU32Encoder()]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: INITIALIZE_CHECKED_DISCRIMINATOR }) ); } export function getInitializeCheckedInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU32Decoder()]]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getInitializeCheckedInstructionDataCodec(): FixedSizeCodec< @@ -98,13 +96,9 @@ export type InitializeCheckedInput< TAccountStakeAuthority extends string = string, TAccountWithdrawAuthority extends string = string, > = { - /** Uninitialized stake account */ stake: Address; - /** Rent sysvar */ - rentSysvar?: Address; - /** The stake authority */ + rentSysvar: Address; stakeAuthority: Address; - /** The withdraw authority */ withdrawAuthority: TransactionSigner; }; @@ -147,12 +141,6 @@ export function getInitializeCheckedInstruction< ResolvedAccount >; - // Resolve default values. - if (!accounts.rentSysvar.value) { - accounts.rentSysvar.value = - 'SysvarRent111111111111111111111111111111111' as Address<'SysvarRent111111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ @@ -178,13 +166,9 @@ export type ParsedInitializeCheckedInstruction< > = { programAddress: Address; accounts: { - /** Uninitialized stake account */ stake: TAccountMetas[0]; - /** Rent sysvar */ rentSysvar: TAccountMetas[1]; - /** The stake authority */ stakeAuthority: TAccountMetas[2]; - /** The withdraw authority */ withdrawAuthority: TAccountMetas[3]; }; data: InitializeCheckedInstructionData; diff --git a/clients/js/src/generated/instructions/merge.ts b/clients/js/src/generated/instructions/merge.ts index 502cfd33..e68d9ac2 100644 --- a/clients/js/src/generated/instructions/merge.ts +++ b/clients/js/src/generated/instructions/merge.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -34,35 +34,33 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const MERGE_DISCRIMINATOR = 7; export function getMergeDiscriminatorBytes() { - return getU32Encoder().encode(MERGE_DISCRIMINATOR); + return getU8Encoder().encode(MERGE_DISCRIMINATOR); } export type MergeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, - TAccountDestinationStake extends string | AccountMeta = string, - TAccountSourceStake extends string | AccountMeta = string, - TAccountClockSysvar extends - | string - | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', - TAccountStakeHistory extends string | AccountMeta = string, + TAccountDestination extends string | AccountMeta = string, + TAccountSource extends string | AccountMeta = string, + TAccountClockSysvar extends string | AccountMeta = string, + TAccountStakeHistorySysvar extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountDestinationStake extends string - ? WritableAccount - : TAccountDestinationStake, - TAccountSourceStake extends string - ? WritableAccount - : TAccountSourceStake, + TAccountDestination extends string + ? WritableAccount + : TAccountDestination, + TAccountSource extends string + ? WritableAccount + : TAccountSource, TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, - TAccountStakeHistory extends string - ? ReadonlyAccount - : TAccountStakeHistory, + TAccountStakeHistorySysvar extends string + ? ReadonlyAccount + : TAccountStakeHistorySysvar, TAccountStakeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -77,13 +75,13 @@ export type MergeInstructionDataArgs = {}; export function getMergeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU32Encoder()]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: MERGE_DISCRIMINATOR }) ); } export function getMergeInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU32Decoder()]]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getMergeInstructionDataCodec(): FixedSizeCodec< @@ -97,46 +95,41 @@ export function getMergeInstructionDataCodec(): FixedSizeCodec< } export type MergeInput< - TAccountDestinationStake extends string = string, - TAccountSourceStake extends string = string, + TAccountDestination extends string = string, + TAccountSource extends string = string, TAccountClockSysvar extends string = string, - TAccountStakeHistory extends string = string, + TAccountStakeHistorySysvar extends string = string, TAccountStakeAuthority extends string = string, > = { - /** Destination stake account */ - destinationStake: Address; - /** Source stake account */ - sourceStake: Address; - /** Clock sysvar */ - clockSysvar?: Address; - /** Stake history sysvar */ - stakeHistory: Address; - /** Stake authority */ + destination: Address; + source: Address; + clockSysvar: Address; + stakeHistorySysvar: Address; stakeAuthority: TransactionSigner; }; export function getMergeInstruction< - TAccountDestinationStake extends string, - TAccountSourceStake extends string, + TAccountDestination extends string, + TAccountSource extends string, TAccountClockSysvar extends string, - TAccountStakeHistory extends string, + TAccountStakeHistorySysvar extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: MergeInput< - TAccountDestinationStake, - TAccountSourceStake, + TAccountDestination, + TAccountSource, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } ): MergeInstruction< TProgramAddress, - TAccountDestinationStake, - TAccountSourceStake, + TAccountDestination, + TAccountSource, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountStakeAuthority > { // Program address. @@ -144,13 +137,13 @@ export function getMergeInstruction< // Original accounts. const originalAccounts = { - destinationStake: { - value: input.destinationStake ?? null, - isWritable: true, - }, - sourceStake: { value: input.sourceStake ?? null, isWritable: true }, + destination: { value: input.destination ?? null, isWritable: true }, + source: { value: input.source ?? null, isWritable: true }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, - stakeHistory: { value: input.stakeHistory ?? null, isWritable: false }, + stakeHistorySysvar: { + value: input.stakeHistorySysvar ?? null, + isWritable: false, + }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -158,29 +151,23 @@ export function getMergeInstruction< ResolvedAccount >; - // Resolve default values. - if (!accounts.clockSysvar.value) { - accounts.clockSysvar.value = - 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ - getAccountMeta(accounts.destinationStake), - getAccountMeta(accounts.sourceStake), + getAccountMeta(accounts.destination), + getAccountMeta(accounts.source), getAccountMeta(accounts.clockSysvar), - getAccountMeta(accounts.stakeHistory), + getAccountMeta(accounts.stakeHistorySysvar), getAccountMeta(accounts.stakeAuthority), ], data: getMergeInstructionDataEncoder().encode({}), programAddress, } as MergeInstruction< TProgramAddress, - TAccountDestinationStake, - TAccountSourceStake, + TAccountDestination, + TAccountSource, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountStakeAuthority >); } @@ -191,15 +178,10 @@ export type ParsedMergeInstruction< > = { programAddress: Address; accounts: { - /** Destination stake account */ - destinationStake: TAccountMetas[0]; - /** Source stake account */ - sourceStake: TAccountMetas[1]; - /** Clock sysvar */ + destination: TAccountMetas[0]; + source: TAccountMetas[1]; clockSysvar: TAccountMetas[2]; - /** Stake history sysvar */ - stakeHistory: TAccountMetas[3]; - /** Stake authority */ + stakeHistorySysvar: TAccountMetas[3]; stakeAuthority: TAccountMetas[4]; }; data: MergeInstructionData; @@ -226,10 +208,10 @@ export function parseMergeInstruction< return { programAddress: instruction.programAddress, accounts: { - destinationStake: getNextAccount(), - sourceStake: getNextAccount(), + destination: getNextAccount(), + source: getNextAccount(), clockSysvar: getNextAccount(), - stakeHistory: getNextAccount(), + stakeHistorySysvar: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getMergeInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/moveLamports.ts b/clients/js/src/generated/instructions/moveLamports.ts index 3261bb91..8c9805c9 100644 --- a/clients/js/src/generated/instructions/moveLamports.ts +++ b/clients/js/src/generated/instructions/moveLamports.ts @@ -10,10 +10,10 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, getU64Decoder, getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -35,25 +35,25 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const MOVE_LAMPORTS_DISCRIMINATOR = 17; export function getMoveLamportsDiscriminatorBytes() { - return getU32Encoder().encode(MOVE_LAMPORTS_DISCRIMINATOR); + return getU8Encoder().encode(MOVE_LAMPORTS_DISCRIMINATOR); } export type MoveLamportsInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, - TAccountSourceStake extends string | AccountMeta = string, - TAccountDestinationStake extends string | AccountMeta = string, + TAccountSource extends string | AccountMeta = string, + TAccountDestination extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountSourceStake extends string - ? WritableAccount - : TAccountSourceStake, - TAccountDestinationStake extends string - ? WritableAccount - : TAccountDestinationStake, + TAccountSource extends string + ? WritableAccount + : TAccountSource, + TAccountDestination extends string + ? WritableAccount + : TAccountDestination, TAccountStakeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -64,16 +64,16 @@ export type MoveLamportsInstruction< export type MoveLamportsInstructionData = { discriminator: number; - args: bigint; + lamports: bigint; }; -export type MoveLamportsInstructionDataArgs = { args: number | bigint }; +export type MoveLamportsInstructionDataArgs = { lamports: number | bigint }; export function getMoveLamportsInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['args', getU64Encoder()], + ['discriminator', getU8Encoder()], + ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: MOVE_LAMPORTS_DISCRIMINATOR }) ); @@ -81,8 +81,8 @@ export function getMoveLamportsInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['args', getU64Decoder()], + ['discriminator', getU8Decoder()], + ['lamports', getU64Decoder()], ]); } @@ -97,35 +97,32 @@ export function getMoveLamportsInstructionDataCodec(): FixedSizeCodec< } export type MoveLamportsInput< - TAccountSourceStake extends string = string, - TAccountDestinationStake extends string = string, + TAccountSource extends string = string, + TAccountDestination extends string = string, TAccountStakeAuthority extends string = string, > = { - /** Active or inactive source stake account */ - sourceStake: Address; - /** Mergeable destination stake account */ - destinationStake: Address; - /** Stake authority */ + source: Address; + destination: Address; stakeAuthority: TransactionSigner; - args: MoveLamportsInstructionDataArgs['args']; + lamports: MoveLamportsInstructionDataArgs['lamports']; }; export function getMoveLamportsInstruction< - TAccountSourceStake extends string, - TAccountDestinationStake extends string, + TAccountSource extends string, + TAccountDestination extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: MoveLamportsInput< - TAccountSourceStake, - TAccountDestinationStake, + TAccountSource, + TAccountDestination, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } ): MoveLamportsInstruction< TProgramAddress, - TAccountSourceStake, - TAccountDestinationStake, + TAccountSource, + TAccountDestination, TAccountStakeAuthority > { // Program address. @@ -133,11 +130,8 @@ export function getMoveLamportsInstruction< // Original accounts. const originalAccounts = { - sourceStake: { value: input.sourceStake ?? null, isWritable: true }, - destinationStake: { - value: input.destinationStake ?? null, - isWritable: true, - }, + source: { value: input.source ?? null, isWritable: true }, + destination: { value: input.destination ?? null, isWritable: true }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -151,8 +145,8 @@ export function getMoveLamportsInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ - getAccountMeta(accounts.sourceStake), - getAccountMeta(accounts.destinationStake), + getAccountMeta(accounts.source), + getAccountMeta(accounts.destination), getAccountMeta(accounts.stakeAuthority), ], data: getMoveLamportsInstructionDataEncoder().encode( @@ -161,8 +155,8 @@ export function getMoveLamportsInstruction< programAddress, } as MoveLamportsInstruction< TProgramAddress, - TAccountSourceStake, - TAccountDestinationStake, + TAccountSource, + TAccountDestination, TAccountStakeAuthority >); } @@ -173,11 +167,8 @@ export type ParsedMoveLamportsInstruction< > = { programAddress: Address; accounts: { - /** Active or inactive source stake account */ - sourceStake: TAccountMetas[0]; - /** Mergeable destination stake account */ - destinationStake: TAccountMetas[1]; - /** Stake authority */ + source: TAccountMetas[0]; + destination: TAccountMetas[1]; stakeAuthority: TAccountMetas[2]; }; data: MoveLamportsInstructionData; @@ -204,8 +195,8 @@ export function parseMoveLamportsInstruction< return { programAddress: instruction.programAddress, accounts: { - sourceStake: getNextAccount(), - destinationStake: getNextAccount(), + source: getNextAccount(), + destination: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getMoveLamportsInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/moveStake.ts b/clients/js/src/generated/instructions/moveStake.ts index e216194e..e7891b77 100644 --- a/clients/js/src/generated/instructions/moveStake.ts +++ b/clients/js/src/generated/instructions/moveStake.ts @@ -10,10 +10,10 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, getU64Decoder, getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -35,25 +35,25 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const MOVE_STAKE_DISCRIMINATOR = 16; export function getMoveStakeDiscriminatorBytes() { - return getU32Encoder().encode(MOVE_STAKE_DISCRIMINATOR); + return getU8Encoder().encode(MOVE_STAKE_DISCRIMINATOR); } export type MoveStakeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, - TAccountSourceStake extends string | AccountMeta = string, - TAccountDestinationStake extends string | AccountMeta = string, + TAccountSource extends string | AccountMeta = string, + TAccountDestination extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountSourceStake extends string - ? WritableAccount - : TAccountSourceStake, - TAccountDestinationStake extends string - ? WritableAccount - : TAccountDestinationStake, + TAccountSource extends string + ? WritableAccount + : TAccountSource, + TAccountDestination extends string + ? WritableAccount + : TAccountDestination, TAccountStakeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -62,15 +62,18 @@ export type MoveStakeInstruction< ] >; -export type MoveStakeInstructionData = { discriminator: number; args: bigint }; +export type MoveStakeInstructionData = { + discriminator: number; + lamports: bigint; +}; -export type MoveStakeInstructionDataArgs = { args: number | bigint }; +export type MoveStakeInstructionDataArgs = { lamports: number | bigint }; export function getMoveStakeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['args', getU64Encoder()], + ['discriminator', getU8Encoder()], + ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: MOVE_STAKE_DISCRIMINATOR }) ); @@ -78,8 +81,8 @@ export function getMoveStakeInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['args', getU64Decoder()], + ['discriminator', getU8Decoder()], + ['lamports', getU64Decoder()], ]); } @@ -94,35 +97,32 @@ export function getMoveStakeInstructionDataCodec(): FixedSizeCodec< } export type MoveStakeInput< - TAccountSourceStake extends string = string, - TAccountDestinationStake extends string = string, + TAccountSource extends string = string, + TAccountDestination extends string = string, TAccountStakeAuthority extends string = string, > = { - /** Active source stake account */ - sourceStake: Address; - /** Active or inactive destination stake account */ - destinationStake: Address; - /** Stake authority */ + source: Address; + destination: Address; stakeAuthority: TransactionSigner; - args: MoveStakeInstructionDataArgs['args']; + lamports: MoveStakeInstructionDataArgs['lamports']; }; export function getMoveStakeInstruction< - TAccountSourceStake extends string, - TAccountDestinationStake extends string, + TAccountSource extends string, + TAccountDestination extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: MoveStakeInput< - TAccountSourceStake, - TAccountDestinationStake, + TAccountSource, + TAccountDestination, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } ): MoveStakeInstruction< TProgramAddress, - TAccountSourceStake, - TAccountDestinationStake, + TAccountSource, + TAccountDestination, TAccountStakeAuthority > { // Program address. @@ -130,11 +130,8 @@ export function getMoveStakeInstruction< // Original accounts. const originalAccounts = { - sourceStake: { value: input.sourceStake ?? null, isWritable: true }, - destinationStake: { - value: input.destinationStake ?? null, - isWritable: true, - }, + source: { value: input.source ?? null, isWritable: true }, + destination: { value: input.destination ?? null, isWritable: true }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -148,8 +145,8 @@ export function getMoveStakeInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ - getAccountMeta(accounts.sourceStake), - getAccountMeta(accounts.destinationStake), + getAccountMeta(accounts.source), + getAccountMeta(accounts.destination), getAccountMeta(accounts.stakeAuthority), ], data: getMoveStakeInstructionDataEncoder().encode( @@ -158,8 +155,8 @@ export function getMoveStakeInstruction< programAddress, } as MoveStakeInstruction< TProgramAddress, - TAccountSourceStake, - TAccountDestinationStake, + TAccountSource, + TAccountDestination, TAccountStakeAuthority >); } @@ -170,11 +167,8 @@ export type ParsedMoveStakeInstruction< > = { programAddress: Address; accounts: { - /** Active source stake account */ - sourceStake: TAccountMetas[0]; - /** Active or inactive destination stake account */ - destinationStake: TAccountMetas[1]; - /** Stake authority */ + source: TAccountMetas[0]; + destination: TAccountMetas[1]; stakeAuthority: TAccountMetas[2]; }; data: MoveStakeInstructionData; @@ -201,8 +195,8 @@ export function parseMoveStakeInstruction< return { programAddress: instruction.programAddress, accounts: { - sourceStake: getNextAccount(), - destinationStake: getNextAccount(), + source: getNextAccount(), + destination: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getMoveStakeInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/redelegate.ts b/clients/js/src/generated/instructions/redelegate.ts new file mode 100644 index 00000000..de51634a --- /dev/null +++ b/clients/js/src/generated/instructions/redelegate.ts @@ -0,0 +1,93 @@ +/** + * 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, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type AccountMeta, + type Address, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; + +export const REDELEGATE_DISCRIMINATOR = 15; + +export function getRedelegateDiscriminatorBytes() { + return getU8Encoder().encode(REDELEGATE_DISCRIMINATOR); +} + +export type RedelegateInstruction< + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts; + +export type RedelegateInstructionData = { discriminator: number }; + +export type RedelegateInstructionDataArgs = {}; + +export function getRedelegateInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([['discriminator', getU8Encoder()]]), + (value) => ({ ...value, discriminator: REDELEGATE_DISCRIMINATOR }) + ); +} + +export function getRedelegateInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([['discriminator', getU8Decoder()]]); +} + +export function getRedelegateInstructionDataCodec(): FixedSizeCodec< + RedelegateInstructionDataArgs, + RedelegateInstructionData +> { + return combineCodec( + getRedelegateInstructionDataEncoder(), + getRedelegateInstructionDataDecoder() + ); +} + +export type RedelegateInput = {}; + +export function getRedelegateInstruction< + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, +>(config?: { + programAddress?: TProgramAddress; +}): RedelegateInstruction { + // Program address. + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; + + return Object.freeze({ + data: getRedelegateInstructionDataEncoder().encode({}), + programAddress, + } as RedelegateInstruction); +} + +export type ParsedRedelegateInstruction< + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, +> = { programAddress: Address; data: RedelegateInstructionData }; + +export function parseRedelegateInstruction( + instruction: Instruction & InstructionWithData +): ParsedRedelegateInstruction { + return { + programAddress: instruction.programAddress, + data: getRedelegateInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/js/src/generated/instructions/setLockup.ts b/clients/js/src/generated/instructions/setLockup.ts index 1e082f68..10687a84 100644 --- a/clients/js/src/generated/instructions/setLockup.ts +++ b/clients/js/src/generated/instructions/setLockup.ts @@ -8,18 +8,10 @@ import { combineCodec, - getAddressDecoder, - getAddressEncoder, - getI64Decoder, - getI64Encoder, - getOptionDecoder, - getOptionEncoder, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -30,8 +22,6 @@ import { type Instruction, type InstructionWithAccounts, type InstructionWithData, - type Option, - type OptionOrNullable, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, @@ -39,11 +29,17 @@ import { } from '@solana/kit'; import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getLockupArgsDecoder, + getLockupArgsEncoder, + type LockupArgs, + type LockupArgsArgs, +} from '../types'; export const SET_LOCKUP_DISCRIMINATOR = 6; export function getSetLockupDiscriminatorBytes() { - return getU32Encoder().encode(SET_LOCKUP_DISCRIMINATOR); + return getU8Encoder().encode(SET_LOCKUP_DISCRIMINATOR); } export type SetLockupInstruction< @@ -68,24 +64,16 @@ export type SetLockupInstruction< export type SetLockupInstructionData = { discriminator: number; - unixTimestamp: Option; - epoch: Option; - custodian: Option
; + lockup: LockupArgs; }; -export type SetLockupInstructionDataArgs = { - unixTimestamp: OptionOrNullable; - epoch: OptionOrNullable; - custodian: OptionOrNullable
; -}; +export type SetLockupInstructionDataArgs = { lockup: LockupArgsArgs }; export function getSetLockupInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['unixTimestamp', getOptionEncoder(getI64Encoder())], - ['epoch', getOptionEncoder(getU64Encoder())], - ['custodian', getOptionEncoder(getAddressEncoder())], + ['discriminator', getU8Encoder()], + ['lockup', getLockupArgsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_DISCRIMINATOR }) ); @@ -93,10 +81,8 @@ export function getSetLockupInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['unixTimestamp', getOptionDecoder(getI64Decoder())], - ['epoch', getOptionDecoder(getU64Decoder())], - ['custodian', getOptionDecoder(getAddressDecoder())], + ['discriminator', getU8Decoder()], + ['lockup', getLockupArgsDecoder()], ]); } @@ -114,13 +100,9 @@ export type SetLockupInput< TAccountStake extends string = string, TAccountAuthority extends string = string, > = { - /** Initialized stake account */ stake: Address; - /** Lockup authority or withdraw authority */ authority: TransactionSigner; - unixTimestamp: SetLockupInstructionDataArgs['unixTimestamp']; - epoch: SetLockupInstructionDataArgs['epoch']; - custodian: SetLockupInstructionDataArgs['custodian']; + lockup: SetLockupInstructionDataArgs['lockup']; }; export function getSetLockupInstruction< @@ -166,9 +148,7 @@ export type ParsedSetLockupInstruction< > = { programAddress: Address; accounts: { - /** Initialized stake account */ stake: TAccountMetas[0]; - /** Lockup authority or withdraw authority */ authority: TAccountMetas[1]; }; data: SetLockupInstructionData; diff --git a/clients/js/src/generated/instructions/setLockupChecked.ts b/clients/js/src/generated/instructions/setLockupChecked.ts index 12aea9b8..7ae30567 100644 --- a/clients/js/src/generated/instructions/setLockupChecked.ts +++ b/clients/js/src/generated/instructions/setLockupChecked.ts @@ -8,16 +8,10 @@ import { combineCodec, - getI64Decoder, - getI64Encoder, - getOptionDecoder, - getOptionEncoder, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -28,8 +22,6 @@ import { type Instruction, type InstructionWithAccounts, type InstructionWithData, - type Option, - type OptionOrNullable, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, @@ -37,18 +29,24 @@ import { } from '@solana/kit'; import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getLockupCheckedArgsDecoder, + getLockupCheckedArgsEncoder, + type LockupCheckedArgs, + type LockupCheckedArgsArgs, +} from '../types'; export const SET_LOCKUP_CHECKED_DISCRIMINATOR = 12; export function getSetLockupCheckedDiscriminatorBytes() { - return getU32Encoder().encode(SET_LOCKUP_CHECKED_DISCRIMINATOR); + return getU8Encoder().encode(SET_LOCKUP_CHECKED_DISCRIMINATOR); } export type SetLockupCheckedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, TAccountAuthority extends string | AccountMeta = string, - TAccountNewAuthority extends + TAccountNewLockupAuthority extends | string | AccountMeta | undefined = undefined, @@ -64,13 +62,13 @@ export type SetLockupCheckedInstruction< ? ReadonlySignerAccount & AccountSignerMeta : TAccountAuthority, - ...(TAccountNewAuthority extends undefined + ...(TAccountNewLockupAuthority extends undefined ? [] : [ - TAccountNewAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountNewAuthority, + TAccountNewLockupAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountNewLockupAuthority, ]), ...TRemainingAccounts, ] @@ -78,21 +76,18 @@ export type SetLockupCheckedInstruction< export type SetLockupCheckedInstructionData = { discriminator: number; - unixTimestamp: Option; - epoch: Option; + lockup: LockupCheckedArgs; }; export type SetLockupCheckedInstructionDataArgs = { - unixTimestamp: OptionOrNullable; - epoch: OptionOrNullable; + lockup: LockupCheckedArgsArgs; }; export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['unixTimestamp', getOptionEncoder(getI64Encoder())], - ['epoch', getOptionEncoder(getU64Encoder())], + ['discriminator', getU8Encoder()], + ['lockup', getLockupCheckedArgsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_CHECKED_DISCRIMINATOR }) ); @@ -100,9 +95,8 @@ export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['unixTimestamp', getOptionDecoder(getI64Decoder())], - ['epoch', getOptionDecoder(getU64Decoder())], + ['discriminator', getU8Decoder()], + ['lockup', getLockupCheckedArgsDecoder()], ]); } @@ -119,35 +113,31 @@ export function getSetLockupCheckedInstructionDataCodec(): Codec< export type SetLockupCheckedInput< TAccountStake extends string = string, TAccountAuthority extends string = string, - TAccountNewAuthority extends string = string, + TAccountNewLockupAuthority extends string = string, > = { - /** Initialized stake account */ stake: Address; - /** Lockup authority or withdraw authority */ authority: TransactionSigner; - /** New lockup authority */ - newAuthority?: TransactionSigner; - unixTimestamp: SetLockupCheckedInstructionDataArgs['unixTimestamp']; - epoch: SetLockupCheckedInstructionDataArgs['epoch']; + newLockupAuthority?: TransactionSigner; + lockup: SetLockupCheckedInstructionDataArgs['lockup']; }; export function getSetLockupCheckedInstruction< TAccountStake extends string, TAccountAuthority extends string, - TAccountNewAuthority extends string, + TAccountNewLockupAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: SetLockupCheckedInput< TAccountStake, TAccountAuthority, - TAccountNewAuthority + TAccountNewLockupAuthority >, config?: { programAddress?: TProgramAddress } ): SetLockupCheckedInstruction< TProgramAddress, TAccountStake, TAccountAuthority, - TAccountNewAuthority + TAccountNewLockupAuthority > { // Program address. const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; @@ -156,7 +146,10 @@ export function getSetLockupCheckedInstruction< const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, authority: { value: input.authority ?? null, isWritable: false }, - newAuthority: { value: input.newAuthority ?? null, isWritable: false }, + newLockupAuthority: { + value: input.newLockupAuthority ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -171,7 +164,7 @@ export function getSetLockupCheckedInstruction< accounts: [ getAccountMeta(accounts.stake), getAccountMeta(accounts.authority), - getAccountMeta(accounts.newAuthority), + getAccountMeta(accounts.newLockupAuthority), ].filter((x: T | undefined): x is T => x !== undefined), data: getSetLockupCheckedInstructionDataEncoder().encode( args as SetLockupCheckedInstructionDataArgs @@ -181,7 +174,7 @@ export function getSetLockupCheckedInstruction< TProgramAddress, TAccountStake, TAccountAuthority, - TAccountNewAuthority + TAccountNewLockupAuthority >); } @@ -191,12 +184,9 @@ export type ParsedSetLockupCheckedInstruction< > = { programAddress: Address; accounts: { - /** Initialized stake account */ stake: TAccountMetas[0]; - /** Lockup authority or withdraw authority */ authority: TAccountMetas[1]; - /** New lockup authority */ - newAuthority?: TAccountMetas[2] | undefined; + newLockupAuthority?: TAccountMetas[2] | undefined; }; data: SetLockupCheckedInstructionData; }; @@ -230,7 +220,7 @@ export function parseSetLockupCheckedInstruction< accounts: { stake: getNextAccount(), authority: getNextAccount(), - newAuthority: getNextOptionalAccount(), + newLockupAuthority: getNextOptionalAccount(), }, data: getSetLockupCheckedInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/js/src/generated/instructions/split.ts b/clients/js/src/generated/instructions/split.ts index a01549bf..a78de202 100644 --- a/clients/js/src/generated/instructions/split.ts +++ b/clients/js/src/generated/instructions/split.ts @@ -10,10 +10,10 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, getU64Decoder, getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -35,7 +35,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const SPLIT_DISCRIMINATOR = 3; export function getSplitDiscriminatorBytes() { - return getU32Encoder().encode(SPLIT_DISCRIMINATOR); + return getU8Encoder().encode(SPLIT_DISCRIMINATOR); } export type SplitInstruction< @@ -62,15 +62,15 @@ export type SplitInstruction< ] >; -export type SplitInstructionData = { discriminator: number; args: bigint }; +export type SplitInstructionData = { discriminator: number; lamports: bigint }; -export type SplitInstructionDataArgs = { args: number | bigint }; +export type SplitInstructionDataArgs = { lamports: number | bigint }; export function getSplitInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['args', getU64Encoder()], + ['discriminator', getU8Encoder()], + ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: SPLIT_DISCRIMINATOR }) ); @@ -78,8 +78,8 @@ export function getSplitInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['args', getU64Decoder()], + ['discriminator', getU8Decoder()], + ['lamports', getU64Decoder()], ]); } @@ -98,13 +98,10 @@ export type SplitInput< TAccountSplitStake extends string = string, TAccountStakeAuthority extends string = string, > = { - /** Stake account to be split */ stake: Address; - /** Uninitialized stake account */ splitStake: Address; - /** Stake authority */ stakeAuthority: TransactionSigner; - args: SplitInstructionDataArgs['args']; + lamports: SplitInstructionDataArgs['lamports']; }; export function getSplitInstruction< @@ -163,11 +160,8 @@ export type ParsedSplitInstruction< > = { programAddress: Address; accounts: { - /** Stake account to be split */ stake: TAccountMetas[0]; - /** Uninitialized stake account */ splitStake: TAccountMetas[1]; - /** Stake authority */ stakeAuthority: TAccountMetas[2]; }; data: SplitInstructionData; diff --git a/clients/js/src/generated/instructions/withdraw.ts b/clients/js/src/generated/instructions/withdraw.ts index f48b433a..e34620d1 100644 --- a/clients/js/src/generated/instructions/withdraw.ts +++ b/clients/js/src/generated/instructions/withdraw.ts @@ -10,10 +10,10 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU32Decoder, - getU32Encoder, getU64Decoder, getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -36,17 +36,15 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const WITHDRAW_DISCRIMINATOR = 4; export function getWithdrawDiscriminatorBytes() { - return getU32Encoder().encode(WITHDRAW_DISCRIMINATOR); + return getU8Encoder().encode(WITHDRAW_DISCRIMINATOR); } export type WithdrawInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, TAccountRecipient extends string | AccountMeta = string, - TAccountClockSysvar extends - | string - | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', - TAccountStakeHistory extends string | AccountMeta = string, + TAccountClockSysvar extends string | AccountMeta = string, + TAccountStakeHistorySysvar extends string | AccountMeta = string, TAccountWithdrawAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends | string @@ -66,9 +64,9 @@ export type WithdrawInstruction< TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, - TAccountStakeHistory extends string - ? ReadonlyAccount - : TAccountStakeHistory, + TAccountStakeHistorySysvar extends string + ? ReadonlyAccount + : TAccountStakeHistorySysvar, TAccountWithdrawAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -85,15 +83,18 @@ export type WithdrawInstruction< ] >; -export type WithdrawInstructionData = { discriminator: number; args: bigint }; +export type WithdrawInstructionData = { + discriminator: number; + lamports: bigint; +}; -export type WithdrawInstructionDataArgs = { args: number | bigint }; +export type WithdrawInstructionDataArgs = { lamports: number | bigint }; export function getWithdrawInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU32Encoder()], - ['args', getU64Encoder()], + ['discriminator', getU8Encoder()], + ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: WITHDRAW_DISCRIMINATOR }) ); @@ -101,8 +102,8 @@ export function getWithdrawInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU32Decoder()], - ['args', getU64Decoder()], + ['discriminator', getU8Decoder()], + ['lamports', getU64Decoder()], ]); } @@ -120,30 +121,24 @@ export type WithdrawInput< TAccountStake extends string = string, TAccountRecipient extends string = string, TAccountClockSysvar extends string = string, - TAccountStakeHistory extends string = string, + TAccountStakeHistorySysvar extends string = string, TAccountWithdrawAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { - /** Stake account from which to withdraw */ stake: Address; - /** Recipient account */ recipient: Address; - /** Clock sysvar */ - clockSysvar?: Address; - /** Stake history sysvar */ - stakeHistory: Address; - /** Withdraw authority */ + clockSysvar: Address; + stakeHistorySysvar: Address; withdrawAuthority: TransactionSigner; - /** Lockup authority */ lockupAuthority?: TransactionSigner; - args: WithdrawInstructionDataArgs['args']; + lamports: WithdrawInstructionDataArgs['lamports']; }; export function getWithdrawInstruction< TAccountStake extends string, TAccountRecipient extends string, TAccountClockSysvar extends string, - TAccountStakeHistory extends string, + TAccountStakeHistorySysvar extends string, TAccountWithdrawAuthority extends string, TAccountLockupAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, @@ -152,7 +147,7 @@ export function getWithdrawInstruction< TAccountStake, TAccountRecipient, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountWithdrawAuthority, TAccountLockupAuthority >, @@ -162,7 +157,7 @@ export function getWithdrawInstruction< TAccountStake, TAccountRecipient, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountWithdrawAuthority, TAccountLockupAuthority > { @@ -174,7 +169,10 @@ export function getWithdrawInstruction< stake: { value: input.stake ?? null, isWritable: true }, recipient: { value: input.recipient ?? null, isWritable: true }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, - stakeHistory: { value: input.stakeHistory ?? null, isWritable: false }, + stakeHistorySysvar: { + value: input.stakeHistorySysvar ?? null, + isWritable: false, + }, withdrawAuthority: { value: input.withdrawAuthority ?? null, isWritable: false, @@ -192,19 +190,13 @@ export function getWithdrawInstruction< // Original args. const args = { ...input }; - // Resolve default values. - if (!accounts.clockSysvar.value) { - accounts.clockSysvar.value = - 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ getAccountMeta(accounts.stake), getAccountMeta(accounts.recipient), getAccountMeta(accounts.clockSysvar), - getAccountMeta(accounts.stakeHistory), + getAccountMeta(accounts.stakeHistorySysvar), getAccountMeta(accounts.withdrawAuthority), getAccountMeta(accounts.lockupAuthority), ].filter((x: T | undefined): x is T => x !== undefined), @@ -217,7 +209,7 @@ export function getWithdrawInstruction< TAccountStake, TAccountRecipient, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountWithdrawAuthority, TAccountLockupAuthority >); @@ -229,17 +221,11 @@ export type ParsedWithdrawInstruction< > = { programAddress: Address; accounts: { - /** Stake account from which to withdraw */ stake: TAccountMetas[0]; - /** Recipient account */ recipient: TAccountMetas[1]; - /** Clock sysvar */ clockSysvar: TAccountMetas[2]; - /** Stake history sysvar */ - stakeHistory: TAccountMetas[3]; - /** Withdraw authority */ + stakeHistorySysvar: TAccountMetas[3]; withdrawAuthority: TAccountMetas[4]; - /** Lockup authority */ lockupAuthority?: TAccountMetas[5] | undefined; }; data: WithdrawInstructionData; @@ -275,7 +261,7 @@ export function parseWithdrawInstruction< stake: getNextAccount(), recipient: getNextAccount(), clockSysvar: getNextAccount(), - stakeHistory: getNextAccount(), + stakeHistorySysvar: getNextAccount(), withdrawAuthority: getNextAccount(), lockupAuthority: getNextOptionalAccount(), }, diff --git a/clients/js/src/generated/programs/stake.ts b/clients/js/src/generated/programs/stake.ts index fbbf9681..a61fcf12 100644 --- a/clients/js/src/generated/programs/stake.ts +++ b/clients/js/src/generated/programs/stake.ts @@ -8,7 +8,7 @@ import { containsBytes, - getU32Encoder, + getU8Encoder, type Address, type ReadonlyUint8Array, } from '@solana/kit'; @@ -26,6 +26,7 @@ import { type ParsedMergeInstruction, type ParsedMoveLamportsInstruction, type ParsedMoveStakeInstruction, + type ParsedRedelegateInstruction, type ParsedSetLockupCheckedInstruction, type ParsedSetLockupInstruction, type ParsedSplitInstruction, @@ -55,6 +56,7 @@ export enum StakeInstruction { SetLockupChecked, GetMinimumDelegation, DeactivateDelinquent, + Redelegate, MoveStake, MoveLamports, } @@ -63,55 +65,58 @@ export function identifyStakeInstruction( instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array ): StakeInstruction { const data = 'data' in instruction ? instruction.data : instruction; - if (containsBytes(data, getU32Encoder().encode(0), 0)) { + if (containsBytes(data, getU8Encoder().encode(0), 0)) { return StakeInstruction.Initialize; } - if (containsBytes(data, getU32Encoder().encode(1), 0)) { + if (containsBytes(data, getU8Encoder().encode(1), 0)) { return StakeInstruction.Authorize; } - if (containsBytes(data, getU32Encoder().encode(2), 0)) { + if (containsBytes(data, getU8Encoder().encode(2), 0)) { return StakeInstruction.DelegateStake; } - if (containsBytes(data, getU32Encoder().encode(3), 0)) { + if (containsBytes(data, getU8Encoder().encode(3), 0)) { return StakeInstruction.Split; } - if (containsBytes(data, getU32Encoder().encode(4), 0)) { + if (containsBytes(data, getU8Encoder().encode(4), 0)) { return StakeInstruction.Withdraw; } - if (containsBytes(data, getU32Encoder().encode(5), 0)) { + if (containsBytes(data, getU8Encoder().encode(5), 0)) { return StakeInstruction.Deactivate; } - if (containsBytes(data, getU32Encoder().encode(6), 0)) { + if (containsBytes(data, getU8Encoder().encode(6), 0)) { return StakeInstruction.SetLockup; } - if (containsBytes(data, getU32Encoder().encode(7), 0)) { + if (containsBytes(data, getU8Encoder().encode(7), 0)) { return StakeInstruction.Merge; } - if (containsBytes(data, getU32Encoder().encode(8), 0)) { + if (containsBytes(data, getU8Encoder().encode(8), 0)) { return StakeInstruction.AuthorizeWithSeed; } - if (containsBytes(data, getU32Encoder().encode(9), 0)) { + if (containsBytes(data, getU8Encoder().encode(9), 0)) { return StakeInstruction.InitializeChecked; } - if (containsBytes(data, getU32Encoder().encode(10), 0)) { + if (containsBytes(data, getU8Encoder().encode(10), 0)) { return StakeInstruction.AuthorizeChecked; } - if (containsBytes(data, getU32Encoder().encode(11), 0)) { + if (containsBytes(data, getU8Encoder().encode(11), 0)) { return StakeInstruction.AuthorizeCheckedWithSeed; } - if (containsBytes(data, getU32Encoder().encode(12), 0)) { + if (containsBytes(data, getU8Encoder().encode(12), 0)) { return StakeInstruction.SetLockupChecked; } - if (containsBytes(data, getU32Encoder().encode(13), 0)) { + if (containsBytes(data, getU8Encoder().encode(13), 0)) { return StakeInstruction.GetMinimumDelegation; } - if (containsBytes(data, getU32Encoder().encode(14), 0)) { + if (containsBytes(data, getU8Encoder().encode(14), 0)) { return StakeInstruction.DeactivateDelinquent; } - if (containsBytes(data, getU32Encoder().encode(16), 0)) { + if (containsBytes(data, getU8Encoder().encode(15), 0)) { + return StakeInstruction.Redelegate; + } + if (containsBytes(data, getU8Encoder().encode(16), 0)) { return StakeInstruction.MoveStake; } - if (containsBytes(data, getU32Encoder().encode(17), 0)) { + if (containsBytes(data, getU8Encoder().encode(17), 0)) { return StakeInstruction.MoveLamports; } throw new Error( @@ -167,6 +172,9 @@ export type ParsedStakeInstruction< | ({ instructionType: StakeInstruction.DeactivateDelinquent; } & ParsedDeactivateDelinquentInstruction) + | ({ + instructionType: StakeInstruction.Redelegate; + } & ParsedRedelegateInstruction) | ({ instructionType: StakeInstruction.MoveStake; } & ParsedMoveStakeInstruction) diff --git a/clients/js/src/generated/types/authorizeCheckedWithSeedArgs.ts b/clients/js/src/generated/types/authorizeCheckedWithSeedArgs.ts new file mode 100644 index 00000000..d34f08ce --- /dev/null +++ b/clients/js/src/generated/types/authorizeCheckedWithSeedArgs.ts @@ -0,0 +1,69 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + getAddressDecoder, + getAddressEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getUtf8Decoder, + getUtf8Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; +import { + getStakeAuthorizeDecoder, + getStakeAuthorizeEncoder, + type StakeAuthorize, + type StakeAuthorizeArgs, +} from '.'; + +export type AuthorizeCheckedWithSeedArgs = { + stakeAuthorize: StakeAuthorize; + authoritySeed: string; + authorityOwner: Address; +}; + +export type AuthorizeCheckedWithSeedArgsArgs = { + stakeAuthorize: StakeAuthorizeArgs; + authoritySeed: string; + authorityOwner: Address; +}; + +export function getAuthorizeCheckedWithSeedArgsEncoder(): Encoder { + return getStructEncoder([ + ['stakeAuthorize', getStakeAuthorizeEncoder()], + ['authoritySeed', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())], + ['authorityOwner', getAddressEncoder()], + ]); +} + +export function getAuthorizeCheckedWithSeedArgsDecoder(): Decoder { + return getStructDecoder([ + ['stakeAuthorize', getStakeAuthorizeDecoder()], + ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], + ['authorityOwner', getAddressDecoder()], + ]); +} + +export function getAuthorizeCheckedWithSeedArgsCodec(): Codec< + AuthorizeCheckedWithSeedArgsArgs, + AuthorizeCheckedWithSeedArgs +> { + return combineCodec( + getAuthorizeCheckedWithSeedArgsEncoder(), + getAuthorizeCheckedWithSeedArgsDecoder() + ); +} diff --git a/clients/js/src/generated/types/authorizeWithSeedArgs.ts b/clients/js/src/generated/types/authorizeWithSeedArgs.ts new file mode 100644 index 00000000..00ae10db --- /dev/null +++ b/clients/js/src/generated/types/authorizeWithSeedArgs.ts @@ -0,0 +1,73 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + getAddressDecoder, + getAddressEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getUtf8Decoder, + getUtf8Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; +import { + getStakeAuthorizeDecoder, + getStakeAuthorizeEncoder, + type StakeAuthorize, + type StakeAuthorizeArgs, +} from '.'; + +export type AuthorizeWithSeedArgs = { + newAuthorizedPubkey: Address; + stakeAuthorize: StakeAuthorize; + authoritySeed: string; + authorityOwner: Address; +}; + +export type AuthorizeWithSeedArgsArgs = { + newAuthorizedPubkey: Address; + stakeAuthorize: StakeAuthorizeArgs; + authoritySeed: string; + authorityOwner: Address; +}; + +export function getAuthorizeWithSeedArgsEncoder(): Encoder { + return getStructEncoder([ + ['newAuthorizedPubkey', getAddressEncoder()], + ['stakeAuthorize', getStakeAuthorizeEncoder()], + ['authoritySeed', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())], + ['authorityOwner', getAddressEncoder()], + ]); +} + +export function getAuthorizeWithSeedArgsDecoder(): Decoder { + return getStructDecoder([ + ['newAuthorizedPubkey', getAddressDecoder()], + ['stakeAuthorize', getStakeAuthorizeDecoder()], + ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], + ['authorityOwner', getAddressDecoder()], + ]); +} + +export function getAuthorizeWithSeedArgsCodec(): Codec< + AuthorizeWithSeedArgsArgs, + AuthorizeWithSeedArgs +> { + return combineCodec( + getAuthorizeWithSeedArgsEncoder(), + getAuthorizeWithSeedArgsDecoder() + ); +} 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..5bb460d0 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -6,12 +6,18 @@ * @see https://github.com/codama-idl/codama */ +export * from './authorizeCheckedWithSeedArgs'; export * from './authorized'; +export * from './authorizeWithSeedArgs'; export * from './delegation'; +export * from './epoch'; export * from './lockup'; +export * from './lockupArgs'; +export * from './lockupCheckedArgs'; export * from './meta'; export * from './stake'; 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/lockupArgs.ts b/clients/js/src/generated/types/lockupArgs.ts new file mode 100644 index 00000000..f92bd1aa --- /dev/null +++ b/clients/js/src/generated/types/lockupArgs.ts @@ -0,0 +1,65 @@ +/** + * 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, + getAddressDecoder, + getAddressEncoder, + getOptionDecoder, + getOptionEncoder, + getStructDecoder, + getStructEncoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type Option, + type OptionOrNullable, +} from '@solana/kit'; +import { + getEpochDecoder, + getEpochEncoder, + getUnixTimestampDecoder, + getUnixTimestampEncoder, + type Epoch, + type EpochArgs, + type UnixTimestamp, + type UnixTimestampArgs, +} from '.'; + +export type LockupArgs = { + unixTimestamp: Option; + epoch: Option; + custodian: Option
; +}; + +export type LockupArgsArgs = { + unixTimestamp: OptionOrNullable; + epoch: OptionOrNullable; + custodian: OptionOrNullable
; +}; + +export function getLockupArgsEncoder(): Encoder { + return getStructEncoder([ + ['unixTimestamp', getOptionEncoder(getUnixTimestampEncoder())], + ['epoch', getOptionEncoder(getEpochEncoder())], + ['custodian', getOptionEncoder(getAddressEncoder())], + ]); +} + +export function getLockupArgsDecoder(): Decoder { + return getStructDecoder([ + ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], + ['epoch', getOptionDecoder(getEpochDecoder())], + ['custodian', getOptionDecoder(getAddressDecoder())], + ]); +} + +export function getLockupArgsCodec(): Codec { + return combineCodec(getLockupArgsEncoder(), getLockupArgsDecoder()); +} diff --git a/clients/js/src/generated/types/lockupCheckedArgs.ts b/clients/js/src/generated/types/lockupCheckedArgs.ts new file mode 100644 index 00000000..29fbd844 --- /dev/null +++ b/clients/js/src/generated/types/lockupCheckedArgs.ts @@ -0,0 +1,64 @@ +/** + * 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, + getOptionDecoder, + getOptionEncoder, + getStructDecoder, + getStructEncoder, + type Codec, + type Decoder, + type Encoder, + type Option, + type OptionOrNullable, +} from '@solana/kit'; +import { + getEpochDecoder, + getEpochEncoder, + getUnixTimestampDecoder, + getUnixTimestampEncoder, + type Epoch, + type EpochArgs, + type UnixTimestamp, + type UnixTimestampArgs, +} from '.'; + +export type LockupCheckedArgs = { + unixTimestamp: Option; + epoch: Option; +}; + +export type LockupCheckedArgsArgs = { + unixTimestamp: OptionOrNullable; + epoch: OptionOrNullable; +}; + +export function getLockupCheckedArgsEncoder(): Encoder { + return getStructEncoder([ + ['unixTimestamp', getOptionEncoder(getUnixTimestampEncoder())], + ['epoch', getOptionEncoder(getEpochEncoder())], + ]); +} + +export function getLockupCheckedArgsDecoder(): Decoder { + return getStructDecoder([ + ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], + ['epoch', getOptionDecoder(getEpochDecoder())], + ]); +} + +export function getLockupCheckedArgsCodec(): Codec< + LockupCheckedArgsArgs, + LockupCheckedArgs +> { + return combineCodec( + getLockupCheckedArgsEncoder(), + getLockupCheckedArgsDecoder() + ); +} diff --git a/clients/js/src/generated/types/stakeState.ts b/clients/js/src/generated/types/stakeState.ts index 27cacc85..f3f17eb8 100644 --- a/clients/js/src/generated/types/stakeState.ts +++ b/clients/js/src/generated/types/stakeState.ts @@ -14,8 +14,6 @@ import { getStructEncoder, getTupleDecoder, getTupleEncoder, - getU32Decoder, - getU32Encoder, getUnitDecoder, getUnitEncoder, type Codec, @@ -48,43 +46,37 @@ export type StakeStateArgs = | { __kind: 'RewardsPool' }; export function getStakeStateEncoder(): Encoder { - return getDiscriminatedUnionEncoder( + return getDiscriminatedUnionEncoder([ + ['Uninitialized', getUnitEncoder()], [ - ['Uninitialized', getUnitEncoder()], - [ - 'Initialized', - getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), - ], - [ - 'Stake', - getStructEncoder([ - ['fields', getTupleEncoder([getMetaEncoder(), getStakeEncoder()])], - ]), - ], - ['RewardsPool', getUnitEncoder()], + 'Initialized', + getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), ], - { size: getU32Encoder() } - ); + [ + 'Stake', + getStructEncoder([ + ['fields', getTupleEncoder([getMetaEncoder(), getStakeEncoder()])], + ]), + ], + ['RewardsPool', getUnitEncoder()], + ]); } export function getStakeStateDecoder(): Decoder { - return getDiscriminatedUnionDecoder( + return getDiscriminatedUnionDecoder([ + ['Uninitialized', getUnitDecoder()], + [ + 'Initialized', + getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), + ], [ - ['Uninitialized', getUnitDecoder()], - [ - 'Initialized', - getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), - ], - [ - 'Stake', - getStructDecoder([ - ['fields', getTupleDecoder([getMetaDecoder(), getStakeDecoder()])], - ]), - ], - ['RewardsPool', getUnitDecoder()], + 'Stake', + getStructDecoder([ + ['fields', getTupleDecoder([getMetaDecoder(), getStakeDecoder()])], + ]), ], - { size: getU32Decoder() } - ); + ['RewardsPool', getUnitDecoder()], + ]); } export function getStakeStateCodec(): Codec { diff --git a/clients/js/src/generated/types/stakeStateV2.ts b/clients/js/src/generated/types/stakeStateV2.ts index 09aca70f..078ba201 100644 --- a/clients/js/src/generated/types/stakeStateV2.ts +++ b/clients/js/src/generated/types/stakeStateV2.ts @@ -14,8 +14,6 @@ import { getStructEncoder, getTupleDecoder, getTupleEncoder, - getU32Decoder, - getU32Encoder, getUnitDecoder, getUnitEncoder, type Codec, @@ -52,57 +50,51 @@ export type StakeStateV2Args = | { __kind: 'RewardsPool' }; export function getStakeStateV2Encoder(): Encoder { - return getDiscriminatedUnionEncoder( + return getDiscriminatedUnionEncoder([ + ['Uninitialized', getUnitEncoder()], [ - ['Uninitialized', getUnitEncoder()], - [ - 'Initialized', - getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), - ], - [ - 'Stake', - getStructEncoder([ - [ - 'fields', - getTupleEncoder([ - getMetaEncoder(), - getStakeEncoder(), - getStakeFlagsEncoder(), - ]), - ], - ]), - ], - ['RewardsPool', getUnitEncoder()], + 'Initialized', + getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), ], - { size: getU32Encoder() } - ); + [ + 'Stake', + getStructEncoder([ + [ + 'fields', + getTupleEncoder([ + getMetaEncoder(), + getStakeEncoder(), + getStakeFlagsEncoder(), + ]), + ], + ]), + ], + ['RewardsPool', getUnitEncoder()], + ]); } export function getStakeStateV2Decoder(): Decoder { - return getDiscriminatedUnionDecoder( + return getDiscriminatedUnionDecoder([ + ['Uninitialized', getUnitDecoder()], + [ + 'Initialized', + getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), + ], [ - ['Uninitialized', getUnitDecoder()], - [ - 'Initialized', - getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), - ], - [ - 'Stake', - getStructDecoder([ - [ - 'fields', - getTupleDecoder([ - getMetaDecoder(), - getStakeDecoder(), - getStakeFlagsDecoder(), - ]), - ], - ]), - ], - ['RewardsPool', getUnitDecoder()], + 'Stake', + getStructDecoder([ + [ + 'fields', + getTupleDecoder([ + getMetaDecoder(), + getStakeDecoder(), + getStakeFlagsDecoder(), + ]), + ], + ]), ], - { size: getU32Decoder() } - ); + ['RewardsPool', getUnitDecoder()], + ]); } export function getStakeStateV2Codec(): Codec { 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/src/generated/instructions/authorize.rs b/clients/rust/src/generated/instructions/authorize.rs index 2231c750..cd5ad713 100644 --- a/clients/rust/src/generated/instructions/authorize.rs +++ b/clients/rust/src/generated/instructions/authorize.rs @@ -14,13 +14,12 @@ use { /// Accounts. #[derive(Debug)] pub struct Authorize { - /// Stake account to be updated pub stake: solana_program::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, } @@ -71,7 +70,7 @@ impl Authorize { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeInstructionData { - discriminator: u32, + discriminator: u8, } impl AuthorizeInstructionData { @@ -89,8 +88,8 @@ impl Default for AuthorizeInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeInstructionArgs { - pub arg0: Pubkey, - pub arg1: StakeAuthorize, + pub pubkey: Pubkey, + pub stake_authorize: StakeAuthorize, } /// Instruction builder for `Authorize`. @@ -98,7 +97,7 @@ pub struct AuthorizeInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 1. `[]` clock_sysvar /// 2. `[signer]` authority /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] @@ -107,8 +106,8 @@ pub struct AuthorizeBuilder { clock_sysvar: Option, authority: Option, lockup_authority: Option, - arg0: Option, - arg1: Option, + pubkey: Option, + stake_authorize: Option, __remaining_accounts: Vec, } @@ -116,27 +115,22 @@ impl AuthorizeBuilder { pub fn new() -> Self { Self::default() } - /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.clock_sysvar = Some(clock_sysvar); self } - /// Stake or withdraw authority #[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -146,13 +140,13 @@ impl AuthorizeBuilder { self } #[inline(always)] - pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { - self.arg0 = Some(arg0); + pub fn pubkey(&mut self, pubkey: Pubkey) -> &mut Self { + self.pubkey = Some(pubkey); self } #[inline(always)] - pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { - self.arg1 = Some(arg1); + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.stake_authorize = Some(stake_authorize); self } /// Add an additional account to the instruction. @@ -177,15 +171,16 @@ impl AuthorizeBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Authorize { stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarC1ock11111111111111111111111111111111" - )), + clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), authority: self.authority.expect("authority is not set"), lockup_authority: self.lockup_authority, }; let args = AuthorizeInstructionArgs { - arg0: self.arg0.clone().expect("arg0 is not set"), - arg1: self.arg1.clone().expect("arg1 is not set"), + pubkey: self.pubkey.clone().expect("pubkey is not set"), + stake_authorize: self + .stake_authorize + .clone() + .expect("stake_authorize is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -194,13 +189,12 @@ impl AuthorizeBuilder { /// `authorize` CPI accounts. pub struct AuthorizeCpiAccounts<'a, 'b> { - /// Stake account to be updated pub stake: &'b solana_program::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>>, } @@ -208,13 +202,13 @@ pub struct AuthorizeCpiAccounts<'a, 'b> { pub struct AuthorizeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake account to be updated + pub stake: &'b solana_program::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>>, /// The arguments for the instruction. pub __args: AuthorizeInstructionArgs, @@ -344,19 +338,17 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { clock_sysvar: None, authority: None, lockup_authority: None, - arg0: None, - arg1: None, + pubkey: None, + stake_authorize: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -365,7 +357,6 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Stake or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -375,7 +366,6 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -385,13 +375,13 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { - self.instruction.arg0 = Some(arg0); + pub fn pubkey(&mut self, pubkey: Pubkey) -> &mut Self { + self.instruction.pubkey = Some(pubkey); self } #[inline(always)] - pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { - self.instruction.arg1 = Some(arg1); + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.instruction.stake_authorize = Some(stake_authorize); self } /// Add an additional account to the instruction. @@ -436,8 +426,12 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeInstructionArgs { - arg0: self.instruction.arg0.clone().expect("arg0 is not set"), - arg1: self.instruction.arg1.clone().expect("arg1 is not set"), + pubkey: self.instruction.pubkey.clone().expect("pubkey is not set"), + stake_authorize: self + .instruction + .stake_authorize + .clone() + .expect("stake_authorize is not set"), }; let instruction = AuthorizeCpi { __program: self.instruction.__program, @@ -468,8 +462,8 @@ struct AuthorizeCpiBuilderInstruction<'a, 'b> { 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>>, - arg0: Option, - arg1: Option, + pubkey: Option, + stake_authorize: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/authorize_checked.rs b/clients/rust/src/generated/instructions/authorize_checked.rs index 62476187..09e1ad51 100644 --- a/clients/rust/src/generated/instructions/authorize_checked.rs +++ b/clients/rust/src/generated/instructions/authorize_checked.rs @@ -13,15 +13,14 @@ use { /// Accounts. #[derive(Debug)] pub struct AuthorizeChecked { - /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, - /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, - /// The stake or withdraw authority + pub authority: solana_program::pubkey::Pubkey, - /// The new stake or withdraw authority + pub new_authority: solana_program::pubkey::Pubkey, - /// Lockup authority + pub lockup_authority: Option, } @@ -76,7 +75,7 @@ impl AuthorizeChecked { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeCheckedInstructionData { - discriminator: u32, + discriminator: u8, } impl AuthorizeCheckedInstructionData { @@ -102,7 +101,7 @@ pub struct AuthorizeCheckedInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 1. `[]` clock_sysvar /// 2. `[signer]` authority /// 3. `[signer]` new_authority /// 4. `[signer, optional]` lockup_authority @@ -121,33 +120,27 @@ impl AuthorizeCheckedBuilder { pub fn new() -> Self { Self::default() } - /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { 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 { 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 { self.new_authority = Some(new_authority); self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -183,9 +176,7 @@ impl AuthorizeCheckedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = AuthorizeChecked { stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarC1ock11111111111111111111111111111111" - )), + clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), authority: self.authority.expect("authority is not set"), new_authority: self.new_authority.expect("new_authority is not set"), lockup_authority: self.lockup_authority, @@ -203,15 +194,14 @@ 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>, - /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority + pub authority: &'b solana_program::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>>, } @@ -219,15 +209,15 @@ pub struct AuthorizeCheckedCpiAccounts<'a, 'b> { pub struct AuthorizeCheckedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority + pub authority: &'b solana_program::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>>, /// The arguments for the instruction. pub __args: AuthorizeCheckedInstructionArgs, @@ -370,13 +360,11 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { }); Self { instruction } } - /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -385,7 +373,6 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// The stake or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -394,7 +381,6 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { self.instruction.authority = Some(authority); self } - /// The new stake or withdraw authority #[inline(always)] pub fn new_authority( &mut self, @@ -404,7 +390,6 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, 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..c2e5c514 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -6,23 +6,21 @@ //! use { - crate::generated::types::StakeAuthorize, + crate::generated::types::AuthorizeCheckedWithSeedArgs, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, }; /// Accounts. #[derive(Debug)] pub struct AuthorizeCheckedWithSeed { - /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, - /// Base key of stake or withdraw authority - pub base: solana_program::pubkey::Pubkey, - /// Clock sysvar + + pub authority_base: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_program::pubkey::Pubkey, - /// The new stake or withdraw authority + pub new_authority: solana_program::pubkey::Pubkey, - /// Lockup authority + pub lockup_authority: Option, } @@ -44,7 +42,8 @@ impl AuthorizeCheckedWithSeed { self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.base, true, + self.authority_base, + true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, @@ -76,7 +75,7 @@ impl AuthorizeCheckedWithSeed { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeCheckedWithSeedInstructionData { - discriminator: u32, + discriminator: u8, } impl AuthorizeCheckedWithSeedInstructionData { @@ -94,9 +93,7 @@ impl Default for AuthorizeCheckedWithSeedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeCheckedWithSeedInstructionArgs { - pub stake_authorize: StakeAuthorize, - pub authority_seed: String, - pub authority_owner: Pubkey, + pub args: AuthorizeCheckedWithSeedArgs, } /// Instruction builder for `AuthorizeCheckedWithSeed`. @@ -104,20 +101,18 @@ pub struct AuthorizeCheckedWithSeedInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` base -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 1. `[signer]` authority_base +/// 2. `[]` clock_sysvar /// 3. `[signer]` new_authority /// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeCheckedWithSeedBuilder { stake: Option, - base: Option, + authority_base: Option, clock_sysvar: Option, new_authority: Option, lockup_authority: Option, - stake_authorize: Option, - authority_seed: Option, - authority_owner: Option, + args: Option, __remaining_accounts: Vec, } @@ -125,33 +120,27 @@ impl AuthorizeCheckedWithSeedBuilder { pub fn new() -> Self { Self::default() } - /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { - self.base = Some(base); + pub fn authority_base(&mut self, authority_base: solana_program::pubkey::Pubkey) -> &mut Self { + self.authority_base = Some(authority_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 { 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 { self.new_authority = Some(new_authority); self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -161,18 +150,8 @@ impl AuthorizeCheckedWithSeedBuilder { self } #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { - self.stake_authorize = Some(stake_authorize); - self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { - self.authority_seed = Some(authority_seed); - self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { - self.authority_owner = Some(authority_owner); + pub fn args(&mut self, args: AuthorizeCheckedWithSeedArgs) -> &mut Self { + self.args = Some(args); self } /// Add an additional account to the instruction. @@ -197,26 +176,13 @@ impl AuthorizeCheckedWithSeedBuilder { pub fn instruction(&self) -> solana_program::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!( - "SysvarC1ock11111111111111111111111111111111" - )), + authority_base: self.authority_base.expect("authority_base is not set"), + clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), new_authority: self.new_authority.expect("new_authority is not set"), lockup_authority: self.lockup_authority, }; let args = AuthorizeCheckedWithSeedInstructionArgs { - stake_authorize: self - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - authority_seed: self - .authority_seed - .clone() - .expect("authority_seed is not set"), - authority_owner: self - .authority_owner - .clone() - .expect("authority_owner is not set"), + args: self.args.clone().expect("args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -225,15 +191,14 @@ 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>, - /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar + + pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::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>>, } @@ -241,15 +206,15 @@ pub struct AuthorizeCheckedWithSeedCpiAccounts<'a, 'b> { pub struct AuthorizeCheckedWithSeedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar + + pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::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>>, /// The arguments for the instruction. pub __args: AuthorizeCheckedWithSeedInstructionArgs, @@ -264,7 +229,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - base: accounts.base, + authority_base: accounts.authority_base, clock_sysvar: accounts.clock_sysvar, new_authority: accounts.new_authority, lockup_authority: accounts.lockup_authority, @@ -310,7 +275,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.base.key, + *self.authority_base.key, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -346,7 +311,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.base.clone()); + account_infos.push(self.authority_base.clone()); account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.new_authority.clone()); if let Some(lockup_authority) = self.lockup_authority { @@ -369,7 +334,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` base +/// 1. `[signer]` authority_base /// 2. `[]` clock_sysvar /// 3. `[signer]` new_authority /// 4. `[signer, optional]` lockup_authority @@ -383,30 +348,28 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { let instruction = Box::new(AuthorizeCheckedWithSeedCpiBuilderInstruction { __program: program, stake: None, - base: None, + authority_base: None, clock_sysvar: None, new_authority: None, lockup_authority: None, - stake_authorize: None, - authority_seed: None, - authority_owner: None, + args: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::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 { - self.instruction.base = Some(base); + pub fn authority_base( + &mut self, + authority_base: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority_base = Some(authority_base); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -415,7 +378,6 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// The new stake or withdraw authority #[inline(always)] pub fn new_authority( &mut self, @@ -425,7 +387,6 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -435,18 +396,8 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { - self.instruction.stake_authorize = Some(stake_authorize); - self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { - self.instruction.authority_seed = Some(authority_seed); - self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { - self.instruction.authority_owner = Some(authority_owner); + pub fn args(&mut self, args: AuthorizeCheckedWithSeedArgs) -> &mut Self { + self.instruction.args = Some(args); self } /// Add an additional account to the instruction. @@ -491,28 +442,17 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeCheckedWithSeedInstructionArgs { - stake_authorize: self - .instruction - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - authority_seed: self - .instruction - .authority_seed - .clone() - .expect("authority_seed is not set"), - authority_owner: self - .instruction - .authority_owner - .clone() - .expect("authority_owner is not set"), + args: self.instruction.args.clone().expect("args is not set"), }; let instruction = AuthorizeCheckedWithSeedCpi { __program: self.instruction.__program, stake: self.instruction.stake.expect("stake is not set"), - base: self.instruction.base.expect("base is not set"), + authority_base: self + .instruction + .authority_base + .expect("authority_base is not set"), clock_sysvar: self .instruction @@ -538,13 +478,11 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { 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>>, + authority_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>>, - stake_authorize: Option, - authority_seed: Option, - authority_owner: Option, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index 86b83f62..1916ac93 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -6,21 +6,19 @@ //! use { - crate::generated::types::StakeAuthorize, + crate::generated::types::AuthorizeWithSeedArgs, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, }; /// Accounts. #[derive(Debug)] pub struct AuthorizeWithSeed { - /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, - /// Base key of stake or withdraw authority - pub base: solana_program::pubkey::Pubkey, - /// Clock sysvar + + pub authority_base: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Lockup authority + pub lockup_authority: Option, } @@ -42,7 +40,8 @@ impl AuthorizeWithSeed { self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.base, true, + self.authority_base, + true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, @@ -70,7 +69,7 @@ impl AuthorizeWithSeed { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeWithSeedInstructionData { - discriminator: u32, + discriminator: u8, } impl AuthorizeWithSeedInstructionData { @@ -88,10 +87,7 @@ impl Default for AuthorizeWithSeedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeWithSeedInstructionArgs { - pub new_authorized_pubkey: Pubkey, - pub stake_authorize: StakeAuthorize, - pub authority_seed: String, - pub authority_owner: Pubkey, + pub args: AuthorizeWithSeedArgs, } /// Instruction builder for `AuthorizeWithSeed`. @@ -99,19 +95,16 @@ pub struct AuthorizeWithSeedInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` base -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 1. `[signer]` authority_base +/// 2. `[]` clock_sysvar /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeWithSeedBuilder { stake: Option, - base: Option, + authority_base: Option, clock_sysvar: Option, lockup_authority: Option, - new_authorized_pubkey: Option, - stake_authorize: Option, - authority_seed: Option, - authority_owner: Option, + args: Option, __remaining_accounts: Vec, } @@ -119,27 +112,22 @@ impl AuthorizeWithSeedBuilder { pub fn new() -> Self { Self::default() } - /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { - self.base = Some(base); + pub fn authority_base(&mut self, authority_base: solana_program::pubkey::Pubkey) -> &mut Self { + self.authority_base = Some(authority_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 { self.clock_sysvar = Some(clock_sysvar); self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -149,23 +137,8 @@ impl AuthorizeWithSeedBuilder { self } #[inline(always)] - pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { - self.new_authorized_pubkey = Some(new_authorized_pubkey); - self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { - self.stake_authorize = Some(stake_authorize); - self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { - self.authority_seed = Some(authority_seed); - self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { - self.authority_owner = Some(authority_owner); + pub fn args(&mut self, args: AuthorizeWithSeedArgs) -> &mut Self { + self.args = Some(args); self } /// Add an additional account to the instruction. @@ -190,29 +163,12 @@ impl AuthorizeWithSeedBuilder { pub fn instruction(&self) -> solana_program::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!( - "SysvarC1ock11111111111111111111111111111111" - )), + authority_base: self.authority_base.expect("authority_base is not set"), + clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), lockup_authority: self.lockup_authority, }; let args = AuthorizeWithSeedInstructionArgs { - new_authorized_pubkey: self - .new_authorized_pubkey - .clone() - .expect("new_authorized_pubkey is not set"), - stake_authorize: self - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - authority_seed: self - .authority_seed - .clone() - .expect("authority_seed is not set"), - authority_owner: self - .authority_owner - .clone() - .expect("authority_owner is not set"), + args: self.args.clone().expect("args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -221,13 +177,12 @@ 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>, - /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar + + pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } @@ -235,13 +190,13 @@ pub struct AuthorizeWithSeedCpiAccounts<'a, 'b> { pub struct AuthorizeWithSeedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar + + pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeWithSeedInstructionArgs, @@ -256,7 +211,7 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - base: accounts.base, + authority_base: accounts.authority_base, clock_sysvar: accounts.clock_sysvar, lockup_authority: accounts.lockup_authority, __args: args, @@ -301,7 +256,7 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.base.key, + *self.authority_base.key, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -333,7 +288,7 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.base.clone()); + account_infos.push(self.authority_base.clone()); account_infos.push(self.clock_sysvar.clone()); if let Some(lockup_authority) = self.lockup_authority { account_infos.push(lockup_authority.clone()); @@ -355,7 +310,7 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` base +/// 1. `[signer]` authority_base /// 2. `[]` clock_sysvar /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] @@ -368,30 +323,27 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { let instruction = Box::new(AuthorizeWithSeedCpiBuilderInstruction { __program: program, stake: None, - base: None, + authority_base: None, clock_sysvar: None, lockup_authority: None, - new_authorized_pubkey: None, - stake_authorize: None, - authority_seed: None, - authority_owner: None, + args: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::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 { - self.instruction.base = Some(base); + pub fn authority_base( + &mut self, + authority_base: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority_base = Some(authority_base); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -401,7 +353,6 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -411,23 +362,8 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { - self.instruction.new_authorized_pubkey = Some(new_authorized_pubkey); - self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { - self.instruction.stake_authorize = Some(stake_authorize); - self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { - self.instruction.authority_seed = Some(authority_seed); - self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { - self.instruction.authority_owner = Some(authority_owner); + pub fn args(&mut self, args: AuthorizeWithSeedArgs) -> &mut Self { + self.instruction.args = Some(args); self } /// Add an additional account to the instruction. @@ -472,33 +408,17 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeWithSeedInstructionArgs { - new_authorized_pubkey: self - .instruction - .new_authorized_pubkey - .clone() - .expect("new_authorized_pubkey is not set"), - stake_authorize: self - .instruction - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - authority_seed: self - .instruction - .authority_seed - .clone() - .expect("authority_seed is not set"), - authority_owner: self - .instruction - .authority_owner - .clone() - .expect("authority_owner is not set"), + args: self.instruction.args.clone().expect("args is not set"), }; let instruction = AuthorizeWithSeedCpi { __program: self.instruction.__program, stake: self.instruction.stake.expect("stake is not set"), - base: self.instruction.base.expect("base is not set"), + authority_base: self + .instruction + .authority_base + .expect("authority_base is not set"), clock_sysvar: self .instruction @@ -519,13 +439,10 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { 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>>, + authority_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>>, - new_authorized_pubkey: Option, - stake_authorize: Option, - authority_seed: Option, - authority_owner: Option, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/deactivate.rs b/clients/rust/src/generated/instructions/deactivate.rs index 468e458b..6493ad46 100644 --- a/clients/rust/src/generated/instructions/deactivate.rs +++ b/clients/rust/src/generated/instructions/deactivate.rs @@ -10,11 +10,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Deactivate { - /// Delegated stake account pub stake: solana_program::pubkey::Pubkey, - /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, } @@ -53,7 +52,7 @@ impl Deactivate { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeactivateInstructionData { - discriminator: u32, + discriminator: u8, } impl DeactivateInstructionData { @@ -73,7 +72,7 @@ impl Default for DeactivateInstructionData { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 1. `[]` clock_sysvar /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct DeactivateBuilder { @@ -87,20 +86,16 @@ impl DeactivateBuilder { pub fn new() -> Self { Self::default() } - /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.clock_sysvar = Some(clock_sysvar); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -131,9 +126,7 @@ impl DeactivateBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Deactivate { stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarC1ock11111111111111111111111111111111" - )), + clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -143,11 +136,10 @@ impl DeactivateBuilder { /// `deactivate` CPI accounts. pub struct DeactivateCpiAccounts<'a, 'b> { - /// Delegated stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -155,11 +147,11 @@ pub struct DeactivateCpiAccounts<'a, 'b> { 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>, - /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -275,13 +267,11 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { }); Self { instruction } } - /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -290,7 +280,6 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/deactivate_delinquent.rs b/clients/rust/src/generated/instructions/deactivate_delinquent.rs index 3ccc5ffe..e09c21cd 100644 --- a/clients/rust/src/generated/instructions/deactivate_delinquent.rs +++ b/clients/rust/src/generated/instructions/deactivate_delinquent.rs @@ -10,11 +10,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// 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, } @@ -53,7 +52,7 @@ impl DeactivateDelinquent { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeactivateDelinquentInstructionData { - discriminator: u32, + discriminator: u8, } impl DeactivateDelinquentInstructionData { @@ -87,13 +86,11 @@ impl DeactivateDelinquentBuilder { pub fn new() -> Self { Self::default() } - /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// Delinquent vote account #[inline(always)] pub fn delinquent_vote( &mut self, @@ -102,7 +99,6 @@ impl DeactivateDelinquentBuilder { self.delinquent_vote = Some(delinquent_vote); self } - /// Reference vote account #[inline(always)] pub fn reference_vote(&mut self, reference_vote: solana_program::pubkey::Pubkey) -> &mut Self { self.reference_vote = Some(reference_vote); @@ -140,11 +136,10 @@ 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>, } @@ -152,11 +147,11 @@ pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { pub struct DeactivateDelinquentCpi<'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>, - /// 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>, } @@ -272,13 +267,11 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { }); Self { instruction } } - /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Delinquent vote account #[inline(always)] pub fn delinquent_vote( &mut self, @@ -287,7 +280,6 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { self.instruction.delinquent_vote = Some(delinquent_vote); self } - /// Reference vote account #[inline(always)] pub fn reference_vote( &mut self, diff --git a/clients/rust/src/generated/instructions/delegate_stake.rs b/clients/rust/src/generated/instructions/delegate_stake.rs index 617f2ca8..0d1bf1ec 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -10,17 +10,16 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct DelegateStake { - /// Initialized stake account to be delegated pub stake: solana_program::pubkey::Pubkey, - /// Vote account to which this stake will be delegated + pub vote: solana_program::pubkey::Pubkey, - /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar - pub stake_history: solana_program::pubkey::Pubkey, - /// Unused account, formerly the stake config - pub unused: solana_program::pubkey::Pubkey, - /// Stake authority + + pub stake_history_sysvar: solana_program::pubkey::Pubkey, + + pub config: solana_program::pubkey::Pubkey, + pub stake_authority: solana_program::pubkey::Pubkey, } @@ -45,11 +44,11 @@ impl DelegateStake { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.stake_history, + self.stake_history_sysvar, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.unused, + self.config, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -70,7 +69,7 @@ impl DelegateStake { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateStakeInstructionData { - discriminator: u32, + discriminator: u8, } impl DelegateStakeInstructionData { @@ -91,17 +90,17 @@ impl Default for DelegateStakeInstructionData { /// /// 0. `[writable]` stake /// 1. `[]` vote -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[]` stake_history -/// 4. `[]` unused +/// 2. `[]` clock_sysvar +/// 3. `[]` stake_history_sysvar +/// 4. `[]` config /// 5. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct DelegateStakeBuilder { stake: Option, vote: Option, clock_sysvar: Option, - stake_history: Option, - unused: Option, + stake_history_sysvar: Option, + config: Option, stake_authority: Option, __remaining_accounts: Vec, } @@ -110,38 +109,34 @@ impl DelegateStakeBuilder { pub fn new() -> Self { Self::default() } - /// Initialized stake account to be delegated #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { 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 { self.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar #[inline(always)] - pub fn stake_history(&mut self, stake_history: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake_history = Some(stake_history); + pub fn stake_history_sysvar( + &mut self, + stake_history_sysvar: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_history_sysvar = Some(stake_history_sysvar); self } - /// Unused account, formerly the stake config #[inline(always)] - pub fn unused(&mut self, unused: solana_program::pubkey::Pubkey) -> &mut Self { - self.unused = Some(unused); + pub fn config(&mut self, config: solana_program::pubkey::Pubkey) -> &mut Self { + self.config = Some(config); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -173,11 +168,11 @@ impl DelegateStakeBuilder { 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!( - "SysvarC1ock11111111111111111111111111111111" - )), - stake_history: self.stake_history.expect("stake_history is not set"), - unused: self.unused.expect("unused is not set"), + clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), + stake_history_sysvar: self + .stake_history_sysvar + .expect("stake_history_sysvar is not set"), + config: self.config.expect("config is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -187,17 +182,16 @@ 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>, - /// Vote account to which this stake will be delegated + pub vote: &'b solana_program::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>, - /// Unused account, formerly the stake config - pub unused: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + + pub config: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -205,17 +199,17 @@ pub struct DelegateStakeCpiAccounts<'a, 'b> { pub struct DelegateStakeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Initialized stake account to be delegated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Vote account to which this stake will be delegated + pub vote: &'b solana_program::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>, - /// Unused account, formerly the stake config - pub unused: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + + pub config: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -229,8 +223,8 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { stake: accounts.stake, vote: accounts.vote, clock_sysvar: accounts.clock_sysvar, - stake_history: accounts.stake_history, - unused: accounts.unused, + stake_history_sysvar: accounts.stake_history_sysvar, + config: accounts.config, stake_authority: accounts.stake_authority, } } @@ -281,11 +275,11 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.stake_history.key, + *self.stake_history_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.unused.key, + *self.config.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -311,8 +305,8 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { account_infos.push(self.stake.clone()); account_infos.push(self.vote.clone()); account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history.clone()); - account_infos.push(self.unused.clone()); + account_infos.push(self.stake_history_sysvar.clone()); + account_infos.push(self.config.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -333,8 +327,8 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { /// 0. `[writable]` stake /// 1. `[]` vote /// 2. `[]` clock_sysvar -/// 3. `[]` stake_history -/// 4. `[]` unused +/// 3. `[]` stake_history_sysvar +/// 4. `[]` config /// 5. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct DelegateStakeCpiBuilder<'a, 'b> { @@ -348,26 +342,23 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { stake: None, vote: None, clock_sysvar: None, - stake_history: None, - unused: None, + stake_history_sysvar: None, + config: None, stake_authority: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Initialized stake account to be delegated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::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 { self.instruction.vote = Some(vote); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -376,25 +367,22 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar #[inline(always)] - pub fn stake_history( + pub fn stake_history_sysvar( &mut self, - stake_history: &'b solana_program::account_info::AccountInfo<'a>, + stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.stake_history = Some(stake_history); + self.instruction.stake_history_sysvar = Some(stake_history_sysvar); self } - /// Unused account, formerly the stake config #[inline(always)] - pub fn unused( + pub fn config( &mut self, - unused: &'b solana_program::account_info::AccountInfo<'a>, + config: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.unused = Some(unused); + self.instruction.config = Some(config); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -456,12 +444,12 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { .clock_sysvar .expect("clock_sysvar is not set"), - stake_history: self + stake_history_sysvar: self .instruction - .stake_history - .expect("stake_history is not set"), + .stake_history_sysvar + .expect("stake_history_sysvar is not set"), - unused: self.instruction.unused.expect("unused is not set"), + config: self.instruction.config.expect("config is not set"), stake_authority: self .instruction @@ -481,8 +469,8 @@ struct DelegateStakeCpiBuilderInstruction<'a, 'b> { 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_history_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, + config: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/clients/rust/src/generated/instructions/get_minimum_delegation.rs b/clients/rust/src/generated/instructions/get_minimum_delegation.rs index d510e2cb..2aa28183 100644 --- a/clients/rust/src/generated/instructions/get_minimum_delegation.rs +++ b/clients/rust/src/generated/instructions/get_minimum_delegation.rs @@ -35,7 +35,7 @@ impl GetMinimumDelegation { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMinimumDelegationInstructionData { - discriminator: u32, + discriminator: u8, } impl GetMinimumDelegationInstructionData { diff --git a/clients/rust/src/generated/instructions/initialize.rs b/clients/rust/src/generated/instructions/initialize.rs index 24bc81f5..f9977454 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -13,9 +13,8 @@ use { /// Accounts. #[derive(Debug)] pub struct Initialize { - /// Uninitialized stake account pub stake: solana_program::pubkey::Pubkey, - /// Rent sysvar + pub rent_sysvar: solana_program::pubkey::Pubkey, } @@ -56,7 +55,7 @@ impl Initialize { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeInstructionData { - discriminator: u32, + discriminator: u8, } impl InitializeInstructionData { @@ -74,8 +73,8 @@ impl Default for InitializeInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeInstructionArgs { - pub arg0: Authorized, - pub arg1: Lockup, + pub authorized: Authorized, + pub lockup: Lockup, } /// Instruction builder for `Initialize`. @@ -83,13 +82,13 @@ pub struct InitializeInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) +/// 1. `[]` rent_sysvar #[derive(Clone, Debug, Default)] pub struct InitializeBuilder { stake: Option, rent_sysvar: Option, - arg0: Option, - arg1: Option, + authorized: Option, + lockup: Option, __remaining_accounts: Vec, } @@ -97,27 +96,24 @@ impl InitializeBuilder { pub fn new() -> Self { Self::default() } - /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.rent_sysvar = Some(rent_sysvar); self } #[inline(always)] - pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { - self.arg0 = Some(arg0); + pub fn authorized(&mut self, authorized: Authorized) -> &mut Self { + self.authorized = Some(authorized); self } #[inline(always)] - pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { - self.arg1 = Some(arg1); + pub fn lockup(&mut self, lockup: Lockup) -> &mut Self { + self.lockup = Some(lockup); self } /// Add an additional account to the instruction. @@ -142,13 +138,11 @@ impl InitializeBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Initialize { stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), + rent_sysvar: self.rent_sysvar.expect("rent_sysvar is not set"), }; let args = InitializeInstructionArgs { - arg0: self.arg0.clone().expect("arg0 is not set"), - arg1: self.arg1.clone().expect("arg1 is not set"), + authorized: self.authorized.clone().expect("authorized is not set"), + lockup: self.lockup.clone().expect("lockup is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -157,9 +151,8 @@ impl InitializeBuilder { /// `initialize` CPI accounts. pub struct InitializeCpiAccounts<'a, 'b> { - /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, } @@ -167,9 +160,9 @@ pub struct InitializeCpiAccounts<'a, 'b> { pub struct InitializeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Uninitialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: InitializeInstructionArgs, @@ -279,19 +272,17 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { __program: program, stake: None, rent_sysvar: None, - arg0: None, - arg1: None, + authorized: None, + lockup: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Rent sysvar #[inline(always)] pub fn rent_sysvar( &mut self, @@ -301,13 +292,13 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { - self.instruction.arg0 = Some(arg0); + pub fn authorized(&mut self, authorized: Authorized) -> &mut Self { + self.instruction.authorized = Some(authorized); self } #[inline(always)] - pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { - self.instruction.arg1 = Some(arg1); + pub fn lockup(&mut self, lockup: Lockup) -> &mut Self { + self.instruction.lockup = Some(lockup); self } /// Add an additional account to the instruction. @@ -352,8 +343,12 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = InitializeInstructionArgs { - arg0: self.instruction.arg0.clone().expect("arg0 is not set"), - arg1: self.instruction.arg1.clone().expect("arg1 is not set"), + authorized: self + .instruction + .authorized + .clone() + .expect("authorized is not set"), + lockup: self.instruction.lockup.clone().expect("lockup is not set"), }; let instruction = InitializeCpi { __program: self.instruction.__program, @@ -378,8 +373,8 @@ 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>>, - arg0: Option, - arg1: Option, + authorized: Option, + lockup: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/initialize_checked.rs b/clients/rust/src/generated/instructions/initialize_checked.rs index 929046f7..b9c13e40 100644 --- a/clients/rust/src/generated/instructions/initialize_checked.rs +++ b/clients/rust/src/generated/instructions/initialize_checked.rs @@ -10,13 +10,12 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct InitializeChecked { - /// Uninitialized stake account pub stake: solana_program::pubkey::Pubkey, - /// Rent sysvar + pub rent_sysvar: solana_program::pubkey::Pubkey, - /// The stake authority + pub stake_authority: solana_program::pubkey::Pubkey, - /// The withdraw authority + pub withdraw_authority: solana_program::pubkey::Pubkey, } @@ -59,7 +58,7 @@ impl InitializeChecked { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeCheckedInstructionData { - discriminator: u32, + discriminator: u8, } impl InitializeCheckedInstructionData { @@ -79,7 +78,7 @@ impl Default for InitializeCheckedInstructionData { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) +/// 1. `[]` rent_sysvar /// 2. `[]` stake_authority /// 3. `[signer]` withdraw_authority #[derive(Clone, Debug, Default)] @@ -95,20 +94,16 @@ impl InitializeCheckedBuilder { pub fn new() -> Self { Self::default() } - /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.rent_sysvar = Some(rent_sysvar); self } - /// The stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -117,7 +112,6 @@ impl InitializeCheckedBuilder { self.stake_authority = Some(stake_authority); self } - /// The withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -148,9 +142,7 @@ impl InitializeCheckedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = InitializeChecked { stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), + rent_sysvar: self.rent_sysvar.expect("rent_sysvar is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), withdraw_authority: self .withdraw_authority @@ -163,13 +155,12 @@ impl InitializeCheckedBuilder { /// `initialize_checked` CPI accounts. pub struct InitializeCheckedCpiAccounts<'a, 'b> { - /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The withdraw authority + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -177,13 +168,13 @@ pub struct InitializeCheckedCpiAccounts<'a, 'b> { pub struct InitializeCheckedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Uninitialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The withdraw authority + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -307,13 +298,11 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { }); Self { instruction } } - /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Rent sysvar #[inline(always)] pub fn rent_sysvar( &mut self, @@ -322,7 +311,6 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { self.instruction.rent_sysvar = Some(rent_sysvar); self } - /// The stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -331,7 +319,6 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { self.instruction.stake_authority = Some(stake_authority); self } - /// The withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/merge.rs b/clients/rust/src/generated/instructions/merge.rs index e56caa51..73e764cc 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -10,15 +10,14 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// 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, - /// Clock sysvar + pub destination: solana_program::pubkey::Pubkey, + + pub source: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar - pub stake_history: solana_program::pubkey::Pubkey, - /// Stake authority + + pub stake_history_sysvar: solana_program::pubkey::Pubkey, + pub stake_authority: solana_program::pubkey::Pubkey, } @@ -33,11 +32,11 @@ impl Merge { ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - self.destination_stake, + self.destination, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - self.source_stake, + self.source, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -45,7 +44,7 @@ impl Merge { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.stake_history, + self.stake_history_sysvar, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -66,7 +65,7 @@ impl Merge { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MergeInstructionData { - discriminator: u32, + discriminator: u8, } impl MergeInstructionData { @@ -85,17 +84,17 @@ impl Default for MergeInstructionData { /// /// ### Accounts: /// -/// 0. `[writable]` destination_stake -/// 1. `[writable]` source_stake -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[]` stake_history +/// 0. `[writable]` destination +/// 1. `[writable]` source +/// 2. `[]` clock_sysvar +/// 3. `[]` stake_history_sysvar /// 4. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MergeBuilder { - destination_stake: Option, - source_stake: Option, + destination: Option, + source: Option, clock_sysvar: Option, - stake_history: Option, + stake_history_sysvar: Option, stake_authority: Option, __remaining_accounts: Vec, } @@ -104,35 +103,29 @@ impl MergeBuilder { pub fn new() -> Self { Self::default() } - /// Destination stake account #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.destination_stake = Some(destination_stake); + pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { + self.destination = Some(destination); self } - /// Source stake account #[inline(always)] - pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.source_stake = Some(source_stake); + pub fn source(&mut self, source: solana_program::pubkey::Pubkey) -> &mut Self { + self.source = Some(source); self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` - /// Clock sysvar #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar #[inline(always)] - pub fn stake_history(&mut self, stake_history: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake_history = Some(stake_history); + pub fn stake_history_sysvar( + &mut self, + stake_history_sysvar: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_history_sysvar = Some(stake_history_sysvar); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -162,14 +155,12 @@ impl MergeBuilder { #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::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!( - "SysvarC1ock11111111111111111111111111111111" - )), - stake_history: self.stake_history.expect("stake_history is not set"), + destination: self.destination.expect("destination is not set"), + source: self.source.expect("source is not set"), + clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), + stake_history_sysvar: self + .stake_history_sysvar + .expect("stake_history_sysvar is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -179,15 +170,14 @@ 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>, - /// Clock sysvar + pub destination: &'b solana_program::account_info::AccountInfo<'a>, + + pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -195,15 +185,15 @@ pub struct MergeCpiAccounts<'a, 'b> { 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>, - /// Clock sysvar + + pub destination: &'b solana_program::account_info::AccountInfo<'a>, + + pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -214,10 +204,10 @@ impl<'a, 'b> MergeCpi<'a, 'b> { ) -> Self { Self { __program: program, - destination_stake: accounts.destination_stake, - source_stake: accounts.source_stake, + destination: accounts.destination, + source: accounts.source, clock_sysvar: accounts.clock_sysvar, - stake_history: accounts.stake_history, + stake_history_sysvar: accounts.stake_history_sysvar, stake_authority: accounts.stake_authority, } } @@ -256,11 +246,11 @@ impl<'a, 'b> MergeCpi<'a, 'b> { ) -> solana_program::entrypoint::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - *self.destination_stake.key, + *self.destination.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - *self.source_stake.key, + *self.source.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -268,7 +258,7 @@ impl<'a, 'b> MergeCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.stake_history.key, + *self.stake_history_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -291,10 +281,10 @@ impl<'a, 'b> MergeCpi<'a, 'b> { }; let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); account_infos.push(self.__program.clone()); - account_infos.push(self.destination_stake.clone()); - account_infos.push(self.source_stake.clone()); + account_infos.push(self.destination.clone()); + account_infos.push(self.source.clone()); account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history.clone()); + account_infos.push(self.stake_history_sysvar.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -312,10 +302,10 @@ impl<'a, 'b> MergeCpi<'a, 'b> { /// /// ### Accounts: /// -/// 0. `[writable]` destination_stake -/// 1. `[writable]` source_stake +/// 0. `[writable]` destination +/// 1. `[writable]` source /// 2. `[]` clock_sysvar -/// 3. `[]` stake_history +/// 3. `[]` stake_history_sysvar /// 4. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MergeCpiBuilder<'a, 'b> { @@ -326,34 +316,31 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MergeCpiBuilderInstruction { __program: program, - destination_stake: None, - source_stake: None, + destination: None, + source: None, clock_sysvar: None, - stake_history: None, + stake_history_sysvar: None, stake_authority: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Destination stake account #[inline(always)] - pub fn destination_stake( + pub fn destination( &mut self, - destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + destination: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.destination_stake = Some(destination_stake); + self.instruction.destination = Some(destination); self } - /// Source stake account #[inline(always)] - pub fn source_stake( + pub fn source( &mut self, - source_stake: &'b solana_program::account_info::AccountInfo<'a>, + source: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.source_stake = Some(source_stake); + self.instruction.source = Some(source); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -362,16 +349,14 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar #[inline(always)] - pub fn stake_history( + pub fn stake_history_sysvar( &mut self, - stake_history: &'b solana_program::account_info::AccountInfo<'a>, + stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.stake_history = Some(stake_history); + self.instruction.stake_history_sysvar = Some(stake_history_sysvar); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -424,25 +409,22 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { let instruction = MergeCpi { __program: self.instruction.__program, - destination_stake: self + destination: self .instruction - .destination_stake - .expect("destination_stake is not set"), + .destination + .expect("destination is not set"), - source_stake: self - .instruction - .source_stake - .expect("source_stake is not set"), + source: self.instruction.source.expect("source is not set"), clock_sysvar: self .instruction .clock_sysvar .expect("clock_sysvar is not set"), - stake_history: self + stake_history_sysvar: self .instruction - .stake_history - .expect("stake_history is not set"), + .stake_history_sysvar + .expect("stake_history_sysvar is not set"), stake_authority: self .instruction @@ -459,10 +441,10 @@ 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>>, + destination: Option<&'b solana_program::account_info::AccountInfo<'a>>, + source: 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_history_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index 718e3494..3c54614e 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -18,6 +18,7 @@ pub(crate) mod r#initialize_checked; pub(crate) mod r#merge; pub(crate) mod r#move_lamports; pub(crate) mod r#move_stake; +pub(crate) mod r#redelegate; pub(crate) mod r#set_lockup; pub(crate) mod r#set_lockup_checked; pub(crate) mod r#split; @@ -27,6 +28,6 @@ pub use self::{ r#authorize::*, r#authorize_checked::*, r#authorize_checked_with_seed::*, r#authorize_with_seed::*, r#deactivate::*, r#deactivate_delinquent::*, r#delegate_stake::*, r#get_minimum_delegation::*, r#initialize::*, r#initialize_checked::*, r#merge::*, - r#move_lamports::*, r#move_stake::*, r#set_lockup::*, r#set_lockup_checked::*, r#split::*, - r#withdraw::*, + r#move_lamports::*, r#move_stake::*, r#redelegate::*, r#set_lockup::*, r#set_lockup_checked::*, + r#split::*, r#withdraw::*, }; diff --git a/clients/rust/src/generated/instructions/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs index cc30b72c..8d2da78f 100644 --- a/clients/rust/src/generated/instructions/move_lamports.rs +++ b/clients/rust/src/generated/instructions/move_lamports.rs @@ -10,11 +10,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct MoveLamports { - /// Active or inactive source stake account - pub source_stake: solana_program::pubkey::Pubkey, - /// Mergeable destination stake account - pub destination_stake: solana_program::pubkey::Pubkey, - /// Stake authority + pub source: solana_program::pubkey::Pubkey, + + pub destination: solana_program::pubkey::Pubkey, + pub stake_authority: solana_program::pubkey::Pubkey, } @@ -33,11 +32,11 @@ impl MoveLamports { ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - self.source_stake, + self.source, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - self.destination_stake, + self.destination, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -60,7 +59,7 @@ impl MoveLamports { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MoveLamportsInstructionData { - discriminator: u32, + discriminator: u8, } impl MoveLamportsInstructionData { @@ -78,22 +77,22 @@ impl Default for MoveLamportsInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MoveLamportsInstructionArgs { - pub args: u64, + pub lamports: u64, } /// Instruction builder for `MoveLamports`. /// /// ### Accounts: /// -/// 0. `[writable]` source_stake -/// 1. `[writable]` destination_stake +/// 0. `[writable]` source +/// 1. `[writable]` destination /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveLamportsBuilder { - source_stake: Option, - destination_stake: Option, + source: Option, + destination: Option, stake_authority: Option, - args: Option, + lamports: Option, __remaining_accounts: Vec, } @@ -101,22 +100,16 @@ impl MoveLamportsBuilder { pub fn new() -> Self { Self::default() } - /// Active or inactive source stake account #[inline(always)] - pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.source_stake = Some(source_stake); + pub fn source(&mut self, source: solana_program::pubkey::Pubkey) -> &mut Self { + self.source = Some(source); self } - /// Mergeable destination stake account #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.destination_stake = Some(destination_stake); + pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { + self.destination = Some(destination); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -126,8 +119,8 @@ impl MoveLamportsBuilder { self } #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { - self.args = Some(args); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -151,14 +144,12 @@ impl MoveLamportsBuilder { #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = MoveLamports { - source_stake: self.source_stake.expect("source_stake is not set"), - destination_stake: self - .destination_stake - .expect("destination_stake is not set"), + source: self.source.expect("source is not set"), + destination: self.destination.expect("destination is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; let args = MoveLamportsInstructionArgs { - args: self.args.clone().expect("args is not set"), + lamports: self.lamports.clone().expect("lamports is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -167,11 +158,10 @@ 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>, - /// Mergeable destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + pub source: &'b solana_program::account_info::AccountInfo<'a>, + + pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -179,11 +169,11 @@ pub struct MoveLamportsCpiAccounts<'a, 'b> { pub struct MoveLamportsCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Active or inactive source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Mergeable destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + + pub source: &'b solana_program::account_info::AccountInfo<'a>, + + pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: MoveLamportsInstructionArgs, @@ -197,8 +187,8 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { ) -> Self { Self { __program: program, - source_stake: accounts.source_stake, - destination_stake: accounts.destination_stake, + source: accounts.source, + destination: accounts.destination, stake_authority: accounts.stake_authority, __args: args, } @@ -238,11 +228,11 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { ) -> solana_program::entrypoint::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - *self.source_stake.key, + *self.source.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - *self.destination_stake.key, + *self.destination.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -267,8 +257,8 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { }; let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); account_infos.push(self.__program.clone()); - account_infos.push(self.source_stake.clone()); - account_infos.push(self.destination_stake.clone()); + account_infos.push(self.source.clone()); + account_infos.push(self.destination.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -286,8 +276,8 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { /// /// ### Accounts: /// -/// 0. `[writable]` source_stake -/// 1. `[writable]` destination_stake +/// 0. `[writable]` source +/// 1. `[writable]` destination /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MoveLamportsCpiBuilder<'a, 'b> { @@ -298,33 +288,30 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MoveLamportsCpiBuilderInstruction { __program: program, - source_stake: None, - destination_stake: None, + source: None, + destination: None, stake_authority: None, - args: None, + lamports: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Active or inactive source stake account #[inline(always)] - pub fn source_stake( + pub fn source( &mut self, - source_stake: &'b solana_program::account_info::AccountInfo<'a>, + source: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.source_stake = Some(source_stake); + self.instruction.source = Some(source); self } - /// Mergeable destination stake account #[inline(always)] - pub fn destination_stake( + pub fn destination( &mut self, - destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + destination: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.destination_stake = Some(destination_stake); + self.instruction.destination = Some(destination); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -334,8 +321,8 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { - self.instruction.args = Some(args); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.instruction.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -380,20 +367,21 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = MoveLamportsInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), + lamports: self + .instruction + .lamports + .clone() + .expect("lamports is not set"), }; let instruction = MoveLamportsCpi { __program: self.instruction.__program, - source_stake: self - .instruction - .source_stake - .expect("source_stake is not set"), + source: self.instruction.source.expect("source is not set"), - destination_stake: self + destination: self .instruction - .destination_stake - .expect("destination_stake is not set"), + .destination + .expect("destination is not set"), stake_authority: self .instruction @@ -411,10 +399,10 @@ 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>>, + source: Option<&'b solana_program::account_info::AccountInfo<'a>>, + destination: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - args: Option, + lamports: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/move_stake.rs b/clients/rust/src/generated/instructions/move_stake.rs index c8953253..d31d0c6c 100644 --- a/clients/rust/src/generated/instructions/move_stake.rs +++ b/clients/rust/src/generated/instructions/move_stake.rs @@ -10,11 +10,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct MoveStake { - /// Active source stake account - pub source_stake: solana_program::pubkey::Pubkey, - /// Active or inactive destination stake account - pub destination_stake: solana_program::pubkey::Pubkey, - /// Stake authority + pub source: solana_program::pubkey::Pubkey, + + pub destination: solana_program::pubkey::Pubkey, + pub stake_authority: solana_program::pubkey::Pubkey, } @@ -33,11 +32,11 @@ impl MoveStake { ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - self.source_stake, + self.source, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - self.destination_stake, + self.destination, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -60,7 +59,7 @@ impl MoveStake { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MoveStakeInstructionData { - discriminator: u32, + discriminator: u8, } impl MoveStakeInstructionData { @@ -78,22 +77,22 @@ impl Default for MoveStakeInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MoveStakeInstructionArgs { - pub args: u64, + pub lamports: u64, } /// Instruction builder for `MoveStake`. /// /// ### Accounts: /// -/// 0. `[writable]` source_stake -/// 1. `[writable]` destination_stake +/// 0. `[writable]` source +/// 1. `[writable]` destination /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveStakeBuilder { - source_stake: Option, - destination_stake: Option, + source: Option, + destination: Option, stake_authority: Option, - args: Option, + lamports: Option, __remaining_accounts: Vec, } @@ -101,22 +100,16 @@ impl MoveStakeBuilder { pub fn new() -> Self { Self::default() } - /// Active source stake account #[inline(always)] - pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.source_stake = Some(source_stake); + pub fn source(&mut self, source: solana_program::pubkey::Pubkey) -> &mut Self { + self.source = Some(source); self } - /// Active or inactive destination stake account #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.destination_stake = Some(destination_stake); + pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { + self.destination = Some(destination); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -126,8 +119,8 @@ impl MoveStakeBuilder { self } #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { - self.args = Some(args); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -151,14 +144,12 @@ impl MoveStakeBuilder { #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = MoveStake { - source_stake: self.source_stake.expect("source_stake is not set"), - destination_stake: self - .destination_stake - .expect("destination_stake is not set"), + source: self.source.expect("source is not set"), + destination: self.destination.expect("destination is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; let args = MoveStakeInstructionArgs { - args: self.args.clone().expect("args is not set"), + lamports: self.lamports.clone().expect("lamports is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -167,11 +158,10 @@ 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>, - /// Active or inactive destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + pub source: &'b solana_program::account_info::AccountInfo<'a>, + + pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -179,11 +169,11 @@ pub struct MoveStakeCpiAccounts<'a, 'b> { pub struct MoveStakeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Active source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Active or inactive destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + + pub source: &'b solana_program::account_info::AccountInfo<'a>, + + pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: MoveStakeInstructionArgs, @@ -197,8 +187,8 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { ) -> Self { Self { __program: program, - source_stake: accounts.source_stake, - destination_stake: accounts.destination_stake, + source: accounts.source, + destination: accounts.destination, stake_authority: accounts.stake_authority, __args: args, } @@ -238,11 +228,11 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { ) -> solana_program::entrypoint::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - *self.source_stake.key, + *self.source.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - *self.destination_stake.key, + *self.destination.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -267,8 +257,8 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { }; let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); account_infos.push(self.__program.clone()); - account_infos.push(self.source_stake.clone()); - account_infos.push(self.destination_stake.clone()); + account_infos.push(self.source.clone()); + account_infos.push(self.destination.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -286,8 +276,8 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { /// /// ### Accounts: /// -/// 0. `[writable]` source_stake -/// 1. `[writable]` destination_stake +/// 0. `[writable]` source +/// 1. `[writable]` destination /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MoveStakeCpiBuilder<'a, 'b> { @@ -298,33 +288,30 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MoveStakeCpiBuilderInstruction { __program: program, - source_stake: None, - destination_stake: None, + source: None, + destination: None, stake_authority: None, - args: None, + lamports: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Active source stake account #[inline(always)] - pub fn source_stake( + pub fn source( &mut self, - source_stake: &'b solana_program::account_info::AccountInfo<'a>, + source: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.source_stake = Some(source_stake); + self.instruction.source = Some(source); self } - /// Active or inactive destination stake account #[inline(always)] - pub fn destination_stake( + pub fn destination( &mut self, - destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + destination: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.destination_stake = Some(destination_stake); + self.instruction.destination = Some(destination); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -334,8 +321,8 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { - self.instruction.args = Some(args); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.instruction.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -380,20 +367,21 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = MoveStakeInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), + lamports: self + .instruction + .lamports + .clone() + .expect("lamports is not set"), }; let instruction = MoveStakeCpi { __program: self.instruction.__program, - source_stake: self - .instruction - .source_stake - .expect("source_stake is not set"), + source: self.instruction.source.expect("source is not set"), - destination_stake: self + destination: self .instruction - .destination_stake - .expect("destination_stake is not set"), + .destination + .expect("destination is not set"), stake_authority: self .instruction @@ -411,10 +399,10 @@ 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>>, + source: Option<&'b solana_program::account_info::AccountInfo<'a>>, + destination: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - args: Option, + lamports: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/redelegate.rs b/clients/rust/src/generated/instructions/redelegate.rs new file mode 100644 index 00000000..7354ba8a --- /dev/null +++ b/clients/rust/src/generated/instructions/redelegate.rs @@ -0,0 +1,241 @@ +//! 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. +//! +//! +//! + +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +#[derive(Debug)] +pub struct Redelegate {} + +impl Redelegate { + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(remaining_accounts.len()); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&RedelegateInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } +} + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct RedelegateInstructionData { + discriminator: u8, +} + +impl RedelegateInstructionData { + pub fn new() -> Self { + Self { discriminator: 15 } + } +} + +impl Default for RedelegateInstructionData { + fn default() -> Self { + Self::new() + } +} + +/// Instruction builder for `Redelegate`. +/// +/// ### Accounts: +/// +#[derive(Clone, Debug, Default)] +pub struct RedelegateBuilder { + __remaining_accounts: Vec, +} + +impl RedelegateBuilder { + pub fn new() -> Self { + Self::default() + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = Redelegate {}; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } +} + +/// `redelegate` CPI instruction. +pub struct RedelegateCpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, +} + +impl<'a, 'b> RedelegateCpi<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + Self { __program: program } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(remaining_accounts.len()); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let data = borsh::to_vec(&RedelegateInstructionData::new()).unwrap(); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `Redelegate` via CPI. +/// +/// ### Accounts: +/// +#[derive(Clone, Debug)] +pub struct RedelegateCpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> RedelegateCpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(RedelegateCpiBuilderInstruction { + __program: program, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let instruction = RedelegateCpi { + __program: self.instruction.__program, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +#[derive(Clone, Debug)] +struct RedelegateCpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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..8a163e75 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -6,16 +6,15 @@ //! use { + crate::generated::types::LockupArgs, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, }; /// Accounts. #[derive(Debug)] pub struct SetLockup { - /// Initialized stake account pub stake: solana_program::pubkey::Pubkey, - /// Lockup authority or withdraw authority + pub authority: solana_program::pubkey::Pubkey, } @@ -56,7 +55,7 @@ impl SetLockup { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupInstructionData { - discriminator: u32, + discriminator: u8, } impl SetLockupInstructionData { @@ -74,9 +73,7 @@ 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 custodian: Option, + pub lockup: LockupArgs, } /// Instruction builder for `SetLockup`. @@ -89,9 +86,7 @@ pub struct SetLockupInstructionArgs { pub struct SetLockupBuilder { stake: Option, authority: Option, - unix_timestamp: Option, - epoch: Option, - custodian: Option, + lockup: Option, __remaining_accounts: Vec, } @@ -99,34 +94,19 @@ impl SetLockupBuilder { pub fn new() -> Self { Self::default() } - /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.authority = Some(authority); self } - /// `[optional argument]` - #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { - self.unix_timestamp = Some(unix_timestamp); - self - } - /// `[optional argument]` #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { - self.epoch = Some(epoch); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { - self.custodian = Some(custodian); + pub fn lockup(&mut self, lockup: LockupArgs) -> &mut Self { + self.lockup = Some(lockup); self } /// Add an additional account to the instruction. @@ -154,9 +134,7 @@ impl SetLockupBuilder { authority: self.authority.expect("authority is not set"), }; let args = SetLockupInstructionArgs { - unix_timestamp: self.unix_timestamp.clone(), - epoch: self.epoch.clone(), - custodian: self.custodian.clone(), + lockup: self.lockup.clone().expect("lockup is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -165,9 +143,8 @@ impl SetLockupBuilder { /// `set_lockup` CPI accounts. pub struct SetLockupCpiAccounts<'a, 'b> { - /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -175,9 +152,9 @@ pub struct SetLockupCpiAccounts<'a, 'b> { pub struct SetLockupCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Initialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: SetLockupInstructionArgs, @@ -287,20 +264,16 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { __program: program, stake: None, authority: None, - unix_timestamp: None, - epoch: None, - custodian: None, + lockup: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Lockup authority or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -309,22 +282,9 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { self.instruction.authority = Some(authority); self } - /// `[optional argument]` - #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { - self.instruction.unix_timestamp = Some(unix_timestamp); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { - self.instruction.epoch = Some(epoch); - self - } - /// `[optional argument]` #[inline(always)] - pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { - self.instruction.custodian = Some(custodian); + pub fn lockup(&mut self, lockup: LockupArgs) -> &mut Self { + self.instruction.lockup = Some(lockup); self } /// Add an additional account to the instruction. @@ -369,9 +329,7 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = SetLockupInstructionArgs { - unix_timestamp: self.instruction.unix_timestamp.clone(), - epoch: self.instruction.epoch.clone(), - custodian: self.instruction.custodian.clone(), + lockup: self.instruction.lockup.clone().expect("lockup is not set"), }; let instruction = SetLockupCpi { __program: self.instruction.__program, @@ -393,9 +351,7 @@ 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, - custodian: Option, + lockup: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/set_lockup_checked.rs b/clients/rust/src/generated/instructions/set_lockup_checked.rs index fbfb6125..10ecbe92 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -5,17 +5,19 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use { + crate::generated::types::LockupCheckedArgs, + borsh::{BorshDeserialize, BorshSerialize}, +}; /// Accounts. #[derive(Debug)] pub struct SetLockupChecked { - /// Initialized stake account pub stake: solana_program::pubkey::Pubkey, - /// Lockup authority or withdraw authority + pub authority: solana_program::pubkey::Pubkey, - /// New lockup authority - pub new_authority: Option, + + pub new_lockup_authority: Option, } impl SetLockupChecked { @@ -39,9 +41,9 @@ impl SetLockupChecked { self.authority, true, )); - if let Some(new_authority) = self.new_authority { + if let Some(new_lockup_authority) = self.new_lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - new_authority, + new_lockup_authority, true, )); } @@ -61,7 +63,7 @@ impl SetLockupChecked { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupCheckedInstructionData { - discriminator: u32, + discriminator: u8, } impl SetLockupCheckedInstructionData { @@ -79,8 +81,7 @@ 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 lockup: LockupCheckedArgs, } /// Instruction builder for `SetLockupChecked`. @@ -89,14 +90,13 @@ pub struct SetLockupCheckedInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[signer]` authority -/// 2. `[signer, optional]` new_authority +/// 2. `[signer, optional]` new_lockup_authority #[derive(Clone, Debug, Default)] pub struct SetLockupCheckedBuilder { stake: Option, authority: Option, - new_authority: Option, - unix_timestamp: Option, - epoch: Option, + new_lockup_authority: Option, + lockup: Option, __remaining_accounts: Vec, } @@ -104,38 +104,28 @@ impl SetLockupCheckedBuilder { pub fn new() -> Self { Self::default() } - /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.authority = Some(authority); self } /// `[optional account]` - /// New lockup authority #[inline(always)] - pub fn new_authority( + pub fn new_lockup_authority( &mut self, - new_authority: Option, + new_lockup_authority: Option, ) -> &mut Self { - self.new_authority = new_authority; + self.new_lockup_authority = new_lockup_authority; self } - /// `[optional argument]` #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { - self.unix_timestamp = Some(unix_timestamp); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { - self.epoch = Some(epoch); + pub fn lockup(&mut self, lockup: LockupCheckedArgs) -> &mut Self { + self.lockup = Some(lockup); self } /// Add an additional account to the instruction. @@ -161,11 +151,10 @@ impl SetLockupCheckedBuilder { let accounts = SetLockupChecked { stake: self.stake.expect("stake is not set"), authority: self.authority.expect("authority is not set"), - new_authority: self.new_authority, + new_lockup_authority: self.new_lockup_authority, }; let args = SetLockupCheckedInstructionArgs { - unix_timestamp: self.unix_timestamp.clone(), - epoch: self.epoch.clone(), + lockup: self.lockup.clone().expect("lockup is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -174,24 +163,23 @@ impl SetLockupCheckedBuilder { /// `set_lockup_checked` CPI accounts. pub struct SetLockupCheckedCpiAccounts<'a, 'b> { - /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// New lockup authority - pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + + pub new_lockup_authority: Option<&'b solana_program::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>, - /// Initialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// New lockup authority - pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + + pub new_lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: SetLockupCheckedInstructionArgs, } @@ -206,7 +194,7 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { __program: program, stake: accounts.stake, authority: accounts.authority, - new_authority: accounts.new_authority, + new_lockup_authority: accounts.new_lockup_authority, __args: args, } } @@ -252,9 +240,9 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { *self.authority.key, true, )); - if let Some(new_authority) = self.new_authority { + if let Some(new_lockup_authority) = self.new_lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *new_authority.key, + *new_lockup_authority.key, true, )); } @@ -278,8 +266,8 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); account_infos.push(self.authority.clone()); - if let Some(new_authority) = self.new_authority { - account_infos.push(new_authority.clone()); + if let Some(new_lockup_authority) = self.new_lockup_authority { + account_infos.push(new_lockup_authority.clone()); } remaining_accounts .iter() @@ -299,7 +287,7 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { /// /// 0. `[writable]` stake /// 1. `[signer]` authority -/// 2. `[signer, optional]` new_authority +/// 2. `[signer, optional]` new_lockup_authority #[derive(Clone, Debug)] pub struct SetLockupCheckedCpiBuilder<'a, 'b> { instruction: Box>, @@ -311,20 +299,17 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { __program: program, stake: None, authority: None, - new_authority: None, - unix_timestamp: None, - epoch: None, + new_lockup_authority: None, + lockup: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Lockup authority or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -334,25 +319,17 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { self } /// `[optional account]` - /// New lockup authority #[inline(always)] - pub fn new_authority( + pub fn new_lockup_authority( &mut self, - new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + new_lockup_authority: Option<&'b solana_program::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 { - self.instruction.unix_timestamp = Some(unix_timestamp); + self.instruction.new_lockup_authority = new_lockup_authority; self } - /// `[optional argument]` #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { - self.instruction.epoch = Some(epoch); + pub fn lockup(&mut self, lockup: LockupCheckedArgs) -> &mut Self { + self.instruction.lockup = Some(lockup); self } /// Add an additional account to the instruction. @@ -397,8 +374,7 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = SetLockupCheckedInstructionArgs { - unix_timestamp: self.instruction.unix_timestamp.clone(), - epoch: self.instruction.epoch.clone(), + lockup: self.instruction.lockup.clone().expect("lockup is not set"), }; let instruction = SetLockupCheckedCpi { __program: self.instruction.__program, @@ -407,7 +383,7 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { authority: self.instruction.authority.expect("authority is not set"), - new_authority: self.instruction.new_authority, + new_lockup_authority: self.instruction.new_lockup_authority, __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -422,9 +398,8 @@ 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, + new_lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/split.rs b/clients/rust/src/generated/instructions/split.rs index e17198a1..d08f2701 100644 --- a/clients/rust/src/generated/instructions/split.rs +++ b/clients/rust/src/generated/instructions/split.rs @@ -10,11 +10,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// 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 authority + pub stake_authority: solana_program::pubkey::Pubkey, } @@ -59,7 +58,7 @@ impl Split { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SplitInstructionData { - discriminator: u32, + discriminator: u8, } impl SplitInstructionData { @@ -77,7 +76,7 @@ impl Default for SplitInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SplitInstructionArgs { - pub args: u64, + pub lamports: u64, } /// Instruction builder for `Split`. @@ -92,7 +91,7 @@ pub struct SplitBuilder { stake: Option, split_stake: Option, stake_authority: Option, - args: Option, + lamports: Option, __remaining_accounts: Vec, } @@ -100,19 +99,16 @@ impl SplitBuilder { pub fn new() -> Self { Self::default() } - /// Stake account to be split #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// Uninitialized stake account #[inline(always)] pub fn split_stake(&mut self, split_stake: solana_program::pubkey::Pubkey) -> &mut Self { self.split_stake = Some(split_stake); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -122,8 +118,8 @@ impl SplitBuilder { self } #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { - self.args = Some(args); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -152,7 +148,7 @@ impl SplitBuilder { stake_authority: self.stake_authority.expect("stake_authority is not set"), }; let args = SplitInstructionArgs { - args: self.args.clone().expect("args is not set"), + lamports: self.lamports.clone().expect("lamports is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -161,11 +157,10 @@ 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 authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -173,11 +168,11 @@ pub struct SplitCpiAccounts<'a, 'b> { 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>, - /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: SplitInstructionArgs, @@ -295,18 +290,16 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { stake: None, split_stake: None, stake_authority: None, - args: None, + lamports: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Stake account to be split #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Uninitialized stake account #[inline(always)] pub fn split_stake( &mut self, @@ -315,7 +308,6 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { self.instruction.split_stake = Some(split_stake); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -325,8 +317,8 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { - self.instruction.args = Some(args); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.instruction.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -371,7 +363,11 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = SplitInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), + lamports: self + .instruction + .lamports + .clone() + .expect("lamports is not set"), }; let instruction = SplitCpi { __program: self.instruction.__program, @@ -402,7 +398,7 @@ struct SplitCpiBuilderInstruction<'a, 'b> { 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>>, - args: Option, + lamports: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/withdraw.rs b/clients/rust/src/generated/instructions/withdraw.rs index 7d21b1c2..925455a0 100644 --- a/clients/rust/src/generated/instructions/withdraw.rs +++ b/clients/rust/src/generated/instructions/withdraw.rs @@ -10,17 +10,16 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Withdraw { - /// Stake account from which to withdraw pub stake: solana_program::pubkey::Pubkey, - /// Recipient account + pub recipient: solana_program::pubkey::Pubkey, - /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar - pub stake_history: solana_program::pubkey::Pubkey, - /// Withdraw authority + + pub stake_history_sysvar: solana_program::pubkey::Pubkey, + pub withdraw_authority: solana_program::pubkey::Pubkey, - /// Lockup authority + pub lockup_authority: Option, } @@ -50,7 +49,7 @@ impl Withdraw { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.stake_history, + self.stake_history_sysvar, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -79,7 +78,7 @@ impl Withdraw { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WithdrawInstructionData { - discriminator: u32, + discriminator: u8, } impl WithdrawInstructionData { @@ -97,7 +96,7 @@ impl Default for WithdrawInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WithdrawInstructionArgs { - pub args: u64, + pub lamports: u64, } /// Instruction builder for `Withdraw`. @@ -106,8 +105,8 @@ pub struct WithdrawInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[writable]` recipient -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[]` stake_history +/// 2. `[]` clock_sysvar +/// 3. `[]` stake_history_sysvar /// 4. `[signer]` withdraw_authority /// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] @@ -115,10 +114,10 @@ pub struct WithdrawBuilder { stake: Option, recipient: Option, clock_sysvar: Option, - stake_history: Option, + stake_history_sysvar: Option, withdraw_authority: Option, lockup_authority: Option, - args: Option, + lamports: Option, __remaining_accounts: Vec, } @@ -126,32 +125,29 @@ impl WithdrawBuilder { pub fn new() -> Self { Self::default() } - /// Stake account from which to withdraw #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { 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 { self.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar #[inline(always)] - pub fn stake_history(&mut self, stake_history: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake_history = Some(stake_history); + pub fn stake_history_sysvar( + &mut self, + stake_history_sysvar: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_history_sysvar = Some(stake_history_sysvar); self } - /// Withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -161,7 +157,6 @@ impl WithdrawBuilder { self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -171,8 +166,8 @@ impl WithdrawBuilder { self } #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { - self.args = Some(args); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -198,17 +193,17 @@ impl WithdrawBuilder { 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!( - "SysvarC1ock11111111111111111111111111111111" - )), - stake_history: self.stake_history.expect("stake_history is not set"), + clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), + stake_history_sysvar: self + .stake_history_sysvar + .expect("stake_history_sysvar is not set"), withdraw_authority: self .withdraw_authority .expect("withdraw_authority is not set"), lockup_authority: self.lockup_authority, }; let args = WithdrawInstructionArgs { - args: self.args.clone().expect("args is not set"), + lamports: self.lamports.clone().expect("lamports is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -217,17 +212,16 @@ 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>, - /// Recipient account + pub recipient: &'b solana_program::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>, - /// Withdraw authority + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } @@ -235,17 +229,17 @@ pub struct WithdrawCpiAccounts<'a, 'b> { pub struct WithdrawCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake account from which to withdraw + pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Recipient account + pub recipient: &'b solana_program::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>, - /// Withdraw authority + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: WithdrawInstructionArgs, @@ -262,7 +256,7 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { stake: accounts.stake, recipient: accounts.recipient, clock_sysvar: accounts.clock_sysvar, - stake_history: accounts.stake_history, + stake_history_sysvar: accounts.stake_history_sysvar, withdraw_authority: accounts.withdraw_authority, lockup_authority: accounts.lockup_authority, __args: args, @@ -315,7 +309,7 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.stake_history.key, + *self.stake_history_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -349,7 +343,7 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { account_infos.push(self.stake.clone()); account_infos.push(self.recipient.clone()); account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history.clone()); + account_infos.push(self.stake_history_sysvar.clone()); account_infos.push(self.withdraw_authority.clone()); if let Some(lockup_authority) = self.lockup_authority { account_infos.push(lockup_authority.clone()); @@ -373,7 +367,7 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { /// 0. `[writable]` stake /// 1. `[writable]` recipient /// 2. `[]` clock_sysvar -/// 3. `[]` stake_history +/// 3. `[]` stake_history_sysvar /// 4. `[signer]` withdraw_authority /// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] @@ -388,21 +382,19 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { stake: None, recipient: None, clock_sysvar: None, - stake_history: None, + stake_history_sysvar: None, withdraw_authority: None, lockup_authority: None, - args: None, + lamports: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// Stake account from which to withdraw #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Recipient account #[inline(always)] pub fn recipient( &mut self, @@ -411,7 +403,6 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self.instruction.recipient = Some(recipient); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -420,16 +411,14 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Stake history sysvar #[inline(always)] - pub fn stake_history( + pub fn stake_history_sysvar( &mut self, - stake_history: &'b solana_program::account_info::AccountInfo<'a>, + stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.stake_history = Some(stake_history); + self.instruction.stake_history_sysvar = Some(stake_history_sysvar); self } - /// Withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -439,7 +428,6 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -449,8 +437,8 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { - self.instruction.args = Some(args); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.instruction.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -495,7 +483,11 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = WithdrawInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), + lamports: self + .instruction + .lamports + .clone() + .expect("lamports is not set"), }; let instruction = WithdrawCpi { __program: self.instruction.__program, @@ -509,10 +501,10 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { .clock_sysvar .expect("clock_sysvar is not set"), - stake_history: self + stake_history_sysvar: self .instruction - .stake_history - .expect("stake_history is not set"), + .stake_history_sysvar + .expect("stake_history_sysvar is not set"), withdraw_authority: self .instruction @@ -535,10 +527,10 @@ struct WithdrawCpiBuilderInstruction<'a, 'b> { 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>>, + stake_history_sysvar: 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>>, - args: Option, + lamports: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/types/authorize_checked_with_seed_args.rs b/clients/rust/src/generated/types/authorize_checked_with_seed_args.rs new file mode 100644 index 00000000..463eb76c --- /dev/null +++ b/clients/rust/src/generated/types/authorize_checked_with_seed_args.rs @@ -0,0 +1,24 @@ +//! 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. +//! +//! +//! + +use { + crate::generated::types::StakeAuthorize, + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct AuthorizeCheckedWithSeedArgs { + pub stake_authorize: StakeAuthorize, + pub authority_seed: String, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub authority_owner: Pubkey, +} diff --git a/clients/rust/src/generated/types/authorize_with_seed_args.rs b/clients/rust/src/generated/types/authorize_with_seed_args.rs new file mode 100644 index 00000000..9ead65a9 --- /dev/null +++ b/clients/rust/src/generated/types/authorize_with_seed_args.rs @@ -0,0 +1,29 @@ +//! 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. +//! +//! +//! + +use { + crate::generated::types::StakeAuthorize, + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct AuthorizeWithSeedArgs { + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub new_authorized_pubkey: Pubkey, + pub stake_authorize: StakeAuthorize, + pub authority_seed: String, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub authority_owner: Pubkey, +} diff --git a/clients/rust/src/generated/types/delegation.rs b/clients/rust/src/generated/types/delegation.rs index a9066b51..6099f376 100644 --- a/clients/rust/src/generated/types/delegation.rs +++ b/clients/rust/src/generated/types/delegation.rs @@ -6,6 +6,7 @@ //! use { + crate::generated::types::Epoch, borsh::{BorshDeserialize, BorshSerialize}, solana_program::pubkey::Pubkey, }; @@ -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..8b364f93 100644 --- a/clients/rust/src/generated/types/lockup.rs +++ b/clients/rust/src/generated/types/lockup.rs @@ -6,6 +6,7 @@ //! use { + crate::generated::types::{Epoch, UnixTimestamp}, borsh::{BorshDeserialize, BorshSerialize}, solana_program::pubkey::Pubkey, }; @@ -13,8 +14,8 @@ use { #[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/lockup_args.rs b/clients/rust/src/generated/types/lockup_args.rs new file mode 100644 index 00000000..761019ea --- /dev/null +++ b/clients/rust/src/generated/types/lockup_args.rs @@ -0,0 +1,20 @@ +//! 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. +//! +//! +//! + +use { + crate::generated::types::{Epoch, UnixTimestamp}, + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct LockupArgs { + pub unix_timestamp: Option, + pub epoch: Option, + pub custodian: Option, +} diff --git a/clients/rust/src/generated/types/lockup_checked_args.rs b/clients/rust/src/generated/types/lockup_checked_args.rs new file mode 100644 index 00000000..8855f33d --- /dev/null +++ b/clients/rust/src/generated/types/lockup_checked_args.rs @@ -0,0 +1,18 @@ +//! 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. +//! +//! +//! + +use { + crate::generated::types::{Epoch, UnixTimestamp}, + borsh::{BorshDeserialize, BorshSerialize}, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct LockupCheckedArgs { + pub unix_timestamp: Option, + pub epoch: Option, +} diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index 41560dee..9e476ce3 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -5,17 +5,25 @@ //! //! +pub(crate) mod r#authorize_checked_with_seed_args; +pub(crate) mod r#authorize_with_seed_args; pub(crate) mod r#authorized; pub(crate) mod r#delegation; +pub(crate) mod r#epoch; pub(crate) mod r#lockup; +pub(crate) mod r#lockup_args; +pub(crate) mod r#lockup_checked_args; pub(crate) mod r#meta; pub(crate) mod r#stake; 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#authorize_checked_with_seed_args::*, r#authorize_with_seed_args::*, r#authorized::*, + r#delegation::*, r#epoch::*, r#lockup::*, r#lockup_args::*, r#lockup_checked_args::*, + 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; From c31a3dd46ab2d056f245747d5b546fd8b3dafce1 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Fri, 14 Nov 2025 22:02:36 +0000 Subject: [PATCH 04/27] fix type collisions --- .../instructions/authorizeCheckedWithSeed.ts | 16 ++++++++-------- .../instructions/authorizeWithSeed.ts | 16 ++++++++-------- .../js/src/generated/instructions/setLockup.ts | 16 ++++++++-------- .../generated/instructions/setLockupChecked.ts | 16 ++++++++-------- ...gs.ts => authorizeCheckedWithSeedParams.ts} | 18 +++++++++--------- ...hSeedArgs.ts => authorizeWithSeedParams.ts} | 18 +++++++++--------- clients/js/src/generated/types/index.ts | 8 ++++---- ...upCheckedArgs.ts => lockupCheckedParams.ts} | 18 +++++++++--------- .../types/{lockupArgs.ts => lockupParams.ts} | 12 ++++++------ .../authorize_checked_with_seed.rs | 12 ++++++------ .../instructions/authorize_with_seed.rs | 12 ++++++------ .../src/generated/instructions/set_lockup.rs | 12 ++++++------ .../instructions/set_lockup_checked.rs | 12 ++++++------ ...s => authorize_checked_with_seed_params.rs} | 2 +- ...d_args.rs => authorize_with_seed_params.rs} | 2 +- ...hecked_args.rs => lockup_checked_params.rs} | 2 +- .../types/{lockup_args.rs => lockup_params.rs} | 2 +- clients/rust/src/generated/types/mod.rs | 12 ++++++------ interface/idl.json | 8 ++++---- interface/src/instruction.rs | 4 ++++ scripts/generate-clients.mts | 10 ++++++++++ 21 files changed, 121 insertions(+), 107 deletions(-) rename clients/js/src/generated/types/{authorizeCheckedWithSeedArgs.ts => authorizeCheckedWithSeedParams.ts} (70%) rename clients/js/src/generated/types/{authorizeWithSeedArgs.ts => authorizeWithSeedParams.ts} (76%) rename clients/js/src/generated/types/{lockupCheckedArgs.ts => lockupCheckedParams.ts} (73%) rename clients/js/src/generated/types/{lockupArgs.ts => lockupParams.ts} (79%) rename clients/rust/src/generated/types/{authorize_checked_with_seed_args.rs => authorize_checked_with_seed_params.rs} (94%) rename clients/rust/src/generated/types/{authorize_with_seed_args.rs => authorize_with_seed_params.rs} (95%) rename clients/rust/src/generated/types/{lockup_checked_args.rs => lockup_checked_params.rs} (94%) rename clients/rust/src/generated/types/{lockup_args.rs => lockup_params.rs} (96%) diff --git a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts index 34ffaf64..5137cb87 100644 --- a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts @@ -31,10 +31,10 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getAuthorizeCheckedWithSeedArgsDecoder, - getAuthorizeCheckedWithSeedArgsEncoder, - type AuthorizeCheckedWithSeedArgs, - type AuthorizeCheckedWithSeedArgsArgs, + getAuthorizeCheckedWithSeedParamsDecoder, + getAuthorizeCheckedWithSeedParamsEncoder, + type AuthorizeCheckedWithSeedParams, + type AuthorizeCheckedWithSeedParamsArgs, } from '../types'; export const AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR = 11; @@ -86,18 +86,18 @@ export type AuthorizeCheckedWithSeedInstruction< export type AuthorizeCheckedWithSeedInstructionData = { discriminator: number; - args: AuthorizeCheckedWithSeedArgs; + args: AuthorizeCheckedWithSeedParams; }; export type AuthorizeCheckedWithSeedInstructionDataArgs = { - args: AuthorizeCheckedWithSeedArgsArgs; + args: AuthorizeCheckedWithSeedParamsArgs; }; export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU8Encoder()], - ['args', getAuthorizeCheckedWithSeedArgsEncoder()], + ['args', getAuthorizeCheckedWithSeedParamsEncoder()], ]), (value) => ({ ...value, @@ -109,7 +109,7 @@ export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU8Decoder()], - ['args', getAuthorizeCheckedWithSeedArgsDecoder()], + ['args', getAuthorizeCheckedWithSeedParamsDecoder()], ]); } diff --git a/clients/js/src/generated/instructions/authorizeWithSeed.ts b/clients/js/src/generated/instructions/authorizeWithSeed.ts index 809b0e76..1e57ca11 100644 --- a/clients/js/src/generated/instructions/authorizeWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeWithSeed.ts @@ -31,10 +31,10 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getAuthorizeWithSeedArgsDecoder, - getAuthorizeWithSeedArgsEncoder, - type AuthorizeWithSeedArgs, - type AuthorizeWithSeedArgsArgs, + getAuthorizeWithSeedParamsDecoder, + getAuthorizeWithSeedParamsEncoder, + type AuthorizeWithSeedParams, + type AuthorizeWithSeedParamsArgs, } from '../types'; export const AUTHORIZE_WITH_SEED_DISCRIMINATOR = 8; @@ -81,18 +81,18 @@ export type AuthorizeWithSeedInstruction< export type AuthorizeWithSeedInstructionData = { discriminator: number; - args: AuthorizeWithSeedArgs; + args: AuthorizeWithSeedParams; }; export type AuthorizeWithSeedInstructionDataArgs = { - args: AuthorizeWithSeedArgsArgs; + args: AuthorizeWithSeedParamsArgs; }; export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU8Encoder()], - ['args', getAuthorizeWithSeedArgsEncoder()], + ['args', getAuthorizeWithSeedParamsEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_WITH_SEED_DISCRIMINATOR }) ); @@ -101,7 +101,7 @@ export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU8Decoder()], - ['args', getAuthorizeWithSeedArgsDecoder()], + ['args', getAuthorizeWithSeedParamsDecoder()], ]); } diff --git a/clients/js/src/generated/instructions/setLockup.ts b/clients/js/src/generated/instructions/setLockup.ts index 10687a84..574532e7 100644 --- a/clients/js/src/generated/instructions/setLockup.ts +++ b/clients/js/src/generated/instructions/setLockup.ts @@ -30,10 +30,10 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getLockupArgsDecoder, - getLockupArgsEncoder, - type LockupArgs, - type LockupArgsArgs, + getLockupParamsDecoder, + getLockupParamsEncoder, + type LockupParams, + type LockupParamsArgs, } from '../types'; export const SET_LOCKUP_DISCRIMINATOR = 6; @@ -64,16 +64,16 @@ export type SetLockupInstruction< export type SetLockupInstructionData = { discriminator: number; - lockup: LockupArgs; + lockup: LockupParams; }; -export type SetLockupInstructionDataArgs = { lockup: LockupArgsArgs }; +export type SetLockupInstructionDataArgs = { lockup: LockupParamsArgs }; export function getSetLockupInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU8Encoder()], - ['lockup', getLockupArgsEncoder()], + ['lockup', getLockupParamsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_DISCRIMINATOR }) ); @@ -82,7 +82,7 @@ export function getSetLockupInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU8Decoder()], - ['lockup', getLockupArgsDecoder()], + ['lockup', getLockupParamsDecoder()], ]); } diff --git a/clients/js/src/generated/instructions/setLockupChecked.ts b/clients/js/src/generated/instructions/setLockupChecked.ts index 7ae30567..cf119206 100644 --- a/clients/js/src/generated/instructions/setLockupChecked.ts +++ b/clients/js/src/generated/instructions/setLockupChecked.ts @@ -30,10 +30,10 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getLockupCheckedArgsDecoder, - getLockupCheckedArgsEncoder, - type LockupCheckedArgs, - type LockupCheckedArgsArgs, + getLockupCheckedParamsDecoder, + getLockupCheckedParamsEncoder, + type LockupCheckedParams, + type LockupCheckedParamsArgs, } from '../types'; export const SET_LOCKUP_CHECKED_DISCRIMINATOR = 12; @@ -76,18 +76,18 @@ export type SetLockupCheckedInstruction< export type SetLockupCheckedInstructionData = { discriminator: number; - lockup: LockupCheckedArgs; + lockup: LockupCheckedParams; }; export type SetLockupCheckedInstructionDataArgs = { - lockup: LockupCheckedArgsArgs; + lockup: LockupCheckedParamsArgs; }; export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU8Encoder()], - ['lockup', getLockupCheckedArgsEncoder()], + ['lockup', getLockupCheckedParamsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_CHECKED_DISCRIMINATOR }) ); @@ -96,7 +96,7 @@ export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU8Decoder()], - ['lockup', getLockupCheckedArgsDecoder()], + ['lockup', getLockupCheckedParamsDecoder()], ]); } diff --git a/clients/js/src/generated/types/authorizeCheckedWithSeedArgs.ts b/clients/js/src/generated/types/authorizeCheckedWithSeedParams.ts similarity index 70% rename from clients/js/src/generated/types/authorizeCheckedWithSeedArgs.ts rename to clients/js/src/generated/types/authorizeCheckedWithSeedParams.ts index d34f08ce..2343ed80 100644 --- a/clients/js/src/generated/types/authorizeCheckedWithSeedArgs.ts +++ b/clients/js/src/generated/types/authorizeCheckedWithSeedParams.ts @@ -30,19 +30,19 @@ import { type StakeAuthorizeArgs, } from '.'; -export type AuthorizeCheckedWithSeedArgs = { +export type AuthorizeCheckedWithSeedParams = { stakeAuthorize: StakeAuthorize; authoritySeed: string; authorityOwner: Address; }; -export type AuthorizeCheckedWithSeedArgsArgs = { +export type AuthorizeCheckedWithSeedParamsArgs = { stakeAuthorize: StakeAuthorizeArgs; authoritySeed: string; authorityOwner: Address; }; -export function getAuthorizeCheckedWithSeedArgsEncoder(): Encoder { +export function getAuthorizeCheckedWithSeedParamsEncoder(): Encoder { return getStructEncoder([ ['stakeAuthorize', getStakeAuthorizeEncoder()], ['authoritySeed', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())], @@ -50,7 +50,7 @@ export function getAuthorizeCheckedWithSeedArgsEncoder(): Encoder { +export function getAuthorizeCheckedWithSeedParamsDecoder(): Decoder { return getStructDecoder([ ['stakeAuthorize', getStakeAuthorizeDecoder()], ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], @@ -58,12 +58,12 @@ export function getAuthorizeCheckedWithSeedArgsDecoder(): Decoder { return combineCodec( - getAuthorizeCheckedWithSeedArgsEncoder(), - getAuthorizeCheckedWithSeedArgsDecoder() + getAuthorizeCheckedWithSeedParamsEncoder(), + getAuthorizeCheckedWithSeedParamsDecoder() ); } diff --git a/clients/js/src/generated/types/authorizeWithSeedArgs.ts b/clients/js/src/generated/types/authorizeWithSeedParams.ts similarity index 76% rename from clients/js/src/generated/types/authorizeWithSeedArgs.ts rename to clients/js/src/generated/types/authorizeWithSeedParams.ts index 00ae10db..4e0f1209 100644 --- a/clients/js/src/generated/types/authorizeWithSeedArgs.ts +++ b/clients/js/src/generated/types/authorizeWithSeedParams.ts @@ -30,21 +30,21 @@ import { type StakeAuthorizeArgs, } from '.'; -export type AuthorizeWithSeedArgs = { +export type AuthorizeWithSeedParams = { newAuthorizedPubkey: Address; stakeAuthorize: StakeAuthorize; authoritySeed: string; authorityOwner: Address; }; -export type AuthorizeWithSeedArgsArgs = { +export type AuthorizeWithSeedParamsArgs = { newAuthorizedPubkey: Address; stakeAuthorize: StakeAuthorizeArgs; authoritySeed: string; authorityOwner: Address; }; -export function getAuthorizeWithSeedArgsEncoder(): Encoder { +export function getAuthorizeWithSeedParamsEncoder(): Encoder { return getStructEncoder([ ['newAuthorizedPubkey', getAddressEncoder()], ['stakeAuthorize', getStakeAuthorizeEncoder()], @@ -53,7 +53,7 @@ export function getAuthorizeWithSeedArgsEncoder(): Encoder { +export function getAuthorizeWithSeedParamsDecoder(): Decoder { return getStructDecoder([ ['newAuthorizedPubkey', getAddressDecoder()], ['stakeAuthorize', getStakeAuthorizeDecoder()], @@ -62,12 +62,12 @@ export function getAuthorizeWithSeedArgsDecoder(): Decoder { return combineCodec( - getAuthorizeWithSeedArgsEncoder(), - getAuthorizeWithSeedArgsDecoder() + getAuthorizeWithSeedParamsEncoder(), + getAuthorizeWithSeedParamsDecoder() ); } diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index 5bb460d0..1ada0996 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -6,14 +6,14 @@ * @see https://github.com/codama-idl/codama */ -export * from './authorizeCheckedWithSeedArgs'; +export * from './authorizeCheckedWithSeedParams'; export * from './authorized'; -export * from './authorizeWithSeedArgs'; +export * from './authorizeWithSeedParams'; export * from './delegation'; export * from './epoch'; export * from './lockup'; -export * from './lockupArgs'; -export * from './lockupCheckedArgs'; +export * from './lockupCheckedParams'; +export * from './lockupParams'; export * from './meta'; export * from './stake'; export * from './stakeAuthorize'; diff --git a/clients/js/src/generated/types/lockupCheckedArgs.ts b/clients/js/src/generated/types/lockupCheckedParams.ts similarity index 73% rename from clients/js/src/generated/types/lockupCheckedArgs.ts rename to clients/js/src/generated/types/lockupCheckedParams.ts index 29fbd844..8979ebc2 100644 --- a/clients/js/src/generated/types/lockupCheckedArgs.ts +++ b/clients/js/src/generated/types/lockupCheckedParams.ts @@ -29,36 +29,36 @@ import { type UnixTimestampArgs, } from '.'; -export type LockupCheckedArgs = { +export type LockupCheckedParams = { unixTimestamp: Option; epoch: Option; }; -export type LockupCheckedArgsArgs = { +export type LockupCheckedParamsArgs = { unixTimestamp: OptionOrNullable; epoch: OptionOrNullable; }; -export function getLockupCheckedArgsEncoder(): Encoder { +export function getLockupCheckedParamsEncoder(): Encoder { return getStructEncoder([ ['unixTimestamp', getOptionEncoder(getUnixTimestampEncoder())], ['epoch', getOptionEncoder(getEpochEncoder())], ]); } -export function getLockupCheckedArgsDecoder(): Decoder { +export function getLockupCheckedParamsDecoder(): Decoder { return getStructDecoder([ ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], ['epoch', getOptionDecoder(getEpochDecoder())], ]); } -export function getLockupCheckedArgsCodec(): Codec< - LockupCheckedArgsArgs, - LockupCheckedArgs +export function getLockupCheckedParamsCodec(): Codec< + LockupCheckedParamsArgs, + LockupCheckedParams > { return combineCodec( - getLockupCheckedArgsEncoder(), - getLockupCheckedArgsDecoder() + getLockupCheckedParamsEncoder(), + getLockupCheckedParamsDecoder() ); } diff --git a/clients/js/src/generated/types/lockupArgs.ts b/clients/js/src/generated/types/lockupParams.ts similarity index 79% rename from clients/js/src/generated/types/lockupArgs.ts rename to clients/js/src/generated/types/lockupParams.ts index f92bd1aa..5936cba9 100644 --- a/clients/js/src/generated/types/lockupArgs.ts +++ b/clients/js/src/generated/types/lockupParams.ts @@ -32,19 +32,19 @@ import { type UnixTimestampArgs, } from '.'; -export type LockupArgs = { +export type LockupParams = { unixTimestamp: Option; epoch: Option; custodian: Option
; }; -export type LockupArgsArgs = { +export type LockupParamsArgs = { unixTimestamp: OptionOrNullable; epoch: OptionOrNullable; custodian: OptionOrNullable
; }; -export function getLockupArgsEncoder(): Encoder { +export function getLockupParamsEncoder(): Encoder { return getStructEncoder([ ['unixTimestamp', getOptionEncoder(getUnixTimestampEncoder())], ['epoch', getOptionEncoder(getEpochEncoder())], @@ -52,7 +52,7 @@ export function getLockupArgsEncoder(): Encoder { ]); } -export function getLockupArgsDecoder(): Decoder { +export function getLockupParamsDecoder(): Decoder { return getStructDecoder([ ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], ['epoch', getOptionDecoder(getEpochDecoder())], @@ -60,6 +60,6 @@ export function getLockupArgsDecoder(): Decoder { ]); } -export function getLockupArgsCodec(): Codec { - return combineCodec(getLockupArgsEncoder(), getLockupArgsDecoder()); +export function getLockupParamsCodec(): Codec { + return combineCodec(getLockupParamsEncoder(), getLockupParamsDecoder()); } 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 c2e5c514..8f2ee2a6 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -6,7 +6,7 @@ //! use { - crate::generated::types::AuthorizeCheckedWithSeedArgs, + crate::generated::types::AuthorizeCheckedWithSeedParams, borsh::{BorshDeserialize, BorshSerialize}, }; @@ -93,7 +93,7 @@ impl Default for AuthorizeCheckedWithSeedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeCheckedWithSeedInstructionArgs { - pub args: AuthorizeCheckedWithSeedArgs, + pub args: AuthorizeCheckedWithSeedParams, } /// Instruction builder for `AuthorizeCheckedWithSeed`. @@ -112,7 +112,7 @@ pub struct AuthorizeCheckedWithSeedBuilder { clock_sysvar: Option, new_authority: Option, lockup_authority: Option, - args: Option, + args: Option, __remaining_accounts: Vec, } @@ -150,7 +150,7 @@ impl AuthorizeCheckedWithSeedBuilder { self } #[inline(always)] - pub fn args(&mut self, args: AuthorizeCheckedWithSeedArgs) -> &mut Self { + pub fn args(&mut self, args: AuthorizeCheckedWithSeedParams) -> &mut Self { self.args = Some(args); self } @@ -396,7 +396,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn args(&mut self, args: AuthorizeCheckedWithSeedArgs) -> &mut Self { + pub fn args(&mut self, args: AuthorizeCheckedWithSeedParams) -> &mut Self { self.instruction.args = Some(args); self } @@ -482,7 +482,7 @@ struct AuthorizeCheckedWithSeedCpiBuilderInstruction<'a, 'b> { 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>>, - args: Option, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index 1916ac93..f7a08069 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -6,7 +6,7 @@ //! use { - crate::generated::types::AuthorizeWithSeedArgs, + crate::generated::types::AuthorizeWithSeedParams, borsh::{BorshDeserialize, BorshSerialize}, }; @@ -87,7 +87,7 @@ impl Default for AuthorizeWithSeedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeWithSeedInstructionArgs { - pub args: AuthorizeWithSeedArgs, + pub args: AuthorizeWithSeedParams, } /// Instruction builder for `AuthorizeWithSeed`. @@ -104,7 +104,7 @@ pub struct AuthorizeWithSeedBuilder { authority_base: Option, clock_sysvar: Option, lockup_authority: Option, - args: Option, + args: Option, __remaining_accounts: Vec, } @@ -137,7 +137,7 @@ impl AuthorizeWithSeedBuilder { self } #[inline(always)] - pub fn args(&mut self, args: AuthorizeWithSeedArgs) -> &mut Self { + pub fn args(&mut self, args: AuthorizeWithSeedParams) -> &mut Self { self.args = Some(args); self } @@ -362,7 +362,7 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn args(&mut self, args: AuthorizeWithSeedArgs) -> &mut Self { + pub fn args(&mut self, args: AuthorizeWithSeedParams) -> &mut Self { self.instruction.args = Some(args); self } @@ -442,7 +442,7 @@ struct AuthorizeWithSeedCpiBuilderInstruction<'a, 'b> { authority_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>>, - args: Option, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/set_lockup.rs b/clients/rust/src/generated/instructions/set_lockup.rs index 8a163e75..33947e8d 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -6,7 +6,7 @@ //! use { - crate::generated::types::LockupArgs, + crate::generated::types::LockupParams, borsh::{BorshDeserialize, BorshSerialize}, }; @@ -73,7 +73,7 @@ impl Default for SetLockupInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupInstructionArgs { - pub lockup: LockupArgs, + pub lockup: LockupParams, } /// Instruction builder for `SetLockup`. @@ -86,7 +86,7 @@ pub struct SetLockupInstructionArgs { pub struct SetLockupBuilder { stake: Option, authority: Option, - lockup: Option, + lockup: Option, __remaining_accounts: Vec, } @@ -105,7 +105,7 @@ impl SetLockupBuilder { self } #[inline(always)] - pub fn lockup(&mut self, lockup: LockupArgs) -> &mut Self { + pub fn lockup(&mut self, lockup: LockupParams) -> &mut Self { self.lockup = Some(lockup); self } @@ -283,7 +283,7 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn lockup(&mut self, lockup: LockupArgs) -> &mut Self { + pub fn lockup(&mut self, lockup: LockupParams) -> &mut Self { self.instruction.lockup = Some(lockup); self } @@ -351,7 +351,7 @@ 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>>, - lockup: Option, + lockup: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/set_lockup_checked.rs b/clients/rust/src/generated/instructions/set_lockup_checked.rs index 10ecbe92..3b95f966 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -6,7 +6,7 @@ //! use { - crate::generated::types::LockupCheckedArgs, + crate::generated::types::LockupCheckedParams, borsh::{BorshDeserialize, BorshSerialize}, }; @@ -81,7 +81,7 @@ impl Default for SetLockupCheckedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupCheckedInstructionArgs { - pub lockup: LockupCheckedArgs, + pub lockup: LockupCheckedParams, } /// Instruction builder for `SetLockupChecked`. @@ -96,7 +96,7 @@ pub struct SetLockupCheckedBuilder { stake: Option, authority: Option, new_lockup_authority: Option, - lockup: Option, + lockup: Option, __remaining_accounts: Vec, } @@ -124,7 +124,7 @@ impl SetLockupCheckedBuilder { self } #[inline(always)] - pub fn lockup(&mut self, lockup: LockupCheckedArgs) -> &mut Self { + pub fn lockup(&mut self, lockup: LockupCheckedParams) -> &mut Self { self.lockup = Some(lockup); self } @@ -328,7 +328,7 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn lockup(&mut self, lockup: LockupCheckedArgs) -> &mut Self { + pub fn lockup(&mut self, lockup: LockupCheckedParams) -> &mut Self { self.instruction.lockup = Some(lockup); self } @@ -399,7 +399,7 @@ struct SetLockupCheckedCpiBuilderInstruction<'a, 'b> { stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, new_lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - lockup: Option, + lockup: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/types/authorize_checked_with_seed_args.rs b/clients/rust/src/generated/types/authorize_checked_with_seed_params.rs similarity index 94% rename from clients/rust/src/generated/types/authorize_checked_with_seed_args.rs rename to clients/rust/src/generated/types/authorize_checked_with_seed_params.rs index 463eb76c..70a65233 100644 --- a/clients/rust/src/generated/types/authorize_checked_with_seed_args.rs +++ b/clients/rust/src/generated/types/authorize_checked_with_seed_params.rs @@ -13,7 +13,7 @@ use { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeCheckedWithSeedArgs { +pub struct AuthorizeCheckedWithSeedParams { pub stake_authorize: StakeAuthorize, pub authority_seed: String, #[cfg_attr( diff --git a/clients/rust/src/generated/types/authorize_with_seed_args.rs b/clients/rust/src/generated/types/authorize_with_seed_params.rs similarity index 95% rename from clients/rust/src/generated/types/authorize_with_seed_args.rs rename to clients/rust/src/generated/types/authorize_with_seed_params.rs index 9ead65a9..1d1e2a2e 100644 --- a/clients/rust/src/generated/types/authorize_with_seed_args.rs +++ b/clients/rust/src/generated/types/authorize_with_seed_params.rs @@ -13,7 +13,7 @@ use { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeWithSeedArgs { +pub struct AuthorizeWithSeedParams { #[cfg_attr( feature = "serde", serde(with = "serde_with::As::") diff --git a/clients/rust/src/generated/types/lockup_checked_args.rs b/clients/rust/src/generated/types/lockup_checked_params.rs similarity index 94% rename from clients/rust/src/generated/types/lockup_checked_args.rs rename to clients/rust/src/generated/types/lockup_checked_params.rs index 8855f33d..6bf3cf6d 100644 --- a/clients/rust/src/generated/types/lockup_checked_args.rs +++ b/clients/rust/src/generated/types/lockup_checked_params.rs @@ -12,7 +12,7 @@ use { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockupCheckedArgs { +pub struct LockupCheckedParams { pub unix_timestamp: Option, pub epoch: Option, } diff --git a/clients/rust/src/generated/types/lockup_args.rs b/clients/rust/src/generated/types/lockup_params.rs similarity index 96% rename from clients/rust/src/generated/types/lockup_args.rs rename to clients/rust/src/generated/types/lockup_params.rs index 761019ea..c1ec7850 100644 --- a/clients/rust/src/generated/types/lockup_args.rs +++ b/clients/rust/src/generated/types/lockup_params.rs @@ -13,7 +13,7 @@ use { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockupArgs { +pub struct LockupParams { pub unix_timestamp: Option, pub epoch: Option, pub custodian: Option, diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index 9e476ce3..bf81f076 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -5,14 +5,14 @@ //! //! -pub(crate) mod r#authorize_checked_with_seed_args; -pub(crate) mod r#authorize_with_seed_args; +pub(crate) mod r#authorize_checked_with_seed_params; +pub(crate) mod r#authorize_with_seed_params; pub(crate) mod r#authorized; pub(crate) mod r#delegation; pub(crate) mod r#epoch; pub(crate) mod r#lockup; -pub(crate) mod r#lockup_args; -pub(crate) mod r#lockup_checked_args; +pub(crate) mod r#lockup_checked_params; +pub(crate) mod r#lockup_params; pub(crate) mod r#meta; pub(crate) mod r#stake; pub(crate) mod r#stake_authorize; @@ -22,8 +22,8 @@ pub(crate) mod r#stake_state_v2; pub(crate) mod r#unix_timestamp; pub use self::{ - r#authorize_checked_with_seed_args::*, r#authorize_with_seed_args::*, r#authorized::*, - r#delegation::*, r#epoch::*, r#lockup::*, r#lockup_args::*, r#lockup_checked_args::*, + r#authorize_checked_with_seed_params::*, r#authorize_with_seed_params::*, r#authorized::*, + r#delegation::*, r#epoch::*, r#lockup::*, r#lockup_checked_params::*, r#lockup_params::*, r#meta::*, r#stake::*, r#stake_authorize::*, r#stake_flags::*, r#stake_state::*, r#stake_state_v2::*, r#unix_timestamp::*, }; diff --git a/interface/idl.json b/interface/idl.json index ee8a6ecc..2dfe1919 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -6,7 +6,7 @@ "definedTypes": [ { "kind": "definedTypeNode", - "name": "lockupArgs", + "name": "lockupParams", "type": { "fields": [ { @@ -62,7 +62,7 @@ }, { "kind": "definedTypeNode", - "name": "lockupCheckedArgs", + "name": "lockupCheckedParams", "type": { "fields": [ { @@ -103,7 +103,7 @@ }, { "kind": "definedTypeNode", - "name": "authorizeWithSeedArgs", + "name": "authorizeWithSeedParams", "type": { "fields": [ { @@ -150,7 +150,7 @@ }, { "kind": "definedTypeNode", - "name": "authorizeCheckedWithSeedArgs", + "name": "authorizeCheckedWithSeedParams", "type": { "fields": [ { diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index d0428c3b..97a0f39f 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -355,6 +355,7 @@ pub enum StakeInstruction { } #[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] +#[codama(name = "lockupParams")] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) @@ -366,6 +367,7 @@ pub struct LockupArgs { } #[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] +#[codama(name = "lockupCheckedParams")] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) @@ -376,6 +378,7 @@ pub struct LockupCheckedArgs { } #[derive(CodamaType, Debug, PartialEq, Eq, Clone)] +#[codama(name = "authorizeWithSeedParams")] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) @@ -388,6 +391,7 @@ pub struct AuthorizeWithSeedArgs { } #[derive(CodamaType, Debug, PartialEq, Eq, Clone)] +#[codama(name = "authorizeCheckedWithSeedParams")] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) diff --git a/scripts/generate-clients.mts b/scripts/generate-clients.mts index da2c673f..68bbb855 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -18,6 +18,16 @@ codama.update( }) ); +// 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' }, + }) +); + // Add type aliases for semantic external types codama.update( c.bottomUpTransformerVisitor([ From 066e986497112c941ce0660b057826c62f77973c Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Fri, 14 Nov 2025 22:26:03 +0000 Subject: [PATCH 05/27] restore omitted u32 disc casts --- clients/js/src/generated/types/stakeState.ts | 56 +++++++------ .../js/src/generated/types/stakeStateV2.ts | 84 ++++++++++--------- scripts/generate-clients.mts | 22 +++++ 3 files changed, 100 insertions(+), 62 deletions(-) diff --git a/clients/js/src/generated/types/stakeState.ts b/clients/js/src/generated/types/stakeState.ts index f3f17eb8..27cacc85 100644 --- a/clients/js/src/generated/types/stakeState.ts +++ b/clients/js/src/generated/types/stakeState.ts @@ -14,6 +14,8 @@ import { getStructEncoder, getTupleDecoder, getTupleEncoder, + getU32Decoder, + getU32Encoder, getUnitDecoder, getUnitEncoder, type Codec, @@ -46,37 +48,43 @@ export type StakeStateArgs = | { __kind: 'RewardsPool' }; export function getStakeStateEncoder(): Encoder { - return getDiscriminatedUnionEncoder([ - ['Uninitialized', getUnitEncoder()], + return getDiscriminatedUnionEncoder( [ - 'Initialized', - getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), + ['Uninitialized', getUnitEncoder()], + [ + 'Initialized', + getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), + ], + [ + 'Stake', + getStructEncoder([ + ['fields', getTupleEncoder([getMetaEncoder(), getStakeEncoder()])], + ]), + ], + ['RewardsPool', getUnitEncoder()], ], - [ - 'Stake', - getStructEncoder([ - ['fields', getTupleEncoder([getMetaEncoder(), getStakeEncoder()])], - ]), - ], - ['RewardsPool', getUnitEncoder()], - ]); + { size: getU32Encoder() } + ); } export function getStakeStateDecoder(): Decoder { - return getDiscriminatedUnionDecoder([ - ['Uninitialized', getUnitDecoder()], - [ - 'Initialized', - getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), - ], + return getDiscriminatedUnionDecoder( [ - 'Stake', - getStructDecoder([ - ['fields', getTupleDecoder([getMetaDecoder(), getStakeDecoder()])], - ]), + ['Uninitialized', getUnitDecoder()], + [ + 'Initialized', + getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), + ], + [ + 'Stake', + getStructDecoder([ + ['fields', getTupleDecoder([getMetaDecoder(), getStakeDecoder()])], + ]), + ], + ['RewardsPool', getUnitDecoder()], ], - ['RewardsPool', getUnitDecoder()], - ]); + { size: getU32Decoder() } + ); } export function getStakeStateCodec(): Codec { diff --git a/clients/js/src/generated/types/stakeStateV2.ts b/clients/js/src/generated/types/stakeStateV2.ts index 078ba201..09aca70f 100644 --- a/clients/js/src/generated/types/stakeStateV2.ts +++ b/clients/js/src/generated/types/stakeStateV2.ts @@ -14,6 +14,8 @@ import { getStructEncoder, getTupleDecoder, getTupleEncoder, + getU32Decoder, + getU32Encoder, getUnitDecoder, getUnitEncoder, type Codec, @@ -50,51 +52,57 @@ export type StakeStateV2Args = | { __kind: 'RewardsPool' }; export function getStakeStateV2Encoder(): Encoder { - return getDiscriminatedUnionEncoder([ - ['Uninitialized', getUnitEncoder()], + return getDiscriminatedUnionEncoder( [ - 'Initialized', - getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), + ['Uninitialized', getUnitEncoder()], + [ + 'Initialized', + getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), + ], + [ + 'Stake', + getStructEncoder([ + [ + 'fields', + getTupleEncoder([ + getMetaEncoder(), + getStakeEncoder(), + getStakeFlagsEncoder(), + ]), + ], + ]), + ], + ['RewardsPool', getUnitEncoder()], ], - [ - 'Stake', - getStructEncoder([ - [ - 'fields', - getTupleEncoder([ - getMetaEncoder(), - getStakeEncoder(), - getStakeFlagsEncoder(), - ]), - ], - ]), - ], - ['RewardsPool', getUnitEncoder()], - ]); + { size: getU32Encoder() } + ); } export function getStakeStateV2Decoder(): Decoder { - return getDiscriminatedUnionDecoder([ - ['Uninitialized', getUnitDecoder()], - [ - 'Initialized', - getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), - ], + return getDiscriminatedUnionDecoder( [ - 'Stake', - getStructDecoder([ - [ - 'fields', - getTupleDecoder([ - getMetaDecoder(), - getStakeDecoder(), - getStakeFlagsDecoder(), - ]), - ], - ]), + ['Uninitialized', getUnitDecoder()], + [ + 'Initialized', + getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), + ], + [ + 'Stake', + getStructDecoder([ + [ + 'fields', + getTupleDecoder([ + getMetaDecoder(), + getStakeDecoder(), + getStakeFlagsDecoder(), + ]), + ], + ]), + ], + ['RewardsPool', getUnitDecoder()], ], - ['RewardsPool', getUnitDecoder()], - ]); + { size: getU32Decoder() } + ); } export function getStakeStateV2Codec(): Codec { diff --git a/scripts/generate-clients.mts b/scripts/generate-clients.mts index 68bbb855..388861e7 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -89,6 +89,28 @@ codama.update( return { ...node, optionalAccountStrategy: 'omitted' }; }, }, + { + // enum discriminator -> u32 + select: '[definedTypeNode]stakeState.[enumTypeNode]', + transform: (node) => { + c.assertIsNode(node, 'enumTypeNode'); + return { + ...node, + size: c.numberTypeNode('u32'), + }; + }, + }, + { + // enum discriminator -> u32 + select: '[definedTypeNode]stakeStateV2.[enumTypeNode]', + transform: (node) => { + c.assertIsNode(node, 'enumTypeNode'); + return { + ...node, + size: c.numberTypeNode('u32'), + }; + }, + }, ]) ); From 0e5cbefbb6937eb9dce7101445b26ba34b2344d0 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Fri, 14 Nov 2025 22:33:47 +0000 Subject: [PATCH 06/27] instruction u8->u32 transformer --- .../src/generated/instructions/authorize.ts | 10 ++--- .../instructions/authorizeChecked.ts | 10 ++--- .../instructions/authorizeCheckedWithSeed.ts | 10 ++--- .../instructions/authorizeWithSeed.ts | 10 ++--- .../src/generated/instructions/deactivate.ts | 10 ++--- .../instructions/deactivateDelinquent.ts | 10 ++--- .../generated/instructions/delegateStake.ts | 10 ++--- .../instructions/getMinimumDelegation.ts | 10 ++--- .../src/generated/instructions/initialize.ts | 10 ++--- .../instructions/initializeChecked.ts | 10 ++--- .../js/src/generated/instructions/merge.ts | 10 ++--- .../generated/instructions/moveLamports.ts | 10 ++--- .../src/generated/instructions/moveStake.ts | 10 ++--- .../src/generated/instructions/redelegate.ts | 10 ++--- .../src/generated/instructions/setLockup.ts | 10 ++--- .../instructions/setLockupChecked.ts | 10 ++--- .../js/src/generated/instructions/split.ts | 10 ++--- .../js/src/generated/instructions/withdraw.ts | 10 ++--- clients/js/src/generated/programs/stake.ts | 38 +++++++++---------- .../src/generated/instructions/authorize.rs | 2 +- .../instructions/authorize_checked.rs | 2 +- .../authorize_checked_with_seed.rs | 2 +- .../instructions/authorize_with_seed.rs | 2 +- .../src/generated/instructions/deactivate.rs | 2 +- .../instructions/deactivate_delinquent.rs | 2 +- .../generated/instructions/delegate_stake.rs | 2 +- .../instructions/get_minimum_delegation.rs | 2 +- .../src/generated/instructions/initialize.rs | 2 +- .../instructions/initialize_checked.rs | 2 +- .../rust/src/generated/instructions/merge.rs | 2 +- .../generated/instructions/move_lamports.rs | 2 +- .../src/generated/instructions/move_stake.rs | 2 +- .../src/generated/instructions/redelegate.rs | 2 +- .../src/generated/instructions/set_lockup.rs | 2 +- .../instructions/set_lockup_checked.rs | 2 +- .../rust/src/generated/instructions/split.rs | 2 +- .../src/generated/instructions/withdraw.rs | 2 +- scripts/generate-clients.mts | 12 +++++- 38 files changed, 137 insertions(+), 129 deletions(-) diff --git a/clients/js/src/generated/instructions/authorize.ts b/clients/js/src/generated/instructions/authorize.ts index f73c2f59..e1a14a42 100644 --- a/clients/js/src/generated/instructions/authorize.ts +++ b/clients/js/src/generated/instructions/authorize.ts @@ -12,8 +12,8 @@ import { getAddressEncoder, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -42,7 +42,7 @@ import { export const AUTHORIZE_DISCRIMINATOR = 1; export function getAuthorizeDiscriminatorBytes() { - return getU8Encoder().encode(AUTHORIZE_DISCRIMINATOR); + return getU32Encoder().encode(AUTHORIZE_DISCRIMINATOR); } export type AuthorizeInstruction< @@ -95,7 +95,7 @@ export type AuthorizeInstructionDataArgs = { export function getAuthorizeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['pubkey', getAddressEncoder()], ['stakeAuthorize', getStakeAuthorizeEncoder()], ]), @@ -105,7 +105,7 @@ export function getAuthorizeInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['pubkey', getAddressDecoder()], ['stakeAuthorize', getStakeAuthorizeDecoder()], ]); diff --git a/clients/js/src/generated/instructions/authorizeChecked.ts b/clients/js/src/generated/instructions/authorizeChecked.ts index 36d289e4..8db194e0 100644 --- a/clients/js/src/generated/instructions/authorizeChecked.ts +++ b/clients/js/src/generated/instructions/authorizeChecked.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -40,7 +40,7 @@ import { export const AUTHORIZE_CHECKED_DISCRIMINATOR = 10; export function getAuthorizeCheckedDiscriminatorBytes() { - return getU8Encoder().encode(AUTHORIZE_CHECKED_DISCRIMINATOR); + return getU32Encoder().encode(AUTHORIZE_CHECKED_DISCRIMINATOR); } export type AuthorizeCheckedInstruction< @@ -96,7 +96,7 @@ export type AuthorizeCheckedInstructionDataArgs = { export function getAuthorizeCheckedInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['stakeAuthorize', getStakeAuthorizeEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_CHECKED_DISCRIMINATOR }) @@ -105,7 +105,7 @@ export function getAuthorizeCheckedInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['stakeAuthorize', getStakeAuthorizeDecoder()], ]); } diff --git a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts index 5137cb87..6d94a408 100644 --- a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -40,7 +40,7 @@ import { export const AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR = 11; export function getAuthorizeCheckedWithSeedDiscriminatorBytes() { - return getU8Encoder().encode(AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR); + return getU32Encoder().encode(AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR); } export type AuthorizeCheckedWithSeedInstruction< @@ -96,7 +96,7 @@ export type AuthorizeCheckedWithSeedInstructionDataArgs = { export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['args', getAuthorizeCheckedWithSeedParamsEncoder()], ]), (value) => ({ @@ -108,7 +108,7 @@ export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['args', getAuthorizeCheckedWithSeedParamsDecoder()], ]); } diff --git a/clients/js/src/generated/instructions/authorizeWithSeed.ts b/clients/js/src/generated/instructions/authorizeWithSeed.ts index 1e57ca11..4d7a4959 100644 --- a/clients/js/src/generated/instructions/authorizeWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeWithSeed.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -40,7 +40,7 @@ import { export const AUTHORIZE_WITH_SEED_DISCRIMINATOR = 8; export function getAuthorizeWithSeedDiscriminatorBytes() { - return getU8Encoder().encode(AUTHORIZE_WITH_SEED_DISCRIMINATOR); + return getU32Encoder().encode(AUTHORIZE_WITH_SEED_DISCRIMINATOR); } export type AuthorizeWithSeedInstruction< @@ -91,7 +91,7 @@ export type AuthorizeWithSeedInstructionDataArgs = { export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['args', getAuthorizeWithSeedParamsEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_WITH_SEED_DISCRIMINATOR }) @@ -100,7 +100,7 @@ export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['args', getAuthorizeWithSeedParamsDecoder()], ]); } diff --git a/clients/js/src/generated/instructions/deactivate.ts b/clients/js/src/generated/instructions/deactivate.ts index 1b9a3d01..b7064b1d 100644 --- a/clients/js/src/generated/instructions/deactivate.ts +++ b/clients/js/src/generated/instructions/deactivate.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -34,7 +34,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const DEACTIVATE_DISCRIMINATOR = 5; export function getDeactivateDiscriminatorBytes() { - return getU8Encoder().encode(DEACTIVATE_DISCRIMINATOR); + return getU32Encoder().encode(DEACTIVATE_DISCRIMINATOR); } export type DeactivateInstruction< @@ -67,13 +67,13 @@ export type DeactivateInstructionDataArgs = {}; export function getDeactivateInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU8Encoder()]]), + getStructEncoder([['discriminator', getU32Encoder()]]), (value) => ({ ...value, discriminator: DEACTIVATE_DISCRIMINATOR }) ); } export function getDeactivateInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU8Decoder()]]); + return getStructDecoder([['discriminator', getU32Decoder()]]); } export function getDeactivateInstructionDataCodec(): FixedSizeCodec< diff --git a/clients/js/src/generated/instructions/deactivateDelinquent.ts b/clients/js/src/generated/instructions/deactivateDelinquent.ts index 328bfc2b..5ff247a5 100644 --- a/clients/js/src/generated/instructions/deactivateDelinquent.ts +++ b/clients/js/src/generated/instructions/deactivateDelinquent.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type Address, @@ -31,7 +31,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const DEACTIVATE_DELINQUENT_DISCRIMINATOR = 14; export function getDeactivateDelinquentDiscriminatorBytes() { - return getU8Encoder().encode(DEACTIVATE_DELINQUENT_DISCRIMINATOR); + return getU32Encoder().encode(DEACTIVATE_DELINQUENT_DISCRIMINATOR); } export type DeactivateDelinquentInstruction< @@ -63,7 +63,7 @@ export type DeactivateDelinquentInstructionDataArgs = {}; export function getDeactivateDelinquentInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU8Encoder()]]), + getStructEncoder([['discriminator', getU32Encoder()]]), (value) => ({ ...value, discriminator: DEACTIVATE_DELINQUENT_DISCRIMINATOR, @@ -72,7 +72,7 @@ export function getDeactivateDelinquentInstructionDataEncoder(): FixedSizeEncode } export function getDeactivateDelinquentInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU8Decoder()]]); + return getStructDecoder([['discriminator', getU32Decoder()]]); } export function getDeactivateDelinquentInstructionDataCodec(): FixedSizeCodec< diff --git a/clients/js/src/generated/instructions/delegateStake.ts b/clients/js/src/generated/instructions/delegateStake.ts index 85695b27..9560c145 100644 --- a/clients/js/src/generated/instructions/delegateStake.ts +++ b/clients/js/src/generated/instructions/delegateStake.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -34,7 +34,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const DELEGATE_STAKE_DISCRIMINATOR = 2; export function getDelegateStakeDiscriminatorBytes() { - return getU8Encoder().encode(DELEGATE_STAKE_DISCRIMINATOR); + return getU32Encoder().encode(DELEGATE_STAKE_DISCRIMINATOR); } export type DelegateStakeInstruction< @@ -79,13 +79,13 @@ export type DelegateStakeInstructionDataArgs = {}; export function getDelegateStakeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU8Encoder()]]), + getStructEncoder([['discriminator', getU32Encoder()]]), (value) => ({ ...value, discriminator: DELEGATE_STAKE_DISCRIMINATOR }) ); } export function getDelegateStakeInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU8Decoder()]]); + return getStructDecoder([['discriminator', getU32Decoder()]]); } export function getDelegateStakeInstructionDataCodec(): FixedSizeCodec< diff --git a/clients/js/src/generated/instructions/getMinimumDelegation.ts b/clients/js/src/generated/instructions/getMinimumDelegation.ts index b7c4e3e4..6e1a2f5a 100644 --- a/clients/js/src/generated/instructions/getMinimumDelegation.ts +++ b/clients/js/src/generated/instructions/getMinimumDelegation.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type Address, @@ -28,7 +28,7 @@ import { STAKE_PROGRAM_ADDRESS } from '../programs'; export const GET_MINIMUM_DELEGATION_DISCRIMINATOR = 13; export function getGetMinimumDelegationDiscriminatorBytes() { - return getU8Encoder().encode(GET_MINIMUM_DELEGATION_DISCRIMINATOR); + return getU32Encoder().encode(GET_MINIMUM_DELEGATION_DISCRIMINATOR); } export type GetMinimumDelegationInstruction< @@ -44,7 +44,7 @@ export type GetMinimumDelegationInstructionDataArgs = {}; export function getGetMinimumDelegationInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU8Encoder()]]), + getStructEncoder([['discriminator', getU32Encoder()]]), (value) => ({ ...value, discriminator: GET_MINIMUM_DELEGATION_DISCRIMINATOR, @@ -53,7 +53,7 @@ export function getGetMinimumDelegationInstructionDataEncoder(): FixedSizeEncode } export function getGetMinimumDelegationInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU8Decoder()]]); + return getStructDecoder([['discriminator', getU32Decoder()]]); } export function getGetMinimumDelegationInstructionDataCodec(): FixedSizeCodec< diff --git a/clients/js/src/generated/instructions/initialize.ts b/clients/js/src/generated/instructions/initialize.ts index c46e285b..2808eec7 100644 --- a/clients/js/src/generated/instructions/initialize.ts +++ b/clients/js/src/generated/instructions/initialize.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type Address, @@ -41,7 +41,7 @@ import { export const INITIALIZE_DISCRIMINATOR = 0; export function getInitializeDiscriminatorBytes() { - return getU8Encoder().encode(INITIALIZE_DISCRIMINATOR); + return getU32Encoder().encode(INITIALIZE_DISCRIMINATOR); } export type InitializeInstruction< @@ -77,7 +77,7 @@ export type InitializeInstructionDataArgs = { export function getInitializeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['authorized', getAuthorizedEncoder()], ['lockup', getLockupEncoder()], ]), @@ -87,7 +87,7 @@ export function getInitializeInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['authorized', getAuthorizedDecoder()], ['lockup', getLockupDecoder()], ]); diff --git a/clients/js/src/generated/instructions/initializeChecked.ts b/clients/js/src/generated/instructions/initializeChecked.ts index fc2c95c8..7ee23f0e 100644 --- a/clients/js/src/generated/instructions/initializeChecked.ts +++ b/clients/js/src/generated/instructions/initializeChecked.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -34,7 +34,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const INITIALIZE_CHECKED_DISCRIMINATOR = 9; export function getInitializeCheckedDiscriminatorBytes() { - return getU8Encoder().encode(INITIALIZE_CHECKED_DISCRIMINATOR); + return getU32Encoder().encode(INITIALIZE_CHECKED_DISCRIMINATOR); } export type InitializeCheckedInstruction< @@ -71,13 +71,13 @@ export type InitializeCheckedInstructionDataArgs = {}; export function getInitializeCheckedInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU8Encoder()]]), + getStructEncoder([['discriminator', getU32Encoder()]]), (value) => ({ ...value, discriminator: INITIALIZE_CHECKED_DISCRIMINATOR }) ); } export function getInitializeCheckedInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU8Decoder()]]); + return getStructDecoder([['discriminator', getU32Decoder()]]); } export function getInitializeCheckedInstructionDataCodec(): FixedSizeCodec< diff --git a/clients/js/src/generated/instructions/merge.ts b/clients/js/src/generated/instructions/merge.ts index e68d9ac2..f42600e9 100644 --- a/clients/js/src/generated/instructions/merge.ts +++ b/clients/js/src/generated/instructions/merge.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -34,7 +34,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const MERGE_DISCRIMINATOR = 7; export function getMergeDiscriminatorBytes() { - return getU8Encoder().encode(MERGE_DISCRIMINATOR); + return getU32Encoder().encode(MERGE_DISCRIMINATOR); } export type MergeInstruction< @@ -75,13 +75,13 @@ export type MergeInstructionDataArgs = {}; export function getMergeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU8Encoder()]]), + getStructEncoder([['discriminator', getU32Encoder()]]), (value) => ({ ...value, discriminator: MERGE_DISCRIMINATOR }) ); } export function getMergeInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU8Decoder()]]); + return getStructDecoder([['discriminator', getU32Decoder()]]); } export function getMergeInstructionDataCodec(): FixedSizeCodec< diff --git a/clients/js/src/generated/instructions/moveLamports.ts b/clients/js/src/generated/instructions/moveLamports.ts index 8c9805c9..29d2348b 100644 --- a/clients/js/src/generated/instructions/moveLamports.ts +++ b/clients/js/src/generated/instructions/moveLamports.ts @@ -10,10 +10,10 @@ import { combineCodec, getStructDecoder, getStructEncoder, + getU32Decoder, + getU32Encoder, getU64Decoder, getU64Encoder, - getU8Decoder, - getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -35,7 +35,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const MOVE_LAMPORTS_DISCRIMINATOR = 17; export function getMoveLamportsDiscriminatorBytes() { - return getU8Encoder().encode(MOVE_LAMPORTS_DISCRIMINATOR); + return getU32Encoder().encode(MOVE_LAMPORTS_DISCRIMINATOR); } export type MoveLamportsInstruction< @@ -72,7 +72,7 @@ export type MoveLamportsInstructionDataArgs = { lamports: number | bigint }; export function getMoveLamportsInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: MOVE_LAMPORTS_DISCRIMINATOR }) @@ -81,7 +81,7 @@ export function getMoveLamportsInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['lamports', getU64Decoder()], ]); } diff --git a/clients/js/src/generated/instructions/moveStake.ts b/clients/js/src/generated/instructions/moveStake.ts index e7891b77..fdf2d6b0 100644 --- a/clients/js/src/generated/instructions/moveStake.ts +++ b/clients/js/src/generated/instructions/moveStake.ts @@ -10,10 +10,10 @@ import { combineCodec, getStructDecoder, getStructEncoder, + getU32Decoder, + getU32Encoder, getU64Decoder, getU64Encoder, - getU8Decoder, - getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -35,7 +35,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const MOVE_STAKE_DISCRIMINATOR = 16; export function getMoveStakeDiscriminatorBytes() { - return getU8Encoder().encode(MOVE_STAKE_DISCRIMINATOR); + return getU32Encoder().encode(MOVE_STAKE_DISCRIMINATOR); } export type MoveStakeInstruction< @@ -72,7 +72,7 @@ export type MoveStakeInstructionDataArgs = { lamports: number | bigint }; export function getMoveStakeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: MOVE_STAKE_DISCRIMINATOR }) @@ -81,7 +81,7 @@ export function getMoveStakeInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['lamports', getU64Decoder()], ]); } diff --git a/clients/js/src/generated/instructions/redelegate.ts b/clients/js/src/generated/instructions/redelegate.ts index de51634a..42152166 100644 --- a/clients/js/src/generated/instructions/redelegate.ts +++ b/clients/js/src/generated/instructions/redelegate.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type Address, @@ -28,7 +28,7 @@ import { STAKE_PROGRAM_ADDRESS } from '../programs'; export const REDELEGATE_DISCRIMINATOR = 15; export function getRedelegateDiscriminatorBytes() { - return getU8Encoder().encode(REDELEGATE_DISCRIMINATOR); + return getU32Encoder().encode(REDELEGATE_DISCRIMINATOR); } export type RedelegateInstruction< @@ -44,13 +44,13 @@ export type RedelegateInstructionDataArgs = {}; export function getRedelegateInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( - getStructEncoder([['discriminator', getU8Encoder()]]), + getStructEncoder([['discriminator', getU32Encoder()]]), (value) => ({ ...value, discriminator: REDELEGATE_DISCRIMINATOR }) ); } export function getRedelegateInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU8Decoder()]]); + return getStructDecoder([['discriminator', getU32Decoder()]]); } export function getRedelegateInstructionDataCodec(): FixedSizeCodec< diff --git a/clients/js/src/generated/instructions/setLockup.ts b/clients/js/src/generated/instructions/setLockup.ts index 574532e7..1eca28de 100644 --- a/clients/js/src/generated/instructions/setLockup.ts +++ b/clients/js/src/generated/instructions/setLockup.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -39,7 +39,7 @@ import { export const SET_LOCKUP_DISCRIMINATOR = 6; export function getSetLockupDiscriminatorBytes() { - return getU8Encoder().encode(SET_LOCKUP_DISCRIMINATOR); + return getU32Encoder().encode(SET_LOCKUP_DISCRIMINATOR); } export type SetLockupInstruction< @@ -72,7 +72,7 @@ export type SetLockupInstructionDataArgs = { lockup: LockupParamsArgs }; export function getSetLockupInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['lockup', getLockupParamsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_DISCRIMINATOR }) @@ -81,7 +81,7 @@ export function getSetLockupInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['lockup', getLockupParamsDecoder()], ]); } diff --git a/clients/js/src/generated/instructions/setLockupChecked.ts b/clients/js/src/generated/instructions/setLockupChecked.ts index cf119206..6f6d0b76 100644 --- a/clients/js/src/generated/instructions/setLockupChecked.ts +++ b/clients/js/src/generated/instructions/setLockupChecked.ts @@ -10,8 +10,8 @@ import { combineCodec, getStructDecoder, getStructEncoder, - getU8Decoder, - getU8Encoder, + getU32Decoder, + getU32Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -39,7 +39,7 @@ import { export const SET_LOCKUP_CHECKED_DISCRIMINATOR = 12; export function getSetLockupCheckedDiscriminatorBytes() { - return getU8Encoder().encode(SET_LOCKUP_CHECKED_DISCRIMINATOR); + return getU32Encoder().encode(SET_LOCKUP_CHECKED_DISCRIMINATOR); } export type SetLockupCheckedInstruction< @@ -86,7 +86,7 @@ export type SetLockupCheckedInstructionDataArgs = { export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['lockup', getLockupCheckedParamsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_CHECKED_DISCRIMINATOR }) @@ -95,7 +95,7 @@ export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['lockup', getLockupCheckedParamsDecoder()], ]); } diff --git a/clients/js/src/generated/instructions/split.ts b/clients/js/src/generated/instructions/split.ts index a78de202..4a2df973 100644 --- a/clients/js/src/generated/instructions/split.ts +++ b/clients/js/src/generated/instructions/split.ts @@ -10,10 +10,10 @@ import { combineCodec, getStructDecoder, getStructEncoder, + getU32Decoder, + getU32Encoder, getU64Decoder, getU64Encoder, - getU8Decoder, - getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -35,7 +35,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const SPLIT_DISCRIMINATOR = 3; export function getSplitDiscriminatorBytes() { - return getU8Encoder().encode(SPLIT_DISCRIMINATOR); + return getU32Encoder().encode(SPLIT_DISCRIMINATOR); } export type SplitInstruction< @@ -69,7 +69,7 @@ export type SplitInstructionDataArgs = { lamports: number | bigint }; export function getSplitInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: SPLIT_DISCRIMINATOR }) @@ -78,7 +78,7 @@ export function getSplitInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['lamports', getU64Decoder()], ]); } diff --git a/clients/js/src/generated/instructions/withdraw.ts b/clients/js/src/generated/instructions/withdraw.ts index e34620d1..d91dc22e 100644 --- a/clients/js/src/generated/instructions/withdraw.ts +++ b/clients/js/src/generated/instructions/withdraw.ts @@ -10,10 +10,10 @@ import { combineCodec, getStructDecoder, getStructEncoder, + getU32Decoder, + getU32Encoder, getU64Decoder, getU64Encoder, - getU8Decoder, - getU8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -36,7 +36,7 @@ import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; export const WITHDRAW_DISCRIMINATOR = 4; export function getWithdrawDiscriminatorBytes() { - return getU8Encoder().encode(WITHDRAW_DISCRIMINATOR); + return getU32Encoder().encode(WITHDRAW_DISCRIMINATOR); } export type WithdrawInstruction< @@ -93,7 +93,7 @@ export type WithdrawInstructionDataArgs = { lamports: number | bigint }; export function getWithdrawInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ - ['discriminator', getU8Encoder()], + ['discriminator', getU32Encoder()], ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: WITHDRAW_DISCRIMINATOR }) @@ -102,7 +102,7 @@ export function getWithdrawInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ - ['discriminator', getU8Decoder()], + ['discriminator', getU32Decoder()], ['lamports', getU64Decoder()], ]); } diff --git a/clients/js/src/generated/programs/stake.ts b/clients/js/src/generated/programs/stake.ts index a61fcf12..c7e8dafb 100644 --- a/clients/js/src/generated/programs/stake.ts +++ b/clients/js/src/generated/programs/stake.ts @@ -8,7 +8,7 @@ import { containsBytes, - getU8Encoder, + getU32Encoder, type Address, type ReadonlyUint8Array, } from '@solana/kit'; @@ -65,58 +65,58 @@ export function identifyStakeInstruction( instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array ): StakeInstruction { const data = 'data' in instruction ? instruction.data : instruction; - if (containsBytes(data, getU8Encoder().encode(0), 0)) { + if (containsBytes(data, getU32Encoder().encode(0), 0)) { return StakeInstruction.Initialize; } - if (containsBytes(data, getU8Encoder().encode(1), 0)) { + if (containsBytes(data, getU32Encoder().encode(1), 0)) { return StakeInstruction.Authorize; } - if (containsBytes(data, getU8Encoder().encode(2), 0)) { + if (containsBytes(data, getU32Encoder().encode(2), 0)) { return StakeInstruction.DelegateStake; } - if (containsBytes(data, getU8Encoder().encode(3), 0)) { + if (containsBytes(data, getU32Encoder().encode(3), 0)) { return StakeInstruction.Split; } - if (containsBytes(data, getU8Encoder().encode(4), 0)) { + if (containsBytes(data, getU32Encoder().encode(4), 0)) { return StakeInstruction.Withdraw; } - if (containsBytes(data, getU8Encoder().encode(5), 0)) { + if (containsBytes(data, getU32Encoder().encode(5), 0)) { return StakeInstruction.Deactivate; } - if (containsBytes(data, getU8Encoder().encode(6), 0)) { + if (containsBytes(data, getU32Encoder().encode(6), 0)) { return StakeInstruction.SetLockup; } - if (containsBytes(data, getU8Encoder().encode(7), 0)) { + if (containsBytes(data, getU32Encoder().encode(7), 0)) { return StakeInstruction.Merge; } - if (containsBytes(data, getU8Encoder().encode(8), 0)) { + if (containsBytes(data, getU32Encoder().encode(8), 0)) { return StakeInstruction.AuthorizeWithSeed; } - if (containsBytes(data, getU8Encoder().encode(9), 0)) { + if (containsBytes(data, getU32Encoder().encode(9), 0)) { return StakeInstruction.InitializeChecked; } - if (containsBytes(data, getU8Encoder().encode(10), 0)) { + if (containsBytes(data, getU32Encoder().encode(10), 0)) { return StakeInstruction.AuthorizeChecked; } - if (containsBytes(data, getU8Encoder().encode(11), 0)) { + if (containsBytes(data, getU32Encoder().encode(11), 0)) { return StakeInstruction.AuthorizeCheckedWithSeed; } - if (containsBytes(data, getU8Encoder().encode(12), 0)) { + if (containsBytes(data, getU32Encoder().encode(12), 0)) { return StakeInstruction.SetLockupChecked; } - if (containsBytes(data, getU8Encoder().encode(13), 0)) { + if (containsBytes(data, getU32Encoder().encode(13), 0)) { return StakeInstruction.GetMinimumDelegation; } - if (containsBytes(data, getU8Encoder().encode(14), 0)) { + if (containsBytes(data, getU32Encoder().encode(14), 0)) { return StakeInstruction.DeactivateDelinquent; } - if (containsBytes(data, getU8Encoder().encode(15), 0)) { + if (containsBytes(data, getU32Encoder().encode(15), 0)) { return StakeInstruction.Redelegate; } - if (containsBytes(data, getU8Encoder().encode(16), 0)) { + if (containsBytes(data, getU32Encoder().encode(16), 0)) { return StakeInstruction.MoveStake; } - if (containsBytes(data, getU8Encoder().encode(17), 0)) { + if (containsBytes(data, getU32Encoder().encode(17), 0)) { return StakeInstruction.MoveLamports; } throw new Error( diff --git a/clients/rust/src/generated/instructions/authorize.rs b/clients/rust/src/generated/instructions/authorize.rs index cd5ad713..5f6900f7 100644 --- a/clients/rust/src/generated/instructions/authorize.rs +++ b/clients/rust/src/generated/instructions/authorize.rs @@ -70,7 +70,7 @@ impl Authorize { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeInstructionData { - discriminator: u8, + discriminator: u32, } impl AuthorizeInstructionData { diff --git a/clients/rust/src/generated/instructions/authorize_checked.rs b/clients/rust/src/generated/instructions/authorize_checked.rs index 09e1ad51..a4317be0 100644 --- a/clients/rust/src/generated/instructions/authorize_checked.rs +++ b/clients/rust/src/generated/instructions/authorize_checked.rs @@ -75,7 +75,7 @@ impl AuthorizeChecked { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeCheckedInstructionData { - discriminator: u8, + discriminator: u32, } impl AuthorizeCheckedInstructionData { 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 8f2ee2a6..79d5a461 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -75,7 +75,7 @@ impl AuthorizeCheckedWithSeed { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeCheckedWithSeedInstructionData { - discriminator: u8, + discriminator: u32, } impl AuthorizeCheckedWithSeedInstructionData { diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index f7a08069..a6e0e666 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -69,7 +69,7 @@ impl AuthorizeWithSeed { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeWithSeedInstructionData { - discriminator: u8, + discriminator: u32, } impl AuthorizeWithSeedInstructionData { diff --git a/clients/rust/src/generated/instructions/deactivate.rs b/clients/rust/src/generated/instructions/deactivate.rs index 6493ad46..8cad1dcb 100644 --- a/clients/rust/src/generated/instructions/deactivate.rs +++ b/clients/rust/src/generated/instructions/deactivate.rs @@ -52,7 +52,7 @@ impl Deactivate { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeactivateInstructionData { - discriminator: u8, + discriminator: u32, } impl DeactivateInstructionData { diff --git a/clients/rust/src/generated/instructions/deactivate_delinquent.rs b/clients/rust/src/generated/instructions/deactivate_delinquent.rs index e09c21cd..c5e0542f 100644 --- a/clients/rust/src/generated/instructions/deactivate_delinquent.rs +++ b/clients/rust/src/generated/instructions/deactivate_delinquent.rs @@ -52,7 +52,7 @@ impl DeactivateDelinquent { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeactivateDelinquentInstructionData { - discriminator: u8, + discriminator: u32, } impl DeactivateDelinquentInstructionData { diff --git a/clients/rust/src/generated/instructions/delegate_stake.rs b/clients/rust/src/generated/instructions/delegate_stake.rs index 0d1bf1ec..998dd18c 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -69,7 +69,7 @@ impl DelegateStake { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateStakeInstructionData { - discriminator: u8, + discriminator: u32, } impl DelegateStakeInstructionData { diff --git a/clients/rust/src/generated/instructions/get_minimum_delegation.rs b/clients/rust/src/generated/instructions/get_minimum_delegation.rs index 2aa28183..d510e2cb 100644 --- a/clients/rust/src/generated/instructions/get_minimum_delegation.rs +++ b/clients/rust/src/generated/instructions/get_minimum_delegation.rs @@ -35,7 +35,7 @@ impl GetMinimumDelegation { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMinimumDelegationInstructionData { - discriminator: u8, + discriminator: u32, } impl GetMinimumDelegationInstructionData { diff --git a/clients/rust/src/generated/instructions/initialize.rs b/clients/rust/src/generated/instructions/initialize.rs index f9977454..66248d4b 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -55,7 +55,7 @@ impl Initialize { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeInstructionData { - discriminator: u8, + discriminator: u32, } impl InitializeInstructionData { diff --git a/clients/rust/src/generated/instructions/initialize_checked.rs b/clients/rust/src/generated/instructions/initialize_checked.rs index b9c13e40..f89f1c10 100644 --- a/clients/rust/src/generated/instructions/initialize_checked.rs +++ b/clients/rust/src/generated/instructions/initialize_checked.rs @@ -58,7 +58,7 @@ impl InitializeChecked { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeCheckedInstructionData { - discriminator: u8, + discriminator: u32, } impl InitializeCheckedInstructionData { diff --git a/clients/rust/src/generated/instructions/merge.rs b/clients/rust/src/generated/instructions/merge.rs index 73e764cc..e2c9338e 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -65,7 +65,7 @@ impl Merge { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MergeInstructionData { - discriminator: u8, + discriminator: u32, } impl MergeInstructionData { diff --git a/clients/rust/src/generated/instructions/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs index 8d2da78f..3fa47f2e 100644 --- a/clients/rust/src/generated/instructions/move_lamports.rs +++ b/clients/rust/src/generated/instructions/move_lamports.rs @@ -59,7 +59,7 @@ impl MoveLamports { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MoveLamportsInstructionData { - discriminator: u8, + discriminator: u32, } impl MoveLamportsInstructionData { diff --git a/clients/rust/src/generated/instructions/move_stake.rs b/clients/rust/src/generated/instructions/move_stake.rs index d31d0c6c..d1690724 100644 --- a/clients/rust/src/generated/instructions/move_stake.rs +++ b/clients/rust/src/generated/instructions/move_stake.rs @@ -59,7 +59,7 @@ impl MoveStake { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MoveStakeInstructionData { - discriminator: u8, + discriminator: u32, } impl MoveStakeInstructionData { diff --git a/clients/rust/src/generated/instructions/redelegate.rs b/clients/rust/src/generated/instructions/redelegate.rs index 7354ba8a..7e3ad5f3 100644 --- a/clients/rust/src/generated/instructions/redelegate.rs +++ b/clients/rust/src/generated/instructions/redelegate.rs @@ -35,7 +35,7 @@ impl Redelegate { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RedelegateInstructionData { - discriminator: u8, + discriminator: u32, } impl RedelegateInstructionData { diff --git a/clients/rust/src/generated/instructions/set_lockup.rs b/clients/rust/src/generated/instructions/set_lockup.rs index 33947e8d..fb7ff41c 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -55,7 +55,7 @@ impl SetLockup { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupInstructionData { - discriminator: u8, + discriminator: u32, } impl SetLockupInstructionData { diff --git a/clients/rust/src/generated/instructions/set_lockup_checked.rs b/clients/rust/src/generated/instructions/set_lockup_checked.rs index 3b95f966..8461a0b7 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -63,7 +63,7 @@ impl SetLockupChecked { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupCheckedInstructionData { - discriminator: u8, + discriminator: u32, } impl SetLockupCheckedInstructionData { diff --git a/clients/rust/src/generated/instructions/split.rs b/clients/rust/src/generated/instructions/split.rs index d08f2701..348020e6 100644 --- a/clients/rust/src/generated/instructions/split.rs +++ b/clients/rust/src/generated/instructions/split.rs @@ -58,7 +58,7 @@ impl Split { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SplitInstructionData { - discriminator: u8, + discriminator: u32, } impl SplitInstructionData { diff --git a/clients/rust/src/generated/instructions/withdraw.rs b/clients/rust/src/generated/instructions/withdraw.rs index 925455a0..eceba2a9 100644 --- a/clients/rust/src/generated/instructions/withdraw.rs +++ b/clients/rust/src/generated/instructions/withdraw.rs @@ -78,7 +78,7 @@ impl Withdraw { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WithdrawInstructionData { - discriminator: u8, + discriminator: u32, } impl WithdrawInstructionData { diff --git a/scripts/generate-clients.mts b/scripts/generate-clients.mts index 388861e7..be7cc834 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -82,11 +82,19 @@ codama.update( }, }, { - // Use omitted optional account strategy for all instructions + // instruction: use omitted optional accounts + fix discriminator u8 -> u32 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 + ), + }; }, }, { From 2d3868aea877974b0650b1b053881e4ad079b78a Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Fri, 14 Nov 2025 22:39:56 +0000 Subject: [PATCH 07/27] re-hide redelegate from client gen --- .../js/src/generated/instructions/index.ts | 1 - .../src/generated/instructions/redelegate.ts | 93 ------- clients/js/src/generated/programs/stake.ts | 8 - .../rust/src/generated/instructions/mod.rs | 5 +- .../src/generated/instructions/redelegate.rs | 241 ------------------ scripts/generate-clients.mts | 7 + 6 files changed, 9 insertions(+), 346 deletions(-) delete mode 100644 clients/js/src/generated/instructions/redelegate.ts delete mode 100644 clients/rust/src/generated/instructions/redelegate.rs diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index 1ccb4a45..1eb46db5 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -19,7 +19,6 @@ export * from './initializeChecked'; export * from './merge'; export * from './moveLamports'; export * from './moveStake'; -export * from './redelegate'; export * from './setLockup'; export * from './setLockupChecked'; export * from './split'; diff --git a/clients/js/src/generated/instructions/redelegate.ts b/clients/js/src/generated/instructions/redelegate.ts deleted file mode 100644 index 42152166..00000000 --- a/clients/js/src/generated/instructions/redelegate.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * 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, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type Address, - type FixedSizeCodec, - type FixedSizeDecoder, - type FixedSizeEncoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { STAKE_PROGRAM_ADDRESS } from '../programs'; - -export const REDELEGATE_DISCRIMINATOR = 15; - -export function getRedelegateDiscriminatorBytes() { - return getU32Encoder().encode(REDELEGATE_DISCRIMINATOR); -} - -export type RedelegateInstruction< - TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts; - -export type RedelegateInstructionData = { discriminator: number }; - -export type RedelegateInstructionDataArgs = {}; - -export function getRedelegateInstructionDataEncoder(): FixedSizeEncoder { - return transformEncoder( - getStructEncoder([['discriminator', getU32Encoder()]]), - (value) => ({ ...value, discriminator: REDELEGATE_DISCRIMINATOR }) - ); -} - -export function getRedelegateInstructionDataDecoder(): FixedSizeDecoder { - return getStructDecoder([['discriminator', getU32Decoder()]]); -} - -export function getRedelegateInstructionDataCodec(): FixedSizeCodec< - RedelegateInstructionDataArgs, - RedelegateInstructionData -> { - return combineCodec( - getRedelegateInstructionDataEncoder(), - getRedelegateInstructionDataDecoder() - ); -} - -export type RedelegateInput = {}; - -export function getRedelegateInstruction< - TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, ->(config?: { - programAddress?: TProgramAddress; -}): RedelegateInstruction { - // Program address. - const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; - - return Object.freeze({ - data: getRedelegateInstructionDataEncoder().encode({}), - programAddress, - } as RedelegateInstruction); -} - -export type ParsedRedelegateInstruction< - TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, -> = { programAddress: Address; data: RedelegateInstructionData }; - -export function parseRedelegateInstruction( - instruction: Instruction & InstructionWithData -): ParsedRedelegateInstruction { - return { - programAddress: instruction.programAddress, - data: getRedelegateInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/clients/js/src/generated/programs/stake.ts b/clients/js/src/generated/programs/stake.ts index c7e8dafb..fbbf9681 100644 --- a/clients/js/src/generated/programs/stake.ts +++ b/clients/js/src/generated/programs/stake.ts @@ -26,7 +26,6 @@ import { type ParsedMergeInstruction, type ParsedMoveLamportsInstruction, type ParsedMoveStakeInstruction, - type ParsedRedelegateInstruction, type ParsedSetLockupCheckedInstruction, type ParsedSetLockupInstruction, type ParsedSplitInstruction, @@ -56,7 +55,6 @@ export enum StakeInstruction { SetLockupChecked, GetMinimumDelegation, DeactivateDelinquent, - Redelegate, MoveStake, MoveLamports, } @@ -110,9 +108,6 @@ export function identifyStakeInstruction( if (containsBytes(data, getU32Encoder().encode(14), 0)) { return StakeInstruction.DeactivateDelinquent; } - if (containsBytes(data, getU32Encoder().encode(15), 0)) { - return StakeInstruction.Redelegate; - } if (containsBytes(data, getU32Encoder().encode(16), 0)) { return StakeInstruction.MoveStake; } @@ -172,9 +167,6 @@ export type ParsedStakeInstruction< | ({ instructionType: StakeInstruction.DeactivateDelinquent; } & ParsedDeactivateDelinquentInstruction) - | ({ - instructionType: StakeInstruction.Redelegate; - } & ParsedRedelegateInstruction) | ({ instructionType: StakeInstruction.MoveStake; } & ParsedMoveStakeInstruction) diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index 3c54614e..718e3494 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -18,7 +18,6 @@ pub(crate) mod r#initialize_checked; pub(crate) mod r#merge; pub(crate) mod r#move_lamports; pub(crate) mod r#move_stake; -pub(crate) mod r#redelegate; pub(crate) mod r#set_lockup; pub(crate) mod r#set_lockup_checked; pub(crate) mod r#split; @@ -28,6 +27,6 @@ pub use self::{ r#authorize::*, r#authorize_checked::*, r#authorize_checked_with_seed::*, r#authorize_with_seed::*, r#deactivate::*, r#deactivate_delinquent::*, r#delegate_stake::*, r#get_minimum_delegation::*, r#initialize::*, r#initialize_checked::*, r#merge::*, - r#move_lamports::*, r#move_stake::*, r#redelegate::*, r#set_lockup::*, r#set_lockup_checked::*, - r#split::*, r#withdraw::*, + r#move_lamports::*, r#move_stake::*, r#set_lockup::*, r#set_lockup_checked::*, r#split::*, + r#withdraw::*, }; diff --git a/clients/rust/src/generated/instructions/redelegate.rs b/clients/rust/src/generated/instructions/redelegate.rs deleted file mode 100644 index 7e3ad5f3..00000000 --- a/clients/rust/src/generated/instructions/redelegate.rs +++ /dev/null @@ -1,241 +0,0 @@ -//! 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. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Redelegate {} - -impl Redelegate { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(remaining_accounts.len()); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&RedelegateInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RedelegateInstructionData { - discriminator: u32, -} - -impl RedelegateInstructionData { - pub fn new() -> Self { - Self { discriminator: 15 } - } -} - -impl Default for RedelegateInstructionData { - fn default() -> Self { - Self::new() - } -} - -/// Instruction builder for `Redelegate`. -/// -/// ### Accounts: -/// -#[derive(Clone, Debug, Default)] -pub struct RedelegateBuilder { - __remaining_accounts: Vec, -} - -impl RedelegateBuilder { - pub fn new() -> Self { - Self::default() - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = Redelegate {}; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `redelegate` CPI instruction. -pub struct RedelegateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, -} - -impl<'a, 'b> RedelegateCpi<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - Self { __program: program } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(remaining_accounts.len()); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&RedelegateInstructionData::new()).unwrap(); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Redelegate` via CPI. -/// -/// ### Accounts: -/// -#[derive(Clone, Debug)] -pub struct RedelegateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RedelegateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RedelegateCpiBuilderInstruction { - __program: program, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let instruction = RedelegateCpi { - __program: self.instruction.__program, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RedelegateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, -} diff --git a/scripts/generate-clients.mts b/scripts/generate-clients.mts index be7cc834..92c43279 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -18,6 +18,13 @@ codama.update( }) ); +// Delete deprecated/disabled instructions +codama.update( + c.updateInstructionsVisitor({ + redelegate: { delete: true }, + }) +); + // Rename instruction argument types to avoid collisions with encoder arg types codama.update( c.updateDefinedTypesVisitor({ From c2c1676bd3fc1423d87c14422e04b62ce50b789b Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Sat, 15 Nov 2025 08:27:19 +0000 Subject: [PATCH 08/27] cleanup --- scripts/generate-clients.mts | 40 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/scripts/generate-clients.mts b/scripts/generate-clients.mts index 92c43279..5edcc397 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -11,16 +11,16 @@ const idl = JSON.parse( ); const codama = c.createFromRoot(idl); -// Rename the program from solanaStakeInterface to stake +// Rename the program. codama.update( c.updateProgramsVisitor({ solanaStakeInterface: { name: 'stake' }, }) ); -// Delete deprecated/disabled instructions codama.update( c.updateInstructionsVisitor({ + // Deprecated instruction. redelegate: { delete: true }, }) ); @@ -89,24 +89,19 @@ codama.update( }, }, { - // instruction: use omitted optional accounts + fix discriminator u8 -> u32 - select: '[instructionNode]', + // enum discriminator -> u32 + select: '[definedTypeNode]stakeState.[enumTypeNode]', transform: (node) => { - c.assertIsNode(node, 'instructionNode'); + c.assertIsNode(node, 'enumTypeNode'); return { ...node, - optionalAccountStrategy: 'omitted', - arguments: node.arguments.map((arg) => - arg.name === 'discriminator' - ? { ...arg, type: c.numberTypeNode('u32') } - : arg - ), + size: c.numberTypeNode('u32'), }; }, }, { // enum discriminator -> u32 - select: '[definedTypeNode]stakeState.[enumTypeNode]', + select: '[definedTypeNode]stakeStateV2.[enumTypeNode]', transform: (node) => { c.assertIsNode(node, 'enumTypeNode'); return { @@ -116,20 +111,26 @@ codama.update( }, }, { - // enum discriminator -> u32 - select: '[definedTypeNode]stakeStateV2.[enumTypeNode]', + // Use omitted optional account strategy for all instructions. + // + fix discriminator u8 -> u32. + select: '[instructionNode]', transform: (node) => { - c.assertIsNode(node, 'enumTypeNode'); + c.assertIsNode(node, 'instructionNode'); return { ...node, - size: c.numberTypeNode('u32'), + optionalAccountStrategy: 'omitted', + arguments: node.arguments.map((arg) => + arg.name === 'discriminator' + ? { ...arg, type: c.numberTypeNode('u32') } + : arg + ), }; }, }, ]) ); -// Render JavaScript client +// Render JavaScript. const jsClient = path.join(workingDirectory, 'clients', 'js'); codama.accept( renderJavaScriptVisitor(path.join(jsClient, 'src', 'generated'), { @@ -140,14 +141,14 @@ codama.accept( ); // Remove the stake account from the accounts since the Rust client -// provides its own implementation in the hooked module +// provides its own implementation. codama.update( c.updateAccountsVisitor({ stakeStateAccount: { delete: true }, }) ); -// Render Rust client +// Render Rust. const rustClient = path.join(workingDirectory, 'clients', 'rust'); codama.accept( renderRustVisitor(path.join(rustClient, 'src', 'generated'), { @@ -163,6 +164,7 @@ codama.accept( 'serde::Deserialize', 'Clone', 'Debug', + // 'Eq', <- Remove 'Eq' from the default traits. 'PartialEq', ], }, From e2fbb5067f0eb306e690be4493847d408b3b1631 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Tue, 18 Nov 2025 11:40:13 +0000 Subject: [PATCH 09/27] align (un-break) some account and arg names --- .../instructions/authorizeCheckedWithSeed.ts | 45 +++++----- .../instructions/authorizeWithSeed.ts | 39 ++++---- .../generated/instructions/delegateStake.ts | 28 +++--- .../js/src/generated/instructions/merge.ts | 59 +++++++------ .../generated/instructions/moveLamports.ts | 59 +++++++------ .../src/generated/instructions/moveStake.ts | 59 +++++++------ .../src/generated/instructions/setLockup.ts | 10 +-- .../instructions/setLockupChecked.ts | 44 +++++----- .../authorize_checked_with_seed.rs | 76 ++++++++-------- .../instructions/authorize_with_seed.rs | 76 ++++++++-------- .../generated/instructions/delegate_stake.rs | 38 ++++---- .../rust/src/generated/instructions/merge.rs | 88 ++++++++++--------- .../generated/instructions/move_lamports.rs | 88 ++++++++++--------- .../src/generated/instructions/move_stake.rs | 88 ++++++++++--------- .../src/generated/instructions/set_lockup.rs | 24 ++--- .../instructions/set_lockup_checked.rs | 73 ++++++++------- interface/idl.json | 28 +++--- interface/src/instruction.rs | 48 ++++++---- 18 files changed, 521 insertions(+), 449 deletions(-) diff --git a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts index 6d94a408..faf70df9 100644 --- a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts @@ -46,7 +46,7 @@ export function getAuthorizeCheckedWithSeedDiscriminatorBytes() { export type AuthorizeCheckedWithSeedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountAuthorityBase extends string | AccountMeta = string, + TAccountBase extends string | AccountMeta = string, TAccountClockSysvar extends string | AccountMeta = string, TAccountNewAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends @@ -61,10 +61,9 @@ export type AuthorizeCheckedWithSeedInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountAuthorityBase extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthorityBase, + TAccountBase extends string + ? ReadonlySignerAccount & AccountSignerMeta + : TAccountBase, TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, @@ -86,18 +85,21 @@ export type AuthorizeCheckedWithSeedInstruction< export type AuthorizeCheckedWithSeedInstructionData = { discriminator: number; - args: AuthorizeCheckedWithSeedParams; + authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedParams; }; export type AuthorizeCheckedWithSeedInstructionDataArgs = { - args: AuthorizeCheckedWithSeedParamsArgs; + authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedParamsArgs; }; export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['args', getAuthorizeCheckedWithSeedParamsEncoder()], + [ + 'authorizeCheckedWithSeedArgs', + getAuthorizeCheckedWithSeedParamsEncoder(), + ], ]), (value) => ({ ...value, @@ -109,7 +111,10 @@ export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['args', getAuthorizeCheckedWithSeedParamsDecoder()], + [ + 'authorizeCheckedWithSeedArgs', + getAuthorizeCheckedWithSeedParamsDecoder(), + ], ]); } @@ -125,22 +130,22 @@ export function getAuthorizeCheckedWithSeedInstructionDataCodec(): Codec< export type AuthorizeCheckedWithSeedInput< TAccountStake extends string = string, - TAccountAuthorityBase extends string = string, + TAccountBase extends string = string, TAccountClockSysvar extends string = string, TAccountNewAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { stake: Address; - authorityBase: TransactionSigner; + base: TransactionSigner; clockSysvar: Address; newAuthority: TransactionSigner; lockupAuthority?: TransactionSigner; - args: AuthorizeCheckedWithSeedInstructionDataArgs['args']; + authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedInstructionDataArgs['authorizeCheckedWithSeedArgs']; }; export function getAuthorizeCheckedWithSeedInstruction< TAccountStake extends string, - TAccountAuthorityBase extends string, + TAccountBase extends string, TAccountClockSysvar extends string, TAccountNewAuthority extends string, TAccountLockupAuthority extends string, @@ -148,7 +153,7 @@ export function getAuthorizeCheckedWithSeedInstruction< >( input: AuthorizeCheckedWithSeedInput< TAccountStake, - TAccountAuthorityBase, + TAccountBase, TAccountClockSysvar, TAccountNewAuthority, TAccountLockupAuthority @@ -157,7 +162,7 @@ export function getAuthorizeCheckedWithSeedInstruction< ): AuthorizeCheckedWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountAuthorityBase, + TAccountBase, TAccountClockSysvar, TAccountNewAuthority, TAccountLockupAuthority @@ -168,7 +173,7 @@ export function getAuthorizeCheckedWithSeedInstruction< // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - authorityBase: { value: input.authorityBase ?? null, isWritable: false }, + base: { value: input.base ?? null, isWritable: false }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, newAuthority: { value: input.newAuthority ?? null, isWritable: false }, lockupAuthority: { @@ -188,7 +193,7 @@ export function getAuthorizeCheckedWithSeedInstruction< return Object.freeze({ accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.authorityBase), + getAccountMeta(accounts.base), getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.newAuthority), getAccountMeta(accounts.lockupAuthority), @@ -200,7 +205,7 @@ export function getAuthorizeCheckedWithSeedInstruction< } as AuthorizeCheckedWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountAuthorityBase, + TAccountBase, TAccountClockSysvar, TAccountNewAuthority, TAccountLockupAuthority @@ -214,7 +219,7 @@ export type ParsedAuthorizeCheckedWithSeedInstruction< programAddress: Address; accounts: { stake: TAccountMetas[0]; - authorityBase: TAccountMetas[1]; + base: TAccountMetas[1]; clockSysvar: TAccountMetas[2]; newAuthority: TAccountMetas[3]; lockupAuthority?: TAccountMetas[4] | undefined; @@ -250,7 +255,7 @@ export function parseAuthorizeCheckedWithSeedInstruction< programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - authorityBase: getNextAccount(), + base: getNextAccount(), clockSysvar: getNextAccount(), newAuthority: getNextAccount(), lockupAuthority: getNextOptionalAccount(), diff --git a/clients/js/src/generated/instructions/authorizeWithSeed.ts b/clients/js/src/generated/instructions/authorizeWithSeed.ts index 4d7a4959..764894d3 100644 --- a/clients/js/src/generated/instructions/authorizeWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeWithSeed.ts @@ -46,7 +46,7 @@ export function getAuthorizeWithSeedDiscriminatorBytes() { export type AuthorizeWithSeedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountAuthorityBase extends string | AccountMeta = string, + TAccountBase extends string | AccountMeta = string, TAccountClockSysvar extends string | AccountMeta = string, TAccountLockupAuthority extends | string @@ -60,10 +60,9 @@ export type AuthorizeWithSeedInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountAuthorityBase extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthorityBase, + TAccountBase extends string + ? ReadonlySignerAccount & AccountSignerMeta + : TAccountBase, TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, @@ -81,18 +80,18 @@ export type AuthorizeWithSeedInstruction< export type AuthorizeWithSeedInstructionData = { discriminator: number; - args: AuthorizeWithSeedParams; + authorizeWithSeedArgs: AuthorizeWithSeedParams; }; export type AuthorizeWithSeedInstructionDataArgs = { - args: AuthorizeWithSeedParamsArgs; + authorizeWithSeedArgs: AuthorizeWithSeedParamsArgs; }; export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['args', getAuthorizeWithSeedParamsEncoder()], + ['authorizeWithSeedArgs', getAuthorizeWithSeedParamsEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_WITH_SEED_DISCRIMINATOR }) ); @@ -101,7 +100,7 @@ export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['args', getAuthorizeWithSeedParamsDecoder()], + ['authorizeWithSeedArgs', getAuthorizeWithSeedParamsDecoder()], ]); } @@ -117,27 +116,27 @@ export function getAuthorizeWithSeedInstructionDataCodec(): Codec< export type AuthorizeWithSeedInput< TAccountStake extends string = string, - TAccountAuthorityBase extends string = string, + TAccountBase extends string = string, TAccountClockSysvar extends string = string, TAccountLockupAuthority extends string = string, > = { stake: Address; - authorityBase: TransactionSigner; + base: TransactionSigner; clockSysvar: Address; lockupAuthority?: TransactionSigner; - args: AuthorizeWithSeedInstructionDataArgs['args']; + authorizeWithSeedArgs: AuthorizeWithSeedInstructionDataArgs['authorizeWithSeedArgs']; }; export function getAuthorizeWithSeedInstruction< TAccountStake extends string, - TAccountAuthorityBase extends string, + TAccountBase extends string, TAccountClockSysvar extends string, TAccountLockupAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: AuthorizeWithSeedInput< TAccountStake, - TAccountAuthorityBase, + TAccountBase, TAccountClockSysvar, TAccountLockupAuthority >, @@ -145,7 +144,7 @@ export function getAuthorizeWithSeedInstruction< ): AuthorizeWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountAuthorityBase, + TAccountBase, TAccountClockSysvar, TAccountLockupAuthority > { @@ -155,7 +154,7 @@ export function getAuthorizeWithSeedInstruction< // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - authorityBase: { value: input.authorityBase ?? null, isWritable: false }, + base: { value: input.base ?? null, isWritable: false }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, lockupAuthority: { value: input.lockupAuthority ?? null, @@ -174,7 +173,7 @@ export function getAuthorizeWithSeedInstruction< return Object.freeze({ accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.authorityBase), + getAccountMeta(accounts.base), getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.lockupAuthority), ].filter((x: T | undefined): x is T => x !== undefined), @@ -185,7 +184,7 @@ export function getAuthorizeWithSeedInstruction< } as AuthorizeWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountAuthorityBase, + TAccountBase, TAccountClockSysvar, TAccountLockupAuthority >); @@ -198,7 +197,7 @@ export type ParsedAuthorizeWithSeedInstruction< programAddress: Address; accounts: { stake: TAccountMetas[0]; - authorityBase: TAccountMetas[1]; + base: TAccountMetas[1]; clockSysvar: TAccountMetas[2]; lockupAuthority?: TAccountMetas[3] | undefined; }; @@ -233,7 +232,7 @@ export function parseAuthorizeWithSeedInstruction< programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - authorityBase: getNextAccount(), + base: getNextAccount(), clockSysvar: getNextAccount(), lockupAuthority: getNextOptionalAccount(), }, diff --git a/clients/js/src/generated/instructions/delegateStake.ts b/clients/js/src/generated/instructions/delegateStake.ts index 9560c145..e0e1033b 100644 --- a/clients/js/src/generated/instructions/delegateStake.ts +++ b/clients/js/src/generated/instructions/delegateStake.ts @@ -43,7 +43,7 @@ export type DelegateStakeInstruction< TAccountVote extends string | AccountMeta = string, TAccountClockSysvar extends string | AccountMeta = string, TAccountStakeHistorySysvar extends string | AccountMeta = string, - TAccountConfig extends string | AccountMeta = string, + TAccountUnused extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & @@ -62,9 +62,9 @@ export type DelegateStakeInstruction< TAccountStakeHistorySysvar extends string ? ReadonlyAccount : TAccountStakeHistorySysvar, - TAccountConfig extends string - ? ReadonlyAccount - : TAccountConfig, + TAccountUnused extends string + ? ReadonlyAccount + : TAccountUnused, TAccountStakeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -103,14 +103,14 @@ export type DelegateStakeInput< TAccountVote extends string = string, TAccountClockSysvar extends string = string, TAccountStakeHistorySysvar extends string = string, - TAccountConfig extends string = string, + TAccountUnused extends string = string, TAccountStakeAuthority extends string = string, > = { stake: Address; vote: Address; clockSysvar: Address; stakeHistorySysvar: Address; - config: Address; + unused: Address; stakeAuthority: TransactionSigner; }; @@ -119,7 +119,7 @@ export function getDelegateStakeInstruction< TAccountVote extends string, TAccountClockSysvar extends string, TAccountStakeHistorySysvar extends string, - TAccountConfig extends string, + TAccountUnused extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( @@ -128,7 +128,7 @@ export function getDelegateStakeInstruction< TAccountVote, TAccountClockSysvar, TAccountStakeHistorySysvar, - TAccountConfig, + TAccountUnused, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } @@ -138,7 +138,7 @@ export function getDelegateStakeInstruction< TAccountVote, TAccountClockSysvar, TAccountStakeHistorySysvar, - TAccountConfig, + TAccountUnused, TAccountStakeAuthority > { // Program address. @@ -153,7 +153,7 @@ export function getDelegateStakeInstruction< value: input.stakeHistorySysvar ?? null, isWritable: false, }, - config: { value: input.config ?? null, isWritable: false }, + unused: { value: input.unused ?? null, isWritable: false }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -168,7 +168,7 @@ export function getDelegateStakeInstruction< getAccountMeta(accounts.vote), getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.stakeHistorySysvar), - getAccountMeta(accounts.config), + getAccountMeta(accounts.unused), getAccountMeta(accounts.stakeAuthority), ], data: getDelegateStakeInstructionDataEncoder().encode({}), @@ -179,7 +179,7 @@ export function getDelegateStakeInstruction< TAccountVote, TAccountClockSysvar, TAccountStakeHistorySysvar, - TAccountConfig, + TAccountUnused, TAccountStakeAuthority >); } @@ -194,7 +194,7 @@ export type ParsedDelegateStakeInstruction< vote: TAccountMetas[1]; clockSysvar: TAccountMetas[2]; stakeHistorySysvar: TAccountMetas[3]; - config: TAccountMetas[4]; + unused: TAccountMetas[4]; stakeAuthority: TAccountMetas[5]; }; data: DelegateStakeInstructionData; @@ -225,7 +225,7 @@ export function parseDelegateStakeInstruction< vote: getNextAccount(), clockSysvar: getNextAccount(), stakeHistorySysvar: getNextAccount(), - config: getNextAccount(), + unused: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getDelegateStakeInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/merge.ts b/clients/js/src/generated/instructions/merge.ts index f42600e9..be7d091f 100644 --- a/clients/js/src/generated/instructions/merge.ts +++ b/clients/js/src/generated/instructions/merge.ts @@ -39,8 +39,8 @@ export function getMergeDiscriminatorBytes() { export type MergeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, - TAccountDestination extends string | AccountMeta = string, - TAccountSource extends string | AccountMeta = string, + TAccountDestinationStake extends string | AccountMeta = string, + TAccountSourceStake extends string | AccountMeta = string, TAccountClockSysvar extends string | AccountMeta = string, TAccountStakeHistorySysvar extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, @@ -49,12 +49,12 @@ export type MergeInstruction< InstructionWithData & InstructionWithAccounts< [ - TAccountDestination extends string - ? WritableAccount - : TAccountDestination, - TAccountSource extends string - ? WritableAccount - : TAccountSource, + TAccountDestinationStake extends string + ? WritableAccount + : TAccountDestinationStake, + TAccountSourceStake extends string + ? WritableAccount + : TAccountSourceStake, TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, @@ -95,30 +95,30 @@ export function getMergeInstructionDataCodec(): FixedSizeCodec< } export type MergeInput< - TAccountDestination extends string = string, - TAccountSource extends string = string, + TAccountDestinationStake extends string = string, + TAccountSourceStake extends string = string, TAccountClockSysvar extends string = string, TAccountStakeHistorySysvar extends string = string, TAccountStakeAuthority extends string = string, > = { - destination: Address; - source: Address; + destinationStake: Address; + sourceStake: Address; clockSysvar: Address; stakeHistorySysvar: Address; stakeAuthority: TransactionSigner; }; export function getMergeInstruction< - TAccountDestination extends string, - TAccountSource extends string, + TAccountDestinationStake extends string, + TAccountSourceStake extends string, TAccountClockSysvar extends string, TAccountStakeHistorySysvar extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: MergeInput< - TAccountDestination, - TAccountSource, + TAccountDestinationStake, + TAccountSourceStake, TAccountClockSysvar, TAccountStakeHistorySysvar, TAccountStakeAuthority @@ -126,8 +126,8 @@ export function getMergeInstruction< config?: { programAddress?: TProgramAddress } ): MergeInstruction< TProgramAddress, - TAccountDestination, - TAccountSource, + TAccountDestinationStake, + TAccountSourceStake, TAccountClockSysvar, TAccountStakeHistorySysvar, TAccountStakeAuthority @@ -137,8 +137,11 @@ export function getMergeInstruction< // Original accounts. const originalAccounts = { - destination: { value: input.destination ?? null, isWritable: true }, - source: { value: input.source ?? null, isWritable: true }, + destinationStake: { + value: input.destinationStake ?? null, + isWritable: true, + }, + sourceStake: { value: input.sourceStake ?? null, isWritable: true }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, stakeHistorySysvar: { value: input.stakeHistorySysvar ?? null, @@ -154,8 +157,8 @@ export function getMergeInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ - getAccountMeta(accounts.destination), - getAccountMeta(accounts.source), + getAccountMeta(accounts.destinationStake), + getAccountMeta(accounts.sourceStake), getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.stakeHistorySysvar), getAccountMeta(accounts.stakeAuthority), @@ -164,8 +167,8 @@ export function getMergeInstruction< programAddress, } as MergeInstruction< TProgramAddress, - TAccountDestination, - TAccountSource, + TAccountDestinationStake, + TAccountSourceStake, TAccountClockSysvar, TAccountStakeHistorySysvar, TAccountStakeAuthority @@ -178,8 +181,8 @@ export type ParsedMergeInstruction< > = { programAddress: Address; accounts: { - destination: TAccountMetas[0]; - source: TAccountMetas[1]; + destinationStake: TAccountMetas[0]; + sourceStake: TAccountMetas[1]; clockSysvar: TAccountMetas[2]; stakeHistorySysvar: TAccountMetas[3]; stakeAuthority: TAccountMetas[4]; @@ -208,8 +211,8 @@ export function parseMergeInstruction< return { programAddress: instruction.programAddress, accounts: { - destination: getNextAccount(), - source: getNextAccount(), + destinationStake: getNextAccount(), + sourceStake: getNextAccount(), clockSysvar: getNextAccount(), stakeHistorySysvar: getNextAccount(), stakeAuthority: getNextAccount(), diff --git a/clients/js/src/generated/instructions/moveLamports.ts b/clients/js/src/generated/instructions/moveLamports.ts index 29d2348b..00409072 100644 --- a/clients/js/src/generated/instructions/moveLamports.ts +++ b/clients/js/src/generated/instructions/moveLamports.ts @@ -40,20 +40,20 @@ export function getMoveLamportsDiscriminatorBytes() { export type MoveLamportsInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, - TAccountSource extends string | AccountMeta = string, - TAccountDestination extends string | AccountMeta = string, + TAccountSourceStake extends string | AccountMeta = string, + TAccountDestinationStake extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountSource extends string - ? WritableAccount - : TAccountSource, - TAccountDestination extends string - ? WritableAccount - : TAccountDestination, + TAccountSourceStake extends string + ? WritableAccount + : TAccountSourceStake, + TAccountDestinationStake extends string + ? WritableAccount + : TAccountDestinationStake, TAccountStakeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -97,32 +97,32 @@ export function getMoveLamportsInstructionDataCodec(): FixedSizeCodec< } export type MoveLamportsInput< - TAccountSource extends string = string, - TAccountDestination extends string = string, + TAccountSourceStake extends string = string, + TAccountDestinationStake extends string = string, TAccountStakeAuthority extends string = string, > = { - source: Address; - destination: Address; + sourceStake: Address; + destinationStake: Address; stakeAuthority: TransactionSigner; lamports: MoveLamportsInstructionDataArgs['lamports']; }; export function getMoveLamportsInstruction< - TAccountSource extends string, - TAccountDestination extends string, + TAccountSourceStake extends string, + TAccountDestinationStake extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: MoveLamportsInput< - TAccountSource, - TAccountDestination, + TAccountSourceStake, + TAccountDestinationStake, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } ): MoveLamportsInstruction< TProgramAddress, - TAccountSource, - TAccountDestination, + TAccountSourceStake, + TAccountDestinationStake, TAccountStakeAuthority > { // Program address. @@ -130,8 +130,11 @@ export function getMoveLamportsInstruction< // Original accounts. const originalAccounts = { - source: { value: input.source ?? null, isWritable: true }, - destination: { value: input.destination ?? null, isWritable: true }, + sourceStake: { value: input.sourceStake ?? null, isWritable: true }, + destinationStake: { + value: input.destinationStake ?? null, + isWritable: true, + }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -145,8 +148,8 @@ export function getMoveLamportsInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ - getAccountMeta(accounts.source), - getAccountMeta(accounts.destination), + getAccountMeta(accounts.sourceStake), + getAccountMeta(accounts.destinationStake), getAccountMeta(accounts.stakeAuthority), ], data: getMoveLamportsInstructionDataEncoder().encode( @@ -155,8 +158,8 @@ export function getMoveLamportsInstruction< programAddress, } as MoveLamportsInstruction< TProgramAddress, - TAccountSource, - TAccountDestination, + TAccountSourceStake, + TAccountDestinationStake, TAccountStakeAuthority >); } @@ -167,8 +170,8 @@ export type ParsedMoveLamportsInstruction< > = { programAddress: Address; accounts: { - source: TAccountMetas[0]; - destination: TAccountMetas[1]; + sourceStake: TAccountMetas[0]; + destinationStake: TAccountMetas[1]; stakeAuthority: TAccountMetas[2]; }; data: MoveLamportsInstructionData; @@ -195,8 +198,8 @@ export function parseMoveLamportsInstruction< return { programAddress: instruction.programAddress, accounts: { - source: getNextAccount(), - destination: getNextAccount(), + sourceStake: getNextAccount(), + destinationStake: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getMoveLamportsInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/moveStake.ts b/clients/js/src/generated/instructions/moveStake.ts index fdf2d6b0..4d862bc6 100644 --- a/clients/js/src/generated/instructions/moveStake.ts +++ b/clients/js/src/generated/instructions/moveStake.ts @@ -40,20 +40,20 @@ export function getMoveStakeDiscriminatorBytes() { export type MoveStakeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, - TAccountSource extends string | AccountMeta = string, - TAccountDestination extends string | AccountMeta = string, + TAccountSourceStake extends string | AccountMeta = string, + TAccountDestinationStake extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountSource extends string - ? WritableAccount - : TAccountSource, - TAccountDestination extends string - ? WritableAccount - : TAccountDestination, + TAccountSourceStake extends string + ? WritableAccount + : TAccountSourceStake, + TAccountDestinationStake extends string + ? WritableAccount + : TAccountDestinationStake, TAccountStakeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -97,32 +97,32 @@ export function getMoveStakeInstructionDataCodec(): FixedSizeCodec< } export type MoveStakeInput< - TAccountSource extends string = string, - TAccountDestination extends string = string, + TAccountSourceStake extends string = string, + TAccountDestinationStake extends string = string, TAccountStakeAuthority extends string = string, > = { - source: Address; - destination: Address; + sourceStake: Address; + destinationStake: Address; stakeAuthority: TransactionSigner; lamports: MoveStakeInstructionDataArgs['lamports']; }; export function getMoveStakeInstruction< - TAccountSource extends string, - TAccountDestination extends string, + TAccountSourceStake extends string, + TAccountDestinationStake extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: MoveStakeInput< - TAccountSource, - TAccountDestination, + TAccountSourceStake, + TAccountDestinationStake, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } ): MoveStakeInstruction< TProgramAddress, - TAccountSource, - TAccountDestination, + TAccountSourceStake, + TAccountDestinationStake, TAccountStakeAuthority > { // Program address. @@ -130,8 +130,11 @@ export function getMoveStakeInstruction< // Original accounts. const originalAccounts = { - source: { value: input.source ?? null, isWritable: true }, - destination: { value: input.destination ?? null, isWritable: true }, + sourceStake: { value: input.sourceStake ?? null, isWritable: true }, + destinationStake: { + value: input.destinationStake ?? null, + isWritable: true, + }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -145,8 +148,8 @@ export function getMoveStakeInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ - getAccountMeta(accounts.source), - getAccountMeta(accounts.destination), + getAccountMeta(accounts.sourceStake), + getAccountMeta(accounts.destinationStake), getAccountMeta(accounts.stakeAuthority), ], data: getMoveStakeInstructionDataEncoder().encode( @@ -155,8 +158,8 @@ export function getMoveStakeInstruction< programAddress, } as MoveStakeInstruction< TProgramAddress, - TAccountSource, - TAccountDestination, + TAccountSourceStake, + TAccountDestinationStake, TAccountStakeAuthority >); } @@ -167,8 +170,8 @@ export type ParsedMoveStakeInstruction< > = { programAddress: Address; accounts: { - source: TAccountMetas[0]; - destination: TAccountMetas[1]; + sourceStake: TAccountMetas[0]; + destinationStake: TAccountMetas[1]; stakeAuthority: TAccountMetas[2]; }; data: MoveStakeInstructionData; @@ -195,8 +198,8 @@ export function parseMoveStakeInstruction< return { programAddress: instruction.programAddress, accounts: { - source: getNextAccount(), - destination: getNextAccount(), + sourceStake: getNextAccount(), + destinationStake: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getMoveStakeInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/setLockup.ts b/clients/js/src/generated/instructions/setLockup.ts index 1eca28de..3492f11f 100644 --- a/clients/js/src/generated/instructions/setLockup.ts +++ b/clients/js/src/generated/instructions/setLockup.ts @@ -64,16 +64,16 @@ export type SetLockupInstruction< export type SetLockupInstructionData = { discriminator: number; - lockup: LockupParams; + lockupArgs: LockupParams; }; -export type SetLockupInstructionDataArgs = { lockup: LockupParamsArgs }; +export type SetLockupInstructionDataArgs = { lockupArgs: LockupParamsArgs }; export function getSetLockupInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['lockup', getLockupParamsEncoder()], + ['lockupArgs', getLockupParamsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_DISCRIMINATOR }) ); @@ -82,7 +82,7 @@ export function getSetLockupInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['lockup', getLockupParamsDecoder()], + ['lockupArgs', getLockupParamsDecoder()], ]); } @@ -102,7 +102,7 @@ export type SetLockupInput< > = { stake: Address; authority: TransactionSigner; - lockup: SetLockupInstructionDataArgs['lockup']; + lockupArgs: SetLockupInstructionDataArgs['lockupArgs']; }; export function getSetLockupInstruction< diff --git a/clients/js/src/generated/instructions/setLockupChecked.ts b/clients/js/src/generated/instructions/setLockupChecked.ts index 6f6d0b76..b2ca50e2 100644 --- a/clients/js/src/generated/instructions/setLockupChecked.ts +++ b/clients/js/src/generated/instructions/setLockupChecked.ts @@ -46,7 +46,7 @@ export type SetLockupCheckedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, TAccountAuthority extends string | AccountMeta = string, - TAccountNewLockupAuthority extends + TAccountLockupAuthority extends | string | AccountMeta | undefined = undefined, @@ -62,13 +62,13 @@ export type SetLockupCheckedInstruction< ? ReadonlySignerAccount & AccountSignerMeta : TAccountAuthority, - ...(TAccountNewLockupAuthority extends undefined + ...(TAccountLockupAuthority extends undefined ? [] : [ - TAccountNewLockupAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountNewLockupAuthority, + TAccountLockupAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountLockupAuthority, ]), ...TRemainingAccounts, ] @@ -76,18 +76,18 @@ export type SetLockupCheckedInstruction< export type SetLockupCheckedInstructionData = { discriminator: number; - lockup: LockupCheckedParams; + lockupCheckedArgs: LockupCheckedParams; }; export type SetLockupCheckedInstructionDataArgs = { - lockup: LockupCheckedParamsArgs; + lockupCheckedArgs: LockupCheckedParamsArgs; }; export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['lockup', getLockupCheckedParamsEncoder()], + ['lockupCheckedArgs', getLockupCheckedParamsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_CHECKED_DISCRIMINATOR }) ); @@ -96,7 +96,7 @@ export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['lockup', getLockupCheckedParamsDecoder()], + ['lockupCheckedArgs', getLockupCheckedParamsDecoder()], ]); } @@ -113,31 +113,31 @@ export function getSetLockupCheckedInstructionDataCodec(): Codec< export type SetLockupCheckedInput< TAccountStake extends string = string, TAccountAuthority extends string = string, - TAccountNewLockupAuthority extends string = string, + TAccountLockupAuthority extends string = string, > = { stake: Address; authority: TransactionSigner; - newLockupAuthority?: TransactionSigner; - lockup: SetLockupCheckedInstructionDataArgs['lockup']; + lockupAuthority?: TransactionSigner; + lockupCheckedArgs: SetLockupCheckedInstructionDataArgs['lockupCheckedArgs']; }; export function getSetLockupCheckedInstruction< TAccountStake extends string, TAccountAuthority extends string, - TAccountNewLockupAuthority extends string, + TAccountLockupAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: SetLockupCheckedInput< TAccountStake, TAccountAuthority, - TAccountNewLockupAuthority + TAccountLockupAuthority >, config?: { programAddress?: TProgramAddress } ): SetLockupCheckedInstruction< TProgramAddress, TAccountStake, TAccountAuthority, - TAccountNewLockupAuthority + TAccountLockupAuthority > { // Program address. const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; @@ -146,8 +146,8 @@ export function getSetLockupCheckedInstruction< const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, authority: { value: input.authority ?? null, isWritable: false }, - newLockupAuthority: { - value: input.newLockupAuthority ?? null, + lockupAuthority: { + value: input.lockupAuthority ?? null, isWritable: false, }, }; @@ -164,7 +164,7 @@ export function getSetLockupCheckedInstruction< accounts: [ getAccountMeta(accounts.stake), getAccountMeta(accounts.authority), - getAccountMeta(accounts.newLockupAuthority), + getAccountMeta(accounts.lockupAuthority), ].filter((x: T | undefined): x is T => x !== undefined), data: getSetLockupCheckedInstructionDataEncoder().encode( args as SetLockupCheckedInstructionDataArgs @@ -174,7 +174,7 @@ export function getSetLockupCheckedInstruction< TProgramAddress, TAccountStake, TAccountAuthority, - TAccountNewLockupAuthority + TAccountLockupAuthority >); } @@ -186,7 +186,7 @@ export type ParsedSetLockupCheckedInstruction< accounts: { stake: TAccountMetas[0]; authority: TAccountMetas[1]; - newLockupAuthority?: TAccountMetas[2] | undefined; + lockupAuthority?: TAccountMetas[2] | undefined; }; data: SetLockupCheckedInstructionData; }; @@ -220,7 +220,7 @@ export function parseSetLockupCheckedInstruction< accounts: { stake: getNextAccount(), authority: getNextAccount(), - newLockupAuthority: getNextOptionalAccount(), + lockupAuthority: getNextOptionalAccount(), }, data: getSetLockupCheckedInstructionDataDecoder().decode(instruction.data), }; 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 79d5a461..8f2843f9 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -15,7 +15,7 @@ use { pub struct AuthorizeCheckedWithSeed { pub stake: solana_program::pubkey::Pubkey, - pub authority_base: solana_program::pubkey::Pubkey, + pub base: solana_program::pubkey::Pubkey, pub clock_sysvar: solana_program::pubkey::Pubkey, @@ -42,8 +42,7 @@ impl AuthorizeCheckedWithSeed { self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.authority_base, - true, + self.base, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, @@ -93,7 +92,7 @@ impl Default for AuthorizeCheckedWithSeedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeCheckedWithSeedInstructionArgs { - pub args: AuthorizeCheckedWithSeedParams, + pub authorize_checked_with_seed_args: AuthorizeCheckedWithSeedParams, } /// Instruction builder for `AuthorizeCheckedWithSeed`. @@ -101,18 +100,18 @@ pub struct AuthorizeCheckedWithSeedInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` authority_base +/// 1. `[signer]` base /// 2. `[]` clock_sysvar /// 3. `[signer]` new_authority /// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeCheckedWithSeedBuilder { stake: Option, - authority_base: Option, + base: Option, clock_sysvar: Option, new_authority: Option, lockup_authority: Option, - args: Option, + authorize_checked_with_seed_args: Option, __remaining_accounts: Vec, } @@ -126,8 +125,8 @@ impl AuthorizeCheckedWithSeedBuilder { self } #[inline(always)] - pub fn authority_base(&mut self, authority_base: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority_base = Some(authority_base); + pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { + self.base = Some(base); self } #[inline(always)] @@ -150,8 +149,11 @@ impl AuthorizeCheckedWithSeedBuilder { self } #[inline(always)] - pub fn args(&mut self, args: AuthorizeCheckedWithSeedParams) -> &mut Self { - self.args = Some(args); + pub fn authorize_checked_with_seed_args( + &mut self, + authorize_checked_with_seed_args: AuthorizeCheckedWithSeedParams, + ) -> &mut Self { + self.authorize_checked_with_seed_args = Some(authorize_checked_with_seed_args); self } /// Add an additional account to the instruction. @@ -176,13 +178,16 @@ impl AuthorizeCheckedWithSeedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = AuthorizeCheckedWithSeed { stake: self.stake.expect("stake is not set"), - authority_base: self.authority_base.expect("authority_base is not set"), + base: self.base.expect("base is not set"), clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), new_authority: self.new_authority.expect("new_authority is not set"), lockup_authority: self.lockup_authority, }; let args = AuthorizeCheckedWithSeedInstructionArgs { - args: self.args.clone().expect("args is not set"), + authorize_checked_with_seed_args: self + .authorize_checked_with_seed_args + .clone() + .expect("authorize_checked_with_seed_args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -193,7 +198,7 @@ impl AuthorizeCheckedWithSeedBuilder { pub struct AuthorizeCheckedWithSeedCpiAccounts<'a, 'b> { pub stake: &'b solana_program::account_info::AccountInfo<'a>, - pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + pub base: &'b solana_program::account_info::AccountInfo<'a>, pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, @@ -209,7 +214,7 @@ pub struct AuthorizeCheckedWithSeedCpi<'a, 'b> { pub stake: &'b solana_program::account_info::AccountInfo<'a>, - pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + pub base: &'b solana_program::account_info::AccountInfo<'a>, pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, @@ -229,7 +234,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - authority_base: accounts.authority_base, + base: accounts.base, clock_sysvar: accounts.clock_sysvar, new_authority: accounts.new_authority, lockup_authority: accounts.lockup_authority, @@ -275,7 +280,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.authority_base.key, + *self.base.key, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -311,7 +316,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.authority_base.clone()); + account_infos.push(self.base.clone()); account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.new_authority.clone()); if let Some(lockup_authority) = self.lockup_authority { @@ -334,7 +339,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` authority_base +/// 1. `[signer]` base /// 2. `[]` clock_sysvar /// 3. `[signer]` new_authority /// 4. `[signer, optional]` lockup_authority @@ -348,11 +353,11 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { let instruction = Box::new(AuthorizeCheckedWithSeedCpiBuilderInstruction { __program: program, stake: None, - authority_base: None, + base: None, clock_sysvar: None, new_authority: None, lockup_authority: None, - args: None, + authorize_checked_with_seed_args: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -363,11 +368,8 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn authority_base( - &mut self, - authority_base: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.authority_base = Some(authority_base); + pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.base = Some(base); self } #[inline(always)] @@ -396,8 +398,11 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn args(&mut self, args: AuthorizeCheckedWithSeedParams) -> &mut Self { - self.instruction.args = Some(args); + pub fn authorize_checked_with_seed_args( + &mut self, + authorize_checked_with_seed_args: AuthorizeCheckedWithSeedParams, + ) -> &mut Self { + self.instruction.authorize_checked_with_seed_args = Some(authorize_checked_with_seed_args); self } /// Add an additional account to the instruction. @@ -442,17 +447,18 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeCheckedWithSeedInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), + authorize_checked_with_seed_args: self + .instruction + .authorize_checked_with_seed_args + .clone() + .expect("authorize_checked_with_seed_args is not set"), }; let instruction = AuthorizeCheckedWithSeedCpi { __program: self.instruction.__program, stake: self.instruction.stake.expect("stake is not set"), - authority_base: self - .instruction - .authority_base - .expect("authority_base is not set"), + base: self.instruction.base.expect("base is not set"), clock_sysvar: self .instruction @@ -478,11 +484,11 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { struct AuthorizeCheckedWithSeedCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority_base: 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>>, - args: Option, + authorize_checked_with_seed_args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index a6e0e666..d495e2de 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -15,7 +15,7 @@ use { pub struct AuthorizeWithSeed { pub stake: solana_program::pubkey::Pubkey, - pub authority_base: solana_program::pubkey::Pubkey, + pub base: solana_program::pubkey::Pubkey, pub clock_sysvar: solana_program::pubkey::Pubkey, @@ -40,8 +40,7 @@ impl AuthorizeWithSeed { self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.authority_base, - true, + self.base, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, @@ -87,7 +86,7 @@ impl Default for AuthorizeWithSeedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeWithSeedInstructionArgs { - pub args: AuthorizeWithSeedParams, + pub authorize_with_seed_args: AuthorizeWithSeedParams, } /// Instruction builder for `AuthorizeWithSeed`. @@ -95,16 +94,16 @@ pub struct AuthorizeWithSeedInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` authority_base +/// 1. `[signer]` base /// 2. `[]` clock_sysvar /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeWithSeedBuilder { stake: Option, - authority_base: Option, + base: Option, clock_sysvar: Option, lockup_authority: Option, - args: Option, + authorize_with_seed_args: Option, __remaining_accounts: Vec, } @@ -118,8 +117,8 @@ impl AuthorizeWithSeedBuilder { self } #[inline(always)] - pub fn authority_base(&mut self, authority_base: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority_base = Some(authority_base); + pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { + self.base = Some(base); self } #[inline(always)] @@ -137,8 +136,11 @@ impl AuthorizeWithSeedBuilder { self } #[inline(always)] - pub fn args(&mut self, args: AuthorizeWithSeedParams) -> &mut Self { - self.args = Some(args); + pub fn authorize_with_seed_args( + &mut self, + authorize_with_seed_args: AuthorizeWithSeedParams, + ) -> &mut Self { + self.authorize_with_seed_args = Some(authorize_with_seed_args); self } /// Add an additional account to the instruction. @@ -163,12 +165,15 @@ impl AuthorizeWithSeedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = AuthorizeWithSeed { stake: self.stake.expect("stake is not set"), - authority_base: self.authority_base.expect("authority_base is not set"), + base: self.base.expect("base is not set"), clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), lockup_authority: self.lockup_authority, }; let args = AuthorizeWithSeedInstructionArgs { - args: self.args.clone().expect("args is not set"), + authorize_with_seed_args: self + .authorize_with_seed_args + .clone() + .expect("authorize_with_seed_args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -179,7 +184,7 @@ impl AuthorizeWithSeedBuilder { pub struct AuthorizeWithSeedCpiAccounts<'a, 'b> { pub stake: &'b solana_program::account_info::AccountInfo<'a>, - pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + pub base: &'b solana_program::account_info::AccountInfo<'a>, pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, @@ -193,7 +198,7 @@ pub struct AuthorizeWithSeedCpi<'a, 'b> { pub stake: &'b solana_program::account_info::AccountInfo<'a>, - pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + pub base: &'b solana_program::account_info::AccountInfo<'a>, pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, @@ -211,7 +216,7 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - authority_base: accounts.authority_base, + base: accounts.base, clock_sysvar: accounts.clock_sysvar, lockup_authority: accounts.lockup_authority, __args: args, @@ -256,7 +261,7 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.authority_base.key, + *self.base.key, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -288,7 +293,7 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.authority_base.clone()); + account_infos.push(self.base.clone()); account_infos.push(self.clock_sysvar.clone()); if let Some(lockup_authority) = self.lockup_authority { account_infos.push(lockup_authority.clone()); @@ -310,7 +315,7 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` authority_base +/// 1. `[signer]` base /// 2. `[]` clock_sysvar /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] @@ -323,10 +328,10 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { let instruction = Box::new(AuthorizeWithSeedCpiBuilderInstruction { __program: program, stake: None, - authority_base: None, + base: None, clock_sysvar: None, lockup_authority: None, - args: None, + authorize_with_seed_args: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -337,11 +342,8 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn authority_base( - &mut self, - authority_base: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.authority_base = Some(authority_base); + pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.base = Some(base); self } #[inline(always)] @@ -362,8 +364,11 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn args(&mut self, args: AuthorizeWithSeedParams) -> &mut Self { - self.instruction.args = Some(args); + pub fn authorize_with_seed_args( + &mut self, + authorize_with_seed_args: AuthorizeWithSeedParams, + ) -> &mut Self { + self.instruction.authorize_with_seed_args = Some(authorize_with_seed_args); self } /// Add an additional account to the instruction. @@ -408,17 +413,18 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeWithSeedInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), + authorize_with_seed_args: self + .instruction + .authorize_with_seed_args + .clone() + .expect("authorize_with_seed_args is not set"), }; let instruction = AuthorizeWithSeedCpi { __program: self.instruction.__program, stake: self.instruction.stake.expect("stake is not set"), - authority_base: self - .instruction - .authority_base - .expect("authority_base is not set"), + base: self.instruction.base.expect("base is not set"), clock_sysvar: self .instruction @@ -439,10 +445,10 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { struct AuthorizeWithSeedCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority_base: 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>>, - args: Option, + authorize_with_seed_args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/delegate_stake.rs b/clients/rust/src/generated/instructions/delegate_stake.rs index 998dd18c..19e33208 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -18,7 +18,7 @@ pub struct DelegateStake { pub stake_history_sysvar: solana_program::pubkey::Pubkey, - pub config: solana_program::pubkey::Pubkey, + pub unused: solana_program::pubkey::Pubkey, pub stake_authority: solana_program::pubkey::Pubkey, } @@ -48,7 +48,7 @@ impl DelegateStake { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.config, + self.unused, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -92,7 +92,7 @@ impl Default for DelegateStakeInstructionData { /// 1. `[]` vote /// 2. `[]` clock_sysvar /// 3. `[]` stake_history_sysvar -/// 4. `[]` config +/// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct DelegateStakeBuilder { @@ -100,7 +100,7 @@ pub struct DelegateStakeBuilder { vote: Option, clock_sysvar: Option, stake_history_sysvar: Option, - config: Option, + unused: Option, stake_authority: Option, __remaining_accounts: Vec, } @@ -133,8 +133,8 @@ impl DelegateStakeBuilder { self } #[inline(always)] - pub fn config(&mut self, config: solana_program::pubkey::Pubkey) -> &mut Self { - self.config = Some(config); + pub fn unused(&mut self, unused: solana_program::pubkey::Pubkey) -> &mut Self { + self.unused = Some(unused); self } #[inline(always)] @@ -172,7 +172,7 @@ impl DelegateStakeBuilder { stake_history_sysvar: self .stake_history_sysvar .expect("stake_history_sysvar is not set"), - config: self.config.expect("config is not set"), + unused: self.unused.expect("unused is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -190,7 +190,7 @@ pub struct DelegateStakeCpiAccounts<'a, 'b> { pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - pub config: &'b solana_program::account_info::AccountInfo<'a>, + pub unused: &'b solana_program::account_info::AccountInfo<'a>, pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -208,7 +208,7 @@ pub struct DelegateStakeCpi<'a, 'b> { pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - pub config: &'b solana_program::account_info::AccountInfo<'a>, + pub unused: &'b solana_program::account_info::AccountInfo<'a>, pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -224,7 +224,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { vote: accounts.vote, clock_sysvar: accounts.clock_sysvar, stake_history_sysvar: accounts.stake_history_sysvar, - config: accounts.config, + unused: accounts.unused, stake_authority: accounts.stake_authority, } } @@ -279,7 +279,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.config.key, + *self.unused.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -306,7 +306,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { account_infos.push(self.vote.clone()); account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.stake_history_sysvar.clone()); - account_infos.push(self.config.clone()); + account_infos.push(self.unused.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -328,7 +328,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { /// 1. `[]` vote /// 2. `[]` clock_sysvar /// 3. `[]` stake_history_sysvar -/// 4. `[]` config +/// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct DelegateStakeCpiBuilder<'a, 'b> { @@ -343,7 +343,7 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { vote: None, clock_sysvar: None, stake_history_sysvar: None, - config: None, + unused: None, stake_authority: None, __remaining_accounts: Vec::new(), }); @@ -376,11 +376,11 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn config( + pub fn unused( &mut self, - config: &'b solana_program::account_info::AccountInfo<'a>, + unused: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.config = Some(config); + self.instruction.unused = Some(unused); self } #[inline(always)] @@ -449,7 +449,7 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { .stake_history_sysvar .expect("stake_history_sysvar is not set"), - config: self.instruction.config.expect("config is not set"), + unused: self.instruction.unused.expect("unused is not set"), stake_authority: self .instruction @@ -470,7 +470,7 @@ struct DelegateStakeCpiBuilderInstruction<'a, 'b> { vote: Option<&'b solana_program::account_info::AccountInfo<'a>>, clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_history_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - config: 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>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/clients/rust/src/generated/instructions/merge.rs b/clients/rust/src/generated/instructions/merge.rs index e2c9338e..a38a825b 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -10,9 +10,9 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Merge { - pub destination: solana_program::pubkey::Pubkey, + pub destination_stake: solana_program::pubkey::Pubkey, - pub source: solana_program::pubkey::Pubkey, + pub source_stake: solana_program::pubkey::Pubkey, pub clock_sysvar: solana_program::pubkey::Pubkey, @@ -32,11 +32,11 @@ impl Merge { ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - self.destination, + self.destination_stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - self.source, + self.source_stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -84,15 +84,15 @@ impl Default for MergeInstructionData { /// /// ### Accounts: /// -/// 0. `[writable]` destination -/// 1. `[writable]` source +/// 0. `[writable]` destination_stake +/// 1. `[writable]` source_stake /// 2. `[]` clock_sysvar /// 3. `[]` stake_history_sysvar /// 4. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MergeBuilder { - destination: Option, - source: Option, + destination_stake: Option, + source_stake: Option, clock_sysvar: Option, stake_history_sysvar: Option, stake_authority: Option, @@ -104,13 +104,16 @@ impl MergeBuilder { Self::default() } #[inline(always)] - pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { - self.destination = Some(destination); + pub fn destination_stake( + &mut self, + destination_stake: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.destination_stake = Some(destination_stake); self } #[inline(always)] - pub fn source(&mut self, source: solana_program::pubkey::Pubkey) -> &mut Self { - self.source = Some(source); + pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.source_stake = Some(source_stake); self } #[inline(always)] @@ -155,8 +158,10 @@ impl MergeBuilder { #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Merge { - destination: self.destination.expect("destination is not set"), - source: self.source.expect("source is not set"), + 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.expect("clock_sysvar is not set"), stake_history_sysvar: self .stake_history_sysvar @@ -170,9 +175,9 @@ impl MergeBuilder { /// `merge` CPI accounts. pub struct MergeCpiAccounts<'a, 'b> { - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, @@ -186,9 +191,9 @@ pub struct MergeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, @@ -204,8 +209,8 @@ impl<'a, 'b> MergeCpi<'a, 'b> { ) -> Self { Self { __program: program, - destination: accounts.destination, - source: accounts.source, + destination_stake: accounts.destination_stake, + source_stake: accounts.source_stake, clock_sysvar: accounts.clock_sysvar, stake_history_sysvar: accounts.stake_history_sysvar, stake_authority: accounts.stake_authority, @@ -246,11 +251,11 @@ impl<'a, 'b> MergeCpi<'a, 'b> { ) -> solana_program::entrypoint::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - *self.destination.key, + *self.destination_stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - *self.source.key, + *self.source_stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -281,8 +286,8 @@ impl<'a, 'b> MergeCpi<'a, 'b> { }; let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); account_infos.push(self.__program.clone()); - account_infos.push(self.destination.clone()); - account_infos.push(self.source.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.source_stake.clone()); account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.stake_history_sysvar.clone()); account_infos.push(self.stake_authority.clone()); @@ -302,8 +307,8 @@ impl<'a, 'b> MergeCpi<'a, 'b> { /// /// ### Accounts: /// -/// 0. `[writable]` destination -/// 1. `[writable]` source +/// 0. `[writable]` destination_stake +/// 1. `[writable]` source_stake /// 2. `[]` clock_sysvar /// 3. `[]` stake_history_sysvar /// 4. `[signer]` stake_authority @@ -316,8 +321,8 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MergeCpiBuilderInstruction { __program: program, - destination: None, - source: None, + destination_stake: None, + source_stake: None, clock_sysvar: None, stake_history_sysvar: None, stake_authority: None, @@ -326,19 +331,19 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn destination( + pub fn destination_stake( &mut self, - destination: &'b solana_program::account_info::AccountInfo<'a>, + destination_stake: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.destination = Some(destination); + self.instruction.destination_stake = Some(destination_stake); self } #[inline(always)] - pub fn source( + pub fn source_stake( &mut self, - source: &'b solana_program::account_info::AccountInfo<'a>, + source_stake: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.source = Some(source); + self.instruction.source_stake = Some(source_stake); self } #[inline(always)] @@ -409,12 +414,15 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { let instruction = MergeCpi { __program: self.instruction.__program, - destination: self + destination_stake: self .instruction - .destination - .expect("destination is not set"), + .destination_stake + .expect("destination_stake is not set"), - source: self.instruction.source.expect("source is not set"), + source_stake: self + .instruction + .source_stake + .expect("source_stake is not set"), clock_sysvar: self .instruction @@ -441,8 +449,8 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct MergeCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, - destination: Option<&'b solana_program::account_info::AccountInfo<'a>>, - source: Option<&'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_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, diff --git a/clients/rust/src/generated/instructions/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs index 3fa47f2e..f2ff4042 100644 --- a/clients/rust/src/generated/instructions/move_lamports.rs +++ b/clients/rust/src/generated/instructions/move_lamports.rs @@ -10,9 +10,9 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct MoveLamports { - pub source: solana_program::pubkey::Pubkey, + pub source_stake: solana_program::pubkey::Pubkey, - pub destination: solana_program::pubkey::Pubkey, + pub destination_stake: solana_program::pubkey::Pubkey, pub stake_authority: solana_program::pubkey::Pubkey, } @@ -32,11 +32,11 @@ impl MoveLamports { ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - self.source, + self.source_stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - self.destination, + self.destination_stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -84,13 +84,13 @@ pub struct MoveLamportsInstructionArgs { /// /// ### Accounts: /// -/// 0. `[writable]` source -/// 1. `[writable]` destination +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveLamportsBuilder { - source: Option, - destination: Option, + source_stake: Option, + destination_stake: Option, stake_authority: Option, lamports: Option, __remaining_accounts: Vec, @@ -101,13 +101,16 @@ impl MoveLamportsBuilder { Self::default() } #[inline(always)] - pub fn source(&mut self, source: solana_program::pubkey::Pubkey) -> &mut Self { - self.source = Some(source); + pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.source_stake = Some(source_stake); self } #[inline(always)] - pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { - self.destination = Some(destination); + pub fn destination_stake( + &mut self, + destination_stake: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.destination_stake = Some(destination_stake); self } #[inline(always)] @@ -144,8 +147,10 @@ impl MoveLamportsBuilder { #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = MoveLamports { - source: self.source.expect("source is not set"), - destination: self.destination.expect("destination is not set"), + source_stake: self.source_stake.expect("source_stake is not set"), + destination_stake: self + .destination_stake + .expect("destination_stake is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; let args = MoveLamportsInstructionArgs { @@ -158,9 +163,9 @@ impl MoveLamportsBuilder { /// `move_lamports` CPI accounts. pub struct MoveLamportsCpiAccounts<'a, 'b> { - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -170,9 +175,9 @@ pub struct MoveLamportsCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. @@ -187,8 +192,8 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { ) -> Self { Self { __program: program, - source: accounts.source, - destination: accounts.destination, + source_stake: accounts.source_stake, + destination_stake: accounts.destination_stake, stake_authority: accounts.stake_authority, __args: args, } @@ -228,11 +233,11 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { ) -> solana_program::entrypoint::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - *self.source.key, + *self.source_stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - *self.destination.key, + *self.destination_stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -257,8 +262,8 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { }; let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); account_infos.push(self.__program.clone()); - account_infos.push(self.source.clone()); - account_infos.push(self.destination.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.destination_stake.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -276,8 +281,8 @@ impl<'a, 'b> MoveLamportsCpi<'a, 'b> { /// /// ### Accounts: /// -/// 0. `[writable]` source -/// 1. `[writable]` destination +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MoveLamportsCpiBuilder<'a, 'b> { @@ -288,8 +293,8 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MoveLamportsCpiBuilderInstruction { __program: program, - source: None, - destination: None, + source_stake: None, + destination_stake: None, stake_authority: None, lamports: None, __remaining_accounts: Vec::new(), @@ -297,19 +302,19 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn source( + pub fn source_stake( &mut self, - source: &'b solana_program::account_info::AccountInfo<'a>, + source_stake: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.source = Some(source); + self.instruction.source_stake = Some(source_stake); self } #[inline(always)] - pub fn destination( + pub fn destination_stake( &mut self, - destination: &'b solana_program::account_info::AccountInfo<'a>, + destination_stake: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.destination = Some(destination); + self.instruction.destination_stake = Some(destination_stake); self } #[inline(always)] @@ -376,12 +381,15 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { let instruction = MoveLamportsCpi { __program: self.instruction.__program, - source: self.instruction.source.expect("source is not set"), + source_stake: self + .instruction + .source_stake + .expect("source_stake is not set"), - destination: self + destination_stake: self .instruction - .destination - .expect("destination is not set"), + .destination_stake + .expect("destination_stake is not set"), stake_authority: self .instruction @@ -399,8 +407,8 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct MoveLamportsCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, - source: Option<&'b solana_program::account_info::AccountInfo<'a>>, - destination: Option<&'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>>, lamports: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. diff --git a/clients/rust/src/generated/instructions/move_stake.rs b/clients/rust/src/generated/instructions/move_stake.rs index d1690724..959f0c49 100644 --- a/clients/rust/src/generated/instructions/move_stake.rs +++ b/clients/rust/src/generated/instructions/move_stake.rs @@ -10,9 +10,9 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct MoveStake { - pub source: solana_program::pubkey::Pubkey, + pub source_stake: solana_program::pubkey::Pubkey, - pub destination: solana_program::pubkey::Pubkey, + pub destination_stake: solana_program::pubkey::Pubkey, pub stake_authority: solana_program::pubkey::Pubkey, } @@ -32,11 +32,11 @@ impl MoveStake { ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - self.source, + self.source_stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - self.destination, + self.destination_stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -84,13 +84,13 @@ pub struct MoveStakeInstructionArgs { /// /// ### Accounts: /// -/// 0. `[writable]` source -/// 1. `[writable]` destination +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveStakeBuilder { - source: Option, - destination: Option, + source_stake: Option, + destination_stake: Option, stake_authority: Option, lamports: Option, __remaining_accounts: Vec, @@ -101,13 +101,16 @@ impl MoveStakeBuilder { Self::default() } #[inline(always)] - pub fn source(&mut self, source: solana_program::pubkey::Pubkey) -> &mut Self { - self.source = Some(source); + pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.source_stake = Some(source_stake); self } #[inline(always)] - pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { - self.destination = Some(destination); + pub fn destination_stake( + &mut self, + destination_stake: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.destination_stake = Some(destination_stake); self } #[inline(always)] @@ -144,8 +147,10 @@ impl MoveStakeBuilder { #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = MoveStake { - source: self.source.expect("source is not set"), - destination: self.destination.expect("destination is not set"), + source_stake: self.source_stake.expect("source_stake is not set"), + destination_stake: self + .destination_stake + .expect("destination_stake is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; let args = MoveStakeInstructionArgs { @@ -158,9 +163,9 @@ impl MoveStakeBuilder { /// `move_stake` CPI accounts. pub struct MoveStakeCpiAccounts<'a, 'b> { - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -170,9 +175,9 @@ pub struct MoveStakeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. @@ -187,8 +192,8 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { ) -> Self { Self { __program: program, - source: accounts.source, - destination: accounts.destination, + source_stake: accounts.source_stake, + destination_stake: accounts.destination_stake, stake_authority: accounts.stake_authority, __args: args, } @@ -228,11 +233,11 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { ) -> solana_program::entrypoint::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - *self.source.key, + *self.source_stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - *self.destination.key, + *self.destination_stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -257,8 +262,8 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { }; let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); account_infos.push(self.__program.clone()); - account_infos.push(self.source.clone()); - account_infos.push(self.destination.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.destination_stake.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -276,8 +281,8 @@ impl<'a, 'b> MoveStakeCpi<'a, 'b> { /// /// ### Accounts: /// -/// 0. `[writable]` source -/// 1. `[writable]` destination +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MoveStakeCpiBuilder<'a, 'b> { @@ -288,8 +293,8 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MoveStakeCpiBuilderInstruction { __program: program, - source: None, - destination: None, + source_stake: None, + destination_stake: None, stake_authority: None, lamports: None, __remaining_accounts: Vec::new(), @@ -297,19 +302,19 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn source( + pub fn source_stake( &mut self, - source: &'b solana_program::account_info::AccountInfo<'a>, + source_stake: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.source = Some(source); + self.instruction.source_stake = Some(source_stake); self } #[inline(always)] - pub fn destination( + pub fn destination_stake( &mut self, - destination: &'b solana_program::account_info::AccountInfo<'a>, + destination_stake: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.destination = Some(destination); + self.instruction.destination_stake = Some(destination_stake); self } #[inline(always)] @@ -376,12 +381,15 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { let instruction = MoveStakeCpi { __program: self.instruction.__program, - source: self.instruction.source.expect("source is not set"), + source_stake: self + .instruction + .source_stake + .expect("source_stake is not set"), - destination: self + destination_stake: self .instruction - .destination - .expect("destination is not set"), + .destination_stake + .expect("destination_stake is not set"), stake_authority: self .instruction @@ -399,8 +407,8 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct MoveStakeCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, - source: Option<&'b solana_program::account_info::AccountInfo<'a>>, - destination: Option<&'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>>, lamports: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. diff --git a/clients/rust/src/generated/instructions/set_lockup.rs b/clients/rust/src/generated/instructions/set_lockup.rs index fb7ff41c..e339cb24 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -73,7 +73,7 @@ impl Default for SetLockupInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupInstructionArgs { - pub lockup: LockupParams, + pub lockup_args: LockupParams, } /// Instruction builder for `SetLockup`. @@ -86,7 +86,7 @@ pub struct SetLockupInstructionArgs { pub struct SetLockupBuilder { stake: Option, authority: Option, - lockup: Option, + lockup_args: Option, __remaining_accounts: Vec, } @@ -105,8 +105,8 @@ impl SetLockupBuilder { self } #[inline(always)] - pub fn lockup(&mut self, lockup: LockupParams) -> &mut Self { - self.lockup = Some(lockup); + pub fn lockup_args(&mut self, lockup_args: LockupParams) -> &mut Self { + self.lockup_args = Some(lockup_args); self } /// Add an additional account to the instruction. @@ -134,7 +134,7 @@ impl SetLockupBuilder { authority: self.authority.expect("authority is not set"), }; let args = SetLockupInstructionArgs { - lockup: self.lockup.clone().expect("lockup is not set"), + lockup_args: self.lockup_args.clone().expect("lockup_args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -264,7 +264,7 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { __program: program, stake: None, authority: None, - lockup: None, + lockup_args: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -283,8 +283,8 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn lockup(&mut self, lockup: LockupParams) -> &mut Self { - self.instruction.lockup = Some(lockup); + pub fn lockup_args(&mut self, lockup_args: LockupParams) -> &mut Self { + self.instruction.lockup_args = Some(lockup_args); self } /// Add an additional account to the instruction. @@ -329,7 +329,11 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = SetLockupInstructionArgs { - lockup: self.instruction.lockup.clone().expect("lockup is not set"), + lockup_args: self + .instruction + .lockup_args + .clone() + .expect("lockup_args is not set"), }; let instruction = SetLockupCpi { __program: self.instruction.__program, @@ -351,7 +355,7 @@ 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>>, - lockup: Option, + lockup_args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/set_lockup_checked.rs b/clients/rust/src/generated/instructions/set_lockup_checked.rs index 8461a0b7..60ae2d6b 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -17,7 +17,7 @@ pub struct SetLockupChecked { pub authority: solana_program::pubkey::Pubkey, - pub new_lockup_authority: Option, + pub lockup_authority: Option, } impl SetLockupChecked { @@ -41,9 +41,9 @@ impl SetLockupChecked { self.authority, true, )); - if let Some(new_lockup_authority) = self.new_lockup_authority { + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - new_lockup_authority, + lockup_authority, true, )); } @@ -81,7 +81,7 @@ impl Default for SetLockupCheckedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupCheckedInstructionArgs { - pub lockup: LockupCheckedParams, + pub lockup_checked_args: LockupCheckedParams, } /// Instruction builder for `SetLockupChecked`. @@ -90,13 +90,13 @@ pub struct SetLockupCheckedInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[signer]` authority -/// 2. `[signer, optional]` new_lockup_authority +/// 2. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct SetLockupCheckedBuilder { stake: Option, authority: Option, - new_lockup_authority: Option, - lockup: Option, + lockup_authority: Option, + lockup_checked_args: Option, __remaining_accounts: Vec, } @@ -116,16 +116,16 @@ impl SetLockupCheckedBuilder { } /// `[optional account]` #[inline(always)] - pub fn new_lockup_authority( + pub fn lockup_authority( &mut self, - new_lockup_authority: Option, + lockup_authority: Option, ) -> &mut Self { - self.new_lockup_authority = new_lockup_authority; + self.lockup_authority = lockup_authority; self } #[inline(always)] - pub fn lockup(&mut self, lockup: LockupCheckedParams) -> &mut Self { - self.lockup = Some(lockup); + pub fn lockup_checked_args(&mut self, lockup_checked_args: LockupCheckedParams) -> &mut Self { + self.lockup_checked_args = Some(lockup_checked_args); self } /// Add an additional account to the instruction. @@ -151,10 +151,13 @@ impl SetLockupCheckedBuilder { let accounts = SetLockupChecked { stake: self.stake.expect("stake is not set"), authority: self.authority.expect("authority is not set"), - new_lockup_authority: self.new_lockup_authority, + lockup_authority: self.lockup_authority, }; let args = SetLockupCheckedInstructionArgs { - lockup: self.lockup.clone().expect("lockup is not set"), + lockup_checked_args: self + .lockup_checked_args + .clone() + .expect("lockup_checked_args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -167,7 +170,7 @@ pub struct SetLockupCheckedCpiAccounts<'a, 'b> { pub authority: &'b solana_program::account_info::AccountInfo<'a>, - pub new_lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } /// `set_lockup_checked` CPI instruction. @@ -179,7 +182,7 @@ pub struct SetLockupCheckedCpi<'a, 'b> { pub authority: &'b solana_program::account_info::AccountInfo<'a>, - pub new_lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: SetLockupCheckedInstructionArgs, } @@ -194,7 +197,7 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { __program: program, stake: accounts.stake, authority: accounts.authority, - new_lockup_authority: accounts.new_lockup_authority, + lockup_authority: accounts.lockup_authority, __args: args, } } @@ -240,9 +243,9 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { *self.authority.key, true, )); - if let Some(new_lockup_authority) = self.new_lockup_authority { + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *new_lockup_authority.key, + *lockup_authority.key, true, )); } @@ -266,8 +269,8 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); account_infos.push(self.authority.clone()); - if let Some(new_lockup_authority) = self.new_lockup_authority { - account_infos.push(new_lockup_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); } remaining_accounts .iter() @@ -287,7 +290,7 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { /// /// 0. `[writable]` stake /// 1. `[signer]` authority -/// 2. `[signer, optional]` new_lockup_authority +/// 2. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct SetLockupCheckedCpiBuilder<'a, 'b> { instruction: Box>, @@ -299,8 +302,8 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { __program: program, stake: None, authority: None, - new_lockup_authority: None, - lockup: None, + lockup_authority: None, + lockup_checked_args: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -320,16 +323,16 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { } /// `[optional account]` #[inline(always)] - pub fn new_lockup_authority( + pub fn lockup_authority( &mut self, - new_lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.new_lockup_authority = new_lockup_authority; + self.instruction.lockup_authority = lockup_authority; self } #[inline(always)] - pub fn lockup(&mut self, lockup: LockupCheckedParams) -> &mut Self { - self.instruction.lockup = Some(lockup); + pub fn lockup_checked_args(&mut self, lockup_checked_args: LockupCheckedParams) -> &mut Self { + self.instruction.lockup_checked_args = Some(lockup_checked_args); self } /// Add an additional account to the instruction. @@ -374,7 +377,11 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = SetLockupCheckedInstructionArgs { - lockup: self.instruction.lockup.clone().expect("lockup is not set"), + lockup_checked_args: self + .instruction + .lockup_checked_args + .clone() + .expect("lockup_checked_args is not set"), }; let instruction = SetLockupCheckedCpi { __program: self.instruction.__program, @@ -383,7 +390,7 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { authority: self.instruction.authority.expect("authority is not set"), - new_lockup_authority: self.instruction.new_lockup_authority, + lockup_authority: self.instruction.lockup_authority, __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -398,8 +405,8 @@ 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_lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - lockup: Option, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_checked_args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/interface/idl.json b/interface/idl.json index 2dfe1919..3be9adc7 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -763,7 +763,7 @@ "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", - "name": "config" + "name": "unused" }, { "isSigner": true, @@ -1008,7 +1008,7 @@ }, { "kind": "instructionArgumentNode", - "name": "lockup", + "name": "lockupArgs", "type": { "kind": "definedTypeLinkNode", "name": "lockupArgs" @@ -1031,13 +1031,13 @@ "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", - "name": "destination" + "name": "destinationStake" }, { "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", - "name": "source" + "name": "sourceStake" }, { "isSigner": false, @@ -1096,7 +1096,7 @@ "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", - "name": "authorityBase" + "name": "base" }, { "isSigner": false, @@ -1129,7 +1129,7 @@ }, { "kind": "instructionArgumentNode", - "name": "args", + "name": "authorizeWithSeedArgs", "type": { "kind": "definedTypeLinkNode", "name": "authorizeWithSeedArgs" @@ -1279,7 +1279,7 @@ "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", - "name": "authorityBase" + "name": "base" }, { "isSigner": false, @@ -1318,7 +1318,7 @@ }, { "kind": "instructionArgumentNode", - "name": "args", + "name": "authorizeCheckedWithSeedArgs", "type": { "kind": "definedTypeLinkNode", "name": "authorizeCheckedWithSeedArgs" @@ -1354,7 +1354,7 @@ "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", - "name": "newLockupAuthority" + "name": "lockupAuthority" } ], "arguments": [ @@ -1374,7 +1374,7 @@ }, { "kind": "instructionArgumentNode", - "name": "lockup", + "name": "lockupCheckedArgs", "type": { "kind": "definedTypeLinkNode", "name": "lockupCheckedArgs" @@ -1500,13 +1500,13 @@ "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", - "name": "source" + "name": "sourceStake" }, { "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", - "name": "destination" + "name": "destinationStake" }, { "isSigner": true, @@ -1556,13 +1556,13 @@ "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", - "name": "source" + "name": "sourceStake" }, { "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", - "name": "destination" + "name": "destinationStake" }, { "isSigner": true, diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 97a0f39f..0541fdbf 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -85,7 +85,7 @@ pub enum StakeInstruction { #[codama(account(name = "vote"))] #[codama(account(name = "clock_sysvar"))] #[codama(account(name = "stake_history_sysvar"))] - #[codama(account(name = "config"))] + #[codama(account(name = "unused"))] #[codama(account(name = "stake_authority", signer))] DelegateStake, @@ -141,7 +141,7 @@ pub enum StakeInstruction { /// 1. `[SIGNER]` Lockup authority or withdraw authority #[codama(account(name = "stake", writable))] #[codama(account(name = "authority", signer))] - SetLockup { lockup: LockupArgs }, + SetLockup { lockup_args: LockupArgs }, /// Merge two stake accounts. /// @@ -167,8 +167,8 @@ pub enum StakeInstruction { /// 2. `[]` Clock sysvar /// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history /// 4. `[SIGNER]` Stake authority - #[codama(account(name = "destination", writable))] - #[codama(account(name = "source", writable))] + #[codama(account(name = "destination_stake", writable))] + #[codama(account(name = "source_stake", writable))] #[codama(account(name = "clock_sysvar"))] #[codama(account(name = "stake_history_sysvar"))] #[codama(account(name = "stake_authority", signer))] @@ -183,10 +183,12 @@ pub enum StakeInstruction { /// 3. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration #[codama(account(name = "stake", writable))] - #[codama(account(name = "authority_base", signer))] + #[codama(account(name = "base", signer))] #[codama(account(name = "clock_sysvar"))] #[codama(account(name = "lockup_authority", optional, signer))] - AuthorizeWithSeed { args: AuthorizeWithSeedArgs }, + AuthorizeWithSeed { + authorize_with_seed_args: AuthorizeWithSeedArgs, + }, /// Initialize a stake with authorization information /// @@ -236,11 +238,13 @@ pub enum StakeInstruction { /// 4. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration #[codama(account(name = "stake", writable))] - #[codama(account(name = "authority_base", signer))] + #[codama(account(name = "base", signer))] #[codama(account(name = "clock_sysvar"))] #[codama(account(name = "new_authority", signer))] #[codama(account(name = "lockup_authority", optional, signer))] - AuthorizeCheckedWithSeed { args: AuthorizeCheckedWithSeedArgs }, + AuthorizeCheckedWithSeed { + authorize_checked_with_seed_args: AuthorizeCheckedWithSeedArgs, + }, /// Set stake lockup /// @@ -256,8 +260,10 @@ pub enum StakeInstruction { /// 2. Optional: `[SIGNER]` New lockup authority #[codama(account(name = "stake", writable))] #[codama(account(name = "authority", signer))] - #[codama(account(name = "new_lockup_authority", optional, signer))] - SetLockupChecked { lockup: LockupCheckedArgs }, + #[codama(account(name = "lockup_authority", optional, signer))] + SetLockupChecked { + lockup_checked_args: LockupCheckedArgs, + }, /// Get the minimum stake delegation, in lamports /// @@ -330,8 +336,8 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of the stake to move, which may be the entire delegation - #[codama(account(name = "source", writable))] - #[codama(account(name = "destination", writable))] + #[codama(account(name = "source_stake", writable))] + #[codama(account(name = "destination_stake", writable))] #[codama(account(name = "stake_authority", signer))] MoveStake { lamports: u64 }, @@ -348,8 +354,8 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of available lamports to move - #[codama(account(name = "source", writable))] - #[codama(account(name = "destination", writable))] + #[codama(account(name = "source_stake", writable))] + #[codama(account(name = "destination_stake", writable))] #[codama(account(name = "stake_authority", signer))] MoveLamports { lamports: u64 }, } @@ -732,7 +738,9 @@ pub fn authorize_with_seed( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeWithSeed { args }, + &StakeInstruction::AuthorizeWithSeed { + authorize_with_seed_args: args, + }, account_metas, ) } @@ -766,7 +774,9 @@ pub fn authorize_checked_with_seed( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeCheckedWithSeed { args }, + &StakeInstruction::AuthorizeCheckedWithSeed { + authorize_checked_with_seed_args: args, + }, account_metas, ) } @@ -834,7 +844,9 @@ pub fn set_lockup( ]; Instruction::new_with_bincode( ID, - &StakeInstruction::SetLockup { lockup: *lockup }, + &StakeInstruction::SetLockup { + lockup_args: *lockup, + }, account_metas, ) } @@ -860,7 +872,7 @@ pub fn set_lockup_checked( Instruction::new_with_bincode( ID, &StakeInstruction::SetLockupChecked { - lockup: lockup_checked, + lockup_checked_args: lockup_checked, }, account_metas, ) From 154660fd1ee2683e11614a86b056073b20ea0c31 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Tue, 18 Nov 2025 11:48:18 +0000 Subject: [PATCH 10/27] explicitly use arg0, arg1 to prevent breaking --- .../src/generated/instructions/authorize.ts | 20 ++++---- .../src/generated/instructions/initialize.ts | 20 ++++---- .../instructions/setLockupChecked.ts | 35 +++++++------- .../src/generated/instructions/authorize.rs | 47 ++++++++----------- .../src/generated/instructions/initialize.rs | 44 ++++++++--------- .../instructions/set_lockup_checked.rs | 46 +++++++++--------- interface/idl.json | 10 ++-- interface/src/instruction.rs | 24 ++++------ 8 files changed, 113 insertions(+), 133 deletions(-) diff --git a/clients/js/src/generated/instructions/authorize.ts b/clients/js/src/generated/instructions/authorize.ts index e1a14a42..26ca3296 100644 --- a/clients/js/src/generated/instructions/authorize.ts +++ b/clients/js/src/generated/instructions/authorize.ts @@ -83,21 +83,21 @@ export type AuthorizeInstruction< export type AuthorizeInstructionData = { discriminator: number; - pubkey: Address; - stakeAuthorize: StakeAuthorize; + arg0: Address; + arg1: StakeAuthorize; }; export type AuthorizeInstructionDataArgs = { - pubkey: Address; - stakeAuthorize: StakeAuthorizeArgs; + arg0: Address; + arg1: StakeAuthorizeArgs; }; export function getAuthorizeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['pubkey', getAddressEncoder()], - ['stakeAuthorize', getStakeAuthorizeEncoder()], + ['arg0', getAddressEncoder()], + ['arg1', getStakeAuthorizeEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_DISCRIMINATOR }) ); @@ -106,8 +106,8 @@ export function getAuthorizeInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['pubkey', getAddressDecoder()], - ['stakeAuthorize', getStakeAuthorizeDecoder()], + ['arg0', getAddressDecoder()], + ['arg1', getStakeAuthorizeDecoder()], ]); } @@ -131,8 +131,8 @@ export type AuthorizeInput< clockSysvar: Address; authority: TransactionSigner; lockupAuthority?: TransactionSigner; - pubkey: AuthorizeInstructionDataArgs['pubkey']; - stakeAuthorize: AuthorizeInstructionDataArgs['stakeAuthorize']; + arg0: AuthorizeInstructionDataArgs['arg0']; + arg1: AuthorizeInstructionDataArgs['arg1']; }; export function getAuthorizeInstruction< diff --git a/clients/js/src/generated/instructions/initialize.ts b/clients/js/src/generated/instructions/initialize.ts index 2808eec7..ba3a0a0a 100644 --- a/clients/js/src/generated/instructions/initialize.ts +++ b/clients/js/src/generated/instructions/initialize.ts @@ -65,21 +65,21 @@ export type InitializeInstruction< export type InitializeInstructionData = { discriminator: number; - authorized: Authorized; - lockup: Lockup; + arg0: Authorized; + arg1: Lockup; }; export type InitializeInstructionDataArgs = { - authorized: AuthorizedArgs; - lockup: LockupArgs; + arg0: AuthorizedArgs; + arg1: LockupArgs; }; export function getInitializeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['authorized', getAuthorizedEncoder()], - ['lockup', getLockupEncoder()], + ['arg0', getAuthorizedEncoder()], + ['arg1', getLockupEncoder()], ]), (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) ); @@ -88,8 +88,8 @@ export function getInitializeInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['authorized', getAuthorizedDecoder()], - ['lockup', getLockupDecoder()], + ['arg0', getAuthorizedDecoder()], + ['arg1', getLockupDecoder()], ]); } @@ -109,8 +109,8 @@ export type InitializeInput< > = { stake: Address; rentSysvar: Address; - authorized: InitializeInstructionDataArgs['authorized']; - lockup: InitializeInstructionDataArgs['lockup']; + arg0: InitializeInstructionDataArgs['arg0']; + arg1: InitializeInstructionDataArgs['arg1']; }; export function getInitializeInstruction< diff --git a/clients/js/src/generated/instructions/setLockupChecked.ts b/clients/js/src/generated/instructions/setLockupChecked.ts index b2ca50e2..020e3a9a 100644 --- a/clients/js/src/generated/instructions/setLockupChecked.ts +++ b/clients/js/src/generated/instructions/setLockupChecked.ts @@ -46,7 +46,7 @@ export type SetLockupCheckedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, TAccountAuthority extends string | AccountMeta = string, - TAccountLockupAuthority extends + TAccountNewAuthority extends | string | AccountMeta | undefined = undefined, @@ -62,13 +62,13 @@ export type SetLockupCheckedInstruction< ? ReadonlySignerAccount & AccountSignerMeta : TAccountAuthority, - ...(TAccountLockupAuthority extends undefined + ...(TAccountNewAuthority extends undefined ? [] : [ - TAccountLockupAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountLockupAuthority, + TAccountNewAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountNewAuthority, ]), ...TRemainingAccounts, ] @@ -113,31 +113,31 @@ export function getSetLockupCheckedInstructionDataCodec(): Codec< export type SetLockupCheckedInput< TAccountStake extends string = string, TAccountAuthority extends string = string, - TAccountLockupAuthority extends string = string, + TAccountNewAuthority extends string = string, > = { stake: Address; authority: TransactionSigner; - lockupAuthority?: TransactionSigner; + newAuthority?: TransactionSigner; lockupCheckedArgs: SetLockupCheckedInstructionDataArgs['lockupCheckedArgs']; }; export function getSetLockupCheckedInstruction< TAccountStake extends string, TAccountAuthority extends string, - TAccountLockupAuthority extends string, + TAccountNewAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: SetLockupCheckedInput< TAccountStake, TAccountAuthority, - TAccountLockupAuthority + TAccountNewAuthority >, config?: { programAddress?: TProgramAddress } ): SetLockupCheckedInstruction< TProgramAddress, TAccountStake, TAccountAuthority, - TAccountLockupAuthority + TAccountNewAuthority > { // Program address. const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; @@ -146,10 +146,7 @@ export function getSetLockupCheckedInstruction< const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, authority: { value: input.authority ?? null, isWritable: false }, - lockupAuthority: { - value: input.lockupAuthority ?? null, - isWritable: false, - }, + newAuthority: { value: input.newAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -164,7 +161,7 @@ export function getSetLockupCheckedInstruction< accounts: [ getAccountMeta(accounts.stake), getAccountMeta(accounts.authority), - getAccountMeta(accounts.lockupAuthority), + getAccountMeta(accounts.newAuthority), ].filter((x: T | undefined): x is T => x !== undefined), data: getSetLockupCheckedInstructionDataEncoder().encode( args as SetLockupCheckedInstructionDataArgs @@ -174,7 +171,7 @@ export function getSetLockupCheckedInstruction< TProgramAddress, TAccountStake, TAccountAuthority, - TAccountLockupAuthority + TAccountNewAuthority >); } @@ -186,7 +183,7 @@ export type ParsedSetLockupCheckedInstruction< accounts: { stake: TAccountMetas[0]; authority: TAccountMetas[1]; - lockupAuthority?: TAccountMetas[2] | undefined; + newAuthority?: TAccountMetas[2] | undefined; }; data: SetLockupCheckedInstructionData; }; @@ -220,7 +217,7 @@ export function parseSetLockupCheckedInstruction< accounts: { stake: getNextAccount(), authority: getNextAccount(), - lockupAuthority: getNextOptionalAccount(), + newAuthority: getNextOptionalAccount(), }, data: getSetLockupCheckedInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/rust/src/generated/instructions/authorize.rs b/clients/rust/src/generated/instructions/authorize.rs index 5f6900f7..74ec8f22 100644 --- a/clients/rust/src/generated/instructions/authorize.rs +++ b/clients/rust/src/generated/instructions/authorize.rs @@ -88,8 +88,8 @@ impl Default for AuthorizeInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeInstructionArgs { - pub pubkey: Pubkey, - pub stake_authorize: StakeAuthorize, + pub arg0: Pubkey, + pub arg1: StakeAuthorize, } /// Instruction builder for `Authorize`. @@ -106,8 +106,8 @@ pub struct AuthorizeBuilder { clock_sysvar: Option, authority: Option, lockup_authority: Option, - pubkey: Option, - stake_authorize: Option, + arg0: Option, + arg1: Option, __remaining_accounts: Vec, } @@ -140,13 +140,13 @@ impl AuthorizeBuilder { self } #[inline(always)] - pub fn pubkey(&mut self, pubkey: Pubkey) -> &mut Self { - self.pubkey = Some(pubkey); + pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { + self.arg0 = Some(arg0); self } #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { - self.stake_authorize = Some(stake_authorize); + pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { + self.arg1 = Some(arg1); self } /// Add an additional account to the instruction. @@ -176,11 +176,8 @@ impl AuthorizeBuilder { lockup_authority: self.lockup_authority, }; let args = AuthorizeInstructionArgs { - pubkey: self.pubkey.clone().expect("pubkey is not set"), - stake_authorize: self - .stake_authorize - .clone() - .expect("stake_authorize is not set"), + arg0: self.arg0.clone().expect("arg0 is not set"), + arg1: self.arg1.clone().expect("arg1 is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -338,8 +335,8 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { clock_sysvar: None, authority: None, lockup_authority: None, - pubkey: None, - stake_authorize: None, + arg0: None, + arg1: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -375,13 +372,13 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn pubkey(&mut self, pubkey: Pubkey) -> &mut Self { - self.instruction.pubkey = Some(pubkey); + pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { + self.instruction.arg0 = Some(arg0); self } #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { - self.instruction.stake_authorize = Some(stake_authorize); + pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { + self.instruction.arg1 = Some(arg1); self } /// Add an additional account to the instruction. @@ -426,12 +423,8 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeInstructionArgs { - pubkey: self.instruction.pubkey.clone().expect("pubkey is not set"), - stake_authorize: self - .instruction - .stake_authorize - .clone() - .expect("stake_authorize is not set"), + arg0: self.instruction.arg0.clone().expect("arg0 is not set"), + arg1: self.instruction.arg1.clone().expect("arg1 is not set"), }; let instruction = AuthorizeCpi { __program: self.instruction.__program, @@ -462,8 +455,8 @@ struct AuthorizeCpiBuilderInstruction<'a, 'b> { 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>>, - pubkey: Option, - stake_authorize: Option, + arg0: Option, + arg1: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/initialize.rs b/clients/rust/src/generated/instructions/initialize.rs index 66248d4b..ccb39c05 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -73,8 +73,8 @@ impl Default for InitializeInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeInstructionArgs { - pub authorized: Authorized, - pub lockup: Lockup, + pub arg0: Authorized, + pub arg1: Lockup, } /// Instruction builder for `Initialize`. @@ -87,8 +87,8 @@ pub struct InitializeInstructionArgs { pub struct InitializeBuilder { stake: Option, rent_sysvar: Option, - authorized: Option, - lockup: Option, + arg0: Option, + arg1: Option, __remaining_accounts: Vec, } @@ -107,13 +107,13 @@ impl InitializeBuilder { self } #[inline(always)] - pub fn authorized(&mut self, authorized: Authorized) -> &mut Self { - self.authorized = Some(authorized); + pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { + self.arg0 = Some(arg0); self } #[inline(always)] - pub fn lockup(&mut self, lockup: Lockup) -> &mut Self { - self.lockup = Some(lockup); + pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { + self.arg1 = Some(arg1); self } /// Add an additional account to the instruction. @@ -141,8 +141,8 @@ impl InitializeBuilder { rent_sysvar: self.rent_sysvar.expect("rent_sysvar is not set"), }; let args = InitializeInstructionArgs { - authorized: self.authorized.clone().expect("authorized is not set"), - lockup: self.lockup.clone().expect("lockup is not set"), + arg0: self.arg0.clone().expect("arg0 is not set"), + arg1: self.arg1.clone().expect("arg1 is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -272,8 +272,8 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { __program: program, stake: None, rent_sysvar: None, - authorized: None, - lockup: None, + arg0: None, + arg1: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -292,13 +292,13 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn authorized(&mut self, authorized: Authorized) -> &mut Self { - self.instruction.authorized = Some(authorized); + pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { + self.instruction.arg0 = Some(arg0); self } #[inline(always)] - pub fn lockup(&mut self, lockup: Lockup) -> &mut Self { - self.instruction.lockup = Some(lockup); + pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { + self.instruction.arg1 = Some(arg1); self } /// Add an additional account to the instruction. @@ -343,12 +343,8 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = InitializeInstructionArgs { - authorized: self - .instruction - .authorized - .clone() - .expect("authorized is not set"), - lockup: self.instruction.lockup.clone().expect("lockup is not set"), + arg0: self.instruction.arg0.clone().expect("arg0 is not set"), + arg1: self.instruction.arg1.clone().expect("arg1 is not set"), }; let instruction = InitializeCpi { __program: self.instruction.__program, @@ -373,8 +369,8 @@ 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>>, - authorized: Option, - lockup: Option, + arg0: Option, + arg1: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/set_lockup_checked.rs b/clients/rust/src/generated/instructions/set_lockup_checked.rs index 60ae2d6b..1b0b4315 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -17,7 +17,7 @@ pub struct SetLockupChecked { pub authority: solana_program::pubkey::Pubkey, - pub lockup_authority: Option, + pub new_authority: Option, } impl SetLockupChecked { @@ -41,9 +41,9 @@ impl SetLockupChecked { self.authority, true, )); - if let Some(lockup_authority) = self.lockup_authority { + if let Some(new_authority) = self.new_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - lockup_authority, + new_authority, true, )); } @@ -90,12 +90,12 @@ pub struct SetLockupCheckedInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[signer]` authority -/// 2. `[signer, optional]` lockup_authority +/// 2. `[signer, optional]` new_authority #[derive(Clone, Debug, Default)] pub struct SetLockupCheckedBuilder { stake: Option, authority: Option, - lockup_authority: Option, + new_authority: Option, lockup_checked_args: Option, __remaining_accounts: Vec, } @@ -116,11 +116,11 @@ impl SetLockupCheckedBuilder { } /// `[optional account]` #[inline(always)] - pub fn lockup_authority( + pub fn new_authority( &mut self, - lockup_authority: Option, + new_authority: Option, ) -> &mut Self { - self.lockup_authority = lockup_authority; + self.new_authority = new_authority; self } #[inline(always)] @@ -151,7 +151,7 @@ impl SetLockupCheckedBuilder { let accounts = SetLockupChecked { stake: self.stake.expect("stake is not set"), authority: self.authority.expect("authority is not set"), - lockup_authority: self.lockup_authority, + new_authority: self.new_authority, }; let args = SetLockupCheckedInstructionArgs { lockup_checked_args: self @@ -170,7 +170,7 @@ pub struct SetLockupCheckedCpiAccounts<'a, 'b> { pub authority: &'b solana_program::account_info::AccountInfo<'a>, - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } /// `set_lockup_checked` CPI instruction. @@ -182,7 +182,7 @@ pub struct SetLockupCheckedCpi<'a, 'b> { pub authority: &'b solana_program::account_info::AccountInfo<'a>, - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: SetLockupCheckedInstructionArgs, } @@ -197,7 +197,7 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { __program: program, stake: accounts.stake, authority: accounts.authority, - lockup_authority: accounts.lockup_authority, + new_authority: accounts.new_authority, __args: args, } } @@ -243,9 +243,9 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { *self.authority.key, true, )); - if let Some(lockup_authority) = self.lockup_authority { + if let Some(new_authority) = self.new_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, + *new_authority.key, true, )); } @@ -269,8 +269,8 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); account_infos.push(self.authority.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); + if let Some(new_authority) = self.new_authority { + account_infos.push(new_authority.clone()); } remaining_accounts .iter() @@ -290,7 +290,7 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { /// /// 0. `[writable]` stake /// 1. `[signer]` authority -/// 2. `[signer, optional]` lockup_authority +/// 2. `[signer, optional]` new_authority #[derive(Clone, Debug)] pub struct SetLockupCheckedCpiBuilder<'a, 'b> { instruction: Box>, @@ -302,7 +302,7 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { __program: program, stake: None, authority: None, - lockup_authority: None, + new_authority: None, lockup_checked_args: None, __remaining_accounts: Vec::new(), }); @@ -323,11 +323,11 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { } /// `[optional account]` #[inline(always)] - pub fn lockup_authority( + pub fn new_authority( &mut self, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; + self.instruction.new_authority = new_authority; self } #[inline(always)] @@ -390,7 +390,7 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { authority: self.instruction.authority.expect("authority is not set"), - lockup_authority: self.instruction.lockup_authority, + new_authority: self.instruction.new_authority, __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -405,7 +405,7 @@ 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>>, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, lockup_checked_args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/interface/idl.json b/interface/idl.json index 3be9adc7..7e630d60 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -639,7 +639,7 @@ }, { "kind": "instructionArgumentNode", - "name": "authorized", + "name": "arg0", "type": { "kind": "definedTypeLinkNode", "name": "authorized" @@ -647,7 +647,7 @@ }, { "kind": "instructionArgumentNode", - "name": "lockup", + "name": "arg1", "type": { "kind": "definedTypeLinkNode", "name": "lockup" @@ -709,14 +709,14 @@ }, { "kind": "instructionArgumentNode", - "name": "pubkey", + "name": "arg0", "type": { "kind": "publicKeyTypeNode" } }, { "kind": "instructionArgumentNode", - "name": "stakeAuthorize", + "name": "arg1", "type": { "kind": "definedTypeLinkNode", "name": "stakeAuthorize" @@ -1354,7 +1354,7 @@ "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", - "name": "lockupAuthority" + "name": "newAuthority" } ], "arguments": [ diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 0541fdbf..e725eb03 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -47,10 +47,7 @@ pub enum StakeInstruction { /// withdrawal restrictions. #[codama(account(name = "stake", writable))] #[codama(account(name = "rent_sysvar"))] - Initialize { - authorized: Authorized, - lockup: Lockup, - }, + Initialize { arg0: Authorized, arg1: Lockup }, /// Authorize a key to manage stake or withdrawal /// @@ -64,10 +61,7 @@ pub enum StakeInstruction { #[codama(account(name = "clock_sysvar"))] #[codama(account(name = "authority", signer))] #[codama(account(name = "lockup_authority", optional, signer))] - Authorize { - pubkey: Pubkey, - stake_authorize: StakeAuthorize, - }, + Authorize { arg0: Pubkey, arg1: StakeAuthorize }, /// Delegate a stake to a particular vote account /// @@ -260,7 +254,7 @@ pub enum StakeInstruction { /// 2. Optional: `[SIGNER]` New lockup authority #[codama(account(name = "stake", writable))] #[codama(account(name = "authority", signer))] - #[codama(account(name = "lockup_authority", optional, signer))] + #[codama(account(name = "new_authority", optional, signer))] SetLockupChecked { lockup_checked_args: LockupCheckedArgs, }, @@ -336,8 +330,8 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of the stake to move, which may be the entire delegation - #[codama(account(name = "source_stake", writable))] - #[codama(account(name = "destination_stake", writable))] + #[codama(account(name = "sourceStake", writable))] + #[codama(account(name = "destinationStake", writable))] #[codama(account(name = "stake_authority", signer))] MoveStake { lamports: u64 }, @@ -413,8 +407,8 @@ pub fn initialize(stake_pubkey: &Pubkey, authorized: &Authorized, lockup: &Locku Instruction::new_with_bincode( ID, &StakeInstruction::Initialize { - authorized: *authorized, - lockup: *lockup, + arg0: *authorized, + arg1: *lockup, }, vec![ AccountMeta::new(*stake_pubkey, false), @@ -676,8 +670,8 @@ pub fn authorize( Instruction::new_with_bincode( ID, &StakeInstruction::Authorize { - pubkey: *new_authorized_pubkey, - stake_authorize, + arg0: *new_authorized_pubkey, + arg1: stake_authorize, }, account_metas, ) From d400f915eda9ee92ca3773fd4ede0767cebf28da Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Tue, 18 Nov 2025 13:32:35 +0000 Subject: [PATCH 11/27] use ugly name (unbreak) --- .../generated/instructions/moveLamports.ts | 10 ++++---- .../src/generated/instructions/moveStake.ts | 13 ++++------ .../generated/instructions/move_lamports.rs | 24 ++++++++----------- .../src/generated/instructions/move_stake.rs | 24 ++++++++----------- interface/idl.json | 4 ++-- interface/src/instruction.rs | 6 +++-- 6 files changed, 36 insertions(+), 45 deletions(-) diff --git a/clients/js/src/generated/instructions/moveLamports.ts b/clients/js/src/generated/instructions/moveLamports.ts index 00409072..67282630 100644 --- a/clients/js/src/generated/instructions/moveLamports.ts +++ b/clients/js/src/generated/instructions/moveLamports.ts @@ -64,16 +64,16 @@ export type MoveLamportsInstruction< export type MoveLamportsInstructionData = { discriminator: number; - lamports: bigint; + args: bigint; }; -export type MoveLamportsInstructionDataArgs = { lamports: number | bigint }; +export type MoveLamportsInstructionDataArgs = { args: number | bigint }; export function getMoveLamportsInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['lamports', getU64Encoder()], + ['args', getU64Encoder()], ]), (value) => ({ ...value, discriminator: MOVE_LAMPORTS_DISCRIMINATOR }) ); @@ -82,7 +82,7 @@ export function getMoveLamportsInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['lamports', getU64Decoder()], + ['args', getU64Decoder()], ]); } @@ -104,7 +104,7 @@ export type MoveLamportsInput< sourceStake: Address; destinationStake: Address; stakeAuthority: TransactionSigner; - lamports: MoveLamportsInstructionDataArgs['lamports']; + args: MoveLamportsInstructionDataArgs['args']; }; export function getMoveLamportsInstruction< diff --git a/clients/js/src/generated/instructions/moveStake.ts b/clients/js/src/generated/instructions/moveStake.ts index 4d862bc6..6d1cbba6 100644 --- a/clients/js/src/generated/instructions/moveStake.ts +++ b/clients/js/src/generated/instructions/moveStake.ts @@ -62,18 +62,15 @@ export type MoveStakeInstruction< ] >; -export type MoveStakeInstructionData = { - discriminator: number; - lamports: bigint; -}; +export type MoveStakeInstructionData = { discriminator: number; args: bigint }; -export type MoveStakeInstructionDataArgs = { lamports: number | bigint }; +export type MoveStakeInstructionDataArgs = { args: number | bigint }; export function getMoveStakeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['lamports', getU64Encoder()], + ['args', getU64Encoder()], ]), (value) => ({ ...value, discriminator: MOVE_STAKE_DISCRIMINATOR }) ); @@ -82,7 +79,7 @@ export function getMoveStakeInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['lamports', getU64Decoder()], + ['args', getU64Decoder()], ]); } @@ -104,7 +101,7 @@ export type MoveStakeInput< sourceStake: Address; destinationStake: Address; stakeAuthority: TransactionSigner; - lamports: MoveStakeInstructionDataArgs['lamports']; + args: MoveStakeInstructionDataArgs['args']; }; export function getMoveStakeInstruction< diff --git a/clients/rust/src/generated/instructions/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs index f2ff4042..77fedfa6 100644 --- a/clients/rust/src/generated/instructions/move_lamports.rs +++ b/clients/rust/src/generated/instructions/move_lamports.rs @@ -77,7 +77,7 @@ impl Default for MoveLamportsInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MoveLamportsInstructionArgs { - pub lamports: u64, + pub args: u64, } /// Instruction builder for `MoveLamports`. @@ -92,7 +92,7 @@ pub struct MoveLamportsBuilder { source_stake: Option, destination_stake: Option, stake_authority: Option, - lamports: Option, + args: Option, __remaining_accounts: Vec, } @@ -122,8 +122,8 @@ impl MoveLamportsBuilder { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.args = Some(args); self } /// Add an additional account to the instruction. @@ -154,7 +154,7 @@ impl MoveLamportsBuilder { stake_authority: self.stake_authority.expect("stake_authority is not set"), }; let args = MoveLamportsInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), + args: self.args.clone().expect("args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -296,7 +296,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { source_stake: None, destination_stake: None, stake_authority: None, - lamports: None, + args: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -326,8 +326,8 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.instruction.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.instruction.args = Some(args); self } /// Add an additional account to the instruction. @@ -372,11 +372,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = MoveLamportsInstructionArgs { - lamports: self - .instruction - .lamports - .clone() - .expect("lamports is not set"), + args: self.instruction.args.clone().expect("args is not set"), }; let instruction = MoveLamportsCpi { __program: self.instruction.__program, @@ -410,7 +406,7 @@ struct MoveLamportsCpiBuilderInstruction<'a, 'b> { 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>>, - lamports: Option, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/move_stake.rs b/clients/rust/src/generated/instructions/move_stake.rs index 959f0c49..96ecb598 100644 --- a/clients/rust/src/generated/instructions/move_stake.rs +++ b/clients/rust/src/generated/instructions/move_stake.rs @@ -77,7 +77,7 @@ impl Default for MoveStakeInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MoveStakeInstructionArgs { - pub lamports: u64, + pub args: u64, } /// Instruction builder for `MoveStake`. @@ -92,7 +92,7 @@ pub struct MoveStakeBuilder { source_stake: Option, destination_stake: Option, stake_authority: Option, - lamports: Option, + args: Option, __remaining_accounts: Vec, } @@ -122,8 +122,8 @@ impl MoveStakeBuilder { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.args = Some(args); self } /// Add an additional account to the instruction. @@ -154,7 +154,7 @@ impl MoveStakeBuilder { stake_authority: self.stake_authority.expect("stake_authority is not set"), }; let args = MoveStakeInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), + args: self.args.clone().expect("args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -296,7 +296,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { source_stake: None, destination_stake: None, stake_authority: None, - lamports: None, + args: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -326,8 +326,8 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.instruction.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.instruction.args = Some(args); self } /// Add an additional account to the instruction. @@ -372,11 +372,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = MoveStakeInstructionArgs { - lamports: self - .instruction - .lamports - .clone() - .expect("lamports is not set"), + args: self.instruction.args.clone().expect("args is not set"), }; let instruction = MoveStakeCpi { __program: self.instruction.__program, @@ -410,7 +406,7 @@ struct MoveStakeCpiBuilderInstruction<'a, 'b> { 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>>, - lamports: Option, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/interface/idl.json b/interface/idl.json index 7e630d60..8ad89a0a 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -1532,7 +1532,7 @@ }, { "kind": "instructionArgumentNode", - "name": "lamports", + "name": "args", "type": { "endian": "le", "format": "u64", @@ -1588,7 +1588,7 @@ }, { "kind": "instructionArgumentNode", - "name": "lamports", + "name": "args", "type": { "endian": "le", "format": "u64", diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index e725eb03..b2ab61e3 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -333,7 +333,8 @@ pub enum StakeInstruction { #[codama(account(name = "sourceStake", writable))] #[codama(account(name = "destinationStake", writable))] #[codama(account(name = "stake_authority", signer))] - MoveStake { lamports: u64 }, + // sadly named `args` to avoid breaking users of old IDL + MoveStake { args: u64 }, /// Move unstaked lamports between accounts with the same authorities and lockups, using Staker /// authority. @@ -351,7 +352,8 @@ pub enum StakeInstruction { #[codama(account(name = "source_stake", writable))] #[codama(account(name = "destination_stake", writable))] #[codama(account(name = "stake_authority", signer))] - MoveLamports { lamports: u64 }, + // sadly named `args` to avoid breaking users of old IDL + MoveLamports { args: u64 }, } #[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] From 37f1e09f3363a0753923b6a9d2434fa521bf74bc Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Tue, 18 Nov 2025 13:39:09 +0000 Subject: [PATCH 12/27] fix tests --- interface/src/instruction.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index b2ab61e3..74271dc3 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -974,7 +974,11 @@ pub fn move_stake( AccountMeta::new_readonly(*authorized_pubkey, true), ]; - Instruction::new_with_bincode(ID, &StakeInstruction::MoveStake { lamports }, account_metas) + Instruction::new_with_bincode( + ID, + &StakeInstruction::MoveStake { args: lamports }, + account_metas, + ) } #[cfg(feature = "bincode")] @@ -992,7 +996,7 @@ pub fn move_lamports( Instruction::new_with_bincode( ID, - &StakeInstruction::MoveLamports { lamports }, + &StakeInstruction::MoveLamports { args: lamports }, account_metas, ) } From be3521b33f3c7397788c51a1b5dec1c6c24474ca Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Thu, 20 Nov 2025 15:50:19 +0000 Subject: [PATCH 13/27] use codama 0.6.4 docs param --- Cargo.lock | 44 ++-- .../src/generated/instructions/authorize.ts | 8 + .../instructions/authorizeChecked.ts | 10 + .../instructions/authorizeCheckedWithSeed.ts | 10 + .../instructions/authorizeWithSeed.ts | 8 + .../src/generated/instructions/deactivate.ts | 6 + .../instructions/deactivateDelinquent.ts | 6 + .../generated/instructions/delegateStake.ts | 12 + .../src/generated/instructions/initialize.ts | 4 + .../instructions/initializeChecked.ts | 8 + .../js/src/generated/instructions/merge.ts | 10 + .../generated/instructions/moveLamports.ts | 6 + .../src/generated/instructions/moveStake.ts | 6 + .../src/generated/instructions/setLockup.ts | 4 + .../instructions/setLockupChecked.ts | 6 + .../js/src/generated/instructions/split.ts | 6 + .../js/src/generated/instructions/withdraw.ts | 12 + .../src/generated/instructions/authorize.rs | 30 ++- .../instructions/authorize_checked.rs | 38 ++- .../authorize_checked_with_seed.rs | 38 ++- .../instructions/authorize_with_seed.rs | 30 ++- .../src/generated/instructions/deactivate.rs | 22 +- .../instructions/deactivate_delinquent.rs | 22 +- .../generated/instructions/delegate_stake.rs | 46 ++-- .../src/generated/instructions/initialize.rs | 14 +- .../instructions/initialize_checked.rs | 30 ++- .../rust/src/generated/instructions/merge.rs | 38 ++- .../generated/instructions/move_lamports.rs | 22 +- .../src/generated/instructions/move_stake.rs | 22 +- .../src/generated/instructions/set_lockup.rs | 14 +- .../instructions/set_lockup_checked.rs | 22 +- .../rust/src/generated/instructions/split.rs | 22 +- .../src/generated/instructions/withdraw.rs | 46 ++-- interface/Cargo.toml | 6 +- interface/idl.json | 183 ++++++++++++++ interface/src/instruction.rs | 234 +++++++++++++----- 36 files changed, 808 insertions(+), 237 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1efc35e8..1ea003ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -942,9 +942,9 @@ dependencies = [ [[package]] name = "codama" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c48b3524aa7ad4c96e9efab8eebf6f1c48dbeac2d82945aa40c61824e958f2" +checksum = "c46db268f2c816f7a6834c0fff1fc0320450ef5d81975bbf0a6eeb52ef9c93ca" dependencies = [ "codama-errors", "codama-korok-plugins", @@ -958,9 +958,9 @@ dependencies = [ [[package]] name = "codama-attributes" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c746407a3ad52c46bd790db787adc3cc45ce35941cfd766681dc30d76137127" +checksum = "404f1560d84ee21be65bedc9a25ab1e8a41a862aaaa9e31b3f7e909cd0f8bbdf" dependencies = [ "codama-errors", "codama-nodes", @@ -973,9 +973,9 @@ dependencies = [ [[package]] name = "codama-errors" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc87d9486b8b0c55079667e3735d98efa3ce6304c9d5977a306e84f2fc7247c" +checksum = "2e56c7fdd1cfabadd8f2535b3901dc5bce44dffd2299ac4249285a95d9922840" dependencies = [ "cargo_toml", "proc-macro2", @@ -986,9 +986,9 @@ dependencies = [ [[package]] name = "codama-korok-plugins" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff0421200f8fedbc02a63741a0303f0c77dc4d1a7e07839995c696283bda955" +checksum = "7463a0931cfd90ae69f681aca23e7e93e0e6bc2dad1028e11c9051803ad6567f" dependencies = [ "codama-errors", "codama-korok-visitors", @@ -997,9 +997,9 @@ dependencies = [ [[package]] name = "codama-korok-visitors" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05b04c22204928bbc5d7e513abcfaf9c94d0e289afe4d31c9873c171882979a" +checksum = "3ad5f926bb3ea0ebe38992f4395dfb87363323083939b7a09560878503322e3c" dependencies = [ "cargo_toml", "codama-attributes", @@ -1013,9 +1013,9 @@ dependencies = [ [[package]] name = "codama-koroks" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb7056e426920bbb1ed7936eabf55cbcf100e05312e2e813bfcc3e02e6d6722" +checksum = "8816dac083eeafabfec24b23553a504fe349f6eedf4c387679f73a501cfe8710" dependencies = [ "codama-attributes", "codama-errors", @@ -1029,9 +1029,9 @@ dependencies = [ [[package]] name = "codama-macros" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d81f04d181107665dde8c5ceaff7e12af0ea9e30125818994165541a58997c50" +checksum = "2545c465cfe9f0ff96f33c8b7ef58db212e307afaff56e5274379e2b9b3f9e7e" dependencies = [ "codama-attributes", "codama-errors", @@ -1044,9 +1044,9 @@ dependencies = [ [[package]] name = "codama-nodes" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943fc6ab9092c8bd6a417ea1df808e6ca4f6a940903c34cf6d06e1ee8e30b839" +checksum = "2f6df08db9a0a16da729816c8de1ad670efb300683955abd7b0de07899c3486d" dependencies = [ "codama-errors", "codama-nodes-derive", @@ -1057,9 +1057,9 @@ dependencies = [ [[package]] name = "codama-nodes-derive" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e971fff8f456bc7cc2d95e33a9f64956ebf57df10e1e8094488c4c2f0b8f6a76" +checksum = "238404cfc7c05c8f62207a909be22e4840f27f69cce61ee940ce1e27a346c797" dependencies = [ "codama-errors", "codama-syn-helpers", @@ -1071,9 +1071,9 @@ dependencies = [ [[package]] name = "codama-stores" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b656f6efc8fe614b913b4651321f48fa612f6c44edbcdb256fd3f216f45dc29" +checksum = "5f60573db8f7b599b4028ecfeebf86cfc3291d157c05e43872e0dc80a5fad009" dependencies = [ "cargo_toml", "codama-errors", @@ -1083,9 +1083,9 @@ dependencies = [ [[package]] name = "codama-syn-helpers" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30fb789956efa136fad8b509875e80f27659dcac0ad9872571de8369e0e9bc0f" +checksum = "09cf58f8fea7cc924b4c91e55536a5c77a1fce2059905c8f05d167cb4ec3bced" dependencies = [ "codama-errors", "derive_more", diff --git a/clients/js/src/generated/instructions/authorize.ts b/clients/js/src/generated/instructions/authorize.ts index 26ca3296..8d41a206 100644 --- a/clients/js/src/generated/instructions/authorize.ts +++ b/clients/js/src/generated/instructions/authorize.ts @@ -127,9 +127,13 @@ export type AuthorizeInput< TAccountAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { + /** Stake account to be updated */ stake: Address; + /** Clock sysvar */ clockSysvar: Address; + /** The stake or withdraw authority */ authority: TransactionSigner; + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; arg0: AuthorizeInstructionDataArgs['arg0']; arg1: AuthorizeInstructionDataArgs['arg1']; @@ -204,9 +208,13 @@ export type ParsedAuthorizeInstruction< > = { programAddress: Address; accounts: { + /** Stake account to be updated */ stake: TAccountMetas[0]; + /** Clock sysvar */ clockSysvar: TAccountMetas[1]; + /** The stake or withdraw authority */ authority: TAccountMetas[2]; + /** 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 8db194e0..e0c31e32 100644 --- a/clients/js/src/generated/instructions/authorizeChecked.ts +++ b/clients/js/src/generated/instructions/authorizeChecked.ts @@ -127,10 +127,15 @@ export type AuthorizeCheckedInput< TAccountNewAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { + /** Stake account to be updated */ stake: Address; + /** Clock sysvar */ clockSysvar: Address; + /** The stake or withdraw authority */ authority: TransactionSigner; + /** The new stake or withdraw authority */ newAuthority: TransactionSigner; + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; stakeAuthorize: AuthorizeCheckedInstructionDataArgs['stakeAuthorize']; }; @@ -210,10 +215,15 @@ export type ParsedAuthorizeCheckedInstruction< > = { programAddress: Address; accounts: { + /** Stake account to be updated */ stake: TAccountMetas[0]; + /** Clock sysvar */ clockSysvar: TAccountMetas[1]; + /** The stake or withdraw authority */ authority: TAccountMetas[2]; + /** The new stake or withdraw authority */ newAuthority: TAccountMetas[3]; + /** 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 faf70df9..70ca718b 100644 --- a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts @@ -135,10 +135,15 @@ export type AuthorizeCheckedWithSeedInput< TAccountNewAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { + /** Stake account to be updated */ stake: Address; + /** Base key of stake or withdraw authority */ base: TransactionSigner; + /** Clock sysvar */ clockSysvar: Address; + /** The new stake or withdraw authority */ newAuthority: TransactionSigner; + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedInstructionDataArgs['authorizeCheckedWithSeedArgs']; }; @@ -218,10 +223,15 @@ export type ParsedAuthorizeCheckedWithSeedInstruction< > = { programAddress: Address; accounts: { + /** Stake account to be updated */ stake: TAccountMetas[0]; + /** Base key of stake or withdraw authority */ base: TAccountMetas[1]; + /** Clock sysvar */ clockSysvar: TAccountMetas[2]; + /** The new stake or withdraw authority */ newAuthority: TAccountMetas[3]; + /** 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 764894d3..679ff874 100644 --- a/clients/js/src/generated/instructions/authorizeWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeWithSeed.ts @@ -120,9 +120,13 @@ export type AuthorizeWithSeedInput< TAccountClockSysvar extends string = string, TAccountLockupAuthority extends string = string, > = { + /** Stake account to be updated */ stake: Address; + /** Base key of stake or withdraw authority */ base: TransactionSigner; + /** Clock sysvar */ clockSysvar: Address; + /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; authorizeWithSeedArgs: AuthorizeWithSeedInstructionDataArgs['authorizeWithSeedArgs']; }; @@ -196,9 +200,13 @@ export type ParsedAuthorizeWithSeedInstruction< > = { programAddress: Address; accounts: { + /** Stake account to be updated */ stake: TAccountMetas[0]; + /** Base key of stake or withdraw authority */ base: TAccountMetas[1]; + /** Clock sysvar */ clockSysvar: TAccountMetas[2]; + /** 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 b7064b1d..457ee39d 100644 --- a/clients/js/src/generated/instructions/deactivate.ts +++ b/clients/js/src/generated/instructions/deactivate.ts @@ -91,8 +91,11 @@ export type DeactivateInput< TAccountClockSysvar extends string = string, TAccountStakeAuthority extends string = string, > = { + /** Delegated stake account to be deactivated */ stake: Address; + /** Clock sysvar */ clockSysvar: Address; + /** Stake authority */ stakeAuthority: TransactionSigner; }; @@ -151,8 +154,11 @@ export type ParsedDeactivateInstruction< > = { programAddress: Address; accounts: { + /** Delegated stake account to be deactivated */ stake: TAccountMetas[0]; + /** Clock sysvar */ clockSysvar: TAccountMetas[1]; + /** Stake authority */ stakeAuthority: TAccountMetas[2]; }; data: DeactivateInstructionData; diff --git a/clients/js/src/generated/instructions/deactivateDelinquent.ts b/clients/js/src/generated/instructions/deactivateDelinquent.ts index 5ff247a5..f393ab28 100644 --- a/clients/js/src/generated/instructions/deactivateDelinquent.ts +++ b/clients/js/src/generated/instructions/deactivateDelinquent.ts @@ -90,8 +90,11 @@ export type DeactivateDelinquentInput< TAccountDelinquentVote extends string = string, TAccountReferenceVote extends string = string, > = { + /** Delegated stake account */ stake: Address; + /** Delinquent vote account for the delegated stake account */ delinquentVote: Address; + /** Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs */ referenceVote: Address; }; @@ -150,8 +153,11 @@ export type ParsedDeactivateDelinquentInstruction< > = { programAddress: Address; accounts: { + /** Delegated stake account */ stake: TAccountMetas[0]; + /** Delinquent vote account for the delegated stake account */ delinquentVote: TAccountMetas[1]; + /** Reference vote account that has voted at least once in the last [`crate::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 e0e1033b..23385112 100644 --- a/clients/js/src/generated/instructions/delegateStake.ts +++ b/clients/js/src/generated/instructions/delegateStake.ts @@ -106,11 +106,17 @@ export type DelegateStakeInput< TAccountUnused extends string = string, TAccountStakeAuthority extends string = string, > = { + /** Initialized stake account to be delegated */ stake: Address; + /** Vote account to which this stake will be delegated */ vote: Address; + /** Clock sysvar */ clockSysvar: Address; + /** Stake history sysvar that carries stake warmup/cooldown history */ stakeHistorySysvar: Address; + /** Unused account, formerly the stake config */ unused: Address; + /** Stake authority */ stakeAuthority: TransactionSigner; }; @@ -190,11 +196,17 @@ export type ParsedDelegateStakeInstruction< > = { programAddress: Address; accounts: { + /** Initialized stake account to be delegated */ stake: TAccountMetas[0]; + /** Vote account to which this stake will be delegated */ vote: TAccountMetas[1]; + /** Clock sysvar */ clockSysvar: TAccountMetas[2]; + /** Stake history sysvar that carries stake warmup/cooldown history */ stakeHistorySysvar: TAccountMetas[3]; + /** Unused account, formerly the stake config */ unused: TAccountMetas[4]; + /** Stake authority */ stakeAuthority: TAccountMetas[5]; }; data: DelegateStakeInstructionData; diff --git a/clients/js/src/generated/instructions/initialize.ts b/clients/js/src/generated/instructions/initialize.ts index ba3a0a0a..301df521 100644 --- a/clients/js/src/generated/instructions/initialize.ts +++ b/clients/js/src/generated/instructions/initialize.ts @@ -107,7 +107,9 @@ export type InitializeInput< TAccountStake extends string = string, TAccountRentSysvar extends string = string, > = { + /** Uninitialized stake account */ stake: Address; + /** Rent sysvar */ rentSysvar: Address; arg0: InitializeInstructionDataArgs['arg0']; arg1: InitializeInstructionDataArgs['arg1']; @@ -160,7 +162,9 @@ export type ParsedInitializeInstruction< > = { programAddress: Address; accounts: { + /** Uninitialized stake account */ stake: TAccountMetas[0]; + /** Rent sysvar */ rentSysvar: TAccountMetas[1]; }; data: InitializeInstructionData; diff --git a/clients/js/src/generated/instructions/initializeChecked.ts b/clients/js/src/generated/instructions/initializeChecked.ts index 7ee23f0e..1941ac0a 100644 --- a/clients/js/src/generated/instructions/initializeChecked.ts +++ b/clients/js/src/generated/instructions/initializeChecked.ts @@ -96,9 +96,13 @@ export type InitializeCheckedInput< TAccountStakeAuthority extends string = string, TAccountWithdrawAuthority extends string = string, > = { + /** Uninitialized stake account */ stake: Address; + /** Rent sysvar */ rentSysvar: Address; + /** The stake authority */ stakeAuthority: Address; + /** The withdraw authority */ withdrawAuthority: TransactionSigner; }; @@ -166,9 +170,13 @@ export type ParsedInitializeCheckedInstruction< > = { programAddress: Address; accounts: { + /** Uninitialized stake account */ stake: TAccountMetas[0]; + /** Rent sysvar */ rentSysvar: TAccountMetas[1]; + /** The stake authority */ stakeAuthority: TAccountMetas[2]; + /** The withdraw authority */ withdrawAuthority: TAccountMetas[3]; }; data: InitializeCheckedInstructionData; diff --git a/clients/js/src/generated/instructions/merge.ts b/clients/js/src/generated/instructions/merge.ts index be7d091f..11ce768a 100644 --- a/clients/js/src/generated/instructions/merge.ts +++ b/clients/js/src/generated/instructions/merge.ts @@ -101,10 +101,15 @@ export type MergeInput< TAccountStakeHistorySysvar extends string = string, TAccountStakeAuthority extends string = string, > = { + /** Destination stake account for the merge */ destinationStake: Address; + /** Source stake account for to merge. This account will be drained */ sourceStake: Address; + /** Clock sysvar */ clockSysvar: Address; + /** Stake history sysvar that carries stake warmup/cooldown history */ stakeHistorySysvar: Address; + /** Stake authority */ stakeAuthority: TransactionSigner; }; @@ -181,10 +186,15 @@ export type ParsedMergeInstruction< > = { programAddress: Address; accounts: { + /** Destination stake account for the merge */ destinationStake: TAccountMetas[0]; + /** Source stake account for to merge. This account will be drained */ sourceStake: TAccountMetas[1]; + /** Clock sysvar */ clockSysvar: TAccountMetas[2]; + /** Stake history sysvar that carries stake warmup/cooldown history */ stakeHistorySysvar: TAccountMetas[3]; + /** Stake authority */ stakeAuthority: TAccountMetas[4]; }; data: MergeInstructionData; diff --git a/clients/js/src/generated/instructions/moveLamports.ts b/clients/js/src/generated/instructions/moveLamports.ts index 67282630..3261bb91 100644 --- a/clients/js/src/generated/instructions/moveLamports.ts +++ b/clients/js/src/generated/instructions/moveLamports.ts @@ -101,8 +101,11 @@ export type MoveLamportsInput< TAccountDestinationStake extends string = string, TAccountStakeAuthority extends string = string, > = { + /** Active or inactive source stake account */ sourceStake: Address; + /** Mergeable destination stake account */ destinationStake: Address; + /** Stake authority */ stakeAuthority: TransactionSigner; args: MoveLamportsInstructionDataArgs['args']; }; @@ -170,8 +173,11 @@ export type ParsedMoveLamportsInstruction< > = { programAddress: Address; accounts: { + /** Active or inactive source stake account */ sourceStake: TAccountMetas[0]; + /** Mergeable destination stake account */ destinationStake: TAccountMetas[1]; + /** Stake authority */ stakeAuthority: TAccountMetas[2]; }; data: MoveLamportsInstructionData; diff --git a/clients/js/src/generated/instructions/moveStake.ts b/clients/js/src/generated/instructions/moveStake.ts index 6d1cbba6..e216194e 100644 --- a/clients/js/src/generated/instructions/moveStake.ts +++ b/clients/js/src/generated/instructions/moveStake.ts @@ -98,8 +98,11 @@ export type MoveStakeInput< TAccountDestinationStake extends string = string, TAccountStakeAuthority extends string = string, > = { + /** Active source stake account */ sourceStake: Address; + /** Active or inactive destination stake account */ destinationStake: Address; + /** Stake authority */ stakeAuthority: TransactionSigner; args: MoveStakeInstructionDataArgs['args']; }; @@ -167,8 +170,11 @@ export type ParsedMoveStakeInstruction< > = { programAddress: Address; accounts: { + /** Active source stake account */ sourceStake: TAccountMetas[0]; + /** Active or inactive destination stake account */ destinationStake: TAccountMetas[1]; + /** Stake authority */ stakeAuthority: TAccountMetas[2]; }; data: MoveStakeInstructionData; diff --git a/clients/js/src/generated/instructions/setLockup.ts b/clients/js/src/generated/instructions/setLockup.ts index 3492f11f..e09ee48f 100644 --- a/clients/js/src/generated/instructions/setLockup.ts +++ b/clients/js/src/generated/instructions/setLockup.ts @@ -100,7 +100,9 @@ export type SetLockupInput< TAccountStake extends string = string, TAccountAuthority extends string = string, > = { + /** Initialized stake account */ stake: Address; + /** Lockup authority or withdraw authority */ authority: TransactionSigner; lockupArgs: SetLockupInstructionDataArgs['lockupArgs']; }; @@ -148,7 +150,9 @@ export type ParsedSetLockupInstruction< > = { programAddress: Address; accounts: { + /** Initialized stake account */ stake: TAccountMetas[0]; + /** Lockup authority or withdraw authority */ authority: TAccountMetas[1]; }; data: SetLockupInstructionData; diff --git a/clients/js/src/generated/instructions/setLockupChecked.ts b/clients/js/src/generated/instructions/setLockupChecked.ts index 020e3a9a..0f86b0db 100644 --- a/clients/js/src/generated/instructions/setLockupChecked.ts +++ b/clients/js/src/generated/instructions/setLockupChecked.ts @@ -115,8 +115,11 @@ export type SetLockupCheckedInput< TAccountAuthority extends string = string, TAccountNewAuthority extends string = string, > = { + /** Initialized stake account */ stake: Address; + /** Lockup authority or withdraw authority */ authority: TransactionSigner; + /** New lockup authority */ newAuthority?: TransactionSigner; lockupCheckedArgs: SetLockupCheckedInstructionDataArgs['lockupCheckedArgs']; }; @@ -181,8 +184,11 @@ export type ParsedSetLockupCheckedInstruction< > = { programAddress: Address; accounts: { + /** Initialized stake account */ stake: TAccountMetas[0]; + /** Lockup authority or withdraw authority */ authority: TAccountMetas[1]; + /** New lockup authority */ newAuthority?: TAccountMetas[2] | undefined; }; data: SetLockupCheckedInstructionData; diff --git a/clients/js/src/generated/instructions/split.ts b/clients/js/src/generated/instructions/split.ts index 4a2df973..a10b8e3b 100644 --- a/clients/js/src/generated/instructions/split.ts +++ b/clients/js/src/generated/instructions/split.ts @@ -98,8 +98,11 @@ export type SplitInput< TAccountSplitStake extends string = string, TAccountStakeAuthority extends string = string, > = { + /** Stake account to be split; must be in the Initialized or Stake state */ stake: Address; + /** Uninitialized stake account that will take the split-off amount */ splitStake: Address; + /** Stake authority */ stakeAuthority: TransactionSigner; lamports: SplitInstructionDataArgs['lamports']; }; @@ -160,8 +163,11 @@ export type ParsedSplitInstruction< > = { programAddress: Address; accounts: { + /** Stake account to be split; must be in the Initialized or Stake state */ stake: TAccountMetas[0]; + /** Uninitialized stake account that will take the split-off amount */ splitStake: TAccountMetas[1]; + /** Stake authority */ stakeAuthority: TAccountMetas[2]; }; data: SplitInstructionData; diff --git a/clients/js/src/generated/instructions/withdraw.ts b/clients/js/src/generated/instructions/withdraw.ts index d91dc22e..c08d2587 100644 --- a/clients/js/src/generated/instructions/withdraw.ts +++ b/clients/js/src/generated/instructions/withdraw.ts @@ -125,11 +125,17 @@ export type WithdrawInput< TAccountWithdrawAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { + /** Stake account from which to withdraw */ stake: Address; + /** Recipient account */ recipient: Address; + /** Clock sysvar */ clockSysvar: Address; + /** Stake history sysvar that carries stake warmup/cooldown history */ stakeHistorySysvar: Address; + /** Withdraw authority */ withdrawAuthority: TransactionSigner; + /** Lockup authority, if before lockup expiration */ lockupAuthority?: TransactionSigner; lamports: WithdrawInstructionDataArgs['lamports']; }; @@ -221,11 +227,17 @@ export type ParsedWithdrawInstruction< > = { programAddress: Address; accounts: { + /** Stake account from which to withdraw */ stake: TAccountMetas[0]; + /** Recipient account */ recipient: TAccountMetas[1]; + /** Clock sysvar */ clockSysvar: TAccountMetas[2]; + /** Stake history sysvar that carries stake warmup/cooldown history */ stakeHistorySysvar: TAccountMetas[3]; + /** Withdraw authority */ withdrawAuthority: TAccountMetas[4]; + /** Lockup authority, if before lockup expiration */ lockupAuthority?: TAccountMetas[5] | undefined; }; data: WithdrawInstructionData; diff --git a/clients/rust/src/generated/instructions/authorize.rs b/clients/rust/src/generated/instructions/authorize.rs index 74ec8f22..4d915f71 100644 --- a/clients/rust/src/generated/instructions/authorize.rs +++ b/clients/rust/src/generated/instructions/authorize.rs @@ -14,12 +14,13 @@ use { /// Accounts. #[derive(Debug)] pub struct Authorize { + /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, - + /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, - + /// The stake or withdraw authority pub authority: solana_program::pubkey::Pubkey, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option, } @@ -115,22 +116,26 @@ impl AuthorizeBuilder { pub fn new() -> Self { Self::default() } + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::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 { self.authority = Some(authority); self } /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, @@ -186,12 +191,13 @@ impl AuthorizeBuilder { /// `authorize` CPI accounts. pub struct AuthorizeCpiAccounts<'a, 'b> { + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// The stake or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } @@ -199,13 +205,13 @@ pub struct AuthorizeCpiAccounts<'a, 'b> { pub struct AuthorizeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// The stake or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeInstructionArgs, @@ -341,11 +347,13 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -354,6 +362,7 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } + /// The stake or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -363,6 +372,7 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { self } /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/authorize_checked.rs b/clients/rust/src/generated/instructions/authorize_checked.rs index a4317be0..d7b19eaf 100644 --- a/clients/rust/src/generated/instructions/authorize_checked.rs +++ b/clients/rust/src/generated/instructions/authorize_checked.rs @@ -13,14 +13,15 @@ use { /// Accounts. #[derive(Debug)] pub struct AuthorizeChecked { + /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, - + /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, - + /// The stake or withdraw authority pub authority: solana_program::pubkey::Pubkey, - + /// The new stake or withdraw authority pub new_authority: solana_program::pubkey::Pubkey, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option, } @@ -120,27 +121,32 @@ impl AuthorizeCheckedBuilder { pub fn new() -> Self { Self::default() } + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::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 { 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 { self.new_authority = Some(new_authority); self } /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, @@ -194,14 +200,15 @@ 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>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// The stake or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// The new stake or withdraw authority pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } @@ -209,15 +216,15 @@ pub struct AuthorizeCheckedCpiAccounts<'a, 'b> { pub struct AuthorizeCheckedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// The stake or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// The new stake or withdraw authority pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeCheckedInstructionArgs, @@ -360,11 +367,13 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -373,6 +382,7 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } + /// The stake or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -381,6 +391,7 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { self.instruction.authority = Some(authority); self } + /// The new stake or withdraw authority #[inline(always)] pub fn new_authority( &mut self, @@ -390,6 +401,7 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { self } /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, 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 8f2843f9..221bfc16 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -13,14 +13,15 @@ use { /// Accounts. #[derive(Debug)] pub struct AuthorizeCheckedWithSeed { + /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, - + /// Base key of stake or withdraw authority pub base: solana_program::pubkey::Pubkey, - + /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, - + /// The new stake or withdraw authority pub new_authority: solana_program::pubkey::Pubkey, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option, } @@ -119,27 +120,32 @@ impl AuthorizeCheckedWithSeedBuilder { pub fn new() -> Self { Self::default() } + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.base = Some(base); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::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 { self.new_authority = Some(new_authority); self } /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, @@ -196,14 +202,15 @@ 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>, - + /// Base key of stake or withdraw authority pub base: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// The new stake or withdraw authority pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } @@ -211,15 +218,15 @@ pub struct AuthorizeCheckedWithSeedCpiAccounts<'a, 'b> { pub struct AuthorizeCheckedWithSeedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Base key of stake or withdraw authority pub base: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// The new stake or withdraw authority pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeCheckedWithSeedInstructionArgs, @@ -362,16 +369,19 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::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 { self.instruction.base = Some(base); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -380,6 +390,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } + /// The new stake or withdraw authority #[inline(always)] pub fn new_authority( &mut self, @@ -389,6 +400,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self } /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index d495e2de..9a427ce3 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -13,12 +13,13 @@ use { /// Accounts. #[derive(Debug)] pub struct AuthorizeWithSeed { + /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, - + /// Base key of stake or withdraw authority pub base: solana_program::pubkey::Pubkey, - + /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option, } @@ -111,22 +112,26 @@ impl AuthorizeWithSeedBuilder { pub fn new() -> Self { Self::default() } + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.base = Some(base); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, @@ -182,12 +187,13 @@ 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>, - + /// Base key of stake or withdraw authority pub base: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } @@ -195,13 +201,13 @@ pub struct AuthorizeWithSeedCpiAccounts<'a, 'b> { pub struct AuthorizeWithSeedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Base key of stake or withdraw authority pub base: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeWithSeedInstructionArgs, @@ -336,16 +342,19 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::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 { self.instruction.base = Some(base); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -355,6 +364,7 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { self } /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/deactivate.rs b/clients/rust/src/generated/instructions/deactivate.rs index 8cad1dcb..b7e12103 100644 --- a/clients/rust/src/generated/instructions/deactivate.rs +++ b/clients/rust/src/generated/instructions/deactivate.rs @@ -10,10 +10,11 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Deactivate { + /// Delegated stake account to be deactivated pub stake: solana_program::pubkey::Pubkey, - + /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, - + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -86,16 +87,19 @@ impl DeactivateBuilder { pub fn new() -> Self { Self::default() } + /// Delegated stake account to be deactivated #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -136,10 +140,11 @@ impl DeactivateBuilder { /// `deactivate` CPI accounts. pub struct DeactivateCpiAccounts<'a, 'b> { + /// Delegated stake account to be deactivated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -147,11 +152,11 @@ pub struct DeactivateCpiAccounts<'a, 'b> { pub struct DeactivateCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Delegated stake account to be deactivated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -267,11 +272,13 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Delegated stake account to be deactivated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -280,6 +287,7 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/deactivate_delinquent.rs b/clients/rust/src/generated/instructions/deactivate_delinquent.rs index c5e0542f..bbfab17a 100644 --- a/clients/rust/src/generated/instructions/deactivate_delinquent.rs +++ b/clients/rust/src/generated/instructions/deactivate_delinquent.rs @@ -10,10 +10,11 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct DeactivateDelinquent { + /// Delegated stake account pub stake: solana_program::pubkey::Pubkey, - + /// Delinquent vote account for the delegated stake account pub delinquent_vote: solana_program::pubkey::Pubkey, - + /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs pub reference_vote: solana_program::pubkey::Pubkey, } @@ -86,11 +87,13 @@ impl DeactivateDelinquentBuilder { pub fn new() -> Self { Self::default() } + /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } + /// Delinquent vote account for the delegated stake account #[inline(always)] pub fn delinquent_vote( &mut self, @@ -99,6 +102,7 @@ impl DeactivateDelinquentBuilder { self.delinquent_vote = Some(delinquent_vote); self } + /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs #[inline(always)] pub fn reference_vote(&mut self, reference_vote: solana_program::pubkey::Pubkey) -> &mut Self { self.reference_vote = Some(reference_vote); @@ -136,10 +140,11 @@ 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 for the delegated stake account pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, - + /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs pub reference_vote: &'b solana_program::account_info::AccountInfo<'a>, } @@ -147,11 +152,11 @@ pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { pub struct DeactivateDelinquentCpi<'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>, - + /// Delinquent vote account for the delegated stake account pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, - + /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs pub reference_vote: &'b solana_program::account_info::AccountInfo<'a>, } @@ -267,11 +272,13 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } + /// Delinquent vote account for the delegated stake account #[inline(always)] pub fn delinquent_vote( &mut self, @@ -280,6 +287,7 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { self.instruction.delinquent_vote = Some(delinquent_vote); self } + /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs #[inline(always)] pub fn reference_vote( &mut self, diff --git a/clients/rust/src/generated/instructions/delegate_stake.rs b/clients/rust/src/generated/instructions/delegate_stake.rs index 19e33208..ec4123c5 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -10,16 +10,17 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct DelegateStake { + /// Initialized stake account to be delegated pub stake: solana_program::pubkey::Pubkey, - + /// Vote account to which this stake will be delegated pub vote: solana_program::pubkey::Pubkey, - + /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, - + /// Stake history sysvar that carries stake warmup/cooldown history pub stake_history_sysvar: solana_program::pubkey::Pubkey, - + /// Unused account, formerly the stake config pub unused: solana_program::pubkey::Pubkey, - + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -109,21 +110,25 @@ impl DelegateStakeBuilder { pub fn new() -> Self { Self::default() } + /// Initialized stake account to be delegated #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.vote = Some(vote); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history_sysvar( &mut self, @@ -132,11 +137,13 @@ impl DelegateStakeBuilder { self.stake_history_sysvar = Some(stake_history_sysvar); self } + /// Unused account, formerly the stake config #[inline(always)] pub fn unused(&mut self, unused: solana_program::pubkey::Pubkey) -> &mut Self { self.unused = Some(unused); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -182,16 +189,17 @@ 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>, - + /// Vote account to which this stake will be delegated pub vote: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake history sysvar that carries stake warmup/cooldown history pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Unused account, formerly the stake config pub unused: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -199,17 +207,17 @@ pub struct DelegateStakeCpiAccounts<'a, 'b> { pub struct DelegateStakeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Initialized stake account to be delegated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Vote account to which this stake will be delegated pub vote: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake history sysvar that carries stake warmup/cooldown history pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Unused account, formerly the stake config pub unused: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -349,16 +357,19 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Initialized stake account to be delegated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::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 { self.instruction.vote = Some(vote); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -367,6 +378,7 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history_sysvar( &mut self, @@ -375,6 +387,7 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { self.instruction.stake_history_sysvar = Some(stake_history_sysvar); self } + /// Unused account, formerly the stake config #[inline(always)] pub fn unused( &mut self, @@ -383,6 +396,7 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { self.instruction.unused = Some(unused); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/initialize.rs b/clients/rust/src/generated/instructions/initialize.rs index ccb39c05..906dab75 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -13,8 +13,9 @@ use { /// Accounts. #[derive(Debug)] pub struct Initialize { + /// Uninitialized stake account pub stake: solana_program::pubkey::Pubkey, - + /// Rent sysvar pub rent_sysvar: solana_program::pubkey::Pubkey, } @@ -96,11 +97,13 @@ impl InitializeBuilder { pub fn new() -> Self { Self::default() } + /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } + /// Rent sysvar #[inline(always)] pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { self.rent_sysvar = Some(rent_sysvar); @@ -151,8 +154,9 @@ impl InitializeBuilder { /// `initialize` CPI accounts. pub struct InitializeCpiAccounts<'a, 'b> { + /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Rent sysvar pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, } @@ -160,9 +164,9 @@ pub struct InitializeCpiAccounts<'a, 'b> { pub struct InitializeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Rent sysvar pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: InitializeInstructionArgs, @@ -278,11 +282,13 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } + /// Rent sysvar #[inline(always)] pub fn rent_sysvar( &mut self, diff --git a/clients/rust/src/generated/instructions/initialize_checked.rs b/clients/rust/src/generated/instructions/initialize_checked.rs index f89f1c10..4dc23f24 100644 --- a/clients/rust/src/generated/instructions/initialize_checked.rs +++ b/clients/rust/src/generated/instructions/initialize_checked.rs @@ -10,12 +10,13 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct InitializeChecked { + /// Uninitialized stake account pub stake: solana_program::pubkey::Pubkey, - + /// Rent sysvar pub rent_sysvar: solana_program::pubkey::Pubkey, - + /// The stake authority pub stake_authority: solana_program::pubkey::Pubkey, - + /// The withdraw authority pub withdraw_authority: solana_program::pubkey::Pubkey, } @@ -94,16 +95,19 @@ impl InitializeCheckedBuilder { pub fn new() -> Self { Self::default() } + /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } + /// Rent sysvar #[inline(always)] pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { self.rent_sysvar = Some(rent_sysvar); self } + /// The stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -112,6 +116,7 @@ impl InitializeCheckedBuilder { self.stake_authority = Some(stake_authority); self } + /// The withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -155,12 +160,13 @@ impl InitializeCheckedBuilder { /// `initialize_checked` CPI accounts. pub struct InitializeCheckedCpiAccounts<'a, 'b> { + /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Rent sysvar pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// The stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// The withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -168,13 +174,13 @@ pub struct InitializeCheckedCpiAccounts<'a, 'b> { pub struct InitializeCheckedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Rent sysvar pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// The stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// The withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -298,11 +304,13 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } + /// Rent sysvar #[inline(always)] pub fn rent_sysvar( &mut self, @@ -311,6 +319,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { self.instruction.rent_sysvar = Some(rent_sysvar); self } + /// The stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -319,6 +328,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { self.instruction.stake_authority = Some(stake_authority); self } + /// The withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/merge.rs b/clients/rust/src/generated/instructions/merge.rs index a38a825b..dbcb56fb 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -10,14 +10,15 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Merge { + /// Destination stake account for the merge pub destination_stake: solana_program::pubkey::Pubkey, - + /// Source stake account for to merge. This account will be drained pub source_stake: solana_program::pubkey::Pubkey, - + /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, - + /// Stake history sysvar that carries stake warmup/cooldown history pub stake_history_sysvar: solana_program::pubkey::Pubkey, - + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -103,6 +104,7 @@ impl MergeBuilder { pub fn new() -> Self { Self::default() } + /// Destination stake account for the merge #[inline(always)] pub fn destination_stake( &mut self, @@ -111,16 +113,19 @@ impl MergeBuilder { self.destination_stake = Some(destination_stake); self } + /// 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 { self.source_stake = Some(source_stake); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history_sysvar( &mut self, @@ -129,6 +134,7 @@ impl MergeBuilder { self.stake_history_sysvar = Some(stake_history_sysvar); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -175,14 +181,15 @@ impl MergeBuilder { /// `merge` CPI accounts. pub struct MergeCpiAccounts<'a, 'b> { + /// Destination stake account for the merge pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Source stake account for to merge. This account will be drained pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake history sysvar that carries stake warmup/cooldown history pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -190,15 +197,15 @@ pub struct MergeCpiAccounts<'a, 'b> { pub struct MergeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Destination stake account for the merge pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Source stake account for to merge. This account will be drained pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake history sysvar that carries stake warmup/cooldown history pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -330,6 +337,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Destination stake account for the merge #[inline(always)] pub fn destination_stake( &mut self, @@ -338,6 +346,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { self.instruction.destination_stake = Some(destination_stake); self } + /// Source stake account for to merge. This account will be drained #[inline(always)] pub fn source_stake( &mut self, @@ -346,6 +355,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { self.instruction.source_stake = Some(source_stake); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -354,6 +364,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history_sysvar( &mut self, @@ -362,6 +373,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { self.instruction.stake_history_sysvar = Some(stake_history_sysvar); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs index 77fedfa6..cc30b72c 100644 --- a/clients/rust/src/generated/instructions/move_lamports.rs +++ b/clients/rust/src/generated/instructions/move_lamports.rs @@ -10,10 +10,11 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct MoveLamports { + /// Active or inactive source stake account pub source_stake: solana_program::pubkey::Pubkey, - + /// Mergeable destination stake account pub destination_stake: solana_program::pubkey::Pubkey, - + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -100,11 +101,13 @@ impl MoveLamportsBuilder { pub fn new() -> Self { Self::default() } + /// Active or inactive source stake account #[inline(always)] pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { self.source_stake = Some(source_stake); self } + /// Mergeable destination stake account #[inline(always)] pub fn destination_stake( &mut self, @@ -113,6 +116,7 @@ impl MoveLamportsBuilder { self.destination_stake = Some(destination_stake); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -163,10 +167,11 @@ 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>, - + /// Mergeable destination stake account pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -174,11 +179,11 @@ pub struct MoveLamportsCpiAccounts<'a, 'b> { pub struct MoveLamportsCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Active or inactive source stake account pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Mergeable destination stake account pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: MoveLamportsInstructionArgs, @@ -301,6 +306,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Active or inactive source stake account #[inline(always)] pub fn source_stake( &mut self, @@ -309,6 +315,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { self.instruction.source_stake = Some(source_stake); self } + /// Mergeable destination stake account #[inline(always)] pub fn destination_stake( &mut self, @@ -317,6 +324,7 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { self.instruction.destination_stake = Some(destination_stake); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/move_stake.rs b/clients/rust/src/generated/instructions/move_stake.rs index 96ecb598..c8953253 100644 --- a/clients/rust/src/generated/instructions/move_stake.rs +++ b/clients/rust/src/generated/instructions/move_stake.rs @@ -10,10 +10,11 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct MoveStake { + /// Active source stake account pub source_stake: solana_program::pubkey::Pubkey, - + /// Active or inactive destination stake account pub destination_stake: solana_program::pubkey::Pubkey, - + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -100,11 +101,13 @@ impl MoveStakeBuilder { pub fn new() -> Self { Self::default() } + /// Active source stake account #[inline(always)] pub fn source_stake(&mut self, source_stake: solana_program::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, @@ -113,6 +116,7 @@ impl MoveStakeBuilder { self.destination_stake = Some(destination_stake); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -163,10 +167,11 @@ 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>, - + /// Active or inactive destination stake account pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -174,11 +179,11 @@ pub struct MoveStakeCpiAccounts<'a, 'b> { pub struct MoveStakeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Active source stake account pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Active or inactive destination stake account pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: MoveStakeInstructionArgs, @@ -301,6 +306,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Active source stake account #[inline(always)] pub fn source_stake( &mut self, @@ -309,6 +315,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { self.instruction.source_stake = Some(source_stake); self } + /// Active or inactive destination stake account #[inline(always)] pub fn destination_stake( &mut self, @@ -317,6 +324,7 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { self.instruction.destination_stake = Some(destination_stake); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/set_lockup.rs b/clients/rust/src/generated/instructions/set_lockup.rs index e339cb24..dd50f2d3 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -13,8 +13,9 @@ use { /// Accounts. #[derive(Debug)] pub struct SetLockup { + /// Initialized stake account pub stake: solana_program::pubkey::Pubkey, - + /// Lockup authority or withdraw authority pub authority: solana_program::pubkey::Pubkey, } @@ -94,11 +95,13 @@ impl SetLockupBuilder { pub fn new() -> Self { Self::default() } + /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.authority = Some(authority); @@ -143,8 +146,9 @@ impl SetLockupBuilder { /// `set_lockup` CPI accounts. pub struct SetLockupCpiAccounts<'a, 'b> { + /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -152,9 +156,9 @@ pub struct SetLockupCpiAccounts<'a, 'b> { pub struct SetLockupCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: SetLockupInstructionArgs, @@ -269,11 +273,13 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } + /// Lockup authority or withdraw authority #[inline(always)] pub fn authority( &mut self, diff --git a/clients/rust/src/generated/instructions/set_lockup_checked.rs b/clients/rust/src/generated/instructions/set_lockup_checked.rs index 1b0b4315..935d8aa8 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -13,10 +13,11 @@ use { /// Accounts. #[derive(Debug)] pub struct SetLockupChecked { + /// Initialized stake account pub stake: solana_program::pubkey::Pubkey, - + /// Lockup authority or withdraw authority pub authority: solana_program::pubkey::Pubkey, - + /// New lockup authority pub new_authority: Option, } @@ -104,17 +105,20 @@ impl SetLockupCheckedBuilder { pub fn new() -> Self { Self::default() } + /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.authority = Some(authority); self } /// `[optional account]` + /// New lockup authority #[inline(always)] pub fn new_authority( &mut self, @@ -166,10 +170,11 @@ impl SetLockupCheckedBuilder { /// `set_lockup_checked` CPI accounts. pub struct SetLockupCheckedCpiAccounts<'a, 'b> { + /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// New lockup authority pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } @@ -177,11 +182,11 @@ pub struct SetLockupCheckedCpiAccounts<'a, 'b> { pub struct SetLockupCheckedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// New lockup authority pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: SetLockupCheckedInstructionArgs, @@ -308,11 +313,13 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } + /// Lockup authority or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -322,6 +329,7 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { self } /// `[optional account]` + /// New lockup authority #[inline(always)] pub fn new_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/split.rs b/clients/rust/src/generated/instructions/split.rs index 348020e6..36701c29 100644 --- a/clients/rust/src/generated/instructions/split.rs +++ b/clients/rust/src/generated/instructions/split.rs @@ -10,10 +10,11 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Split { + /// Stake account to be split; must be in the Initialized or Stake state pub stake: solana_program::pubkey::Pubkey, - + /// Uninitialized stake account that will take the split-off amount pub split_stake: solana_program::pubkey::Pubkey, - + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -99,16 +100,19 @@ impl SplitBuilder { pub fn new() -> Self { Self::default() } + /// 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 { self.stake = Some(stake); self } + /// 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 { self.split_stake = Some(split_stake); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -157,10 +161,11 @@ impl SplitBuilder { /// `split` CPI accounts. pub struct SplitCpiAccounts<'a, 'b> { + /// Stake account to be split; must be in the Initialized or Stake state pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Uninitialized stake account that will take the split-off amount pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -168,11 +173,11 @@ pub struct SplitCpiAccounts<'a, 'b> { pub struct SplitCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake account to be split; must be in the Initialized or Stake state pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Uninitialized stake account that will take the split-off amount pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: SplitInstructionArgs, @@ -295,11 +300,13 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { }); Self { instruction } } + /// 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 { self.instruction.stake = Some(stake); self } + /// Uninitialized stake account that will take the split-off amount #[inline(always)] pub fn split_stake( &mut self, @@ -308,6 +315,7 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { self.instruction.split_stake = Some(split_stake); self } + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, diff --git a/clients/rust/src/generated/instructions/withdraw.rs b/clients/rust/src/generated/instructions/withdraw.rs index eceba2a9..a436dae5 100644 --- a/clients/rust/src/generated/instructions/withdraw.rs +++ b/clients/rust/src/generated/instructions/withdraw.rs @@ -10,16 +10,17 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Withdraw { + /// Stake account from which to withdraw pub stake: solana_program::pubkey::Pubkey, - + /// Recipient account pub recipient: solana_program::pubkey::Pubkey, - + /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, - + /// Stake history sysvar that carries stake warmup/cooldown history pub stake_history_sysvar: solana_program::pubkey::Pubkey, - + /// Withdraw authority pub withdraw_authority: solana_program::pubkey::Pubkey, - + /// Lockup authority, if before lockup expiration pub lockup_authority: Option, } @@ -125,21 +126,25 @@ impl WithdrawBuilder { pub fn new() -> Self { Self::default() } + /// Stake account from which to withdraw #[inline(always)] pub fn stake(&mut self, stake: solana_program::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 { self.recipient = Some(recipient); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { self.clock_sysvar = Some(clock_sysvar); self } + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history_sysvar( &mut self, @@ -148,6 +153,7 @@ impl WithdrawBuilder { self.stake_history_sysvar = Some(stake_history_sysvar); self } + /// Withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -157,6 +163,7 @@ impl WithdrawBuilder { self } /// `[optional account]` + /// Lockup authority, if before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, @@ -212,16 +219,17 @@ 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>, - + /// Recipient account pub recipient: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake history sysvar that carries stake warmup/cooldown history pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } @@ -229,17 +237,17 @@ pub struct WithdrawCpiAccounts<'a, 'b> { pub struct WithdrawCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake account from which to withdraw pub stake: &'b solana_program::account_info::AccountInfo<'a>, - + /// Recipient account pub recipient: &'b solana_program::account_info::AccountInfo<'a>, - + /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Stake history sysvar that carries stake warmup/cooldown history pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - + /// Withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - + /// Lockup authority, if before lockup expiration pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: WithdrawInstructionArgs, @@ -390,11 +398,13 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { }); Self { instruction } } + /// Stake account from which to withdraw #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } + /// Recipient account #[inline(always)] pub fn recipient( &mut self, @@ -403,6 +413,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self.instruction.recipient = Some(recipient); self } + /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -411,6 +422,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self.instruction.clock_sysvar = Some(clock_sysvar); self } + /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history_sysvar( &mut self, @@ -419,6 +431,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self.instruction.stake_history_sysvar = Some(stake_history_sysvar); self } + /// Withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -428,6 +441,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self } /// `[optional account]` + /// Lockup authority, if before lockup expiration #[inline(always)] pub fn lockup_authority( &mut self, diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 30f0df56..1e631874 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -18,8 +18,8 @@ program-id = "Stake11111111111111111111111111111111111111" [dependencies] borsh = { version = "1.5.7", features = ["derive", "unstable__schema"], optional = true } -codama = "0.6.2" -codama-macros = "0.6.2" +codama = "0.6.4" +codama-macros = "0.6.4" num-traits = "0.2" serde = { version = "1.0.210", optional = true } serde_derive = { version = "1.0.210", optional = true } @@ -35,7 +35,7 @@ solana-sysvar = { version = "3.0.0", optional = true } solana-sysvar-id = { version = "3.0.0", optional = true } [build-dependencies] -codama = "0.6.2" +codama = "0.6.4" serde_json = "1.0" [dev-dependencies] diff --git a/interface/idl.json b/interface/idl.json index 8ad89a0a..d115a336 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -610,12 +610,18 @@ { "accounts": [ { + "docs": [ + "Uninitialized stake account" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "stake" }, { + "docs": [ + "Rent sysvar" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", @@ -667,24 +673,36 @@ { "accounts": [ { + "docs": [ + "Stake account to be updated" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "stake" }, { + "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, @@ -736,36 +754,54 @@ { "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" }, { + "docs": [ + "Clock sysvar" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "clockSysvar" }, { + "docs": [ + "Stake history sysvar that carries stake warmup/cooldown history" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "stakeHistorySysvar" }, { + "docs": [ + "Unused account, formerly the stake config" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "unused" }, { + "docs": [ + "Stake authority" + ], "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", @@ -801,18 +837,27 @@ { "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" }, { + "docs": [ + "Stake authority" + ], "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", @@ -857,36 +902,54 @@ { "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" }, { + "docs": [ + "Clock sysvar" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "clockSysvar" }, { + "docs": [ + "Stake history sysvar that carries stake warmup/cooldown history" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "stakeHistorySysvar" }, { + "docs": [ + "Withdraw authority" + ], "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", "name": "withdrawAuthority" }, { + "docs": [ + "Lockup authority, if before lockup expiration" + ], "isOptional": true, "isSigner": true, "isWritable": false, @@ -932,18 +995,27 @@ { "accounts": [ { + "docs": [ + "Delegated stake account to be deactivated" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "stake" }, { + "docs": [ + "Clock sysvar" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "clockSysvar" }, { + "docs": [ + "Stake authority" + ], "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", @@ -979,12 +1051,18 @@ { "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", @@ -1028,30 +1106,45 @@ { "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" }, { + "docs": [ + "Clock sysvar" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "clockSysvar" }, { + "docs": [ + "Stake history sysvar that carries stake warmup/cooldown history" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "stakeHistorySysvar" }, { + "docs": [ + "Stake authority" + ], "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", @@ -1087,24 +1180,36 @@ { "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" }, { + "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, @@ -1149,24 +1254,36 @@ { "accounts": [ { + "docs": [ + "Uninitialized stake account" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "stake" }, { + "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", @@ -1202,30 +1319,45 @@ { "accounts": [ { + "docs": [ + "Stake account to be updated" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "stake" }, { + "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": [ + "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, @@ -1270,30 +1402,45 @@ { "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" }, { + "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" }, { + "docs": [ + "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + ], "isOptional": true, "isSigner": true, "isWritable": false, @@ -1338,18 +1485,27 @@ { "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, @@ -1422,18 +1578,27 @@ { "accounts": [ { + "docs": [ + "Delegated stake account" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "stake" }, { + "docs": [ + "Delinquent vote account for the delegated stake account" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "delinquentVote" }, { + "docs": [ + "Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs" + ], "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", @@ -1497,18 +1662,27 @@ { "accounts": [ { + "docs": [ + "Active source stake account" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "sourceStake" }, { + "docs": [ + "Active or inactive destination stake account" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "destinationStake" }, { + "docs": [ + "Stake authority" + ], "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", @@ -1553,18 +1727,27 @@ { "accounts": [ { + "docs": [ + "Active or inactive source stake account" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "sourceStake" }, { + "docs": [ + "Mergeable destination stake account" + ], "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "destinationStake" }, { + "docs": [ + "Stake authority" + ], "isSigner": true, "isWritable": false, "kind": "instructionAccountNode", diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 74271dc3..374e5c4e 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -45,8 +45,8 @@ pub enum StakeInstruction { /// [`Authorized`] carries pubkeys that must sign staker transactions /// and withdrawer transactions; [`Lockup`] carries information about /// withdrawal restrictions. - #[codama(account(name = "stake", writable))] - #[codama(account(name = "rent_sysvar"))] + #[codama(account(name = "stake", writable, docs = "Uninitialized stake account"))] + #[codama(account(name = "rent_sysvar", docs = "Rent sysvar"))] Initialize { arg0: Authorized, arg1: Lockup }, /// Authorize a key to manage stake or withdrawal @@ -57,10 +57,15 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` The stake or withdraw authority /// 3. Optional: `[SIGNER]` Lockup authority, if updating `StakeAuthorize::Withdrawer` before /// lockup expiration - #[codama(account(name = "stake", writable))] - #[codama(account(name = "clock_sysvar"))] - #[codama(account(name = "authority", signer))] - #[codama(account(name = "lockup_authority", optional, signer))] + #[codama(account(name = "stake", writable, docs = "Stake account to be updated"))] + #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[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" + ))] Authorize { arg0: Pubkey, arg1: StakeAuthorize }, /// Delegate a stake to a particular vote account @@ -75,12 +80,22 @@ 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. - #[codama(account(name = "stake", writable))] - #[codama(account(name = "vote"))] - #[codama(account(name = "clock_sysvar"))] - #[codama(account(name = "stake_history_sysvar"))] - #[codama(account(name = "unused"))] - #[codama(account(name = "stake_authority", signer))] + #[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"))] + #[codama(account( + name = "stake_history_sysvar", + docs = "Stake history sysvar that carries stake warmup/cooldown 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. @@ -89,9 +104,17 @@ 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 - #[codama(account(name = "stake", writable))] - #[codama(account(name = "split_stake", writable))] - #[codama(account(name = "stake_authority", signer))] + #[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"))] Split { lamports: u64 }, /// Withdraw unstaked lamports from the stake account @@ -106,12 +129,24 @@ pub enum StakeInstruction { /// /// The `u64` is the portion of the stake account balance to be withdrawn, /// must be `<= StakeAccount.lamports - staked_lamports`. - #[codama(account(name = "stake", writable))] - #[codama(account(name = "recipient", writable))] - #[codama(account(name = "clock_sysvar"))] - #[codama(account(name = "stake_history_sysvar"))] - #[codama(account(name = "withdraw_authority", signer))] - #[codama(account(name = "lockup_authority", optional, signer))] + #[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"))] + #[codama(account( + name = "stake_history_sysvar", + docs = "Stake history sysvar that carries stake warmup/cooldown history" + ))] + #[codama(account(name = "withdraw_authority", signer, docs = "Withdraw authority"))] + #[codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if before lockup expiration" + ))] Withdraw { lamports: u64 }, /// Deactivates the stake in the account @@ -120,9 +155,13 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Delegated stake account /// 1. `[]` Clock sysvar /// 2. `[SIGNER]` Stake authority - #[codama(account(name = "stake", writable))] - #[codama(account(name = "clock_sysvar"))] - #[codama(account(name = "stake_authority", signer))] + #[codama(account( + name = "stake", + writable, + docs = "Delegated stake account to be deactivated" + ))] + #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[codama(account(name = "stake_authority", signer, docs = "Stake authority"))] Deactivate, /// Set stake lockup @@ -133,8 +172,12 @@ pub enum StakeInstruction { /// # Account references /// 0. `[WRITE]` Initialized stake account /// 1. `[SIGNER]` Lockup authority or withdraw authority - #[codama(account(name = "stake", writable))] - #[codama(account(name = "authority", signer))] + #[codama(account(name = "stake", writable, docs = "Initialized stake account"))] + #[codama(account( + name = "authority", + signer, + docs = "Lockup authority or withdraw authority" + ))] SetLockup { lockup_args: LockupArgs }, /// Merge two stake accounts. @@ -161,11 +204,22 @@ pub enum StakeInstruction { /// 2. `[]` Clock sysvar /// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history /// 4. `[SIGNER]` Stake authority - #[codama(account(name = "destination_stake", writable))] - #[codama(account(name = "source_stake", writable))] - #[codama(account(name = "clock_sysvar"))] - #[codama(account(name = "stake_history_sysvar"))] - #[codama(account(name = "stake_authority", signer))] + #[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"))] + #[codama(account( + name = "stake_history_sysvar", + docs = "Stake history sysvar that carries stake warmup/cooldown history" + ))] + #[codama(account(name = "stake_authority", signer, docs = "Stake authority"))] Merge, /// Authorize a key to manage stake or withdrawal with a derived key @@ -176,10 +230,19 @@ pub enum StakeInstruction { /// 2. `[]` Clock sysvar /// 3. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration - #[codama(account(name = "stake", writable))] - #[codama(account(name = "base", signer))] - #[codama(account(name = "clock_sysvar"))] - #[codama(account(name = "lockup_authority", optional, signer))] + #[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"))] + #[codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + ))] AuthorizeWithSeed { authorize_with_seed_args: AuthorizeWithSeedArgs, }, @@ -194,10 +257,10 @@ pub enum StakeInstruction { /// 1. `[]` Rent sysvar /// 2. `[]` The stake authority /// 3. `[SIGNER]` The withdraw authority - #[codama(account(name = "stake", writable))] - #[codama(account(name = "rent_sysvar"))] - #[codama(account(name = "stake_authority"))] - #[codama(account(name = "withdraw_authority", signer))] + #[codama(account(name = "stake", writable, docs = "Uninitialized stake account"))] + #[codama(account(name = "rent_sysvar", docs = "Rent sysvar"))] + #[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 @@ -212,11 +275,20 @@ pub enum StakeInstruction { /// 3. `[SIGNER]` The new stake or withdraw authority /// 4. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration - #[codama(account(name = "stake", writable))] - #[codama(account(name = "clock_sysvar"))] - #[codama(account(name = "authority", signer))] - #[codama(account(name = "new_authority", signer))] - #[codama(account(name = "lockup_authority", optional, signer))] + #[codama(account(name = "stake", writable, docs = "Stake account to be updated"))] + #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[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 { stake_authorize: StakeAuthorize }, /// Authorize a key to manage stake or withdrawal with a derived key @@ -231,11 +303,24 @@ pub enum StakeInstruction { /// 3. `[SIGNER]` The new stake or withdraw authority /// 4. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration - #[codama(account(name = "stake", writable))] - #[codama(account(name = "base", signer))] - #[codama(account(name = "clock_sysvar"))] - #[codama(account(name = "new_authority", signer))] - #[codama(account(name = "lockup_authority", optional, signer))] + #[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"))] + #[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 { authorize_checked_with_seed_args: AuthorizeCheckedWithSeedArgs, }, @@ -252,9 +337,18 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Initialized stake account /// 1. `[SIGNER]` Lockup authority or withdraw authority /// 2. Optional: `[SIGNER]` New lockup authority - #[codama(account(name = "stake", writable))] - #[codama(account(name = "authority", signer))] - #[codama(account(name = "new_authority", optional, signer))] + #[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 { lockup_checked_args: LockupCheckedArgs, }, @@ -282,9 +376,15 @@ pub enum StakeInstruction { /// 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 - #[codama(account(name = "stake", writable))] - #[codama(account(name = "delinquent_vote"))] - #[codama(account(name = "reference_vote"))] + #[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 [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs" + ))] DeactivateDelinquent, /// Redelegate activated stake to another vote account. @@ -330,9 +430,13 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of the stake to move, which may be the entire delegation - #[codama(account(name = "sourceStake", writable))] - #[codama(account(name = "destinationStake", writable))] - #[codama(account(name = "stake_authority", signer))] + #[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 { args: u64 }, @@ -349,9 +453,17 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of available lamports to move - #[codama(account(name = "source_stake", writable))] - #[codama(account(name = "destination_stake", writable))] - #[codama(account(name = "stake_authority", signer))] + #[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 { args: u64 }, } From fd6e63989a972c61f9ba289a262146071bdf1065 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Sat, 22 Nov 2025 13:33:21 +0000 Subject: [PATCH 14/27] properly flatten instruction arguments --- .../instructions/authorizeCheckedWithSeed.ts | 39 ++++--- .../instructions/authorizeWithSeed.ts | 42 +++++-- .../src/generated/instructions/setLockup.ts | 40 +++++-- .../instructions/setLockupChecked.ts | 31 +++-- .../types/authorizeCheckedWithSeedParams.ts | 69 ------------ .../types/authorizeWithSeedParams.ts | 73 ------------ clients/js/src/generated/types/index.ts | 4 - .../generated/types/lockupCheckedParams.ts | 64 ----------- .../js/src/generated/types/lockupParams.ts | 65 ----------- .../authorize_checked_with_seed.rs | 83 ++++++++++---- .../instructions/authorize_with_seed.rs | 106 ++++++++++++++---- .../src/generated/instructions/set_lockup.rs | 65 ++++++++--- .../instructions/set_lockup_checked.rs | 49 +++++--- .../authorize_checked_with_seed_params.rs | 24 ---- .../types/authorize_with_seed_params.rs | 29 ----- .../generated/types/lockup_checked_params.rs | 18 --- .../rust/src/generated/types/lockup_params.rs | 20 ---- clients/rust/src/generated/types/mod.rs | 11 +- scripts/generate-clients.mts | 4 + 19 files changed, 347 insertions(+), 489 deletions(-) delete mode 100644 clients/js/src/generated/types/authorizeCheckedWithSeedParams.ts delete mode 100644 clients/js/src/generated/types/authorizeWithSeedParams.ts delete mode 100644 clients/js/src/generated/types/lockupCheckedParams.ts delete mode 100644 clients/js/src/generated/types/lockupParams.ts delete mode 100644 clients/rust/src/generated/types/authorize_checked_with_seed_params.rs delete mode 100644 clients/rust/src/generated/types/authorize_with_seed_params.rs delete mode 100644 clients/rust/src/generated/types/lockup_checked_params.rs delete mode 100644 clients/rust/src/generated/types/lockup_params.rs diff --git a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts index 70ca718b..0d0d2e52 100644 --- a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts @@ -7,11 +7,17 @@ */ import { + addDecoderSizePrefix, + addEncoderSizePrefix, combineCodec, + getAddressDecoder, + getAddressEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, + getUtf8Decoder, + getUtf8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -31,10 +37,10 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getAuthorizeCheckedWithSeedParamsDecoder, - getAuthorizeCheckedWithSeedParamsEncoder, - type AuthorizeCheckedWithSeedParams, - type AuthorizeCheckedWithSeedParamsArgs, + getStakeAuthorizeDecoder, + getStakeAuthorizeEncoder, + type StakeAuthorize, + type StakeAuthorizeArgs, } from '../types'; export const AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR = 11; @@ -85,21 +91,27 @@ export type AuthorizeCheckedWithSeedInstruction< export type AuthorizeCheckedWithSeedInstructionData = { discriminator: number; - authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedParams; + stakeAuthorize: StakeAuthorize; + authoritySeed: string; + authorityOwner: Address; }; export type AuthorizeCheckedWithSeedInstructionDataArgs = { - authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedParamsArgs; + stakeAuthorize: StakeAuthorizeArgs; + authoritySeed: string; + authorityOwner: Address; }; export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], + ['stakeAuthorize', getStakeAuthorizeEncoder()], [ - 'authorizeCheckedWithSeedArgs', - getAuthorizeCheckedWithSeedParamsEncoder(), + 'authoritySeed', + addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()), ], + ['authorityOwner', getAddressEncoder()], ]), (value) => ({ ...value, @@ -111,10 +123,9 @@ export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - [ - 'authorizeCheckedWithSeedArgs', - getAuthorizeCheckedWithSeedParamsDecoder(), - ], + ['stakeAuthorize', getStakeAuthorizeDecoder()], + ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], + ['authorityOwner', getAddressDecoder()], ]); } @@ -145,7 +156,9 @@ export type AuthorizeCheckedWithSeedInput< newAuthority: TransactionSigner; /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; - authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedInstructionDataArgs['authorizeCheckedWithSeedArgs']; + stakeAuthorize: AuthorizeCheckedWithSeedInstructionDataArgs['stakeAuthorize']; + authoritySeed: AuthorizeCheckedWithSeedInstructionDataArgs['authoritySeed']; + authorityOwner: AuthorizeCheckedWithSeedInstructionDataArgs['authorityOwner']; }; export function getAuthorizeCheckedWithSeedInstruction< diff --git a/clients/js/src/generated/instructions/authorizeWithSeed.ts b/clients/js/src/generated/instructions/authorizeWithSeed.ts index 679ff874..a5843265 100644 --- a/clients/js/src/generated/instructions/authorizeWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeWithSeed.ts @@ -7,11 +7,17 @@ */ import { + addDecoderSizePrefix, + addEncoderSizePrefix, combineCodec, + getAddressDecoder, + getAddressEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, + getUtf8Decoder, + getUtf8Encoder, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -31,10 +37,10 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getAuthorizeWithSeedParamsDecoder, - getAuthorizeWithSeedParamsEncoder, - type AuthorizeWithSeedParams, - type AuthorizeWithSeedParamsArgs, + getStakeAuthorizeDecoder, + getStakeAuthorizeEncoder, + type StakeAuthorize, + type StakeAuthorizeArgs, } from '../types'; export const AUTHORIZE_WITH_SEED_DISCRIMINATOR = 8; @@ -80,18 +86,30 @@ export type AuthorizeWithSeedInstruction< export type AuthorizeWithSeedInstructionData = { discriminator: number; - authorizeWithSeedArgs: AuthorizeWithSeedParams; + newAuthorizedPubkey: Address; + stakeAuthorize: StakeAuthorize; + authoritySeed: string; + authorityOwner: Address; }; export type AuthorizeWithSeedInstructionDataArgs = { - authorizeWithSeedArgs: AuthorizeWithSeedParamsArgs; + newAuthorizedPubkey: Address; + stakeAuthorize: StakeAuthorizeArgs; + authoritySeed: string; + authorityOwner: Address; }; export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['authorizeWithSeedArgs', getAuthorizeWithSeedParamsEncoder()], + ['newAuthorizedPubkey', getAddressEncoder()], + ['stakeAuthorize', getStakeAuthorizeEncoder()], + [ + 'authoritySeed', + addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()), + ], + ['authorityOwner', getAddressEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_WITH_SEED_DISCRIMINATOR }) ); @@ -100,7 +118,10 @@ export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['authorizeWithSeedArgs', getAuthorizeWithSeedParamsDecoder()], + ['newAuthorizedPubkey', getAddressDecoder()], + ['stakeAuthorize', getStakeAuthorizeDecoder()], + ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], + ['authorityOwner', getAddressDecoder()], ]); } @@ -128,7 +149,10 @@ export type AuthorizeWithSeedInput< clockSysvar: Address; /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; - authorizeWithSeedArgs: AuthorizeWithSeedInstructionDataArgs['authorizeWithSeedArgs']; + newAuthorizedPubkey: AuthorizeWithSeedInstructionDataArgs['newAuthorizedPubkey']; + stakeAuthorize: AuthorizeWithSeedInstructionDataArgs['stakeAuthorize']; + authoritySeed: AuthorizeWithSeedInstructionDataArgs['authoritySeed']; + authorityOwner: AuthorizeWithSeedInstructionDataArgs['authorityOwner']; }; export function getAuthorizeWithSeedInstruction< diff --git a/clients/js/src/generated/instructions/setLockup.ts b/clients/js/src/generated/instructions/setLockup.ts index e09ee48f..18dc14b1 100644 --- a/clients/js/src/generated/instructions/setLockup.ts +++ b/clients/js/src/generated/instructions/setLockup.ts @@ -8,6 +8,10 @@ import { combineCodec, + getAddressDecoder, + getAddressEncoder, + getOptionDecoder, + getOptionEncoder, getStructDecoder, getStructEncoder, getU32Decoder, @@ -22,6 +26,8 @@ import { type Instruction, type InstructionWithAccounts, type InstructionWithData, + type Option, + type OptionOrNullable, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, @@ -30,10 +36,14 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getLockupParamsDecoder, - getLockupParamsEncoder, - type LockupParams, - type LockupParamsArgs, + getEpochDecoder, + getEpochEncoder, + getUnixTimestampDecoder, + getUnixTimestampEncoder, + type Epoch, + type EpochArgs, + type UnixTimestamp, + type UnixTimestampArgs, } from '../types'; export const SET_LOCKUP_DISCRIMINATOR = 6; @@ -64,16 +74,24 @@ export type SetLockupInstruction< export type SetLockupInstructionData = { discriminator: number; - lockupArgs: LockupParams; + unixTimestamp: Option; + epoch: Option; + custodian: Option
; }; -export type SetLockupInstructionDataArgs = { lockupArgs: LockupParamsArgs }; +export type SetLockupInstructionDataArgs = { + unixTimestamp: OptionOrNullable; + epoch: OptionOrNullable; + custodian: OptionOrNullable
; +}; export function getSetLockupInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['lockupArgs', getLockupParamsEncoder()], + ['unixTimestamp', getOptionEncoder(getUnixTimestampEncoder())], + ['epoch', getOptionEncoder(getEpochEncoder())], + ['custodian', getOptionEncoder(getAddressEncoder())], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_DISCRIMINATOR }) ); @@ -82,7 +100,9 @@ export function getSetLockupInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['lockupArgs', getLockupParamsDecoder()], + ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], + ['epoch', getOptionDecoder(getEpochDecoder())], + ['custodian', getOptionDecoder(getAddressDecoder())], ]); } @@ -104,7 +124,9 @@ export type SetLockupInput< stake: Address; /** Lockup authority or withdraw authority */ authority: TransactionSigner; - lockupArgs: SetLockupInstructionDataArgs['lockupArgs']; + unixTimestamp: SetLockupInstructionDataArgs['unixTimestamp']; + epoch: SetLockupInstructionDataArgs['epoch']; + custodian: SetLockupInstructionDataArgs['custodian']; }; export function getSetLockupInstruction< diff --git a/clients/js/src/generated/instructions/setLockupChecked.ts b/clients/js/src/generated/instructions/setLockupChecked.ts index 0f86b0db..7256b7ad 100644 --- a/clients/js/src/generated/instructions/setLockupChecked.ts +++ b/clients/js/src/generated/instructions/setLockupChecked.ts @@ -8,6 +8,8 @@ import { combineCodec, + getOptionDecoder, + getOptionEncoder, getStructDecoder, getStructEncoder, getU32Decoder, @@ -22,6 +24,8 @@ import { type Instruction, type InstructionWithAccounts, type InstructionWithData, + type Option, + type OptionOrNullable, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, @@ -30,10 +34,14 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getLockupCheckedParamsDecoder, - getLockupCheckedParamsEncoder, - type LockupCheckedParams, - type LockupCheckedParamsArgs, + getEpochDecoder, + getEpochEncoder, + getUnixTimestampDecoder, + getUnixTimestampEncoder, + type Epoch, + type EpochArgs, + type UnixTimestamp, + type UnixTimestampArgs, } from '../types'; export const SET_LOCKUP_CHECKED_DISCRIMINATOR = 12; @@ -76,18 +84,21 @@ export type SetLockupCheckedInstruction< export type SetLockupCheckedInstructionData = { discriminator: number; - lockupCheckedArgs: LockupCheckedParams; + unixTimestamp: Option; + epoch: Option; }; export type SetLockupCheckedInstructionDataArgs = { - lockupCheckedArgs: LockupCheckedParamsArgs; + unixTimestamp: OptionOrNullable; + epoch: OptionOrNullable; }; export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['lockupCheckedArgs', getLockupCheckedParamsEncoder()], + ['unixTimestamp', getOptionEncoder(getUnixTimestampEncoder())], + ['epoch', getOptionEncoder(getEpochEncoder())], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_CHECKED_DISCRIMINATOR }) ); @@ -96,7 +107,8 @@ export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['lockupCheckedArgs', getLockupCheckedParamsDecoder()], + ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], + ['epoch', getOptionDecoder(getEpochDecoder())], ]); } @@ -121,7 +133,8 @@ export type SetLockupCheckedInput< authority: TransactionSigner; /** New lockup authority */ newAuthority?: TransactionSigner; - lockupCheckedArgs: SetLockupCheckedInstructionDataArgs['lockupCheckedArgs']; + unixTimestamp: SetLockupCheckedInstructionDataArgs['unixTimestamp']; + epoch: SetLockupCheckedInstructionDataArgs['epoch']; }; export function getSetLockupCheckedInstruction< diff --git a/clients/js/src/generated/types/authorizeCheckedWithSeedParams.ts b/clients/js/src/generated/types/authorizeCheckedWithSeedParams.ts deleted file mode 100644 index 2343ed80..00000000 --- a/clients/js/src/generated/types/authorizeCheckedWithSeedParams.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * 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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getUtf8Decoder, - getUtf8Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; -import { - getStakeAuthorizeDecoder, - getStakeAuthorizeEncoder, - type StakeAuthorize, - type StakeAuthorizeArgs, -} from '.'; - -export type AuthorizeCheckedWithSeedParams = { - stakeAuthorize: StakeAuthorize; - authoritySeed: string; - authorityOwner: Address; -}; - -export type AuthorizeCheckedWithSeedParamsArgs = { - stakeAuthorize: StakeAuthorizeArgs; - authoritySeed: string; - authorityOwner: Address; -}; - -export function getAuthorizeCheckedWithSeedParamsEncoder(): Encoder { - return getStructEncoder([ - ['stakeAuthorize', getStakeAuthorizeEncoder()], - ['authoritySeed', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())], - ['authorityOwner', getAddressEncoder()], - ]); -} - -export function getAuthorizeCheckedWithSeedParamsDecoder(): Decoder { - return getStructDecoder([ - ['stakeAuthorize', getStakeAuthorizeDecoder()], - ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], - ['authorityOwner', getAddressDecoder()], - ]); -} - -export function getAuthorizeCheckedWithSeedParamsCodec(): Codec< - AuthorizeCheckedWithSeedParamsArgs, - AuthorizeCheckedWithSeedParams -> { - return combineCodec( - getAuthorizeCheckedWithSeedParamsEncoder(), - getAuthorizeCheckedWithSeedParamsDecoder() - ); -} diff --git a/clients/js/src/generated/types/authorizeWithSeedParams.ts b/clients/js/src/generated/types/authorizeWithSeedParams.ts deleted file mode 100644 index 4e0f1209..00000000 --- a/clients/js/src/generated/types/authorizeWithSeedParams.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * 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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getUtf8Decoder, - getUtf8Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; -import { - getStakeAuthorizeDecoder, - getStakeAuthorizeEncoder, - type StakeAuthorize, - type StakeAuthorizeArgs, -} from '.'; - -export type AuthorizeWithSeedParams = { - newAuthorizedPubkey: Address; - stakeAuthorize: StakeAuthorize; - authoritySeed: string; - authorityOwner: Address; -}; - -export type AuthorizeWithSeedParamsArgs = { - newAuthorizedPubkey: Address; - stakeAuthorize: StakeAuthorizeArgs; - authoritySeed: string; - authorityOwner: Address; -}; - -export function getAuthorizeWithSeedParamsEncoder(): Encoder { - return getStructEncoder([ - ['newAuthorizedPubkey', getAddressEncoder()], - ['stakeAuthorize', getStakeAuthorizeEncoder()], - ['authoritySeed', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())], - ['authorityOwner', getAddressEncoder()], - ]); -} - -export function getAuthorizeWithSeedParamsDecoder(): Decoder { - return getStructDecoder([ - ['newAuthorizedPubkey', getAddressDecoder()], - ['stakeAuthorize', getStakeAuthorizeDecoder()], - ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], - ['authorityOwner', getAddressDecoder()], - ]); -} - -export function getAuthorizeWithSeedParamsCodec(): Codec< - AuthorizeWithSeedParamsArgs, - AuthorizeWithSeedParams -> { - return combineCodec( - getAuthorizeWithSeedParamsEncoder(), - getAuthorizeWithSeedParamsDecoder() - ); -} diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index 1ada0996..7fd6869d 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -6,14 +6,10 @@ * @see https://github.com/codama-idl/codama */ -export * from './authorizeCheckedWithSeedParams'; export * from './authorized'; -export * from './authorizeWithSeedParams'; export * from './delegation'; export * from './epoch'; export * from './lockup'; -export * from './lockupCheckedParams'; -export * from './lockupParams'; export * from './meta'; export * from './stake'; export * from './stakeAuthorize'; diff --git a/clients/js/src/generated/types/lockupCheckedParams.ts b/clients/js/src/generated/types/lockupCheckedParams.ts deleted file mode 100644 index 8979ebc2..00000000 --- a/clients/js/src/generated/types/lockupCheckedParams.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * 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, - getOptionDecoder, - getOptionEncoder, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, - type Option, - type OptionOrNullable, -} from '@solana/kit'; -import { - getEpochDecoder, - getEpochEncoder, - getUnixTimestampDecoder, - getUnixTimestampEncoder, - type Epoch, - type EpochArgs, - type UnixTimestamp, - type UnixTimestampArgs, -} from '.'; - -export type LockupCheckedParams = { - unixTimestamp: Option; - epoch: Option; -}; - -export type LockupCheckedParamsArgs = { - unixTimestamp: OptionOrNullable; - epoch: OptionOrNullable; -}; - -export function getLockupCheckedParamsEncoder(): Encoder { - return getStructEncoder([ - ['unixTimestamp', getOptionEncoder(getUnixTimestampEncoder())], - ['epoch', getOptionEncoder(getEpochEncoder())], - ]); -} - -export function getLockupCheckedParamsDecoder(): Decoder { - return getStructDecoder([ - ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], - ['epoch', getOptionDecoder(getEpochDecoder())], - ]); -} - -export function getLockupCheckedParamsCodec(): Codec< - LockupCheckedParamsArgs, - LockupCheckedParams -> { - return combineCodec( - getLockupCheckedParamsEncoder(), - getLockupCheckedParamsDecoder() - ); -} diff --git a/clients/js/src/generated/types/lockupParams.ts b/clients/js/src/generated/types/lockupParams.ts deleted file mode 100644 index 5936cba9..00000000 --- a/clients/js/src/generated/types/lockupParams.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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, - getAddressDecoder, - getAddressEncoder, - getOptionDecoder, - getOptionEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type Option, - type OptionOrNullable, -} from '@solana/kit'; -import { - getEpochDecoder, - getEpochEncoder, - getUnixTimestampDecoder, - getUnixTimestampEncoder, - type Epoch, - type EpochArgs, - type UnixTimestamp, - type UnixTimestampArgs, -} from '.'; - -export type LockupParams = { - unixTimestamp: Option; - epoch: Option; - custodian: Option
; -}; - -export type LockupParamsArgs = { - unixTimestamp: OptionOrNullable; - epoch: OptionOrNullable; - custodian: OptionOrNullable
; -}; - -export function getLockupParamsEncoder(): Encoder { - return getStructEncoder([ - ['unixTimestamp', getOptionEncoder(getUnixTimestampEncoder())], - ['epoch', getOptionEncoder(getEpochEncoder())], - ['custodian', getOptionEncoder(getAddressEncoder())], - ]); -} - -export function getLockupParamsDecoder(): Decoder { - return getStructDecoder([ - ['unixTimestamp', getOptionDecoder(getUnixTimestampDecoder())], - ['epoch', getOptionDecoder(getEpochDecoder())], - ['custodian', getOptionDecoder(getAddressDecoder())], - ]); -} - -export function getLockupParamsCodec(): Codec { - return combineCodec(getLockupParamsEncoder(), getLockupParamsDecoder()); -} 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 221bfc16..55e02c49 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -6,8 +6,9 @@ //! use { - crate::generated::types::AuthorizeCheckedWithSeedParams, + crate::generated::types::StakeAuthorize, borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, }; /// Accounts. @@ -93,7 +94,9 @@ impl Default for AuthorizeCheckedWithSeedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeCheckedWithSeedInstructionArgs { - pub authorize_checked_with_seed_args: AuthorizeCheckedWithSeedParams, + pub stake_authorize: StakeAuthorize, + pub authority_seed: String, + pub authority_owner: Pubkey, } /// Instruction builder for `AuthorizeCheckedWithSeed`. @@ -112,7 +115,9 @@ pub struct AuthorizeCheckedWithSeedBuilder { clock_sysvar: Option, new_authority: Option, lockup_authority: Option, - authorize_checked_with_seed_args: Option, + stake_authorize: Option, + authority_seed: Option, + authority_owner: Option, __remaining_accounts: Vec, } @@ -155,11 +160,18 @@ impl AuthorizeCheckedWithSeedBuilder { self } #[inline(always)] - pub fn authorize_checked_with_seed_args( - &mut self, - authorize_checked_with_seed_args: AuthorizeCheckedWithSeedParams, - ) -> &mut Self { - self.authorize_checked_with_seed_args = Some(authorize_checked_with_seed_args); + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.stake_authorize = Some(stake_authorize); + self + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + self.authority_seed = Some(authority_seed); + self + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + self.authority_owner = Some(authority_owner); self } /// Add an additional account to the instruction. @@ -190,10 +202,18 @@ impl AuthorizeCheckedWithSeedBuilder { lockup_authority: self.lockup_authority, }; let args = AuthorizeCheckedWithSeedInstructionArgs { - authorize_checked_with_seed_args: self - .authorize_checked_with_seed_args + stake_authorize: self + .stake_authorize + .clone() + .expect("stake_authorize is not set"), + authority_seed: self + .authority_seed .clone() - .expect("authorize_checked_with_seed_args is not set"), + .expect("authority_seed is not set"), + authority_owner: self + .authority_owner + .clone() + .expect("authority_owner is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -364,7 +384,9 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { clock_sysvar: None, new_authority: None, lockup_authority: None, - authorize_checked_with_seed_args: None, + stake_authorize: None, + authority_seed: None, + authority_owner: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -410,11 +432,18 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn authorize_checked_with_seed_args( - &mut self, - authorize_checked_with_seed_args: AuthorizeCheckedWithSeedParams, - ) -> &mut Self { - self.instruction.authorize_checked_with_seed_args = Some(authorize_checked_with_seed_args); + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.instruction.stake_authorize = Some(stake_authorize); + self + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + self.instruction.authority_seed = Some(authority_seed); + self + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + self.instruction.authority_owner = Some(authority_owner); self } /// Add an additional account to the instruction. @@ -459,11 +488,21 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeCheckedWithSeedInstructionArgs { - authorize_checked_with_seed_args: self + stake_authorize: self + .instruction + .stake_authorize + .clone() + .expect("stake_authorize is not set"), + authority_seed: self + .instruction + .authority_seed + .clone() + .expect("authority_seed is not set"), + authority_owner: self .instruction - .authorize_checked_with_seed_args + .authority_owner .clone() - .expect("authorize_checked_with_seed_args is not set"), + .expect("authority_owner is not set"), }; let instruction = AuthorizeCheckedWithSeedCpi { __program: self.instruction.__program, @@ -500,7 +539,9 @@ struct AuthorizeCheckedWithSeedCpiBuilderInstruction<'a, 'b> { 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>>, - authorize_checked_with_seed_args: 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>, diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index 9a427ce3..d9d55cbd 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -6,8 +6,9 @@ //! use { - crate::generated::types::AuthorizeWithSeedParams, + crate::generated::types::StakeAuthorize, borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, }; /// Accounts. @@ -87,7 +88,10 @@ impl Default for AuthorizeWithSeedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeWithSeedInstructionArgs { - pub authorize_with_seed_args: AuthorizeWithSeedParams, + pub new_authorized_pubkey: Pubkey, + pub stake_authorize: StakeAuthorize, + pub authority_seed: String, + pub authority_owner: Pubkey, } /// Instruction builder for `AuthorizeWithSeed`. @@ -104,7 +108,10 @@ pub struct AuthorizeWithSeedBuilder { base: Option, clock_sysvar: Option, lockup_authority: Option, - authorize_with_seed_args: Option, + new_authorized_pubkey: Option, + stake_authorize: Option, + authority_seed: Option, + authority_owner: Option, __remaining_accounts: Vec, } @@ -141,11 +148,23 @@ impl AuthorizeWithSeedBuilder { self } #[inline(always)] - pub fn authorize_with_seed_args( - &mut self, - authorize_with_seed_args: AuthorizeWithSeedParams, - ) -> &mut Self { - self.authorize_with_seed_args = Some(authorize_with_seed_args); + pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { + self.new_authorized_pubkey = Some(new_authorized_pubkey); + self + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.stake_authorize = Some(stake_authorize); + self + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + self.authority_seed = Some(authority_seed); + self + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + self.authority_owner = Some(authority_owner); self } /// Add an additional account to the instruction. @@ -175,10 +194,22 @@ impl AuthorizeWithSeedBuilder { lockup_authority: self.lockup_authority, }; let args = AuthorizeWithSeedInstructionArgs { - authorize_with_seed_args: self - .authorize_with_seed_args + new_authorized_pubkey: self + .new_authorized_pubkey + .clone() + .expect("new_authorized_pubkey is not set"), + stake_authorize: self + .stake_authorize .clone() - .expect("authorize_with_seed_args is not set"), + .expect("stake_authorize is not set"), + authority_seed: self + .authority_seed + .clone() + .expect("authority_seed is not set"), + authority_owner: self + .authority_owner + .clone() + .expect("authority_owner is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -337,7 +368,10 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { base: None, clock_sysvar: None, lockup_authority: None, - authorize_with_seed_args: None, + new_authorized_pubkey: None, + stake_authorize: None, + authority_seed: None, + authority_owner: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -374,11 +408,23 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn authorize_with_seed_args( - &mut self, - authorize_with_seed_args: AuthorizeWithSeedParams, - ) -> &mut Self { - self.instruction.authorize_with_seed_args = Some(authorize_with_seed_args); + pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { + self.instruction.new_authorized_pubkey = Some(new_authorized_pubkey); + self + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.instruction.stake_authorize = Some(stake_authorize); + self + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + self.instruction.authority_seed = Some(authority_seed); + self + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + self.instruction.authority_owner = Some(authority_owner); self } /// Add an additional account to the instruction. @@ -423,11 +469,26 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeWithSeedInstructionArgs { - authorize_with_seed_args: self + new_authorized_pubkey: self + .instruction + .new_authorized_pubkey + .clone() + .expect("new_authorized_pubkey is not set"), + stake_authorize: self + .instruction + .stake_authorize + .clone() + .expect("stake_authorize is not set"), + authority_seed: self + .instruction + .authority_seed + .clone() + .expect("authority_seed is not set"), + authority_owner: self .instruction - .authorize_with_seed_args + .authority_owner .clone() - .expect("authorize_with_seed_args is not set"), + .expect("authority_owner is not set"), }; let instruction = AuthorizeWithSeedCpi { __program: self.instruction.__program, @@ -458,7 +519,10 @@ struct AuthorizeWithSeedCpiBuilderInstruction<'a, 'b> { 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>>, - authorize_with_seed_args: Option, + 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>, diff --git a/clients/rust/src/generated/instructions/set_lockup.rs b/clients/rust/src/generated/instructions/set_lockup.rs index dd50f2d3..d3cb0b62 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -6,8 +6,9 @@ //! use { - crate::generated::types::LockupParams, + crate::generated::types::{Epoch, UnixTimestamp}, borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, }; /// Accounts. @@ -74,7 +75,9 @@ impl Default for SetLockupInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupInstructionArgs { - pub lockup_args: LockupParams, + pub unix_timestamp: Option, + pub epoch: Option, + pub custodian: Option, } /// Instruction builder for `SetLockup`. @@ -87,7 +90,9 @@ pub struct SetLockupInstructionArgs { pub struct SetLockupBuilder { stake: Option, authority: Option, - lockup_args: Option, + unix_timestamp: Option, + epoch: Option, + custodian: Option, __remaining_accounts: Vec, } @@ -107,9 +112,22 @@ impl SetLockupBuilder { self.authority = Some(authority); self } + /// `[optional argument]` #[inline(always)] - pub fn lockup_args(&mut self, lockup_args: LockupParams) -> &mut Self { - self.lockup_args = Some(lockup_args); + 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: Epoch) -> &mut Self { + self.epoch = Some(epoch); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { + self.custodian = Some(custodian); self } /// Add an additional account to the instruction. @@ -137,7 +155,9 @@ impl SetLockupBuilder { authority: self.authority.expect("authority is not set"), }; let args = SetLockupInstructionArgs { - lockup_args: self.lockup_args.clone().expect("lockup_args is not set"), + unix_timestamp: self.unix_timestamp.clone(), + epoch: self.epoch.clone(), + custodian: self.custodian.clone(), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -268,7 +288,9 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { __program: program, stake: None, authority: None, - lockup_args: None, + unix_timestamp: None, + epoch: None, + custodian: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -288,9 +310,22 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { self.instruction.authority = Some(authority); self } + /// `[optional argument]` + #[inline(always)] + 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: Epoch) -> &mut Self { + self.instruction.epoch = Some(epoch); + self + } + /// `[optional argument]` #[inline(always)] - pub fn lockup_args(&mut self, lockup_args: LockupParams) -> &mut Self { - self.instruction.lockup_args = Some(lockup_args); + pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { + self.instruction.custodian = Some(custodian); self } /// Add an additional account to the instruction. @@ -335,11 +370,9 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = SetLockupInstructionArgs { - lockup_args: self - .instruction - .lockup_args - .clone() - .expect("lockup_args is not set"), + unix_timestamp: self.instruction.unix_timestamp.clone(), + epoch: self.instruction.epoch.clone(), + custodian: self.instruction.custodian.clone(), }; let instruction = SetLockupCpi { __program: self.instruction.__program, @@ -361,7 +394,9 @@ 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>>, - lockup_args: Option, + 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>, diff --git a/clients/rust/src/generated/instructions/set_lockup_checked.rs b/clients/rust/src/generated/instructions/set_lockup_checked.rs index 935d8aa8..121a94f8 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -6,7 +6,7 @@ //! use { - crate::generated::types::LockupCheckedParams, + crate::generated::types::{Epoch, UnixTimestamp}, borsh::{BorshDeserialize, BorshSerialize}, }; @@ -82,7 +82,8 @@ impl Default for SetLockupCheckedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetLockupCheckedInstructionArgs { - pub lockup_checked_args: LockupCheckedParams, + pub unix_timestamp: Option, + pub epoch: Option, } /// Instruction builder for `SetLockupChecked`. @@ -97,7 +98,8 @@ pub struct SetLockupCheckedBuilder { stake: Option, authority: Option, new_authority: Option, - lockup_checked_args: Option, + unix_timestamp: Option, + epoch: Option, __remaining_accounts: Vec, } @@ -127,9 +129,16 @@ impl SetLockupCheckedBuilder { self.new_authority = new_authority; self } + /// `[optional argument]` #[inline(always)] - pub fn lockup_checked_args(&mut self, lockup_checked_args: LockupCheckedParams) -> &mut Self { - self.lockup_checked_args = Some(lockup_checked_args); + 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: Epoch) -> &mut Self { + self.epoch = Some(epoch); self } /// Add an additional account to the instruction. @@ -158,10 +167,8 @@ impl SetLockupCheckedBuilder { new_authority: self.new_authority, }; let args = SetLockupCheckedInstructionArgs { - lockup_checked_args: self - .lockup_checked_args - .clone() - .expect("lockup_checked_args is not set"), + unix_timestamp: self.unix_timestamp.clone(), + epoch: self.epoch.clone(), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -308,7 +315,8 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { stake: None, authority: None, new_authority: None, - lockup_checked_args: None, + unix_timestamp: None, + epoch: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -338,9 +346,16 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { self.instruction.new_authority = new_authority; self } + /// `[optional argument]` + #[inline(always)] + 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 lockup_checked_args(&mut self, lockup_checked_args: LockupCheckedParams) -> &mut Self { - self.instruction.lockup_checked_args = Some(lockup_checked_args); + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { + self.instruction.epoch = Some(epoch); self } /// Add an additional account to the instruction. @@ -385,11 +400,8 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = SetLockupCheckedInstructionArgs { - lockup_checked_args: self - .instruction - .lockup_checked_args - .clone() - .expect("lockup_checked_args is not set"), + unix_timestamp: self.instruction.unix_timestamp.clone(), + epoch: self.instruction.epoch.clone(), }; let instruction = SetLockupCheckedCpi { __program: self.instruction.__program, @@ -414,7 +426,8 @@ struct SetLockupCheckedCpiBuilderInstruction<'a, 'b> { 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>>, - lockup_checked_args: Option, + unix_timestamp: Option, + epoch: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/types/authorize_checked_with_seed_params.rs b/clients/rust/src/generated/types/authorize_checked_with_seed_params.rs deleted file mode 100644 index 70a65233..00000000 --- a/clients/rust/src/generated/types/authorize_checked_with_seed_params.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! 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. -//! -//! -//! - -use { - crate::generated::types::StakeAuthorize, - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeCheckedWithSeedParams { - pub stake_authorize: StakeAuthorize, - pub authority_seed: String, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub authority_owner: Pubkey, -} diff --git a/clients/rust/src/generated/types/authorize_with_seed_params.rs b/clients/rust/src/generated/types/authorize_with_seed_params.rs deleted file mode 100644 index 1d1e2a2e..00000000 --- a/clients/rust/src/generated/types/authorize_with_seed_params.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! 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. -//! -//! -//! - -use { - crate::generated::types::StakeAuthorize, - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeWithSeedParams { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub new_authorized_pubkey: Pubkey, - pub stake_authorize: StakeAuthorize, - pub authority_seed: String, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub authority_owner: Pubkey, -} diff --git a/clients/rust/src/generated/types/lockup_checked_params.rs b/clients/rust/src/generated/types/lockup_checked_params.rs deleted file mode 100644 index 6bf3cf6d..00000000 --- a/clients/rust/src/generated/types/lockup_checked_params.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! 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. -//! -//! -//! - -use { - crate::generated::types::{Epoch, UnixTimestamp}, - borsh::{BorshDeserialize, BorshSerialize}, -}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockupCheckedParams { - pub unix_timestamp: Option, - pub epoch: Option, -} diff --git a/clients/rust/src/generated/types/lockup_params.rs b/clients/rust/src/generated/types/lockup_params.rs deleted file mode 100644 index c1ec7850..00000000 --- a/clients/rust/src/generated/types/lockup_params.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! 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. -//! -//! -//! - -use { - crate::generated::types::{Epoch, UnixTimestamp}, - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockupParams { - pub unix_timestamp: Option, - pub epoch: Option, - pub custodian: Option, -} diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index bf81f076..052ebd93 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -5,14 +5,10 @@ //! //! -pub(crate) mod r#authorize_checked_with_seed_params; -pub(crate) mod r#authorize_with_seed_params; pub(crate) mod r#authorized; pub(crate) mod r#delegation; pub(crate) mod r#epoch; pub(crate) mod r#lockup; -pub(crate) mod r#lockup_checked_params; -pub(crate) mod r#lockup_params; pub(crate) mod r#meta; pub(crate) mod r#stake; pub(crate) mod r#stake_authorize; @@ -22,8 +18,7 @@ pub(crate) mod r#stake_state_v2; pub(crate) mod r#unix_timestamp; pub use self::{ - r#authorize_checked_with_seed_params::*, r#authorize_with_seed_params::*, r#authorized::*, - r#delegation::*, r#epoch::*, r#lockup::*, r#lockup_checked_params::*, r#lockup_params::*, - r#meta::*, r#stake::*, r#stake_authorize::*, r#stake_flags::*, r#stake_state::*, - r#stake_state_v2::*, r#unix_timestamp::*, + 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/scripts/generate-clients.mts b/scripts/generate-clients.mts index 5edcc397..e74532ec 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -35,6 +35,10 @@ codama.update( }) ); +// 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([ From 2b1b4aa1040411b57651b7c878d2857a8ed593e1 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Mon, 24 Nov 2025 11:20:54 +0000 Subject: [PATCH 15/27] rm broken doc link --- .../instructions/deactivateDelinquent.ts | 4 +- .../generated/instructions/delegateStake.ts | 31 ++++++------ .../instructions/deactivate_delinquent.rs | 10 ++-- .../generated/instructions/delegate_stake.rs | 47 +++++++++---------- interface/idl.json | 4 +- interface/src/instruction.rs | 8 ++-- 6 files changed, 48 insertions(+), 56 deletions(-) diff --git a/clients/js/src/generated/instructions/deactivateDelinquent.ts b/clients/js/src/generated/instructions/deactivateDelinquent.ts index f393ab28..88ecf8ad 100644 --- a/clients/js/src/generated/instructions/deactivateDelinquent.ts +++ b/clients/js/src/generated/instructions/deactivateDelinquent.ts @@ -94,7 +94,7 @@ export type DeactivateDelinquentInput< stake: Address; /** Delinquent vote account for the delegated stake account */ delinquentVote: Address; - /** Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs */ + /** Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs */ referenceVote: Address; }; @@ -157,7 +157,7 @@ export type ParsedDeactivateDelinquentInstruction< stake: TAccountMetas[0]; /** Delinquent vote account for the delegated stake account */ delinquentVote: TAccountMetas[1]; - /** Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs */ + /** 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 23385112..b6a17e63 100644 --- a/clients/js/src/generated/instructions/delegateStake.ts +++ b/clients/js/src/generated/instructions/delegateStake.ts @@ -42,7 +42,7 @@ export type DelegateStakeInstruction< TAccountStake extends string | AccountMeta = string, TAccountVote extends string | AccountMeta = string, TAccountClockSysvar extends string | AccountMeta = string, - TAccountStakeHistorySysvar extends string | AccountMeta = string, + TAccountStakeHistory extends string | AccountMeta = string, TAccountUnused extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], @@ -59,9 +59,9 @@ export type DelegateStakeInstruction< TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, - TAccountStakeHistorySysvar extends string - ? ReadonlyAccount - : TAccountStakeHistorySysvar, + TAccountStakeHistory extends string + ? ReadonlyAccount + : TAccountStakeHistory, TAccountUnused extends string ? ReadonlyAccount : TAccountUnused, @@ -102,7 +102,7 @@ export type DelegateStakeInput< TAccountStake extends string = string, TAccountVote extends string = string, TAccountClockSysvar extends string = string, - TAccountStakeHistorySysvar extends string = string, + TAccountStakeHistory extends string = string, TAccountUnused extends string = string, TAccountStakeAuthority extends string = string, > = { @@ -113,7 +113,7 @@ export type DelegateStakeInput< /** Clock sysvar */ clockSysvar: Address; /** Stake history sysvar that carries stake warmup/cooldown history */ - stakeHistorySysvar: Address; + stakeHistory: Address; /** Unused account, formerly the stake config */ unused: Address; /** Stake authority */ @@ -124,7 +124,7 @@ export function getDelegateStakeInstruction< TAccountStake extends string, TAccountVote extends string, TAccountClockSysvar extends string, - TAccountStakeHistorySysvar extends string, + TAccountStakeHistory extends string, TAccountUnused extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, @@ -133,7 +133,7 @@ export function getDelegateStakeInstruction< TAccountStake, TAccountVote, TAccountClockSysvar, - TAccountStakeHistorySysvar, + TAccountStakeHistory, TAccountUnused, TAccountStakeAuthority >, @@ -143,7 +143,7 @@ export function getDelegateStakeInstruction< TAccountStake, TAccountVote, TAccountClockSysvar, - TAccountStakeHistorySysvar, + TAccountStakeHistory, TAccountUnused, TAccountStakeAuthority > { @@ -155,10 +155,7 @@ export function getDelegateStakeInstruction< stake: { value: input.stake ?? null, isWritable: true }, vote: { value: input.vote ?? null, isWritable: false }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, - stakeHistorySysvar: { - value: input.stakeHistorySysvar ?? null, - isWritable: false, - }, + stakeHistory: { value: input.stakeHistory ?? null, isWritable: false }, unused: { value: input.unused ?? null, isWritable: false }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; @@ -173,7 +170,7 @@ export function getDelegateStakeInstruction< getAccountMeta(accounts.stake), getAccountMeta(accounts.vote), getAccountMeta(accounts.clockSysvar), - getAccountMeta(accounts.stakeHistorySysvar), + getAccountMeta(accounts.stakeHistory), getAccountMeta(accounts.unused), getAccountMeta(accounts.stakeAuthority), ], @@ -184,7 +181,7 @@ export function getDelegateStakeInstruction< TAccountStake, TAccountVote, TAccountClockSysvar, - TAccountStakeHistorySysvar, + TAccountStakeHistory, TAccountUnused, TAccountStakeAuthority >); @@ -203,7 +200,7 @@ export type ParsedDelegateStakeInstruction< /** Clock sysvar */ clockSysvar: TAccountMetas[2]; /** Stake history sysvar that carries stake warmup/cooldown history */ - stakeHistorySysvar: TAccountMetas[3]; + stakeHistory: TAccountMetas[3]; /** Unused account, formerly the stake config */ unused: TAccountMetas[4]; /** Stake authority */ @@ -236,7 +233,7 @@ export function parseDelegateStakeInstruction< stake: getNextAccount(), vote: getNextAccount(), clockSysvar: getNextAccount(), - stakeHistorySysvar: getNextAccount(), + stakeHistory: getNextAccount(), unused: getNextAccount(), stakeAuthority: getNextAccount(), }, diff --git a/clients/rust/src/generated/instructions/deactivate_delinquent.rs b/clients/rust/src/generated/instructions/deactivate_delinquent.rs index bbfab17a..8bdf283b 100644 --- a/clients/rust/src/generated/instructions/deactivate_delinquent.rs +++ b/clients/rust/src/generated/instructions/deactivate_delinquent.rs @@ -14,7 +14,7 @@ pub struct DeactivateDelinquent { pub stake: solana_program::pubkey::Pubkey, /// Delinquent vote account for the delegated stake account pub delinquent_vote: solana_program::pubkey::Pubkey, - /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs pub reference_vote: solana_program::pubkey::Pubkey, } @@ -102,7 +102,7 @@ impl DeactivateDelinquentBuilder { self.delinquent_vote = Some(delinquent_vote); self } - /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs + /// 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 { self.reference_vote = Some(reference_vote); @@ -144,7 +144,7 @@ pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Delinquent vote account for the delegated stake account pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs pub reference_vote: &'b solana_program::account_info::AccountInfo<'a>, } @@ -156,7 +156,7 @@ pub struct DeactivateDelinquentCpi<'a, 'b> { pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Delinquent vote account for the delegated stake account pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs pub reference_vote: &'b solana_program::account_info::AccountInfo<'a>, } @@ -287,7 +287,7 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { self.instruction.delinquent_vote = Some(delinquent_vote); self } - /// Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs + /// 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, diff --git a/clients/rust/src/generated/instructions/delegate_stake.rs b/clients/rust/src/generated/instructions/delegate_stake.rs index ec4123c5..737774a2 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -17,7 +17,7 @@ pub struct DelegateStake { /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: solana_program::pubkey::Pubkey, + pub stake_history: solana_program::pubkey::Pubkey, /// Unused account, formerly the stake config pub unused: solana_program::pubkey::Pubkey, /// Stake authority @@ -45,7 +45,7 @@ impl DelegateStake { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.stake_history_sysvar, + self.stake_history, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -92,7 +92,7 @@ impl Default for DelegateStakeInstructionData { /// 0. `[writable]` stake /// 1. `[]` vote /// 2. `[]` clock_sysvar -/// 3. `[]` stake_history_sysvar +/// 3. `[]` stake_history /// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug, Default)] @@ -100,7 +100,7 @@ pub struct DelegateStakeBuilder { stake: Option, vote: Option, clock_sysvar: Option, - stake_history_sysvar: Option, + stake_history: Option, unused: Option, stake_authority: Option, __remaining_accounts: Vec, @@ -130,11 +130,8 @@ impl DelegateStakeBuilder { } /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] - pub fn stake_history_sysvar( - &mut self, - stake_history_sysvar: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.stake_history_sysvar = Some(stake_history_sysvar); + pub fn stake_history(&mut self, stake_history: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake_history = Some(stake_history); self } /// Unused account, formerly the stake config @@ -176,9 +173,7 @@ impl DelegateStakeBuilder { stake: self.stake.expect("stake is not set"), vote: self.vote.expect("vote is not set"), clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), - stake_history_sysvar: self - .stake_history_sysvar - .expect("stake_history_sysvar is not set"), + stake_history: self.stake_history.expect("stake_history is not set"), unused: self.unused.expect("unused is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -196,7 +191,7 @@ pub struct DelegateStakeCpiAccounts<'a, 'b> { /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, /// Unused account, formerly the stake config pub unused: &'b solana_program::account_info::AccountInfo<'a>, /// Stake authority @@ -214,7 +209,7 @@ pub struct DelegateStakeCpi<'a, 'b> { /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, /// Unused account, formerly the stake config pub unused: &'b solana_program::account_info::AccountInfo<'a>, /// Stake authority @@ -231,7 +226,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { stake: accounts.stake, vote: accounts.vote, clock_sysvar: accounts.clock_sysvar, - stake_history_sysvar: accounts.stake_history_sysvar, + stake_history: accounts.stake_history, unused: accounts.unused, stake_authority: accounts.stake_authority, } @@ -283,7 +278,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.stake_history_sysvar.key, + *self.stake_history.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -313,7 +308,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { account_infos.push(self.stake.clone()); account_infos.push(self.vote.clone()); account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history_sysvar.clone()); + account_infos.push(self.stake_history.clone()); account_infos.push(self.unused.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts @@ -335,7 +330,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { /// 0. `[writable]` stake /// 1. `[]` vote /// 2. `[]` clock_sysvar -/// 3. `[]` stake_history_sysvar +/// 3. `[]` stake_history /// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug)] @@ -350,7 +345,7 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { stake: None, vote: None, clock_sysvar: None, - stake_history_sysvar: None, + stake_history: None, unused: None, stake_authority: None, __remaining_accounts: Vec::new(), @@ -380,11 +375,11 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { } /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] - pub fn stake_history_sysvar( + pub fn stake_history( &mut self, - stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + stake_history: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.stake_history_sysvar = Some(stake_history_sysvar); + self.instruction.stake_history = Some(stake_history); self } /// Unused account, formerly the stake config @@ -458,10 +453,10 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { .clock_sysvar .expect("clock_sysvar is not set"), - stake_history_sysvar: self + stake_history: self .instruction - .stake_history_sysvar - .expect("stake_history_sysvar is not set"), + .stake_history + .expect("stake_history is not set"), unused: self.instruction.unused.expect("unused is not set"), @@ -483,7 +478,7 @@ struct DelegateStakeCpiBuilderInstruction<'a, 'b> { 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_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>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. diff --git a/interface/idl.json b/interface/idl.json index d115a336..a494a27f 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -787,7 +787,7 @@ "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", - "name": "stakeHistorySysvar" + "name": "stakeHistory" }, { "docs": [ @@ -1597,7 +1597,7 @@ }, { "docs": [ - "Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs" + "Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs" ], "isSigner": false, "isWritable": false, diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 374e5c4e..3e8b6958 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -91,7 +91,7 @@ pub enum StakeInstruction { ))] #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] #[codama(account( - name = "stake_history_sysvar", + name = "stake_history", docs = "Stake history sysvar that carries stake warmup/cooldown history" ))] #[codama(account(name = "unused", docs = "Unused account, formerly the stake config"))] @@ -366,7 +366,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. @@ -375,7 +375,7 @@ 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 #[codama(account(name = "stake", writable, docs = "Delegated stake account"))] #[codama(account( name = "delinquent_vote", @@ -383,7 +383,7 @@ pub enum StakeInstruction { ))] #[codama(account( name = "reference_vote", - docs = "Reference vote account that has voted at least once in the last [`crate::MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION`] epochs" + docs = "Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs" ))] DeactivateDelinquent, From 9e5e13fd460953ee4f8b2ab84540e8748d0fbd40 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:09:22 +0000 Subject: [PATCH 16/27] rm old idl, update format value, add sysvar defaults --- .../src/generated/instructions/authorize.ts | 12 +- .../instructions/authorizeChecked.ts | 12 +- .../instructions/authorizeCheckedWithSeed.ts | 12 +- .../instructions/authorizeWithSeed.ts | 12 +- .../src/generated/instructions/deactivate.ts | 12 +- .../generated/instructions/delegateStake.ts | 22 +- .../src/generated/instructions/initialize.ts | 12 +- .../instructions/initializeChecked.ts | 12 +- .../js/src/generated/instructions/merge.ts | 22 +- .../js/src/generated/instructions/withdraw.ts | 22 +- .../src/generated/instructions/authorize.rs | 7 +- .../instructions/authorize_checked.rs | 7 +- .../authorize_checked_with_seed.rs | 7 +- .../instructions/authorize_with_seed.rs | 7 +- .../src/generated/instructions/deactivate.rs | 7 +- .../generated/instructions/delegate_stake.rs | 14 +- .../src/generated/instructions/initialize.rs | 7 +- .../instructions/initialize_checked.rs | 7 +- .../rust/src/generated/instructions/merge.rs | 16 +- .../src/generated/instructions/withdraw.rs | 16 +- codama.json | 2 +- interface/src/state.rs | 1 + program/idl.json | 502 ------------------ scripts/generate-clients.mts | 18 + 24 files changed, 209 insertions(+), 559 deletions(-) delete mode 100644 program/idl.json diff --git a/clients/js/src/generated/instructions/authorize.ts b/clients/js/src/generated/instructions/authorize.ts index 8d41a206..4411210b 100644 --- a/clients/js/src/generated/instructions/authorize.ts +++ b/clients/js/src/generated/instructions/authorize.ts @@ -48,7 +48,9 @@ export function getAuthorizeDiscriminatorBytes() { export type AuthorizeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountClockSysvar extends string | AccountMeta = string, + TAccountClockSysvar extends + | string + | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends | string @@ -130,7 +132,7 @@ export type AuthorizeInput< /** Stake account to be updated */ stake: Address; /** Clock sysvar */ - clockSysvar: Address; + clockSysvar?: Address; /** The stake or withdraw authority */ authority: TransactionSigner; /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ @@ -181,6 +183,12 @@ export function getAuthorizeInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/js/src/generated/instructions/authorizeChecked.ts b/clients/js/src/generated/instructions/authorizeChecked.ts index e0c31e32..b230f69f 100644 --- a/clients/js/src/generated/instructions/authorizeChecked.ts +++ b/clients/js/src/generated/instructions/authorizeChecked.ts @@ -46,7 +46,9 @@ export function getAuthorizeCheckedDiscriminatorBytes() { export type AuthorizeCheckedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountClockSysvar extends string | AccountMeta = string, + TAccountClockSysvar extends + | string + | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountAuthority extends string | AccountMeta = string, TAccountNewAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends @@ -130,7 +132,7 @@ export type AuthorizeCheckedInput< /** Stake account to be updated */ stake: Address; /** Clock sysvar */ - clockSysvar: Address; + clockSysvar?: Address; /** The stake or withdraw authority */ authority: TransactionSigner; /** The new stake or withdraw authority */ @@ -186,6 +188,12 @@ export function getAuthorizeCheckedInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts index 0d0d2e52..317277e1 100644 --- a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts @@ -53,7 +53,9 @@ export type AuthorizeCheckedWithSeedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, TAccountBase extends string | AccountMeta = string, - TAccountClockSysvar extends string | AccountMeta = string, + TAccountClockSysvar extends + | string + | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountNewAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends | string @@ -151,7 +153,7 @@ export type AuthorizeCheckedWithSeedInput< /** Base key of stake or withdraw authority */ base: TransactionSigner; /** Clock sysvar */ - clockSysvar: Address; + clockSysvar?: Address; /** The new stake or withdraw authority */ newAuthority: TransactionSigner; /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ @@ -207,6 +209,12 @@ export function getAuthorizeCheckedWithSeedInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/js/src/generated/instructions/authorizeWithSeed.ts b/clients/js/src/generated/instructions/authorizeWithSeed.ts index a5843265..0007b5b7 100644 --- a/clients/js/src/generated/instructions/authorizeWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeWithSeed.ts @@ -53,7 +53,9 @@ export type AuthorizeWithSeedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, TAccountBase extends string | AccountMeta = string, - TAccountClockSysvar extends string | AccountMeta = string, + TAccountClockSysvar extends + | string + | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountLockupAuthority extends | string | AccountMeta @@ -146,7 +148,7 @@ export type AuthorizeWithSeedInput< /** Base key of stake or withdraw authority */ base: TransactionSigner; /** Clock sysvar */ - clockSysvar: Address; + clockSysvar?: Address; /** Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration */ lockupAuthority?: TransactionSigner; newAuthorizedPubkey: AuthorizeWithSeedInstructionDataArgs['newAuthorizedPubkey']; @@ -197,6 +199,12 @@ export function getAuthorizeWithSeedInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/js/src/generated/instructions/deactivate.ts b/clients/js/src/generated/instructions/deactivate.ts index 457ee39d..7bbce5a8 100644 --- a/clients/js/src/generated/instructions/deactivate.ts +++ b/clients/js/src/generated/instructions/deactivate.ts @@ -40,7 +40,9 @@ export function getDeactivateDiscriminatorBytes() { export type DeactivateInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountClockSysvar extends string | AccountMeta = string, + TAccountClockSysvar extends + | string + | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & @@ -94,7 +96,7 @@ export type DeactivateInput< /** Delegated stake account to be deactivated */ stake: Address; /** Clock sysvar */ - clockSysvar: Address; + clockSysvar?: Address; /** Stake authority */ stakeAuthority: TransactionSigner; }; @@ -131,6 +133,12 @@ export function getDeactivateInstruction< ResolvedAccount >; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/js/src/generated/instructions/delegateStake.ts b/clients/js/src/generated/instructions/delegateStake.ts index b6a17e63..1797f2fe 100644 --- a/clients/js/src/generated/instructions/delegateStake.ts +++ b/clients/js/src/generated/instructions/delegateStake.ts @@ -41,8 +41,12 @@ export type DelegateStakeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, TAccountVote extends string | AccountMeta = string, - TAccountClockSysvar extends string | AccountMeta = string, - TAccountStakeHistory extends string | AccountMeta = string, + TAccountClockSysvar extends + | string + | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', + TAccountStakeHistory extends + | string + | AccountMeta = 'SysvarStakeHistory1111111111111111111111111', TAccountUnused extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], @@ -111,9 +115,9 @@ export type DelegateStakeInput< /** Vote account to which this stake will be delegated */ vote: Address; /** Clock sysvar */ - clockSysvar: Address; + clockSysvar?: Address; /** Stake history sysvar that carries stake warmup/cooldown history */ - stakeHistory: Address; + stakeHistory?: Address; /** Unused account, formerly the stake config */ unused: Address; /** Stake authority */ @@ -164,6 +168,16 @@ export function getDelegateStakeInstruction< ResolvedAccount >; + // Resolve default values. + if (!accounts.clockSysvar.value) { + 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({ accounts: [ diff --git a/clients/js/src/generated/instructions/initialize.ts b/clients/js/src/generated/instructions/initialize.ts index 301df521..0e22930a 100644 --- a/clients/js/src/generated/instructions/initialize.ts +++ b/clients/js/src/generated/instructions/initialize.ts @@ -47,7 +47,9 @@ export function getInitializeDiscriminatorBytes() { export type InitializeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountRentSysvar extends string | AccountMeta = string, + TAccountRentSysvar extends + | string + | AccountMeta = 'SysvarRent111111111111111111111111111111111', TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & @@ -110,7 +112,7 @@ export type InitializeInput< /** Uninitialized stake account */ stake: Address; /** Rent sysvar */ - rentSysvar: Address; + rentSysvar?: Address; arg0: InitializeInstructionDataArgs['arg0']; arg1: InitializeInstructionDataArgs['arg1']; }; @@ -139,6 +141,12 @@ export function getInitializeInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.rentSysvar.value) { + accounts.rentSysvar.value = + 'SysvarRent111111111111111111111111111111111' as Address<'SysvarRent111111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/js/src/generated/instructions/initializeChecked.ts b/clients/js/src/generated/instructions/initializeChecked.ts index 1941ac0a..4b733d9e 100644 --- a/clients/js/src/generated/instructions/initializeChecked.ts +++ b/clients/js/src/generated/instructions/initializeChecked.ts @@ -40,7 +40,9 @@ export function getInitializeCheckedDiscriminatorBytes() { export type InitializeCheckedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountRentSysvar extends string | AccountMeta = string, + TAccountRentSysvar extends + | string + | AccountMeta = 'SysvarRent111111111111111111111111111111111', TAccountStakeAuthority extends string | AccountMeta = string, TAccountWithdrawAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], @@ -99,7 +101,7 @@ export type InitializeCheckedInput< /** Uninitialized stake account */ stake: Address; /** Rent sysvar */ - rentSysvar: Address; + rentSysvar?: Address; /** The stake authority */ stakeAuthority: Address; /** The withdraw authority */ @@ -145,6 +147,12 @@ export function getInitializeCheckedInstruction< ResolvedAccount >; + // Resolve default values. + if (!accounts.rentSysvar.value) { + accounts.rentSysvar.value = + 'SysvarRent111111111111111111111111111111111' as Address<'SysvarRent111111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/js/src/generated/instructions/merge.ts b/clients/js/src/generated/instructions/merge.ts index 11ce768a..43bd15ec 100644 --- a/clients/js/src/generated/instructions/merge.ts +++ b/clients/js/src/generated/instructions/merge.ts @@ -41,8 +41,12 @@ export type MergeInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountDestinationStake extends string | AccountMeta = string, TAccountSourceStake extends string | AccountMeta = string, - TAccountClockSysvar extends string | AccountMeta = string, - TAccountStakeHistorySysvar extends string | AccountMeta = string, + TAccountClockSysvar extends + | string + | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', + TAccountStakeHistorySysvar extends + | string + | AccountMeta = 'SysvarStakeHistory1111111111111111111111111', TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & @@ -106,9 +110,9 @@ export type MergeInput< /** Source stake account for to merge. This account will be drained */ sourceStake: Address; /** Clock sysvar */ - clockSysvar: Address; + clockSysvar?: Address; /** Stake history sysvar that carries stake warmup/cooldown history */ - stakeHistorySysvar: Address; + stakeHistorySysvar?: Address; /** Stake authority */ stakeAuthority: TransactionSigner; }; @@ -159,6 +163,16 @@ export function getMergeInstruction< ResolvedAccount >; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + if (!accounts.stakeHistorySysvar.value) { + accounts.stakeHistorySysvar.value = + 'SysvarStakeHistory1111111111111111111111111' as Address<'SysvarStakeHistory1111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/js/src/generated/instructions/withdraw.ts b/clients/js/src/generated/instructions/withdraw.ts index c08d2587..cbeacf61 100644 --- a/clients/js/src/generated/instructions/withdraw.ts +++ b/clients/js/src/generated/instructions/withdraw.ts @@ -43,8 +43,12 @@ export type WithdrawInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, TAccountRecipient extends string | AccountMeta = string, - TAccountClockSysvar extends string | AccountMeta = string, - TAccountStakeHistorySysvar extends string | AccountMeta = string, + TAccountClockSysvar extends + | string + | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', + TAccountStakeHistorySysvar extends + | string + | AccountMeta = 'SysvarStakeHistory1111111111111111111111111', TAccountWithdrawAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends | string @@ -130,9 +134,9 @@ export type WithdrawInput< /** Recipient account */ recipient: Address; /** Clock sysvar */ - clockSysvar: Address; + clockSysvar?: Address; /** Stake history sysvar that carries stake warmup/cooldown history */ - stakeHistorySysvar: Address; + stakeHistorySysvar?: Address; /** Withdraw authority */ withdrawAuthority: TransactionSigner; /** Lockup authority, if before lockup expiration */ @@ -196,6 +200,16 @@ export function getWithdrawInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + if (!accounts.stakeHistorySysvar.value) { + accounts.stakeHistorySysvar.value = + 'SysvarStakeHistory1111111111111111111111111' as Address<'SysvarStakeHistory1111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/rust/src/generated/instructions/authorize.rs b/clients/rust/src/generated/instructions/authorize.rs index 4d915f71..badf148d 100644 --- a/clients/rust/src/generated/instructions/authorize.rs +++ b/clients/rust/src/generated/instructions/authorize.rs @@ -98,7 +98,7 @@ pub struct AuthorizeInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` clock_sysvar +/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 2. `[signer]` authority /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] @@ -122,6 +122,7 @@ impl AuthorizeBuilder { 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 { @@ -176,7 +177,9 @@ impl AuthorizeBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Authorize { stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), authority: self.authority.expect("authority is not set"), lockup_authority: self.lockup_authority, }; diff --git a/clients/rust/src/generated/instructions/authorize_checked.rs b/clients/rust/src/generated/instructions/authorize_checked.rs index d7b19eaf..a7998ef5 100644 --- a/clients/rust/src/generated/instructions/authorize_checked.rs +++ b/clients/rust/src/generated/instructions/authorize_checked.rs @@ -102,7 +102,7 @@ pub struct AuthorizeCheckedInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` clock_sysvar +/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 2. `[signer]` authority /// 3. `[signer]` new_authority /// 4. `[signer, optional]` lockup_authority @@ -127,6 +127,7 @@ impl AuthorizeCheckedBuilder { 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 { @@ -182,7 +183,9 @@ impl AuthorizeCheckedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = AuthorizeChecked { stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), authority: self.authority.expect("authority is not set"), new_authority: self.new_authority.expect("new_authority is not set"), lockup_authority: self.lockup_authority, 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 55e02c49..796f5ebb 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -105,7 +105,7 @@ pub struct AuthorizeCheckedWithSeedInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[signer]` base -/// 2. `[]` clock_sysvar +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 3. `[signer]` new_authority /// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] @@ -137,6 +137,7 @@ impl AuthorizeCheckedWithSeedBuilder { 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 { @@ -197,7 +198,9 @@ impl AuthorizeCheckedWithSeedBuilder { let accounts = AuthorizeCheckedWithSeed { stake: self.stake.expect("stake is not set"), base: self.base.expect("base is not set"), - clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), new_authority: self.new_authority.expect("new_authority is not set"), lockup_authority: self.lockup_authority, }; diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index d9d55cbd..beb781f3 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -100,7 +100,7 @@ pub struct AuthorizeWithSeedInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[signer]` base -/// 2. `[]` clock_sysvar +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeWithSeedBuilder { @@ -131,6 +131,7 @@ impl AuthorizeWithSeedBuilder { 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 { @@ -190,7 +191,9 @@ impl AuthorizeWithSeedBuilder { let accounts = AuthorizeWithSeed { stake: self.stake.expect("stake is not set"), base: self.base.expect("base is not set"), - clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), lockup_authority: self.lockup_authority, }; let args = AuthorizeWithSeedInstructionArgs { diff --git a/clients/rust/src/generated/instructions/deactivate.rs b/clients/rust/src/generated/instructions/deactivate.rs index b7e12103..52d6fcb7 100644 --- a/clients/rust/src/generated/instructions/deactivate.rs +++ b/clients/rust/src/generated/instructions/deactivate.rs @@ -73,7 +73,7 @@ impl Default for DeactivateInstructionData { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` clock_sysvar +/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct DeactivateBuilder { @@ -93,6 +93,7 @@ impl DeactivateBuilder { 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 { @@ -130,7 +131,9 @@ impl DeactivateBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Deactivate { stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; diff --git a/clients/rust/src/generated/instructions/delegate_stake.rs b/clients/rust/src/generated/instructions/delegate_stake.rs index 737774a2..59a55c45 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -91,8 +91,8 @@ impl Default for DelegateStakeInstructionData { /// /// 0. `[writable]` stake /// 1. `[]` vote -/// 2. `[]` clock_sysvar -/// 3. `[]` stake_history +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 3. `[optional]` stake_history (default to `SysvarStakeHistory1111111111111111111111111`) /// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug, Default)] @@ -122,12 +122,14 @@ impl DelegateStakeBuilder { 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 { self.clock_sysvar = Some(clock_sysvar); self } + /// `[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 { @@ -172,8 +174,12 @@ impl DelegateStakeBuilder { let accounts = DelegateStake { stake: self.stake.expect("stake is not set"), vote: self.vote.expect("vote is not set"), - clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), - stake_history: self.stake_history.expect("stake_history is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), + stake_history: self.stake_history.unwrap_or(solana_program::pubkey!( + "SysvarStakeHistory1111111111111111111111111" + )), unused: self.unused.expect("unused is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; diff --git a/clients/rust/src/generated/instructions/initialize.rs b/clients/rust/src/generated/instructions/initialize.rs index 906dab75..24bc81f5 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -83,7 +83,7 @@ pub struct InitializeInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` rent_sysvar +/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct InitializeBuilder { stake: Option, @@ -103,6 +103,7 @@ impl InitializeBuilder { 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 { @@ -141,7 +142,9 @@ impl InitializeBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Initialize { stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.expect("rent_sysvar is not set"), + rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarRent111111111111111111111111111111111" + )), }; let args = InitializeInstructionArgs { arg0: self.arg0.clone().expect("arg0 is not set"), diff --git a/clients/rust/src/generated/instructions/initialize_checked.rs b/clients/rust/src/generated/instructions/initialize_checked.rs index 4dc23f24..929046f7 100644 --- a/clients/rust/src/generated/instructions/initialize_checked.rs +++ b/clients/rust/src/generated/instructions/initialize_checked.rs @@ -79,7 +79,7 @@ impl Default for InitializeCheckedInstructionData { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` rent_sysvar +/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) /// 2. `[]` stake_authority /// 3. `[signer]` withdraw_authority #[derive(Clone, Debug, Default)] @@ -101,6 +101,7 @@ impl InitializeCheckedBuilder { 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 { @@ -147,7 +148,9 @@ impl InitializeCheckedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = InitializeChecked { stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.expect("rent_sysvar is not set"), + rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarRent111111111111111111111111111111111" + )), stake_authority: self.stake_authority.expect("stake_authority is not set"), withdraw_authority: self .withdraw_authority diff --git a/clients/rust/src/generated/instructions/merge.rs b/clients/rust/src/generated/instructions/merge.rs index dbcb56fb..5f2feda7 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -87,8 +87,8 @@ impl Default for MergeInstructionData { /// /// 0. `[writable]` destination_stake /// 1. `[writable]` source_stake -/// 2. `[]` clock_sysvar -/// 3. `[]` stake_history_sysvar +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 3. `[optional]` stake_history_sysvar (default to `SysvarStakeHistory1111111111111111111111111`) /// 4. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MergeBuilder { @@ -119,12 +119,14 @@ impl MergeBuilder { 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 { self.clock_sysvar = Some(clock_sysvar); self } + /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history_sysvar( @@ -168,10 +170,12 @@ impl MergeBuilder { .destination_stake .expect("destination_stake is not set"), source_stake: self.source_stake.expect("source_stake is not set"), - clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), - stake_history_sysvar: self - .stake_history_sysvar - .expect("stake_history_sysvar is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), + stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarStakeHistory1111111111111111111111111" + )), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; diff --git a/clients/rust/src/generated/instructions/withdraw.rs b/clients/rust/src/generated/instructions/withdraw.rs index a436dae5..b23a8c10 100644 --- a/clients/rust/src/generated/instructions/withdraw.rs +++ b/clients/rust/src/generated/instructions/withdraw.rs @@ -106,8 +106,8 @@ pub struct WithdrawInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[writable]` recipient -/// 2. `[]` clock_sysvar -/// 3. `[]` stake_history_sysvar +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 3. `[optional]` stake_history_sysvar (default to `SysvarStakeHistory1111111111111111111111111`) /// 4. `[signer]` withdraw_authority /// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] @@ -138,12 +138,14 @@ impl WithdrawBuilder { 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 { self.clock_sysvar = Some(clock_sysvar); self } + /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] pub fn stake_history_sysvar( @@ -200,10 +202,12 @@ impl WithdrawBuilder { let accounts = Withdraw { stake: self.stake.expect("stake is not set"), recipient: self.recipient.expect("recipient is not set"), - clock_sysvar: self.clock_sysvar.expect("clock_sysvar is not set"), - stake_history_sysvar: self - .stake_history_sysvar - .expect("stake_history_sysvar is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), + stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarStakeHistory1111111111111111111111111" + )), withdraw_authority: self .withdraw_authority .expect("withdraw_authority is not set"), diff --git a/codama.json b/codama.json index c1b017a2..ca9ea06e 100644 --- a/codama.json +++ b/codama.json @@ -3,7 +3,7 @@ "idls": [ { "path": "interface/idl.json", - "format": "anchor" + "format": "codama" } ], "generators": [ diff --git a/interface/src/state.rs b/interface/src/state.rs index 79be1158..6dbf6272 100644 --- a/interface/src/state.rs +++ b/interface/src/state.rs @@ -268,6 +268,7 @@ impl StakeStateV2 { feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] +#[codama(enum_discriminator(size = number(u32)))] pub enum StakeAuthorize { Staker, Withdrawer, 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/scripts/generate-clients.mts b/scripts/generate-clients.mts index e74532ec..d8750f34 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -39,6 +39,24 @@ codama.update( codama.update(c.unwrapInstructionArgsDefinedTypesVisitor()); codama.update(c.flattenInstructionDataArgumentsVisitor()); +// Set default values for sysvar accounts (the proper Codama way) +codama.update( + c.setInstructionAccountDefaultValuesVisitor([ + { + account: 'clockSysvar', + defaultValue: c.publicKeyValueNode('SysvarC1ock11111111111111111111111111111111'), + }, + { + account: 'rentSysvar', + defaultValue: c.publicKeyValueNode('SysvarRent111111111111111111111111111111111'), + }, + { + account: /^stake[Hh]istory/, + defaultValue: c.publicKeyValueNode('SysvarStakeHistory1111111111111111111111111'), + }, + ]) +); + // Add type aliases for semantic external types codama.update( c.bottomUpTransformerVisitor([ From 63b546c0190d62848f7fdcba2581d1cee1d3ee6e Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Thu, 4 Dec 2025 13:37:46 +0000 Subject: [PATCH 17/27] use codama sysvar() helper for defaults --- .../instructions/initializeChecked.ts | 12 +- clients/rust/src/generated/errors/mod.rs | 7 +- clients/rust/src/generated/errors/stake.rs | 8 +- .../src/generated/instructions/authorize.rs | 738 +++++++------- .../instructions/authorize_checked.rs | 798 ++++++++------- .../authorize_checked_with_seed.rs | 872 ++++++++--------- .../instructions/authorize_with_seed.rs | 822 ++++++++-------- .../src/generated/instructions/deactivate.rs | 572 ++++++----- .../instructions/deactivate_delinquent.rs | 568 ++++++----- .../generated/instructions/delegate_stake.rs | 799 ++++++++------- .../instructions/get_minimum_delegation.rs | 330 +++---- .../src/generated/instructions/initialize.rs | 574 ++++++----- .../instructions/initialize_checked.rs | 655 ++++++------- .../rust/src/generated/instructions/merge.rs | 751 +++++++-------- .../rust/src/generated/instructions/mod.rs | 59 +- .../generated/instructions/move_lamports.rs | 637 ++++++------ .../src/generated/instructions/move_stake.rs | 637 ++++++------ .../src/generated/instructions/set_lockup.rs | 605 ++++++------ .../instructions/set_lockup_checked.rs | 664 ++++++------- .../rust/src/generated/instructions/split.rs | 627 ++++++------ .../src/generated/instructions/withdraw.rs | 906 +++++++++--------- clients/rust/src/generated/mod.rs | 12 +- clients/rust/src/generated/programs.rs | 6 +- .../rust/src/generated/types/authorized.rs | 23 +- .../rust/src/generated/types/delegation.rs | 26 +- clients/rust/src/generated/types/epoch.rs | 4 + clients/rust/src/generated/types/lockup.rs | 23 +- clients/rust/src/generated/types/meta.rs | 16 +- clients/rust/src/generated/types/mod.rs | 39 +- clients/rust/src/generated/types/stake.rs | 13 +- .../src/generated/types/stake_authorize.rs | 17 +- .../rust/src/generated/types/stake_flags.rs | 7 +- .../rust/src/generated/types/stake_state.rs | 18 +- .../src/generated/types/stake_state_v2.rs | 19 +- .../src/generated/types/unix_timestamp.rs | 4 + clients/rust/src/hooked/mod.rs | 1 + interface/idl.json | 48 + interface/src/instruction.rs | 27 +- scripts/generate-clients.mts | 18 - 39 files changed, 5681 insertions(+), 6281 deletions(-) diff --git a/clients/js/src/generated/instructions/initializeChecked.ts b/clients/js/src/generated/instructions/initializeChecked.ts index 4b733d9e..1941ac0a 100644 --- a/clients/js/src/generated/instructions/initializeChecked.ts +++ b/clients/js/src/generated/instructions/initializeChecked.ts @@ -40,9 +40,7 @@ export function getInitializeCheckedDiscriminatorBytes() { export type InitializeCheckedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountRentSysvar extends - | string - | AccountMeta = 'SysvarRent111111111111111111111111111111111', + TAccountRentSysvar extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TAccountWithdrawAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], @@ -101,7 +99,7 @@ export type InitializeCheckedInput< /** Uninitialized stake account */ stake: Address; /** Rent sysvar */ - rentSysvar?: Address; + rentSysvar: Address; /** The stake authority */ stakeAuthority: Address; /** The withdraw authority */ @@ -147,12 +145,6 @@ export function getInitializeCheckedInstruction< ResolvedAccount >; - // Resolve default values. - if (!accounts.rentSysvar.value) { - accounts.rentSysvar.value = - 'SysvarRent111111111111111111111111111111111' as Address<'SysvarRent111111111111111111111111111111111'>; - } - const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/rust/src/generated/errors/mod.rs b/clients/rust/src/generated/errors/mod.rs index 7f6b2f81..19db3500 100644 --- a/clients/rust/src/generated/errors/mod.rs +++ b/clients/rust/src/generated/errors/mod.rs @@ -5,6 +5,7 @@ //! //! -pub(crate) mod stake; - -pub use self::stake::StakeError; + pub(crate) mod stake; + + pub use self::stake::StakeError; + diff --git a/clients/rust/src/generated/errors/stake.rs b/clients/rust/src/generated/errors/stake.rs index cae66e42..37a23244 100644 --- a/clients/rust/src/generated/errors/stake.rs +++ b/clients/rust/src/generated/errors/stake.rs @@ -5,7 +5,8 @@ //! //! -use {num_derive::FromPrimitive, thiserror::Error}; +use num_derive::FromPrimitive; +use thiserror::Error; #[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] pub enum StakeError { @@ -43,9 +44,7 @@ pub enum StakeError { #[error("Stake account is not delegated to the provided vote account")] VoteAddressMismatch = 0xA, /// 11 - Stake account has not been delinquent for the minimum epochs required for deactivation - #[error( - "Stake account has not been delinquent for the minimum epochs required for deactivation" - )] + #[error("Stake account has not been delinquent for the minimum epochs required for deactivation")] MinimumDelinquentEpochsForDeactivationNotMet = 0xB, /// 12 - Delegation amount is less than the minimum #[error("Delegation amount is less than the minimum")] @@ -75,3 +74,4 @@ impl solana_program::decode_error::DecodeError for StakeError { "StakeError" } } + diff --git a/clients/rust/src/generated/instructions/authorize.rs b/clients/rust/src/generated/instructions/authorize.rs index badf148d..e655d88c 100644 --- a/clients/rust/src/generated/instructions/authorize.rs +++ b/clients/rust/src/generated/instructions/authorize.rs @@ -5,475 +5,443 @@ //! //! -use { - crate::generated::types::StakeAuthorize, - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; +use solana_program::pubkey::Pubkey; +use crate::generated::types::StakeAuthorize; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct Authorize { - /// Stake account to be updated - pub stake: solana_program::pubkey::Pubkey, - /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// The stake or withdraw authority - pub authority: solana_program::pubkey::Pubkey, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option, -} + /// Stake account to be updated + + + + pub stake: solana_program::pubkey::Pubkey, + /// Clock sysvar + + + + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// The stake or withdraw authority + + + + pub authority: solana_program::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 { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction(&self, args: AuthorizeInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( self.clock_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, - true, - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&AuthorizeInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeInstructionData { - discriminator: u32, -} + pub struct AuthorizeInstructionData { + discriminator: u32, + } impl AuthorizeInstructionData { - pub fn new() -> Self { - Self { discriminator: 1 } - } + pub fn new() -> Self { + Self { + discriminator: 1, + } + } } impl Default for AuthorizeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeInstructionArgs { - pub arg0: Pubkey, - pub arg1: StakeAuthorize, -} + pub struct AuthorizeInstructionArgs { + pub arg0: Pubkey, + pub arg1: StakeAuthorize, + } + /// Instruction builder for `Authorize`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 2. `[signer]` authority -/// 3. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) + /// 2. `[signer]` authority + /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeBuilder { - stake: Option, - clock_sysvar: Option, - authority: Option, - lockup_authority: Option, - arg0: Option, - arg1: Option, - __remaining_accounts: Vec, + stake: Option, + clock_sysvar: Option, + authority: Option, + lockup_authority: Option, + arg0: Option, + arg1: Option, + __remaining_accounts: Vec, } impl AuthorizeBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be updated - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account to be updated +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` - /// Clock sysvar - #[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` +/// Clock sysvar +#[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self + self.clock_sysvar = Some(clock_sysvar); + self } - /// The stake or withdraw authority - #[inline(always)] + /// The stake or withdraw authority +#[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self + self.authority = Some(authority); + self } - /// `[optional account]` - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - #[inline(always)] - pub fn lockup_authority( - &mut self, - lockup_authority: Option, - ) -> &mut Self { - self.lockup_authority = lockup_authority; - self + /// `[optional account]` +/// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration +#[inline(always)] + pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { + self.lockup_authority = lockup_authority; + self } - #[inline(always)] - pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { + #[inline(always)] + pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { self.arg0 = Some(arg0); self - } - #[inline(always)] - pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { + } + #[inline(always)] + pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { self.arg1 = Some(arg1); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = Authorize { - stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarC1ock11111111111111111111111111111111" - )), - authority: self.authority.expect("authority is not set"), - lockup_authority: self.lockup_authority, - }; - let args = AuthorizeInstructionArgs { - arg0: self.arg0.clone().expect("arg0 is not set"), - arg1: self.arg1.clone().expect("arg1 is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = Authorize { + stake: self.stake.expect("stake is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!("SysvarC1ock11111111111111111111111111111111")), + authority: self.authority.expect("authority is not set"), + lockup_authority: self.lockup_authority, + }; + let args = AuthorizeInstructionArgs { + arg0: self.arg0.clone().expect("arg0 is not set"), + arg1: self.arg1.clone().expect("arg1 is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `authorize` CPI accounts. -pub struct AuthorizeCpiAccounts<'a, 'b> { - /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, -} + /// `authorize` CPI accounts. + pub struct AuthorizeCpiAccounts<'a, 'b> { + /// Stake account to be updated + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority + + + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be updated + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority + + + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - accounts: AuthorizeCpiAccounts<'a, 'b>, - args: AuthorizeInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - clock_sysvar: accounts.clock_sysvar, - authority: accounts.authority, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: AuthorizeCpiAccounts<'a, 'b>, + args: AuthorizeInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + clock_sysvar: accounts.clock_sysvar, + authority: accounts.authority, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, - true, - )); - if let Some(lockup_authority) = self.lockup_authority { + true + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); + } + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.authority.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); - } - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `Authorize` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[]` clock_sysvar -/// 2. `[signer]` authority -/// 3. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[]` clock_sysvar + /// 2. `[signer]` authority + /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AuthorizeCpiBuilderInstruction { - __program: program, - stake: None, - clock_sysvar: None, - authority: None, - lockup_authority: None, - arg0: None, - arg1: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be updated - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(AuthorizeCpiBuilderInstruction { + __program: program, + stake: None, + clock_sysvar: None, + authority: None, + lockup_authority: None, + arg0: None, + arg1: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account to be updated +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Clock sysvar - #[inline(always)] - pub fn clock_sysvar( - &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self + /// Clock sysvar +#[inline(always)] + pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::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 { - self.instruction.authority = Some(authority); - self + /// The stake or withdraw authority +#[inline(always)] + pub fn authority(&mut self, authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.authority = Some(authority); + self } - /// `[optional account]` - /// 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>>, - ) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self + /// `[optional account]` +/// 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>>) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self } - #[inline(always)] - pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { + #[inline(always)] + pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { self.instruction.arg0 = Some(arg0); self - } - #[inline(always)] - pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { + } + #[inline(always)] + pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { self.instruction.arg1 = Some(arg1); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = AuthorizeInstructionArgs { - arg0: self.instruction.arg0.clone().expect("arg0 is not set"), - arg1: self.instruction.arg1.clone().expect("arg1 is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = AuthorizeInstructionArgs { + arg0: self.instruction.arg0.clone().expect("arg0 is not set"), + arg1: self.instruction.arg1.clone().expect("arg1 is not set"), + }; let instruction = AuthorizeCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - clock_sysvar: self - .instruction - .clock_sysvar - .expect("clock_sysvar is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - arg0: Option, - arg1: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + arg0: Option, + arg1: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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 a7998ef5..0b48ffc9 100644 --- a/clients/rust/src/generated/instructions/authorize_checked.rs +++ b/clients/rust/src/generated/instructions/authorize_checked.rs @@ -5,507 +5,471 @@ //! //! -use { - crate::generated::types::StakeAuthorize, - borsh::{BorshDeserialize, BorshSerialize}, -}; +use crate::generated::types::StakeAuthorize; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct AuthorizeChecked { - /// Stake account to be updated - pub stake: solana_program::pubkey::Pubkey, - /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// The stake or withdraw authority - pub authority: solana_program::pubkey::Pubkey, - /// The new stake or withdraw authority - pub new_authority: solana_program::pubkey::Pubkey, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option, -} + /// Stake account to be updated + + + + pub stake: solana_program::pubkey::Pubkey, + /// Clock sysvar + + + + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// The stake or withdraw authority + + + + pub authority: solana_program::pubkey::Pubkey, + /// The new stake or withdraw authority + + + + pub new_authority: solana_program::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 { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction(&self, args: AuthorizeCheckedInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( self.clock_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.new_authority, - true, - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&AuthorizeCheckedInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeCheckedInstructionData { - discriminator: u32, -} + pub struct AuthorizeCheckedInstructionData { + discriminator: u32, + } impl AuthorizeCheckedInstructionData { - pub fn new() -> Self { - Self { discriminator: 10 } - } + pub fn new() -> Self { + Self { + discriminator: 10, + } + } } impl Default for AuthorizeCheckedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeCheckedInstructionArgs { - pub stake_authorize: StakeAuthorize, -} + pub struct AuthorizeCheckedInstructionArgs { + pub stake_authorize: StakeAuthorize, + } + /// Instruction builder for `AuthorizeChecked`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 2. `[signer]` authority -/// 3. `[signer]` new_authority -/// 4. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) + /// 2. `[signer]` authority + /// 3. `[signer]` new_authority + /// 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_authorize: Option, - __remaining_accounts: Vec, + stake: Option, + clock_sysvar: Option, + authority: Option, + new_authority: Option, + lockup_authority: Option, + stake_authorize: Option, + __remaining_accounts: Vec, } impl AuthorizeCheckedBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be updated - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account to be updated +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` - /// Clock sysvar - #[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` +/// Clock sysvar +#[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self + self.clock_sysvar = Some(clock_sysvar); + self } - /// The stake or withdraw authority - #[inline(always)] + /// The stake or withdraw authority +#[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self + self.authority = Some(authority); + self } - /// The new stake or withdraw authority - #[inline(always)] + /// The new stake or withdraw authority +#[inline(always)] pub fn new_authority(&mut self, new_authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.new_authority = Some(new_authority); - self + self.new_authority = Some(new_authority); + self } - /// `[optional account]` - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - #[inline(always)] - pub fn lockup_authority( - &mut self, - lockup_authority: Option, - ) -> &mut Self { - self.lockup_authority = lockup_authority; - self + /// `[optional account]` +/// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration +#[inline(always)] + pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { + self.lockup_authority = lockup_authority; + self } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.stake_authorize = Some(stake_authorize); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = AuthorizeChecked { - stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarC1ock11111111111111111111111111111111" - )), - authority: self.authority.expect("authority is not set"), - new_authority: self.new_authority.expect("new_authority is not set"), - lockup_authority: self.lockup_authority, - }; - let args = AuthorizeCheckedInstructionArgs { - stake_authorize: self - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = AuthorizeChecked { + stake: self.stake.expect("stake is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!("SysvarC1ock11111111111111111111111111111111")), + authority: self.authority.expect("authority is not set"), + new_authority: self.new_authority.expect("new_authority is not set"), + lockup_authority: self.lockup_authority, + }; + let args = AuthorizeCheckedInstructionArgs { + stake_authorize: self.stake_authorize.clone().expect("stake_authorize is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `authorize_checked` CPI accounts. -pub struct AuthorizeCheckedCpiAccounts<'a, 'b> { - /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The new stake or withdraw authority - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, -} + /// `authorize_checked` CPI accounts. + pub struct AuthorizeCheckedCpiAccounts<'a, 'b> { + /// Stake account to be updated + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority + + + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority + + + + pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The new stake or withdraw authority - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be updated + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority + + + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority + + + + pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - accounts: AuthorizeCheckedCpiAccounts<'a, 'b>, - args: AuthorizeCheckedInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - clock_sysvar: accounts.clock_sysvar, - authority: accounts.authority, - new_authority: accounts.new_authority, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: AuthorizeCheckedCpiAccounts<'a, 'b>, + args: AuthorizeCheckedInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + clock_sysvar: accounts.clock_sysvar, + authority: accounts.authority, + new_authority: accounts.new_authority, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.new_authority.key, - true, - )); - if let Some(lockup_authority) = self.lockup_authority { + true + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); + } + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.authority.clone()); + account_infos.push(self.new_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.new_authority.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); - } - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `AuthorizeChecked` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[]` clock_sysvar -/// 2. `[signer]` authority -/// 3. `[signer]` new_authority -/// 4. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[]` clock_sysvar + /// 2. `[signer]` authority + /// 3. `[signer]` new_authority + /// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeCheckedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AuthorizeCheckedCpiBuilderInstruction { - __program: program, - stake: None, - clock_sysvar: None, - authority: None, - new_authority: None, - lockup_authority: None, - stake_authorize: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be updated - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(AuthorizeCheckedCpiBuilderInstruction { + __program: program, + stake: None, + clock_sysvar: None, + authority: None, + new_authority: None, + lockup_authority: None, + stake_authorize: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account to be updated +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Clock sysvar - #[inline(always)] - pub fn clock_sysvar( - &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self + /// Clock sysvar +#[inline(always)] + pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::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 { - self.instruction.authority = Some(authority); - self + /// The stake or withdraw authority +#[inline(always)] + pub fn authority(&mut self, authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.authority = Some(authority); + self } - /// The new stake or withdraw authority - #[inline(always)] - pub fn new_authority( - &mut self, - new_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_authority = Some(new_authority); - self + /// The new stake or withdraw authority +#[inline(always)] + pub fn new_authority(&mut self, new_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.new_authority = Some(new_authority); + self } - /// `[optional account]` - /// 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>>, - ) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self + /// `[optional account]` +/// 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>>) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.instruction.stake_authorize = Some(stake_authorize); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = AuthorizeCheckedInstructionArgs { - stake_authorize: self - .instruction - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = AuthorizeCheckedInstructionArgs { + stake_authorize: self.instruction.stake_authorize.clone().expect("stake_authorize is not set"), + }; let instruction = AuthorizeCheckedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - clock_sysvar: self - .instruction - .clock_sysvar - .expect("clock_sysvar is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - new_authority: self - .instruction - .new_authority - .expect("new_authority is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + new_authority: self.instruction.new_authority.expect("new_authority is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - stake_authorize: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + stake_authorize: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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 796f5ebb..ca4b42da 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -5,550 +5,504 @@ //! //! -use { - crate::generated::types::StakeAuthorize, - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; +use crate::generated::types::StakeAuthorize; +use solana_program::pubkey::Pubkey; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct AuthorizeCheckedWithSeed { - /// Stake account to be updated - pub stake: solana_program::pubkey::Pubkey, - /// Base key of stake or withdraw authority - pub base: solana_program::pubkey::Pubkey, - /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// The new stake or withdraw authority - pub new_authority: solana_program::pubkey::Pubkey, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option, -} + /// Stake account to be updated + + + + pub stake: solana_program::pubkey::Pubkey, + /// Base key of stake or withdraw authority + + + + pub base: solana_program::pubkey::Pubkey, + /// Clock sysvar + + + + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// The new stake or withdraw authority + + + + pub new_authority: solana_program::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 { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( - self.base, true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn instruction(&self, args: AuthorizeCheckedWithSeedInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( + self.base, + true + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.new_authority, - true, - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } - } + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&AuthorizeCheckedWithSeedInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeCheckedWithSeedInstructionData { - discriminator: u32, -} + pub struct AuthorizeCheckedWithSeedInstructionData { + discriminator: u32, + } impl AuthorizeCheckedWithSeedInstructionData { - pub fn new() -> Self { - Self { discriminator: 11 } - } + pub fn new() -> Self { + Self { + discriminator: 11, + } + } } impl Default for AuthorizeCheckedWithSeedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeCheckedWithSeedInstructionArgs { - pub stake_authorize: StakeAuthorize, - pub authority_seed: String, - pub authority_owner: Pubkey, -} + pub struct AuthorizeCheckedWithSeedInstructionArgs { + pub stake_authorize: StakeAuthorize, + pub authority_seed: String, + pub authority_owner: Pubkey, + } + /// Instruction builder for `AuthorizeCheckedWithSeed`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[signer]` base -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[signer]` new_authority -/// 4. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[signer]` base + /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) + /// 3. `[signer]` new_authority + /// 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_authorize: Option, - authority_seed: Option, - authority_owner: Option, - __remaining_accounts: Vec, + 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, } impl AuthorizeCheckedWithSeedBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be updated - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account to be updated +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Base key of stake or withdraw authority - #[inline(always)] + /// Base key of stake or withdraw authority +#[inline(always)] pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { - self.base = Some(base); - self + self.base = Some(base); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` - /// Clock sysvar - #[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` +/// Clock sysvar +#[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self + self.clock_sysvar = Some(clock_sysvar); + self } - /// The new stake or withdraw authority - #[inline(always)] + /// The new stake or withdraw authority +#[inline(always)] pub fn new_authority(&mut self, new_authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.new_authority = Some(new_authority); - self - } - /// `[optional account]` - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - #[inline(always)] - pub fn lockup_authority( - &mut self, - lockup_authority: Option, - ) -> &mut Self { - self.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.new_authority = Some(new_authority); + self + } + /// `[optional account]` +/// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration +#[inline(always)] + pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.stake_authorize = Some(stake_authorize); self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { self.authority_seed = Some(authority_seed); self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { self.authority_owner = Some(authority_owner); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - 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!( - "SysvarC1ock11111111111111111111111111111111" - )), - new_authority: self.new_authority.expect("new_authority is not set"), - lockup_authority: self.lockup_authority, - }; - let args = AuthorizeCheckedWithSeedInstructionArgs { - stake_authorize: self - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - authority_seed: self - .authority_seed - .clone() - .expect("authority_seed is not set"), - authority_owner: self - .authority_owner - .clone() - .expect("authority_owner is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + 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!("SysvarC1ock11111111111111111111111111111111")), + new_authority: self.new_authority.expect("new_authority is not set"), + lockup_authority: self.lockup_authority, + }; + let args = AuthorizeCheckedWithSeedInstructionArgs { + stake_authorize: self.stake_authorize.clone().expect("stake_authorize is not set"), + authority_seed: self.authority_seed.clone().expect("authority_seed is not set"), + authority_owner: self.authority_owner.clone().expect("authority_owner is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `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>, - /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The new stake or withdraw authority - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, -} + /// `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>, + /// Base key of stake or withdraw authority + + + + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority + + + + pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The new stake or withdraw authority - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be updated + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + + + + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority + + + + pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - accounts: AuthorizeCheckedWithSeedCpiAccounts<'a, 'b>, - args: AuthorizeCheckedWithSeedInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - base: accounts.base, - clock_sysvar: accounts.clock_sysvar, - new_authority: accounts.new_authority, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: AuthorizeCheckedWithSeedCpiAccounts<'a, 'b>, + args: AuthorizeCheckedWithSeedInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + base: accounts.base, + clock_sysvar: accounts.clock_sysvar, + new_authority: accounts.new_authority, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.base.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.new_authority.key, - true, - )); - if let Some(lockup_authority) = self.lockup_authority { + true + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); + } + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.base.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.new_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.base.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.new_authority.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); - } - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `AuthorizeCheckedWithSeed` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[signer]` base -/// 2. `[]` clock_sysvar -/// 3. `[signer]` new_authority -/// 4. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[signer]` base + /// 2. `[]` clock_sysvar + /// 3. `[signer]` new_authority + /// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AuthorizeCheckedWithSeedCpiBuilderInstruction { - __program: program, - stake: None, - base: None, - clock_sysvar: None, - new_authority: None, - lockup_authority: None, - stake_authorize: None, - authority_seed: None, - authority_owner: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be updated - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(AuthorizeCheckedWithSeedCpiBuilderInstruction { + __program: program, + stake: None, + base: None, + clock_sysvar: None, + new_authority: None, + lockup_authority: None, + stake_authorize: None, + authority_seed: None, + authority_owner: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account to be updated +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Base key of stake or withdraw authority - #[inline(always)] + /// Base key of stake or withdraw authority +#[inline(always)] pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base = Some(base); - self - } - /// Clock sysvar - #[inline(always)] - pub fn clock_sysvar( - &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self - } - /// The new stake or withdraw authority - #[inline(always)] - pub fn new_authority( - &mut self, - new_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_authority = Some(new_authority); - self - } - /// `[optional account]` - /// 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>>, - ) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.instruction.base = Some(base); + self + } + /// Clock sysvar +#[inline(always)] + pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self + } + /// The new stake or withdraw authority +#[inline(always)] + pub fn new_authority(&mut self, new_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.new_authority = Some(new_authority); + self + } + /// `[optional account]` +/// 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>>) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.instruction.stake_authorize = Some(stake_authorize); self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { self.instruction.authority_seed = Some(authority_seed); self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { self.instruction.authority_owner = Some(authority_owner); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = AuthorizeCheckedWithSeedInstructionArgs { - stake_authorize: self - .instruction - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - authority_seed: self - .instruction - .authority_seed - .clone() - .expect("authority_seed is not set"), - authority_owner: self - .instruction - .authority_owner - .clone() - .expect("authority_owner is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = AuthorizeCheckedWithSeedInstructionArgs { + stake_authorize: self.instruction.stake_authorize.clone().expect("stake_authorize is not set"), + authority_seed: self.instruction.authority_seed.clone().expect("authority_seed is not set"), + authority_owner: self.instruction.authority_owner.clone().expect("authority_owner is not set"), + }; let instruction = AuthorizeCheckedWithSeedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - base: self.instruction.base.expect("base is not set"), - - clock_sysvar: self - .instruction - .clock_sysvar - .expect("clock_sysvar is not set"), - - new_authority: self - .instruction - .new_authority - .expect("new_authority is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + base: self.instruction.base.expect("base is not set"), + + clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), + + new_authority: self.instruction.new_authority.expect("new_authority is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - 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, - )>, + __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>>, + 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)>, } + diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index beb781f3..101de675 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -5,531 +5,475 @@ //! //! -use { - crate::generated::types::StakeAuthorize, - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; +use solana_program::pubkey::Pubkey; +use crate::generated::types::StakeAuthorize; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct AuthorizeWithSeed { - /// Stake account to be updated - pub stake: solana_program::pubkey::Pubkey, - /// Base key of stake or withdraw authority - pub base: solana_program::pubkey::Pubkey, - /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option, -} + /// Stake account to be updated + + + + pub stake: solana_program::pubkey::Pubkey, + /// Base key of stake or withdraw authority + + + + pub base: solana_program::pubkey::Pubkey, + /// Clock sysvar + + + + pub clock_sysvar: solana_program::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 { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( - self.base, true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn instruction(&self, args: AuthorizeWithSeedInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( + self.base, + true + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false, - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } - } + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&AuthorizeWithSeedInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeWithSeedInstructionData { - discriminator: u32, -} + pub struct AuthorizeWithSeedInstructionData { + discriminator: u32, + } impl AuthorizeWithSeedInstructionData { - pub fn new() -> Self { - Self { discriminator: 8 } - } + pub fn new() -> Self { + Self { + discriminator: 8, + } + } } impl Default for AuthorizeWithSeedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorizeWithSeedInstructionArgs { - pub new_authorized_pubkey: Pubkey, - pub stake_authorize: StakeAuthorize, - pub authority_seed: String, - pub authority_owner: Pubkey, -} + pub struct AuthorizeWithSeedInstructionArgs { + pub new_authorized_pubkey: Pubkey, + pub stake_authorize: StakeAuthorize, + pub authority_seed: String, + pub authority_owner: Pubkey, + } + /// Instruction builder for `AuthorizeWithSeed`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[signer]` base -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[signer]` base + /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) + /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeWithSeedBuilder { - 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, + 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, } impl AuthorizeWithSeedBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be updated - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account to be updated +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Base key of stake or withdraw authority - #[inline(always)] + /// Base key of stake or withdraw authority +#[inline(always)] pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { - self.base = Some(base); - self + self.base = Some(base); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` - /// Clock sysvar - #[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` +/// Clock sysvar +#[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self - } - /// `[optional account]` - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - #[inline(always)] - pub fn lockup_authority( - &mut self, - lockup_authority: Option, - ) -> &mut Self { - self.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); + self + } + /// `[optional account]` +/// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration +#[inline(always)] + pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { self.new_authorized_pubkey = Some(new_authorized_pubkey); self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.stake_authorize = Some(stake_authorize); self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { self.authority_seed = Some(authority_seed); self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { self.authority_owner = Some(authority_owner); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - 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!( - "SysvarC1ock11111111111111111111111111111111" - )), - lockup_authority: self.lockup_authority, - }; - let args = AuthorizeWithSeedInstructionArgs { - new_authorized_pubkey: self - .new_authorized_pubkey - .clone() - .expect("new_authorized_pubkey is not set"), - stake_authorize: self - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - authority_seed: self - .authority_seed - .clone() - .expect("authority_seed is not set"), - authority_owner: self - .authority_owner - .clone() - .expect("authority_owner is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + 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!("SysvarC1ock11111111111111111111111111111111")), + lockup_authority: self.lockup_authority, + }; + let args = AuthorizeWithSeedInstructionArgs { + new_authorized_pubkey: self.new_authorized_pubkey.clone().expect("new_authorized_pubkey is not set"), + stake_authorize: self.stake_authorize.clone().expect("stake_authorize is not set"), + authority_seed: self.authority_seed.clone().expect("authority_seed is not set"), + authority_owner: self.authority_owner.clone().expect("authority_owner is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `authorize_with_seed` CPI accounts. -pub struct AuthorizeWithSeedCpiAccounts<'a, 'b> { - /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, -} + /// `authorize_with_seed` CPI accounts. + pub struct AuthorizeWithSeedCpiAccounts<'a, 'b> { + /// Stake account to be updated + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + + + + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account to be updated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base key of stake or withdraw authority - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be updated + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + + + + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - accounts: AuthorizeWithSeedCpiAccounts<'a, 'b>, - args: AuthorizeWithSeedInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - base: accounts.base, - clock_sysvar: accounts.clock_sysvar, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: AuthorizeWithSeedCpiAccounts<'a, 'b>, + args: AuthorizeWithSeedInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + base: accounts.base, + clock_sysvar: accounts.clock_sysvar, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.base.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false, - )); - if let Some(lockup_authority) = self.lockup_authority { + false + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); + } + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.base.clone()); + account_infos.push(self.clock_sysvar.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.base.clone()); - account_infos.push(self.clock_sysvar.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); - } - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `AuthorizeWithSeed` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[signer]` base -/// 2. `[]` clock_sysvar -/// 3. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[signer]` base + /// 2. `[]` clock_sysvar + /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeWithSeedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AuthorizeWithSeedCpiBuilderInstruction { - __program: program, - stake: None, - base: None, - clock_sysvar: None, - lockup_authority: None, - new_authorized_pubkey: None, - stake_authorize: None, - authority_seed: None, - authority_owner: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be updated - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(AuthorizeWithSeedCpiBuilderInstruction { + __program: program, + stake: None, + base: None, + clock_sysvar: None, + lockup_authority: None, + new_authorized_pubkey: None, + stake_authorize: None, + authority_seed: None, + authority_owner: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account to be updated +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Base key of stake or withdraw authority - #[inline(always)] + /// Base key of stake or withdraw authority +#[inline(always)] pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base = Some(base); - self - } - /// Clock sysvar - #[inline(always)] - pub fn clock_sysvar( - &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self - } - /// `[optional account]` - /// 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>>, - ) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { + self.instruction.base = Some(base); + self + } + /// Clock sysvar +#[inline(always)] + pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self + } + /// `[optional account]` +/// 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>>) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { self.instruction.new_authorized_pubkey = Some(new_authorized_pubkey); self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.instruction.stake_authorize = Some(stake_authorize); self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { self.instruction.authority_seed = Some(authority_seed); self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { self.instruction.authority_owner = Some(authority_owner); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = AuthorizeWithSeedInstructionArgs { - new_authorized_pubkey: self - .instruction - .new_authorized_pubkey - .clone() - .expect("new_authorized_pubkey is not set"), - stake_authorize: self - .instruction - .stake_authorize - .clone() - .expect("stake_authorize is not set"), - authority_seed: self - .instruction - .authority_seed - .clone() - .expect("authority_seed is not set"), - authority_owner: self - .instruction - .authority_owner - .clone() - .expect("authority_owner is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = AuthorizeWithSeedInstructionArgs { + new_authorized_pubkey: self.instruction.new_authorized_pubkey.clone().expect("new_authorized_pubkey is not set"), + stake_authorize: self.instruction.stake_authorize.clone().expect("stake_authorize is not set"), + authority_seed: self.instruction.authority_seed.clone().expect("authority_seed is not set"), + authority_owner: self.instruction.authority_owner.clone().expect("authority_owner is not set"), + }; let instruction = AuthorizeWithSeedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - base: self.instruction.base.expect("base is not set"), - - clock_sysvar: self - .instruction - .clock_sysvar - .expect("clock_sysvar is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + base: self.instruction.base.expect("base is not set"), + + clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - 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, - )>, + __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>>, + 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)>, } + diff --git a/clients/rust/src/generated/instructions/deactivate.rs b/clients/rust/src/generated/instructions/deactivate.rs index 52d6fcb7..eb1af646 100644 --- a/clients/rust/src/generated/instructions/deactivate.rs +++ b/clients/rust/src/generated/instructions/deactivate.rs @@ -5,373 +5,339 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct Deactivate { - /// Delegated stake account to be deactivated - pub stake: solana_program::pubkey::Pubkey, - /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, -} + /// Delegated stake account to be deactivated + + + + pub stake: solana_program::pubkey::Pubkey, + /// Clock sysvar + + + + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake authority + + + + pub stake_authority: solana_program::pubkey::Pubkey, + } impl Deactivate { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::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( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::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( self.clock_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DeactivateInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + true + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&DeactivateInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DeactivateInstructionData { - discriminator: u32, -} + pub struct DeactivateInstructionData { + discriminator: u32, + } impl DeactivateInstructionData { - pub fn new() -> Self { - Self { discriminator: 5 } - } + pub fn new() -> Self { + Self { + discriminator: 5, + } + } } impl Default for DeactivateInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } + + /// Instruction builder for `Deactivate`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 2. `[signer]` stake_authority + /// 0. `[writable]` stake + /// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) + /// 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 to be deactivated - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Delegated stake account to be deactivated +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` - /// Clock sysvar - #[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` +/// Clock sysvar +#[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::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 { - 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 { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self + self.clock_sysvar = Some(clock_sysvar); + self } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = Deactivate { - stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarC1ock11111111111111111111111111111111" - )), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: solana_program::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 { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = Deactivate { + stake: self.stake.expect("stake is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!("SysvarC1ock11111111111111111111111111111111")), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } } -/// `deactivate` CPI accounts. -pub struct DeactivateCpiAccounts<'a, 'b> { - /// Delegated stake account to be deactivated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// `deactivate` CPI accounts. + pub struct DeactivateCpiAccounts<'a, 'b> { + /// Delegated stake account to be deactivated + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::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 to be deactivated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Delegated stake account to be deactivated -impl<'a, 'b> DeactivateCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: DeactivateCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - clock_sysvar: accounts.clock_sysvar, - stake_authority: accounts.stake_authority, + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + +impl<'a, 'b> DeactivateCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: DeactivateCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + clock_sysvar: accounts.clock_sysvar, + stake_authority: accounts.stake_authority, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `Deactivate` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[]` clock_sysvar -/// 2. `[signer]` stake_authority + /// 0. `[writable]` stake + /// 1. `[]` clock_sysvar + /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct DeactivateCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DeactivateCpiBuilderInstruction { - __program: program, - stake: None, - clock_sysvar: None, - stake_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Delegated stake account to be deactivated - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(DeactivateCpiBuilderInstruction { + __program: program, + stake: None, + clock_sysvar: None, + stake_authority: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Delegated stake account to be deactivated +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self - } - /// Clock sysvar - #[inline(always)] - pub fn clock_sysvar( - &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self - } - /// Stake authority - #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self + self.instruction.stake = Some(stake); + self } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self + /// Clock sysvar +#[inline(always)] + pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = DeactivateCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - clock_sysvar: self - .instruction - .clock_sysvar - .expect("clock_sysvar is not set"), - - stake_authority: self - .instruction - .stake_authority - .expect("stake_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), + + stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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 8bdf283b..8fec5ee0 100644 --- a/clients/rust/src/generated/instructions/deactivate_delinquent.rs +++ b/clients/rust/src/generated/instructions/deactivate_delinquent.rs @@ -5,370 +5,338 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct DeactivateDelinquent { - /// Delegated stake account - pub stake: solana_program::pubkey::Pubkey, - /// Delinquent vote account for the delegated stake account - pub delinquent_vote: solana_program::pubkey::Pubkey, - /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs - pub reference_vote: solana_program::pubkey::Pubkey, -} + /// Delegated stake account + + + + pub stake: solana_program::pubkey::Pubkey, + /// Delinquent vote account for the delegated stake account + + + + pub delinquent_vote: solana_program::pubkey::Pubkey, + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs + + + + pub reference_vote: solana_program::pubkey::Pubkey, + } impl DeactivateDelinquent { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::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( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::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( self.delinquent_vote, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.reference_vote, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DeactivateDelinquentInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + false + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&DeactivateDelinquentInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DeactivateDelinquentInstructionData { - discriminator: u32, -} + pub struct DeactivateDelinquentInstructionData { + discriminator: u32, + } impl DeactivateDelinquentInstructionData { - pub fn new() -> Self { - Self { discriminator: 14 } - } + pub fn new() -> Self { + Self { + discriminator: 14, + } + } } impl Default for DeactivateDelinquentInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } + + /// Instruction builder for `DeactivateDelinquent`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[]` delinquent_vote -/// 2. `[]` reference_vote + /// 0. `[writable]` stake + /// 1. `[]` delinquent_vote + /// 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 { - pub fn new() -> Self { - Self::default() - } - /// Delegated stake account - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Delegated stake account +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Delinquent vote account for the delegated stake account - #[inline(always)] - pub fn delinquent_vote( - &mut self, - delinquent_vote: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.delinquent_vote = Some(delinquent_vote); - self + /// Delinquent vote account for the delegated stake account +#[inline(always)] + pub fn delinquent_vote(&mut self, delinquent_vote: solana_program::pubkey::Pubkey) -> &mut Self { + self.delinquent_vote = Some(delinquent_vote); + self } - /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs - #[inline(always)] + /// 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 { - 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 { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = DeactivateDelinquent { - stake: self.stake.expect("stake is not set"), - delinquent_vote: self.delinquent_vote.expect("delinquent_vote is not set"), - reference_vote: self.reference_vote.expect("reference_vote is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + 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 { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = DeactivateDelinquent { + stake: self.stake.expect("stake is not set"), + delinquent_vote: self.delinquent_vote.expect("delinquent_vote is not set"), + reference_vote: self.reference_vote.expect("reference_vote is not set"), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } } -/// `deactivate_delinquent` CPI accounts. -pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { - /// Delegated stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Delinquent vote account for the delegated stake account - pub delinquent_vote: &'b solana_program::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_program::account_info::AccountInfo<'a>, -} + /// `deactivate_delinquent` CPI accounts. + pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { + /// Delegated stake account + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Delinquent vote account for the delegated stake account + + + + pub delinquent_vote: &'b solana_program::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_program::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>, - /// Delegated stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Delinquent vote account for the delegated stake account - pub delinquent_vote: &'b solana_program::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_program::account_info::AccountInfo<'a>, -} + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Delegated stake account -impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: DeactivateDelinquentCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - delinquent_vote: accounts.delinquent_vote, - reference_vote: accounts.reference_vote, + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Delinquent vote account for the delegated stake account + + + + pub delinquent_vote: &'b solana_program::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_program::account_info::AccountInfo<'a>, } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + +impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: DeactivateDelinquentCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + delinquent_vote: accounts.delinquent_vote, + reference_vote: accounts.reference_vote, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.delinquent_vote.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.reference_vote.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.delinquent_vote.clone()); - account_infos.push(self.reference_vote.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + false + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.delinquent_vote.clone()); + account_infos.push(self.reference_vote.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `DeactivateDelinquent` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[]` delinquent_vote -/// 2. `[]` reference_vote + /// 0. `[writable]` stake + /// 1. `[]` delinquent_vote + /// 2. `[]` reference_vote #[derive(Clone, Debug)] pub struct DeactivateDelinquentCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DeactivateDelinquentCpiBuilderInstruction { - __program: program, - stake: None, - delinquent_vote: None, - reference_vote: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Delegated stake account - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(DeactivateDelinquentCpiBuilderInstruction { + __program: program, + stake: None, + delinquent_vote: None, + reference_vote: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Delegated stake account +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self - } - /// 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>, - ) -> &mut Self { - self.instruction.delinquent_vote = Some(delinquent_vote); - self - } - /// 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>, - ) -> &mut Self { - self.instruction.reference_vote = Some(reference_vote); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self + self.instruction.stake = Some(stake); + self } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self + /// 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>) -> &mut Self { + self.instruction.delinquent_vote = Some(delinquent_vote); + self } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + /// 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>) -> &mut Self { + self.instruction.reference_vote = Some(reference_vote); + self } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = DeactivateDelinquentCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - delinquent_vote: self - .instruction - .delinquent_vote - .expect("delinquent_vote is not set"), - - reference_vote: self - .instruction - .reference_vote - .expect("reference_vote is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + delinquent_vote: self.instruction.delinquent_vote.expect("delinquent_vote is not set"), + + reference_vote: self.instruction.reference_vote.expect("reference_vote is not set"), + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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 59a55c45..1ae96234 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -5,492 +5,475 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct DelegateStake { - /// Initialized stake account to be delegated - pub stake: solana_program::pubkey::Pubkey, - /// Vote account to which this stake will be delegated - pub vote: solana_program::pubkey::Pubkey, - /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: solana_program::pubkey::Pubkey, - /// Unused account, formerly the stake config - pub unused: solana_program::pubkey::Pubkey, - /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, -} + /// Initialized stake account to be delegated + + + + pub stake: solana_program::pubkey::Pubkey, + /// Vote account to which this stake will be delegated + + + + pub vote: solana_program::pubkey::Pubkey, + /// Clock sysvar + + + + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake history sysvar that carries stake warmup/cooldown history + + + + pub stake_history: solana_program::pubkey::Pubkey, + /// Unused account, formerly the stake config + + + + pub unused: solana_program::pubkey::Pubkey, + /// Stake authority + + + + pub stake_authority: solana_program::pubkey::Pubkey, + } impl DelegateStake { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::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( - self.vote, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::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( + self.vote, + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_history, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.unused, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DelegateStakeInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + true + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&DelegateStakeInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DelegateStakeInstructionData { - discriminator: u32, -} + pub struct DelegateStakeInstructionData { + discriminator: u32, + } impl DelegateStakeInstructionData { - pub fn new() -> Self { - Self { discriminator: 2 } - } + pub fn new() -> Self { + Self { + discriminator: 2, + } + } } impl Default for DelegateStakeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } + + /// Instruction builder for `DelegateStake`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[]` vote -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[optional]` stake_history (default to `SysvarStakeHistory1111111111111111111111111`) -/// 4. `[]` unused -/// 5. `[signer]` stake_authority + /// 0. `[writable]` stake + /// 1. `[]` vote + /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) + /// 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 { - pub fn new() -> Self { - Self::default() - } - /// Initialized stake account to be delegated - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Initialized stake account to be delegated +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Vote account to which this stake will be delegated - #[inline(always)] + /// Vote account to which this stake will be delegated +#[inline(always)] pub fn vote(&mut self, vote: solana_program::pubkey::Pubkey) -> &mut Self { - self.vote = Some(vote); - self + self.vote = Some(vote); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` - /// Clock sysvar - #[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` +/// Clock sysvar +#[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self + self.clock_sysvar = Some(clock_sysvar); + self } - /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` - /// Stake history sysvar that carries stake warmup/cooldown history - #[inline(always)] + /// `[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 { - self.stake_history = Some(stake_history); - self + self.stake_history = Some(stake_history); + self } - /// Unused account, formerly the stake config - #[inline(always)] + /// Unused account, formerly the stake config +#[inline(always)] pub fn unused(&mut self, unused: solana_program::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 { - 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 { - self.__remaining_accounts.push(account); - self + self.unused = Some(unused); + self } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - 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!( - "SysvarC1ock11111111111111111111111111111111" - )), - stake_history: self.stake_history.unwrap_or(solana_program::pubkey!( - "SysvarStakeHistory1111111111111111111111111" - )), - unused: self.unused.expect("unused is not set"), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: solana_program::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 { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + 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!("SysvarC1ock11111111111111111111111111111111")), + stake_history: self.stake_history.unwrap_or(solana_program::pubkey!("SysvarStakeHistory1111111111111111111111111")), + unused: self.unused.expect("unused is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } } -/// `delegate_stake` CPI accounts. -pub struct DelegateStakeCpiAccounts<'a, 'b> { - /// Initialized stake account to be delegated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Vote account to which this stake will be delegated - pub vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Unused account, formerly the stake config - pub unused: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// `delegate_stake` CPI accounts. + pub struct DelegateStakeCpiAccounts<'a, 'b> { + /// Initialized stake account to be delegated + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Vote account to which this stake will be delegated + + + + pub vote: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + + + + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + /// Unused account, formerly the stake config + + + + pub unused: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::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>, - /// Initialized stake account to be delegated - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Vote account to which this stake will be delegated - pub vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Unused account, formerly the stake config - pub unused: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Initialized stake account to be delegated -impl<'a, 'b> DelegateStakeCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: DelegateStakeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - vote: accounts.vote, - clock_sysvar: accounts.clock_sysvar, - stake_history: accounts.stake_history, - unused: accounts.unused, - stake_authority: accounts.stake_authority, + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Vote account to which this stake will be delegated + + + + pub vote: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + + + + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + /// Unused account, formerly the stake config + + + + pub unused: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + +impl<'a, 'b> DelegateStakeCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: DelegateStakeCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + vote: accounts.vote, + clock_sysvar: accounts.clock_sysvar, + stake_history: accounts.stake_history, + unused: accounts.unused, + stake_authority: accounts.stake_authority, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.vote.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_history.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.unused.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.vote.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history.clone()); - account_infos.push(self.unused.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + true + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.vote.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.stake_history.clone()); + account_infos.push(self.unused.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `DelegateStake` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[]` vote -/// 2. `[]` clock_sysvar -/// 3. `[]` stake_history -/// 4. `[]` unused -/// 5. `[signer]` stake_authority + /// 0. `[writable]` stake + /// 1. `[]` vote + /// 2. `[]` clock_sysvar + /// 3. `[]` stake_history + /// 4. `[]` unused + /// 5. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct DelegateStakeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DelegateStakeCpiBuilderInstruction { - __program: program, - stake: None, - vote: None, - clock_sysvar: None, - stake_history: None, - unused: None, - stake_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Initialized stake account to be delegated - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(DelegateStakeCpiBuilderInstruction { + __program: program, + stake: None, + vote: None, + clock_sysvar: None, + stake_history: None, + unused: None, + stake_authority: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Initialized stake account to be delegated +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Vote account to which this stake will be delegated - #[inline(always)] + /// 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 { - self.instruction.vote = Some(vote); - self - } - /// Clock sysvar - #[inline(always)] - pub fn clock_sysvar( - &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self - } - /// 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>, - ) -> &mut Self { - self.instruction.stake_history = Some(stake_history); - self + self.instruction.vote = Some(vote); + self } - /// Unused account, formerly the stake config - #[inline(always)] - pub fn unused( - &mut self, - unused: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.unused = Some(unused); - self + /// Clock sysvar +#[inline(always)] + pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self } - /// Stake authority - #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// 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>) -> &mut Self { + self.instruction.stake_history = Some(stake_history); + self } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self + /// Unused account, formerly the stake config +#[inline(always)] + pub fn unused(&mut self, unused: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.unused = Some(unused); + self } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = DelegateStakeCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - vote: self.instruction.vote.expect("vote is not set"), - - clock_sysvar: self - .instruction - .clock_sysvar - .expect("clock_sysvar is not set"), - - stake_history: self - .instruction - .stake_history - .expect("stake_history is not set"), - - unused: self.instruction.unused.expect("unused is not set"), - - stake_authority: self - .instruction - .stake_authority - .expect("stake_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + vote: self.instruction.vote.expect("vote is not set"), + + clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), + + stake_history: self.instruction.stake_history.expect("stake_history is not set"), + + unused: self.instruction.unused.expect("unused is not set"), + + stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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..c3ade7a4 100644 --- a/clients/rust/src/generated/instructions/get_minimum_delegation.rs +++ b/clients/rust/src/generated/instructions/get_minimum_delegation.rs @@ -5,160 +5,147 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] -pub struct GetMinimumDelegation {} +pub struct GetMinimumDelegation { + } impl GetMinimumDelegation { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(remaining_accounts.len()); + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::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(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } - } + let data = borsh::to_vec(&GetMinimumDelegationInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct GetMinimumDelegationInstructionData { - discriminator: u32, -} + pub struct GetMinimumDelegationInstructionData { + discriminator: u32, + } impl GetMinimumDelegationInstructionData { - pub fn new() -> Self { - Self { discriminator: 13 } - } + pub fn new() -> Self { + Self { + discriminator: 13, + } + } } impl Default for GetMinimumDelegationInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } + + /// Instruction builder for `GetMinimumDelegation`. /// /// ### Accounts: /// #[derive(Clone, Debug, Default)] pub struct GetMinimumDelegationBuilder { - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl GetMinimumDelegationBuilder { - pub fn new() -> Self { - Self::default() - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = GetMinimumDelegation {}; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } + pub fn new() -> Self { + Self::default() + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = GetMinimumDelegation { + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } } + /// `get_minimum_delegation` CPI instruction. pub struct GetMinimumDelegationCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, -} + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + } impl<'a, 'b> GetMinimumDelegationCpi<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - Self { __program: program } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(remaining_accounts.len()); + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> Self { + Self { + __program: program, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity( remaining_accounts.len()); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } } /// Instruction builder for `GetMinimumDelegation` via CPI. @@ -167,75 +154,50 @@ impl<'a, 'b> GetMinimumDelegationCpi<'a, 'b> { /// #[derive(Clone, Debug)] pub struct GetMinimumDelegationCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> GetMinimumDelegationCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(GetMinimumDelegationCpiBuilderInstruction { - __program: program, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(GetMinimumDelegationCpiBuilderInstruction { + __program: program, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = GetMinimumDelegationCpi { - __program: self.instruction.__program, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[derive(Clone, Debug)] struct GetMinimumDelegationCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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..dcd86f3a 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -5,385 +5,345 @@ //! //! -use { - crate::generated::types::{Authorized, Lockup}, - borsh::{BorshDeserialize, BorshSerialize}, -}; +use crate::generated::types::Authorized; +use crate::generated::types::Lockup; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct Initialize { - /// Uninitialized stake account - pub stake: solana_program::pubkey::Pubkey, - /// Rent sysvar - pub rent_sysvar: solana_program::pubkey::Pubkey, -} + /// Uninitialized stake account + + + + pub stake: solana_program::pubkey::Pubkey, + /// Rent sysvar + + + + pub rent_sysvar: solana_program::pubkey::Pubkey, + } impl Initialize { - pub fn instruction( - &self, - args: InitializeInstructionArgs, - ) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction(&self, args: InitializeInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( 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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + false + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionData { - discriminator: u32, -} + pub struct InitializeInstructionData { + discriminator: u32, + } impl InitializeInstructionData { - pub fn new() -> Self { - Self { discriminator: 0 } - } + pub fn new() -> Self { + Self { + discriminator: 0, + } + } } impl Default for InitializeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionArgs { - pub arg0: Authorized, - pub arg1: Lockup, -} + pub struct InitializeInstructionArgs { + pub arg0: Authorized, + pub arg1: Lockup, + } + /// Instruction builder for `Initialize`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) + /// 0. `[writable]` stake + /// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct InitializeBuilder { - stake: Option, - rent_sysvar: Option, - arg0: Option, - arg1: Option, - __remaining_accounts: Vec, + stake: Option, + rent_sysvar: Option, + arg0: Option, + arg1: Option, + __remaining_accounts: Vec, } impl InitializeBuilder { - pub fn new() -> Self { - Self::default() - } - /// Uninitialized stake account - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Uninitialized stake account +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent sysvar - #[inline(always)] + /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` +/// Rent sysvar +#[inline(always)] pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent_sysvar = Some(rent_sysvar); - self + self.rent_sysvar = Some(rent_sysvar); + self } - #[inline(always)] - pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { + #[inline(always)] + pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { self.arg0 = Some(arg0); self - } - #[inline(always)] - pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { + } + #[inline(always)] + pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { self.arg1 = Some(arg1); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = Initialize { - stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = InitializeInstructionArgs { - arg0: self.arg0.clone().expect("arg0 is not set"), - arg1: self.arg1.clone().expect("arg1 is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = Initialize { + stake: self.stake.expect("stake is not set"), + rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!("SysvarRent111111111111111111111111111111111")), + }; + let args = InitializeInstructionArgs { + arg0: self.arg0.clone().expect("arg0 is not set"), + arg1: self.arg1.clone().expect("arg1 is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `initialize` CPI accounts. -pub struct InitializeCpiAccounts<'a, 'b> { - /// Uninitialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, -} + /// `initialize` CPI accounts. + pub struct InitializeCpiAccounts<'a, 'b> { + /// Uninitialized stake account + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Rent sysvar + + + + pub rent_sysvar: &'b solana_program::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>, - /// Uninitialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Rent sysvar + + + + pub rent_sysvar: &'b solana_program::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>, - accounts: InitializeCpiAccounts<'a, 'b>, - args: InitializeInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - rent_sysvar: accounts.rent_sysvar, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: InitializeCpiAccounts<'a, 'b>, + args: InitializeInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + rent_sysvar: accounts.rent_sysvar, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.rent_sysvar.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.rent_sysvar.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + false + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.rent_sysvar.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `Initialize` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[]` rent_sysvar + /// 0. `[writable]` stake + /// 1. `[]` rent_sysvar #[derive(Clone, Debug)] pub struct InitializeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCpiBuilderInstruction { - __program: program, - stake: None, - rent_sysvar: None, - arg0: None, - arg1: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Uninitialized stake account - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(InitializeCpiBuilderInstruction { + __program: program, + stake: None, + rent_sysvar: None, + arg0: None, + arg1: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Uninitialized stake account +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Rent sysvar - #[inline(always)] - pub fn rent_sysvar( - &mut self, - rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_sysvar = Some(rent_sysvar); - self + /// Rent sysvar +#[inline(always)] + pub fn rent_sysvar(&mut self, rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.rent_sysvar = Some(rent_sysvar); + self } - #[inline(always)] - pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { + #[inline(always)] + pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { self.instruction.arg0 = Some(arg0); self - } - #[inline(always)] - pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { + } + #[inline(always)] + pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { self.instruction.arg1 = Some(arg1); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = InitializeInstructionArgs { - arg0: self.instruction.arg0.clone().expect("arg0 is not set"), - arg1: self.instruction.arg1.clone().expect("arg1 is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = InitializeInstructionArgs { + arg0: self.instruction.arg0.clone().expect("arg0 is not set"), + arg1: self.instruction.arg1.clone().expect("arg1 is not set"), + }; let instruction = InitializeCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - rent_sysvar: self - .instruction - .rent_sysvar - .expect("rent_sysvar is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + rent_sysvar: self.instruction.rent_sysvar.expect("rent_sysvar is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - arg0: Option, - arg1: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + arg0: Option, + arg1: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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..be4a4185 100644 --- a/clients/rust/src/generated/instructions/initialize_checked.rs +++ b/clients/rust/src/generated/instructions/initialize_checked.rs @@ -5,420 +5,383 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct InitializeChecked { - /// Uninitialized stake account - pub stake: solana_program::pubkey::Pubkey, - /// Rent sysvar - pub rent_sysvar: solana_program::pubkey::Pubkey, - /// The stake authority - pub stake_authority: solana_program::pubkey::Pubkey, - /// The withdraw authority - pub withdraw_authority: solana_program::pubkey::Pubkey, -} + /// Uninitialized stake account + + + + pub stake: solana_program::pubkey::Pubkey, + /// Rent sysvar + + + + pub rent_sysvar: solana_program::pubkey::Pubkey, + /// The stake authority + + + + pub stake_authority: solana_program::pubkey::Pubkey, + /// The withdraw authority + + + + pub withdraw_authority: solana_program::pubkey::Pubkey, + } impl InitializeChecked { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::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( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::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( self.rent_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.withdraw_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeCheckedInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + true + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&InitializeCheckedInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCheckedInstructionData { - discriminator: u32, -} + pub struct InitializeCheckedInstructionData { + discriminator: u32, + } impl InitializeCheckedInstructionData { - pub fn new() -> Self { - Self { discriminator: 9 } - } + pub fn new() -> Self { + Self { + discriminator: 9, + } + } } impl Default for InitializeCheckedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } + + /// Instruction builder for `InitializeChecked`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) -/// 2. `[]` stake_authority -/// 3. `[signer]` withdraw_authority + /// 0. `[writable]` stake + /// 1. `[]` rent_sysvar + /// 2. `[]` stake_authority + /// 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 { - pub fn new() -> Self { - Self::default() - } - /// Uninitialized stake account - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Uninitialized stake account +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent sysvar - #[inline(always)] + /// Rent sysvar +#[inline(always)] pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::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 { - self.stake_authority = Some(stake_authority); - self + self.rent_sysvar = Some(rent_sysvar); + self } - /// The withdraw authority - #[inline(always)] - pub fn withdraw_authority( - &mut self, - withdraw_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.withdraw_authority = Some(withdraw_authority); - self + /// The stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: solana_program::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 { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = InitializeChecked { - stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - withdraw_authority: self - .withdraw_authority - .expect("withdraw_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + /// The withdraw authority +#[inline(always)] + pub fn withdraw_authority(&mut self, withdraw_authority: solana_program::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 { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = InitializeChecked { + stake: self.stake.expect("stake is not set"), + rent_sysvar: self.rent_sysvar.expect("rent_sysvar is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + withdraw_authority: self.withdraw_authority.expect("withdraw_authority is not set"), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } } -/// `initialize_checked` CPI accounts. -pub struct InitializeCheckedCpiAccounts<'a, 'b> { - /// Uninitialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The withdraw authority - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// `initialize_checked` CPI accounts. + pub struct InitializeCheckedCpiAccounts<'a, 'b> { + /// Uninitialized stake account + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Rent sysvar + + + + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake authority + + + + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The withdraw authority + + + + pub withdraw_authority: &'b solana_program::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>, - /// Uninitialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The withdraw authority - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account -impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: InitializeCheckedCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - rent_sysvar: accounts.rent_sysvar, - stake_authority: accounts.stake_authority, - withdraw_authority: accounts.withdraw_authority, + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Rent sysvar + + + + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake authority + + + + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The withdraw authority + + + + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + +impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: InitializeCheckedCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + rent_sysvar: accounts.rent_sysvar, + stake_authority: accounts.stake_authority, + withdraw_authority: accounts.withdraw_authority, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.rent_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.withdraw_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.rent_sysvar.clone()); - account_infos.push(self.stake_authority.clone()); - account_infos.push(self.withdraw_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.rent_sysvar.clone()); + account_infos.push(self.stake_authority.clone()); + account_infos.push(self.withdraw_authority.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `InitializeChecked` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[]` rent_sysvar -/// 2. `[]` stake_authority -/// 3. `[signer]` withdraw_authority + /// 0. `[writable]` stake + /// 1. `[]` rent_sysvar + /// 2. `[]` stake_authority + /// 3. `[signer]` withdraw_authority #[derive(Clone, Debug)] pub struct InitializeCheckedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCheckedCpiBuilderInstruction { - __program: program, - stake: None, - rent_sysvar: None, - stake_authority: None, - withdraw_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Uninitialized stake account - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(InitializeCheckedCpiBuilderInstruction { + __program: program, + stake: None, + rent_sysvar: None, + stake_authority: None, + withdraw_authority: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Uninitialized stake account +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self - } - /// Rent sysvar - #[inline(always)] - pub fn rent_sysvar( - &mut self, - rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_sysvar = Some(rent_sysvar); - self + self.instruction.stake = Some(stake); + self } - /// The stake authority - #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// Rent sysvar +#[inline(always)] + pub fn rent_sysvar(&mut self, rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.rent_sysvar = Some(rent_sysvar); + self } - /// The withdraw authority - #[inline(always)] - pub fn withdraw_authority( - &mut self, - withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.withdraw_authority = Some(withdraw_authority); - self + /// The stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self + /// The withdraw authority +#[inline(always)] + pub fn withdraw_authority(&mut self, withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.withdraw_authority = Some(withdraw_authority); + self } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = InitializeCheckedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - rent_sysvar: self - .instruction - .rent_sysvar - .expect("rent_sysvar is not set"), - - stake_authority: self - .instruction - .stake_authority - .expect("stake_authority is not set"), - - withdraw_authority: self - .instruction - .withdraw_authority - .expect("withdraw_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + rent_sysvar: self.instruction.rent_sysvar.expect("rent_sysvar is not set"), + + stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), + + withdraw_authority: self.instruction.withdraw_authority.expect("withdraw_authority is not set"), + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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 5f2feda7..5d372623 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -5,475 +5,430 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct Merge { - /// Destination stake account for the merge - pub destination_stake: solana_program::pubkey::Pubkey, - /// Source stake account for to merge. This account will be drained - pub source_stake: solana_program::pubkey::Pubkey, - /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: solana_program::pubkey::Pubkey, - /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, -} + /// Destination stake account for the merge + + + + pub destination_stake: solana_program::pubkey::Pubkey, + /// Source stake account for to merge. This account will be drained + + + + pub source_stake: solana_program::pubkey::Pubkey, + /// Clock sysvar + + + + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake history sysvar that carries stake warmup/cooldown history + + + + pub stake_history_sysvar: solana_program::pubkey::Pubkey, + /// Stake authority + + + + pub stake_authority: solana_program::pubkey::Pubkey, + } impl Merge { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(5+ remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( self.destination_stake, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.source_stake, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_history_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MergeInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + true + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&MergeInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MergeInstructionData { - discriminator: u32, -} + pub struct MergeInstructionData { + discriminator: u32, + } impl MergeInstructionData { - pub fn new() -> Self { - Self { discriminator: 7 } - } + pub fn new() -> Self { + Self { + discriminator: 7, + } + } } impl Default for MergeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } + + /// Instruction builder for `Merge`. /// /// ### Accounts: /// -/// 0. `[writable]` destination_stake -/// 1. `[writable]` source_stake -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[optional]` stake_history_sysvar (default to `SysvarStakeHistory1111111111111111111111111`) -/// 4. `[signer]` stake_authority + /// 0. `[writable]` destination_stake + /// 1. `[writable]` source_stake + /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) + /// 3. `[optional]` stake_history_sysvar (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_sysvar: Option, - stake_authority: Option, - __remaining_accounts: Vec, + destination_stake: Option, + source_stake: Option, + clock_sysvar: Option, + stake_history_sysvar: Option, + stake_authority: Option, + __remaining_accounts: Vec, } impl MergeBuilder { - pub fn new() -> Self { - Self::default() - } - /// Destination stake account for the merge - #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.destination_stake = Some(destination_stake); - self + pub fn new() -> Self { + Self::default() + } + /// Destination stake account for the merge +#[inline(always)] + pub fn destination_stake(&mut self, destination_stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.destination_stake = Some(destination_stake); + self } - /// Source stake account for to merge. This account will be drained - #[inline(always)] + /// 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 { - self.source_stake = Some(source_stake); - self + self.source_stake = Some(source_stake); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` - /// Clock sysvar - #[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` +/// Clock sysvar +#[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self - } - /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` - /// Stake history sysvar that carries stake warmup/cooldown history - #[inline(always)] - pub fn stake_history_sysvar( - &mut self, - stake_history_sysvar: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.stake_history_sysvar = Some(stake_history_sysvar); - self - } - /// Stake authority - #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: solana_program::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 { - self.__remaining_accounts.push(account); - self + self.clock_sysvar = Some(clock_sysvar); + self } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self + /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` +/// Stake history sysvar that carries stake warmup/cooldown history +#[inline(always)] + pub fn stake_history_sysvar(&mut self, stake_history_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake_history_sysvar = Some(stake_history_sysvar); + self } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::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!( - "SysvarC1ock11111111111111111111111111111111" - )), - stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarStakeHistory1111111111111111111111111" - )), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: solana_program::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 { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + 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!("SysvarC1ock11111111111111111111111111111111")), + stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!("SysvarStakeHistory1111111111111111111111111")), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } } -/// `merge` CPI accounts. -pub struct MergeCpiAccounts<'a, 'b> { - /// Destination stake account for the merge - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Source stake account for to merge. This account will be drained - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// `merge` CPI accounts. + pub struct MergeCpiAccounts<'a, 'b> { + /// Destination stake account for the merge + + + + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Source stake account for to merge. This account will be drained + + + + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + + + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::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 for the merge - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Source stake account for to merge. This account will be drained - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Destination stake account for the merge -impl<'a, 'b> MergeCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: MergeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - destination_stake: accounts.destination_stake, - source_stake: accounts.source_stake, - clock_sysvar: accounts.clock_sysvar, - stake_history_sysvar: accounts.stake_history_sysvar, - stake_authority: accounts.stake_authority, + + + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Source stake account for to merge. This account will be drained + + + + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + + + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + +impl<'a, 'b> MergeCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MergeCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + destination_stake: accounts.destination_stake, + source_stake: accounts.source_stake, + clock_sysvar: accounts.clock_sysvar, + stake_history_sysvar: accounts.stake_history_sysvar, + stake_authority: accounts.stake_authority, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(5+ remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( *self.destination_stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.source_stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_history_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.destination_stake.clone()); - account_infos.push(self.source_stake.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history_sysvar.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + true + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.stake_history_sysvar.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `Merge` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` destination_stake -/// 1. `[writable]` source_stake -/// 2. `[]` clock_sysvar -/// 3. `[]` stake_history_sysvar -/// 4. `[signer]` stake_authority + /// 0. `[writable]` destination_stake + /// 1. `[writable]` source_stake + /// 2. `[]` clock_sysvar + /// 3. `[]` stake_history_sysvar + /// 4. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MergeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> MergeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MergeCpiBuilderInstruction { - __program: program, - destination_stake: None, - source_stake: None, - clock_sysvar: None, - stake_history_sysvar: None, - stake_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Destination stake account for the merge - #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_stake = Some(destination_stake); - self + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MergeCpiBuilderInstruction { + __program: program, + destination_stake: None, + source_stake: None, + clock_sysvar: None, + stake_history_sysvar: None, + stake_authority: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Destination stake account for the merge +#[inline(always)] + pub fn destination_stake(&mut self, destination_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.destination_stake = Some(destination_stake); + self } - /// 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>, - ) -> &mut Self { - self.instruction.source_stake = Some(source_stake); - self + /// 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>) -> &mut Self { + self.instruction.source_stake = Some(source_stake); + self } - /// Clock sysvar - #[inline(always)] - pub fn clock_sysvar( - &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self + /// Clock sysvar +#[inline(always)] + pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self } - /// Stake history sysvar that carries stake warmup/cooldown history - #[inline(always)] - pub fn stake_history_sysvar( - &mut self, - stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.stake_history_sysvar = Some(stake_history_sysvar); - self + /// Stake history sysvar that carries stake warmup/cooldown history +#[inline(always)] + pub fn stake_history_sysvar(&mut self, stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake_history_sysvar = Some(stake_history_sysvar); + self } - /// Stake authority - #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = MergeCpi { - __program: self.instruction.__program, - - destination_stake: self - .instruction - .destination_stake - .expect("destination_stake is not set"), - - source_stake: self - .instruction - .source_stake - .expect("source_stake is not set"), - - clock_sysvar: self - .instruction - .clock_sysvar - .expect("clock_sysvar is not set"), - - stake_history_sysvar: self - .instruction - .stake_history_sysvar - .expect("stake_history_sysvar is not set"), - - stake_authority: self - .instruction - .stake_authority - .expect("stake_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + destination_stake: self.instruction.destination_stake.expect("destination_stake is not set"), + + source_stake: self.instruction.source_stake.expect("source_stake is not set"), + + clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), + + stake_history_sysvar: self.instruction.stake_history_sysvar.expect("stake_history_sysvar is not set"), + + stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, } + diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index 718e3494..bd880fc0 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -5,28 +5,39 @@ //! //! -pub(crate) mod r#authorize; -pub(crate) mod r#authorize_checked; -pub(crate) mod r#authorize_checked_with_seed; -pub(crate) mod r#authorize_with_seed; -pub(crate) mod r#deactivate; -pub(crate) mod r#deactivate_delinquent; -pub(crate) mod r#delegate_stake; -pub(crate) mod r#get_minimum_delegation; -pub(crate) mod r#initialize; -pub(crate) mod r#initialize_checked; -pub(crate) mod r#merge; -pub(crate) mod r#move_lamports; -pub(crate) mod r#move_stake; -pub(crate) mod r#set_lockup; -pub(crate) mod r#set_lockup_checked; -pub(crate) mod r#split; -pub(crate) mod r#withdraw; + pub(crate) mod r#authorize; + pub(crate) mod r#authorize_checked; + pub(crate) mod r#authorize_checked_with_seed; + pub(crate) mod r#authorize_with_seed; + pub(crate) mod r#deactivate; + pub(crate) mod r#deactivate_delinquent; + pub(crate) mod r#delegate_stake; + pub(crate) mod r#get_minimum_delegation; + pub(crate) mod r#initialize; + pub(crate) mod r#initialize_checked; + pub(crate) mod r#merge; + pub(crate) mod r#move_lamports; + pub(crate) mod r#move_stake; + pub(crate) mod r#set_lockup; + pub(crate) mod r#set_lockup_checked; + pub(crate) mod r#split; + pub(crate) mod r#withdraw; + + pub use self::r#authorize::*; + pub use self::r#authorize_checked::*; + pub use self::r#authorize_checked_with_seed::*; + pub use self::r#authorize_with_seed::*; + pub use self::r#deactivate::*; + pub use self::r#deactivate_delinquent::*; + pub use self::r#delegate_stake::*; + pub use self::r#get_minimum_delegation::*; + pub use self::r#initialize::*; + pub use self::r#initialize_checked::*; + pub use self::r#merge::*; + pub use self::r#move_lamports::*; + pub use self::r#move_stake::*; + pub use self::r#set_lockup::*; + pub use self::r#set_lockup_checked::*; + pub use self::r#split::*; + pub use self::r#withdraw::*; -pub use self::{ - r#authorize::*, r#authorize_checked::*, r#authorize_checked_with_seed::*, - r#authorize_with_seed::*, r#deactivate::*, r#deactivate_delinquent::*, r#delegate_stake::*, - r#get_minimum_delegation::*, r#initialize::*, r#initialize_checked::*, r#merge::*, - r#move_lamports::*, r#move_stake::*, r#set_lockup::*, r#set_lockup_checked::*, r#split::*, - r#withdraw::*, -}; diff --git a/clients/rust/src/generated/instructions/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs index cc30b72c..c2f80f32 100644 --- a/clients/rust/src/generated/instructions/move_lamports.rs +++ b/clients/rust/src/generated/instructions/move_lamports.rs @@ -5,420 +5,371 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct MoveLamports { - /// Active or inactive source stake account - pub source_stake: solana_program::pubkey::Pubkey, - /// Mergeable destination stake account - pub destination_stake: solana_program::pubkey::Pubkey, - /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, -} + /// Active or inactive source stake account + + + + pub source_stake: solana_program::pubkey::Pubkey, + /// Mergeable destination stake account + + + + pub destination_stake: solana_program::pubkey::Pubkey, + /// Stake authority + + + + pub stake_authority: solana_program::pubkey::Pubkey, + } impl MoveLamports { - pub fn instruction( - &self, - args: MoveLamportsInstructionArgs, - ) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn instruction(&self, args: MoveLamportsInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( self.source_stake, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.destination_stake, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + true + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&MoveLamportsInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MoveLamportsInstructionData { - discriminator: u32, -} + pub struct MoveLamportsInstructionData { + discriminator: u32, + } impl MoveLamportsInstructionData { - pub fn new() -> Self { - Self { discriminator: 17 } - } + pub fn new() -> Self { + Self { + discriminator: 17, + } + } } impl Default for MoveLamportsInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MoveLamportsInstructionArgs { - pub args: u64, -} + pub struct MoveLamportsInstructionArgs { + pub args: u64, + } + /// Instruction builder for `MoveLamports`. /// /// ### Accounts: /// -/// 0. `[writable]` source_stake -/// 1. `[writable]` destination_stake -/// 2. `[signer]` stake_authority + /// 0. `[writable]` source_stake + /// 1. `[writable]` destination_stake + /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveLamportsBuilder { - source_stake: Option, - destination_stake: Option, - stake_authority: Option, - args: Option, - __remaining_accounts: Vec, + source_stake: Option, + destination_stake: Option, + stake_authority: Option, + args: Option, + __remaining_accounts: Vec, } impl MoveLamportsBuilder { - pub fn new() -> Self { - Self::default() - } - /// Active or inactive source stake account - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Active or inactive source stake account +#[inline(always)] pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.source_stake = Some(source_stake); - 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 { - self.destination_stake = Some(destination_stake); - self + /// Mergeable destination stake account +#[inline(always)] + pub fn destination_stake(&mut self, destination_stake: solana_program::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 { - self.stake_authority = Some(stake_authority); - self + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake_authority = Some(stake_authority); + self } - #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { self.args = Some(args); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = MoveLamports { - source_stake: self.source_stake.expect("source_stake is not set"), - destination_stake: self - .destination_stake - .expect("destination_stake is not set"), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - let args = MoveLamportsInstructionArgs { - args: self.args.clone().expect("args is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = MoveLamports { + source_stake: self.source_stake.expect("source_stake is not set"), + destination_stake: self.destination_stake.expect("destination_stake is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + let args = MoveLamportsInstructionArgs { + args: self.args.clone().expect("args is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `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>, - /// Mergeable destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// `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>, + /// Mergeable destination stake account + + + + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::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>, - /// Active or inactive source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Mergeable destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Active or inactive source stake account + + + + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Mergeable destination stake account + + + + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::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>, - accounts: MoveLamportsCpiAccounts<'a, 'b>, - args: MoveLamportsInstructionArgs, - ) -> Self { - Self { - __program: program, - source_stake: accounts.source_stake, - destination_stake: accounts.destination_stake, - stake_authority: accounts.stake_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MoveLamportsCpiAccounts<'a, 'b>, + args: MoveLamportsInstructionArgs, + ) -> Self { + Self { + __program: program, + source_stake: accounts.source_stake, + destination_stake: accounts.destination_stake, + stake_authority: accounts.stake_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( *self.source_stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.destination_stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.source_stake.clone()); - account_infos.push(self.destination_stake.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `MoveLamports` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` source_stake -/// 1. `[writable]` destination_stake -/// 2. `[signer]` stake_authority + /// 0. `[writable]` source_stake + /// 1. `[writable]` destination_stake + /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MoveLamportsCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MoveLamportsCpiBuilderInstruction { - __program: program, - source_stake: None, - destination_stake: None, - stake_authority: None, - args: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MoveLamportsCpiBuilderInstruction { + __program: program, + source_stake: None, + destination_stake: None, + stake_authority: None, + args: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Active or inactive source stake account +#[inline(always)] + pub fn source_stake(&mut self, source_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.source_stake = Some(source_stake); + self } - /// Active or inactive source stake account - #[inline(always)] - pub fn source_stake( - &mut self, - source_stake: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_stake = Some(source_stake); - self + /// Mergeable destination stake account +#[inline(always)] + pub fn destination_stake(&mut self, destination_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.destination_stake = Some(destination_stake); + self } - /// Mergeable destination stake account - #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_stake = Some(destination_stake); - self + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - /// Stake authority - #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self - } - #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { self.instruction.args = Some(args); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = MoveLamportsInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = MoveLamportsInstructionArgs { + args: self.instruction.args.clone().expect("args is not set"), + }; let instruction = MoveLamportsCpi { - __program: self.instruction.__program, - - source_stake: self - .instruction - .source_stake - .expect("source_stake is not set"), - - destination_stake: self - .instruction - .destination_stake - .expect("destination_stake is not set"), - - stake_authority: self - .instruction - .stake_authority - .expect("stake_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + source_stake: self.instruction.source_stake.expect("source_stake is not set"), + + destination_stake: self.instruction.destination_stake.expect("destination_stake is not set"), + + stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - args: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + args: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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..d596ec5b 100644 --- a/clients/rust/src/generated/instructions/move_stake.rs +++ b/clients/rust/src/generated/instructions/move_stake.rs @@ -5,420 +5,371 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct MoveStake { - /// Active source stake account - pub source_stake: solana_program::pubkey::Pubkey, - /// Active or inactive destination stake account - pub destination_stake: solana_program::pubkey::Pubkey, - /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, -} + /// Active source stake account + + + + pub source_stake: solana_program::pubkey::Pubkey, + /// Active or inactive destination stake account + + + + pub destination_stake: solana_program::pubkey::Pubkey, + /// Stake authority + + + + pub stake_authority: solana_program::pubkey::Pubkey, + } impl MoveStake { - pub fn instruction( - &self, - args: MoveStakeInstructionArgs, - ) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn instruction(&self, args: MoveStakeInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( self.source_stake, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.destination_stake, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + true + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&MoveStakeInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MoveStakeInstructionData { - discriminator: u32, -} + pub struct MoveStakeInstructionData { + discriminator: u32, + } impl MoveStakeInstructionData { - pub fn new() -> Self { - Self { discriminator: 16 } - } + pub fn new() -> Self { + Self { + discriminator: 16, + } + } } impl Default for MoveStakeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MoveStakeInstructionArgs { - pub args: u64, -} + pub struct MoveStakeInstructionArgs { + pub args: u64, + } + /// Instruction builder for `MoveStake`. /// /// ### Accounts: /// -/// 0. `[writable]` source_stake -/// 1. `[writable]` destination_stake -/// 2. `[signer]` stake_authority + /// 0. `[writable]` source_stake + /// 1. `[writable]` destination_stake + /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveStakeBuilder { - source_stake: Option, - destination_stake: Option, - stake_authority: Option, - args: Option, - __remaining_accounts: Vec, + source_stake: Option, + destination_stake: Option, + stake_authority: Option, + args: Option, + __remaining_accounts: Vec, } impl MoveStakeBuilder { - pub fn new() -> Self { - Self::default() - } - /// Active source stake account - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Active source stake account +#[inline(always)] pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.source_stake = Some(source_stake); - 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 { - self.destination_stake = Some(destination_stake); - self + /// Active or inactive destination stake account +#[inline(always)] + pub fn destination_stake(&mut self, destination_stake: solana_program::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 { - self.stake_authority = Some(stake_authority); - self + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake_authority = Some(stake_authority); + self } - #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { self.args = Some(args); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = MoveStake { - source_stake: self.source_stake.expect("source_stake is not set"), - destination_stake: self - .destination_stake - .expect("destination_stake is not set"), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - let args = MoveStakeInstructionArgs { - args: self.args.clone().expect("args is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = MoveStake { + source_stake: self.source_stake.expect("source_stake is not set"), + destination_stake: self.destination_stake.expect("destination_stake is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + let args = MoveStakeInstructionArgs { + args: self.args.clone().expect("args is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `move_stake` CPI accounts. -pub struct MoveStakeCpiAccounts<'a, 'b> { - /// Active source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Active or inactive destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// `move_stake` CPI accounts. + pub struct MoveStakeCpiAccounts<'a, 'b> { + /// Active source stake account + + + + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Active or inactive destination stake account + + + + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::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>, - /// Active source stake account - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Active or inactive destination stake account - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Active source stake account + + + + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Active or inactive destination stake account + + + + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::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>, - accounts: MoveStakeCpiAccounts<'a, 'b>, - args: MoveStakeInstructionArgs, - ) -> Self { - Self { - __program: program, - source_stake: accounts.source_stake, - destination_stake: accounts.destination_stake, - stake_authority: accounts.stake_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MoveStakeCpiAccounts<'a, 'b>, + args: MoveStakeInstructionArgs, + ) -> Self { + Self { + __program: program, + source_stake: accounts.source_stake, + destination_stake: accounts.destination_stake, + stake_authority: accounts.stake_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( *self.source_stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.destination_stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.source_stake.clone()); - account_infos.push(self.destination_stake.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `MoveStake` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` source_stake -/// 1. `[writable]` destination_stake -/// 2. `[signer]` stake_authority + /// 0. `[writable]` source_stake + /// 1. `[writable]` destination_stake + /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MoveStakeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MoveStakeCpiBuilderInstruction { - __program: program, - source_stake: None, - destination_stake: None, - stake_authority: None, - args: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MoveStakeCpiBuilderInstruction { + __program: program, + source_stake: None, + destination_stake: None, + stake_authority: None, + args: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Active source stake account +#[inline(always)] + pub fn source_stake(&mut self, source_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.source_stake = Some(source_stake); + self } - /// Active source stake account - #[inline(always)] - pub fn source_stake( - &mut self, - source_stake: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_stake = Some(source_stake); - self + /// Active or inactive destination stake account +#[inline(always)] + pub fn destination_stake(&mut self, destination_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.destination_stake = Some(destination_stake); + self } - /// Active or inactive destination stake account - #[inline(always)] - pub fn destination_stake( - &mut self, - destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_stake = Some(destination_stake); - self + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - /// Stake authority - #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self - } - #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { self.instruction.args = Some(args); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = MoveStakeInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = MoveStakeInstructionArgs { + args: self.instruction.args.clone().expect("args is not set"), + }; let instruction = MoveStakeCpi { - __program: self.instruction.__program, - - source_stake: self - .instruction - .source_stake - .expect("source_stake is not set"), - - destination_stake: self - .instruction - .destination_stake - .expect("destination_stake is not set"), - - stake_authority: self - .instruction - .stake_authority - .expect("stake_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + source_stake: self.instruction.source_stake.expect("source_stake is not set"), + + destination_stake: self.instruction.destination_stake.expect("destination_stake is not set"), + + stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - args: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + args: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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 d3cb0b62..2df65570 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -5,402 +5,367 @@ //! //! -use { - crate::generated::types::{Epoch, UnixTimestamp}, - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; +use crate::generated::types::UnixTimestamp; +use crate::generated::types::Epoch; +use solana_program::pubkey::Pubkey; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct SetLockup { - /// Initialized stake account - pub stake: solana_program::pubkey::Pubkey, - /// Lockup authority or withdraw authority - pub authority: solana_program::pubkey::Pubkey, -} + /// Initialized stake account + + + + pub stake: solana_program::pubkey::Pubkey, + /// Lockup authority or withdraw authority + + + + pub authority: solana_program::pubkey::Pubkey, + } impl SetLockup { - pub fn instruction( - &self, - args: SetLockupInstructionArgs, - ) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction(&self, args: SetLockupInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( 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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + true + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&SetLockupInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetLockupInstructionData { - discriminator: u32, -} + pub struct SetLockupInstructionData { + discriminator: u32, + } impl SetLockupInstructionData { - pub fn new() -> Self { - Self { discriminator: 6 } - } + pub fn new() -> Self { + Self { + discriminator: 6, + } + } } impl Default for SetLockupInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[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 custodian: Option, -} + pub struct SetLockupInstructionArgs { + pub unix_timestamp: Option, + pub epoch: Option, + pub custodian: Option, + } + /// Instruction builder for `SetLockup`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[signer]` authority + /// 0. `[writable]` stake + /// 1. `[signer]` authority #[derive(Clone, Debug, Default)] pub struct SetLockupBuilder { - stake: Option, - authority: Option, - unix_timestamp: Option, - epoch: Option, - custodian: Option, - __remaining_accounts: Vec, + stake: Option, + authority: Option, + unix_timestamp: Option, + epoch: Option, + custodian: Option, + __remaining_accounts: Vec, } impl SetLockupBuilder { - pub fn new() -> Self { - Self::default() - } - /// Initialized stake account - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Initialized stake account +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Lockup authority or withdraw authority - #[inline(always)] + /// Lockup authority or withdraw authority +#[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self + self.authority = Some(authority); + self } - /// `[optional argument]` - #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: UnixTimestamp) -> &mut Self { + /// `[optional argument]` +#[inline(always)] + 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: Epoch) -> &mut Self { + } + /// `[optional argument]` +#[inline(always)] + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.epoch = Some(epoch); self - } - /// `[optional argument]` - #[inline(always)] - pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { + } + /// `[optional argument]` +#[inline(always)] + pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { self.custodian = Some(custodian); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = SetLockup { - stake: self.stake.expect("stake is not set"), - authority: self.authority.expect("authority is not set"), - }; - let args = SetLockupInstructionArgs { - unix_timestamp: self.unix_timestamp.clone(), - epoch: self.epoch.clone(), - custodian: self.custodian.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = SetLockup { + stake: self.stake.expect("stake is not set"), + authority: self.authority.expect("authority is not set"), + }; + let args = SetLockupInstructionArgs { + unix_timestamp: self.unix_timestamp.clone(), + epoch: self.epoch.clone(), + custodian: self.custodian.clone(), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `set_lockup` CPI accounts. -pub struct SetLockupCpiAccounts<'a, 'b> { - /// Initialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// `set_lockup` CPI accounts. + pub struct SetLockupCpiAccounts<'a, 'b> { + /// Initialized stake account + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority or withdraw authority + + + + pub authority: &'b solana_program::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>, - /// Initialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Initialized stake account + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority or withdraw authority + + + + pub authority: &'b solana_program::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>, - accounts: SetLockupCpiAccounts<'a, 'b>, - args: SetLockupInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - authority: accounts.authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: SetLockupCpiAccounts<'a, 'b>, + args: SetLockupInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + authority: accounts.authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.authority.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `SetLockup` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[signer]` authority + /// 0. `[writable]` stake + /// 1. `[signer]` authority #[derive(Clone, Debug)] pub struct SetLockupCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetLockupCpiBuilderInstruction { - __program: program, - stake: None, - authority: None, - unix_timestamp: None, - epoch: None, - custodian: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Initialized stake account - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(SetLockupCpiBuilderInstruction { + __program: program, + stake: None, + authority: None, + unix_timestamp: None, + epoch: None, + custodian: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Initialized stake account +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - 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 { - self.instruction.authority = Some(authority); - self + /// Lockup authority or withdraw authority +#[inline(always)] + pub fn authority(&mut self, authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.authority = Some(authority); + self } - /// `[optional argument]` - #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: UnixTimestamp) -> &mut Self { + /// `[optional argument]` +#[inline(always)] + 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: Epoch) -> &mut Self { + } + /// `[optional argument]` +#[inline(always)] + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.instruction.epoch = Some(epoch); self - } - /// `[optional argument]` - #[inline(always)] - pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { + } + /// `[optional argument]` +#[inline(always)] + pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { self.instruction.custodian = Some(custodian); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = SetLockupInstructionArgs { - unix_timestamp: self.instruction.unix_timestamp.clone(), - epoch: self.instruction.epoch.clone(), - custodian: self.instruction.custodian.clone(), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = SetLockupInstructionArgs { + unix_timestamp: self.instruction.unix_timestamp.clone(), + epoch: self.instruction.epoch.clone(), + custodian: self.instruction.custodian.clone(), + }; let instruction = SetLockupCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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, - custodian: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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, + custodian: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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 121a94f8..8b20d922 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -5,433 +5,401 @@ //! //! -use { - crate::generated::types::{Epoch, UnixTimestamp}, - borsh::{BorshDeserialize, BorshSerialize}, -}; +use crate::generated::types::UnixTimestamp; +use crate::generated::types::Epoch; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct SetLockupChecked { - /// Initialized stake account - pub stake: solana_program::pubkey::Pubkey, - /// Lockup authority or withdraw authority - pub authority: solana_program::pubkey::Pubkey, - /// New lockup authority - pub new_authority: Option, -} + /// Initialized stake account + + + + pub stake: solana_program::pubkey::Pubkey, + /// Lockup authority or withdraw authority + + + + pub authority: solana_program::pubkey::Pubkey, + /// New lockup authority + + + + pub new_authority: Option, + } impl SetLockupChecked { - pub fn instruction( - &self, - args: SetLockupCheckedInstructionArgs, - ) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction(&self, args: SetLockupCheckedInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( self.authority, - true, - )); - if let Some(new_authority) = self.new_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true + )); + if let Some(new_authority) = self.new_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&SetLockupCheckedInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetLockupCheckedInstructionData { - discriminator: u32, -} + pub struct SetLockupCheckedInstructionData { + discriminator: u32, + } impl SetLockupCheckedInstructionData { - pub fn new() -> Self { - Self { discriminator: 12 } - } + pub fn new() -> Self { + Self { + discriminator: 12, + } + } } impl Default for SetLockupCheckedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[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 struct SetLockupCheckedInstructionArgs { + pub unix_timestamp: Option, + pub epoch: Option, + } + /// Instruction builder for `SetLockupChecked`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[signer]` authority -/// 2. `[signer, optional]` new_authority + /// 0. `[writable]` stake + /// 1. `[signer]` authority + /// 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 { - pub fn new() -> Self { - Self::default() - } - /// Initialized stake account - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Initialized stake account +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Lockup authority or withdraw authority - #[inline(always)] + /// Lockup authority or withdraw authority +#[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self + self.authority = Some(authority); + self } - /// `[optional account]` - /// New lockup authority - #[inline(always)] - pub fn new_authority( - &mut self, - new_authority: Option, - ) -> &mut Self { - self.new_authority = new_authority; - self + /// `[optional account]` +/// New lockup authority +#[inline(always)] + 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: UnixTimestamp) -> &mut Self { + /// `[optional argument]` +#[inline(always)] + 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: Epoch) -> &mut Self { + } + /// `[optional argument]` +#[inline(always)] + 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 { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = SetLockupChecked { - stake: self.stake.expect("stake is not set"), - authority: self.authority.expect("authority is not set"), - new_authority: self.new_authority, - }; - let args = SetLockupCheckedInstructionArgs { - unix_timestamp: self.unix_timestamp.clone(), - epoch: self.epoch.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = SetLockupChecked { + stake: self.stake.expect("stake is not set"), + authority: self.authority.expect("authority is not set"), + new_authority: self.new_authority, + }; + let args = SetLockupCheckedInstructionArgs { + unix_timestamp: self.unix_timestamp.clone(), + epoch: self.epoch.clone(), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `set_lockup_checked` CPI accounts. -pub struct SetLockupCheckedCpiAccounts<'a, 'b> { - /// Initialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// New lockup authority - pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, -} + /// `set_lockup_checked` CPI accounts. + pub struct SetLockupCheckedCpiAccounts<'a, 'b> { + /// Initialized stake account + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority or withdraw authority + + + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// New lockup authority + + + + pub new_authority: Option<&'b solana_program::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>, - /// Initialized stake account - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// New lockup authority - pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Initialized stake account + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority or withdraw authority + + + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// New lockup authority + + + + pub new_authority: Option<&'b solana_program::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>, - accounts: SetLockupCheckedCpiAccounts<'a, 'b>, - args: SetLockupCheckedInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - authority: accounts.authority, - new_authority: accounts.new_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: SetLockupCheckedCpiAccounts<'a, 'b>, + args: SetLockupCheckedInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + authority: accounts.authority, + new_authority: accounts.new_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, - true, - )); - if let Some(new_authority) = self.new_authority { + true + )); + if let Some(new_authority) = self.new_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *new_authority.key, - true, + *new_authority.key, + true, )); + } + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.authority.clone()); + if let Some(new_authority) = self.new_authority { + account_infos.push(new_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.authority.clone()); - if let Some(new_authority) = self.new_authority { - account_infos.push(new_authority.clone()); - } - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `SetLockupChecked` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[signer]` authority -/// 2. `[signer, optional]` new_authority + /// 0. `[writable]` stake + /// 1. `[signer]` authority + /// 2. `[signer, optional]` new_authority #[derive(Clone, Debug)] pub struct SetLockupCheckedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetLockupCheckedCpiBuilderInstruction { - __program: program, - stake: None, - authority: None, - new_authority: None, - unix_timestamp: None, - epoch: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Initialized stake account - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(SetLockupCheckedCpiBuilderInstruction { + __program: program, + stake: None, + authority: None, + new_authority: None, + unix_timestamp: None, + epoch: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Initialized stake account +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - 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 { - self.instruction.authority = Some(authority); - self + /// Lockup authority or withdraw authority +#[inline(always)] + pub fn authority(&mut self, authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.authority = Some(authority); + self } - /// `[optional account]` - /// New lockup authority - #[inline(always)] - pub fn new_authority( - &mut self, - new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.new_authority = new_authority; - self + /// `[optional account]` +/// New lockup authority +#[inline(always)] + pub fn new_authority(&mut self, new_authority: Option<&'b solana_program::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: UnixTimestamp) -> &mut Self { + /// `[optional argument]` +#[inline(always)] + 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: Epoch) -> &mut Self { + } + /// `[optional argument]` +#[inline(always)] + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.instruction.epoch = Some(epoch); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = SetLockupCheckedInstructionArgs { - unix_timestamp: self.instruction.unix_timestamp.clone(), - epoch: self.instruction.epoch.clone(), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = SetLockupCheckedInstructionArgs { + unix_timestamp: self.instruction.unix_timestamp.clone(), + epoch: self.instruction.epoch.clone(), + }; let instruction = SetLockupCheckedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - new_authority: self.instruction.new_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + new_authority: self.instruction.new_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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 36701c29..08a440a6 100644 --- a/clients/rust/src/generated/instructions/split.rs +++ b/clients/rust/src/generated/instructions/split.rs @@ -5,412 +5,371 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct Split { - /// Stake account to be split; must be in the Initialized or Stake state - pub stake: solana_program::pubkey::Pubkey, - /// Uninitialized stake account that will take the split-off amount - pub split_stake: solana_program::pubkey::Pubkey, - /// Stake authority - pub stake_authority: solana_program::pubkey::Pubkey, -} + /// Stake account to be split; must be in the Initialized or Stake state + + + + pub stake: solana_program::pubkey::Pubkey, + /// Uninitialized stake account that will take the split-off amount + + + + pub split_stake: solana_program::pubkey::Pubkey, + /// Stake authority + + + + pub stake_authority: solana_program::pubkey::Pubkey, + } impl Split { - pub fn instruction( - &self, - args: SplitInstructionArgs, - ) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction(&self, args: SplitInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( self.split_stake, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } + true + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&SplitInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitInstructionData { - discriminator: u32, -} + pub struct SplitInstructionData { + discriminator: u32, + } impl SplitInstructionData { - pub fn new() -> Self { - Self { discriminator: 3 } - } + pub fn new() -> Self { + Self { + discriminator: 3, + } + } } impl Default for SplitInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitInstructionArgs { - pub lamports: u64, -} + pub struct SplitInstructionArgs { + pub lamports: u64, + } + /// Instruction builder for `Split`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[writable]` split_stake -/// 2. `[signer]` stake_authority + /// 0. `[writable]` stake + /// 1. `[writable]` split_stake + /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct SplitBuilder { - stake: Option, - split_stake: Option, - stake_authority: Option, - lamports: Option, - __remaining_accounts: Vec, + stake: Option, + split_stake: Option, + stake_authority: Option, + lamports: Option, + __remaining_accounts: Vec, } impl SplitBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be split; must be in the Initialized or Stake state - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// 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 { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Uninitialized stake account that will take the split-off amount - #[inline(always)] + /// 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 { - self.split_stake = Some(split_stake); - 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 { - self.stake_authority = Some(stake_authority); - self + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake_authority = Some(stake_authority); + self } - #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { + #[inline(always)] + pub fn lamports(&mut self, lamports: u64) -> &mut Self { self.lamports = Some(lamports); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - let accounts = Split { - stake: self.stake.expect("stake is not set"), - split_stake: self.split_stake.expect("split_stake is not set"), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - let args = SplitInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + let accounts = Split { + stake: self.stake.expect("stake is not set"), + split_stake: self.split_stake.expect("split_stake is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + let args = SplitInstructionArgs { + lamports: self.lamports.clone().expect("lamports is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `split` CPI accounts. -pub struct SplitCpiAccounts<'a, 'b> { - /// Stake account to be split; must be in the Initialized or Stake state - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Uninitialized stake account that will take the split-off amount - pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, -} + /// `split` CPI accounts. + pub struct SplitCpiAccounts<'a, 'b> { + /// Stake account to be split; must be in the Initialized or Stake state + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account that will take the split-off amount + + + + pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::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; must be in the Initialized or Stake state - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Uninitialized stake account that will take the split-off amount - pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be split; must be in the Initialized or Stake state + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account that will take the split-off amount + + + + pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + + + + pub stake_authority: &'b solana_program::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>, - accounts: SplitCpiAccounts<'a, 'b>, - args: SplitInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - split_stake: accounts.split_stake, - stake_authority: accounts.stake_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: SplitCpiAccounts<'a, 'b>, + args: SplitInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + split_stake: accounts.split_stake, + stake_authority: accounts.stake_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.split_stake.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.split_stake.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.split_stake.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `Split` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[writable]` split_stake -/// 2. `[signer]` stake_authority + /// 0. `[writable]` stake + /// 1. `[writable]` split_stake + /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct SplitCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> SplitCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SplitCpiBuilderInstruction { - __program: program, - stake: None, - split_stake: None, - stake_authority: None, - lamports: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be split; must be in the Initialized or Stake state - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(SplitCpiBuilderInstruction { + __program: program, + stake: None, + split_stake: None, + stake_authority: None, + lamports: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// 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 { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// 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>, - ) -> &mut Self { - self.instruction.split_stake = Some(split_stake); - self + /// 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>) -> &mut Self { + self.instruction.split_stake = Some(split_stake); + self } - /// Stake authority - #[inline(always)] - pub fn stake_authority( - &mut self, - stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// Stake authority +#[inline(always)] + pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { + #[inline(always)] + pub fn lamports(&mut self, lamports: u64) -> &mut Self { self.instruction.lamports = Some(lamports); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = SplitInstructionArgs { - lamports: self - .instruction - .lamports - .clone() - .expect("lamports is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = SplitInstructionArgs { + lamports: self.instruction.lamports.clone().expect("lamports is not set"), + }; let instruction = SplitCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - split_stake: self - .instruction - .split_stake - .expect("split_stake is not set"), - - stake_authority: self - .instruction - .stake_authority - .expect("stake_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + split_stake: self.instruction.split_stake.expect("split_stake is not set"), + + stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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>>, - lamports: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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>>, + lamports: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::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 b23a8c10..a2052b1b 100644 --- a/clients/rust/src/generated/instructions/withdraw.rs +++ b/clients/rust/src/generated/instructions/withdraw.rs @@ -5,554 +5,516 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; /// Accounts. #[derive(Debug)] pub struct Withdraw { - /// Stake account from which to withdraw - pub stake: solana_program::pubkey::Pubkey, - /// Recipient account - pub recipient: solana_program::pubkey::Pubkey, - /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: solana_program::pubkey::Pubkey, - /// Withdraw authority - pub withdraw_authority: solana_program::pubkey::Pubkey, - /// Lockup authority, if before lockup expiration - pub lockup_authority: Option, -} + /// Stake account from which to withdraw + + + + pub stake: solana_program::pubkey::Pubkey, + /// Recipient account + + + + pub recipient: solana_program::pubkey::Pubkey, + /// Clock sysvar + + + + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake history sysvar that carries stake warmup/cooldown history + + + + pub stake_history_sysvar: solana_program::pubkey::Pubkey, + /// Withdraw authority + + + + pub withdraw_authority: solana_program::pubkey::Pubkey, + /// Lockup authority, if before lockup expiration + + + + pub lockup_authority: Option, + } impl Withdraw { - pub fn instruction( - &self, - args: WithdrawInstructionArgs, - ) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction(&self, args: WithdrawInstructionArgs) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_history_sysvar, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.withdraw_authority, - true, - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } - } + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionData { - discriminator: u32, -} + pub struct WithdrawInstructionData { + discriminator: u32, + } impl WithdrawInstructionData { - pub fn new() -> Self { - Self { discriminator: 4 } - } + pub fn new() -> Self { + Self { + discriminator: 4, + } + } } impl Default for WithdrawInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionArgs { - pub lamports: u64, -} + pub struct WithdrawInstructionArgs { + pub lamports: u64, + } + /// Instruction builder for `Withdraw`. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[writable]` recipient -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[optional]` stake_history_sysvar (default to `SysvarStakeHistory1111111111111111111111111`) -/// 4. `[signer]` withdraw_authority -/// 5. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[writable]` recipient + /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) + /// 3. `[optional]` stake_history_sysvar (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_sysvar: Option, - withdraw_authority: Option, - lockup_authority: Option, - lamports: Option, - __remaining_accounts: Vec, + stake: Option, + recipient: Option, + clock_sysvar: Option, + stake_history_sysvar: Option, + withdraw_authority: Option, + lockup_authority: Option, + lamports: Option, + __remaining_accounts: Vec, } impl WithdrawBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account from which to withdraw - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account from which to withdraw +#[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Recipient account - #[inline(always)] + /// Recipient account +#[inline(always)] pub fn recipient(&mut self, recipient: solana_program::pubkey::Pubkey) -> &mut Self { - self.recipient = Some(recipient); - self + self.recipient = Some(recipient); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` - /// Clock sysvar - #[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` +/// Clock sysvar +#[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self - } - /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` - /// Stake history sysvar that carries stake warmup/cooldown history - #[inline(always)] - pub fn stake_history_sysvar( - &mut self, - stake_history_sysvar: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.stake_history_sysvar = Some(stake_history_sysvar); - self - } - /// Withdraw authority - #[inline(always)] - pub fn withdraw_authority( - &mut self, - withdraw_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.withdraw_authority = Some(withdraw_authority); - self - } - /// `[optional account]` - /// Lockup authority, if before lockup expiration - #[inline(always)] - pub fn lockup_authority( - &mut self, - lockup_authority: Option, - ) -> &mut Self { - self.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); + self + } + /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` +/// Stake history sysvar that carries stake warmup/cooldown history +#[inline(always)] + pub fn stake_history_sysvar(&mut self, stake_history_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake_history_sysvar = Some(stake_history_sysvar); + self + } + /// Withdraw authority +#[inline(always)] + pub fn withdraw_authority(&mut self, withdraw_authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.withdraw_authority = Some(withdraw_authority); + self + } + /// `[optional account]` +/// Lockup authority, if before lockup expiration +#[inline(always)] + pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn lamports(&mut self, lamports: u64) -> &mut Self { self.lamports = Some(lamports); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::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 { - 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!( - "SysvarC1ock11111111111111111111111111111111" - )), - stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!( - "SysvarStakeHistory1111111111111111111111111" - )), - withdraw_authority: self - .withdraw_authority - .expect("withdraw_authority is not set"), - lockup_authority: self.lockup_authority, - }; - let args = WithdrawInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { + 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!("SysvarC1ock11111111111111111111111111111111")), + stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!("SysvarStakeHistory1111111111111111111111111")), + withdraw_authority: self.withdraw_authority.expect("withdraw_authority is not set"), + lockup_authority: self.lockup_authority, + }; + let args = WithdrawInstructionArgs { + lamports: self.lamports.clone().expect("lamports is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } -/// `withdraw` CPI accounts. -pub struct WithdrawCpiAccounts<'a, 'b> { - /// Stake account from which to withdraw - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Recipient account - pub recipient: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Withdraw authority - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, -} + /// `withdraw` CPI accounts. + pub struct WithdrawCpiAccounts<'a, 'b> { + /// Stake account from which to withdraw + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Recipient account + + + + pub recipient: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + + + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Withdraw authority + + + + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account from which to withdraw - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Recipient account - pub recipient: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Withdraw authority - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account from which to withdraw + + + + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Recipient account + + + + pub recipient: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + + + + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + + + + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Withdraw authority + + + + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if before lockup expiration + + + + pub lockup_authority: Option<&'b solana_program::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>, - accounts: WithdrawCpiAccounts<'a, 'b>, - args: WithdrawInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - recipient: accounts.recipient, - clock_sysvar: accounts.clock_sysvar, - stake_history_sysvar: accounts.stake_history_sysvar, - withdraw_authority: accounts.withdraw_authority, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: WithdrawCpiAccounts<'a, 'b>, + args: WithdrawInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + recipient: accounts.recipient, + clock_sysvar: accounts.clock_sysvar, + stake_history_sysvar: accounts.stake_history_sysvar, + withdraw_authority: accounts.withdraw_authority, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.recipient.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_history_sysvar.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.withdraw_authority.key, - true, - )); - if let Some(lockup_authority) = self.lockup_authority { + true + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); + } + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.recipient.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.stake_history_sysvar.clone()); + account_infos.push(self.withdraw_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.recipient.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history_sysvar.clone()); - account_infos.push(self.withdraw_authority.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); - } - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } + remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) } + } } /// Instruction builder for `Withdraw` via CPI. /// /// ### Accounts: /// -/// 0. `[writable]` stake -/// 1. `[writable]` recipient -/// 2. `[]` clock_sysvar -/// 3. `[]` stake_history_sysvar -/// 4. `[signer]` withdraw_authority -/// 5. `[signer, optional]` lockup_authority + /// 0. `[writable]` stake + /// 1. `[writable]` recipient + /// 2. `[]` clock_sysvar + /// 3. `[]` stake_history_sysvar + /// 4. `[signer]` withdraw_authority + /// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct WithdrawCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawCpiBuilderInstruction { - __program: program, - stake: None, - recipient: None, - clock_sysvar: None, - stake_history_sysvar: None, - withdraw_authority: None, - lockup_authority: None, - lamports: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account from which to withdraw - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(WithdrawCpiBuilderInstruction { + __program: program, + stake: None, + recipient: None, + clock_sysvar: None, + stake_history_sysvar: None, + withdraw_authority: None, + lockup_authority: None, + lamports: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account from which to withdraw +#[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::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 { - self.instruction.recipient = Some(recipient); - self - } - /// Clock sysvar - #[inline(always)] - pub fn clock_sysvar( - &mut self, - clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self - } - /// Stake history sysvar that carries stake warmup/cooldown history - #[inline(always)] - pub fn stake_history_sysvar( - &mut self, - stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.stake_history_sysvar = Some(stake_history_sysvar); - self - } - /// Withdraw authority - #[inline(always)] - pub fn withdraw_authority( - &mut self, - withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.withdraw_authority = Some(withdraw_authority); - self - } - /// `[optional account]` - /// Lockup authority, if before lockup expiration - #[inline(always)] - pub fn lockup_authority( - &mut self, - lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &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 { + self.instruction.recipient = Some(recipient); + self + } + /// Clock sysvar +#[inline(always)] + pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self + } + /// Stake history sysvar that carries stake warmup/cooldown history +#[inline(always)] + pub fn stake_history_sysvar(&mut self, stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake_history_sysvar = Some(stake_history_sysvar); + self + } + /// Withdraw authority +#[inline(always)] + pub fn withdraw_authority(&mut self, withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.withdraw_authority = Some(withdraw_authority); + self + } + /// `[optional account]` +/// Lockup authority, if before lockup expiration +#[inline(always)] + pub fn lockup_authority(&mut self, lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn lamports(&mut self, lamports: u64) -> &mut Self { self.instruction.lamports = Some(lamports); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = WithdrawInstructionArgs { - lamports: self - .instruction - .lamports - .clone() - .expect("lamports is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { + self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { + self.instruction.__remaining_accounts.extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = WithdrawInstructionArgs { + lamports: self.instruction.lamports.clone().expect("lamports is not set"), + }; let instruction = WithdrawCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - recipient: self.instruction.recipient.expect("recipient is not set"), - - clock_sysvar: self - .instruction - .clock_sysvar - .expect("clock_sysvar is not set"), - - stake_history_sysvar: self - .instruction - .stake_history_sysvar - .expect("stake_history_sysvar is not set"), - - withdraw_authority: self - .instruction - .withdraw_authority - .expect("withdraw_authority is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + recipient: self.instruction.recipient.expect("recipient is not set"), + + clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), + + stake_history_sysvar: self.instruction.stake_history_sysvar.expect("stake_history_sysvar is not set"), + + withdraw_authority: self.instruction.withdraw_authority.expect("withdraw_authority is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) + } } #[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_sysvar: 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>>, - lamports: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __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_sysvar: 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>>, + lamports: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, } + diff --git a/clients/rust/src/generated/mod.rs b/clients/rust/src/generated/mod.rs index 93378cfd..22d4f515 100644 --- a/clients/rust/src/generated/mod.rs +++ b/clients/rust/src/generated/mod.rs @@ -5,9 +5,9 @@ //! //! -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod types; - -pub(crate) use programs::*; + pub mod errors; + pub mod instructions; + pub mod programs; + pub mod types; + + pub(crate) use programs::*; diff --git a/clients/rust/src/generated/programs.rs b/clients/rust/src/generated/programs.rs index e3286ac3..087bb7ec 100644 --- a/clients/rust/src/generated/programs.rs +++ b/clients/rust/src/generated/programs.rs @@ -7,5 +7,7 @@ use solana_program::{pubkey, pubkey::Pubkey}; -/// `stake` program ID. -pub const STAKE_ID: Pubkey = pubkey!("Stake11111111111111111111111111111111111111"); + + /// `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..8b291610 100644 --- a/clients/rust/src/generated/types/authorized.rs +++ b/clients/rust/src/generated/types/authorized.rs @@ -5,22 +5,17 @@ //! //! -use { - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; +use solana_program::pubkey::Pubkey; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Authorized { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub staker: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub withdrawer: Pubkey, +#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] +pub staker: Pubkey, +#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] +pub withdrawer: Pubkey, } + + diff --git a/clients/rust/src/generated/types/delegation.rs b/clients/rust/src/generated/types/delegation.rs index 6099f376..fdb95eca 100644 --- a/clients/rust/src/generated/types/delegation.rs +++ b/clients/rust/src/generated/types/delegation.rs @@ -5,22 +5,20 @@ //! //! -use { - crate::generated::types::Epoch, - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; +use solana_program::pubkey::Pubkey; +use crate::generated::types::Epoch; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Delegation { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub voter_pubkey: Pubkey, - pub stake: u64, - pub activation_epoch: Epoch, - pub deactivation_epoch: Epoch, - pub warmup_cooldown_rate: f64, +#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] +pub voter_pubkey: Pubkey, +pub stake: 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 index 0060ad16..a9686c89 100644 --- a/clients/rust/src/generated/types/epoch.rs +++ b/clients/rust/src/generated/types/epoch.rs @@ -5,4 +5,8 @@ //! //! + + pub type Epoch = u64; + + diff --git a/clients/rust/src/generated/types/lockup.rs b/clients/rust/src/generated/types/lockup.rs index 8b364f93..76cf4b06 100644 --- a/clients/rust/src/generated/types/lockup.rs +++ b/clients/rust/src/generated/types/lockup.rs @@ -5,20 +5,19 @@ //! //! -use { - crate::generated::types::{Epoch, UnixTimestamp}, - borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, -}; +use crate::generated::types::UnixTimestamp; +use crate::generated::types::Epoch; +use solana_program::pubkey::Pubkey; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Lockup { - pub unix_timestamp: UnixTimestamp, - pub epoch: Epoch, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub custodian: Pubkey, +pub unix_timestamp: UnixTimestamp, +pub epoch: Epoch, +#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] +pub custodian: Pubkey, } + + diff --git a/clients/rust/src/generated/types/meta.rs b/clients/rust/src/generated/types/meta.rs index 3bca5fb1..ee68f54d 100644 --- a/clients/rust/src/generated/types/meta.rs +++ b/clients/rust/src/generated/types/meta.rs @@ -5,15 +5,17 @@ //! //! -use { - crate::generated::types::{Authorized, Lockup}, - borsh::{BorshDeserialize, BorshSerialize}, -}; +use crate::generated::types::Authorized; +use crate::generated::types::Lockup; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Meta { - pub rent_exempt_reserve: u64, - pub authorized: Authorized, - pub lockup: Lockup, +pub rent_exempt_reserve: u64, +pub authorized: Authorized, +pub lockup: Lockup, } + + diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index 052ebd93..85d63fb4 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -5,20 +5,27 @@ //! //! -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; -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(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; + 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::*; + pub use self::r#delegation::*; + pub use self::r#epoch::*; + pub use self::r#lockup::*; + pub use self::r#meta::*; + pub use self::r#stake::*; + pub use self::r#stake_authorize::*; + pub use self::r#stake_flags::*; + pub use self::r#stake_state::*; + pub use self::r#stake_state_v2::*; + pub use self::r#unix_timestamp::*; -pub use self::{ - 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/stake.rs b/clients/rust/src/generated/types/stake.rs index 0ca55fda..460b3b35 100644 --- a/clients/rust/src/generated/types/stake.rs +++ b/clients/rust/src/generated/types/stake.rs @@ -5,14 +5,15 @@ //! //! -use { - crate::generated::types::Delegation, - borsh::{BorshDeserialize, BorshSerialize}, -}; +use crate::generated::types::Delegation; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Stake { - pub delegation: Delegation, - pub credits_observed: u64, +pub delegation: Delegation, +pub credits_observed: u64, } + + diff --git a/clients/rust/src/generated/types/stake_authorize.rs b/clients/rust/src/generated/types/stake_authorize.rs index aef2f6a0..cac2b03c 100644 --- a/clients/rust/src/generated/types/stake_authorize.rs +++ b/clients/rust/src/generated/types/stake_authorize.rs @@ -5,16 +5,15 @@ //! //! -use { - borsh::{BorshDeserialize, BorshSerialize}, - num_derive::FromPrimitive, -}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; +use num_derive::FromPrimitive; -#[derive( - BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq, Copy, PartialOrd, Hash, FromPrimitive, -)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq, Copy, PartialOrd, Hash, FromPrimitive)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum StakeAuthorize { - Staker, - Withdrawer, +Staker, +Withdrawer, } + + diff --git a/clients/rust/src/generated/types/stake_flags.rs b/clients/rust/src/generated/types/stake_flags.rs index 234dea08..93f96caf 100644 --- a/clients/rust/src/generated/types/stake_flags.rs +++ b/clients/rust/src/generated/types/stake_flags.rs @@ -5,10 +5,13 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct StakeFlags { - pub bits: u8, +pub bits: u8, } + + diff --git a/clients/rust/src/generated/types/stake_state.rs b/clients/rust/src/generated/types/stake_state.rs index 0125ac5f..e096251a 100644 --- a/clients/rust/src/generated/types/stake_state.rs +++ b/clients/rust/src/generated/types/stake_state.rs @@ -5,16 +5,18 @@ //! //! -use { - crate::generated::types::{Meta, Stake}, - borsh::{BorshDeserialize, BorshSerialize}, -}; +use crate::generated::types::Meta; +use crate::generated::types::Stake; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum StakeState { - Uninitialized, - Initialized(Meta), - Stake(Meta, Stake), - RewardsPool, +Uninitialized, +Initialized(Meta), +Stake(Meta, Stake), +RewardsPool, } + + diff --git a/clients/rust/src/generated/types/stake_state_v2.rs b/clients/rust/src/generated/types/stake_state_v2.rs index 4d997448..42424678 100644 --- a/clients/rust/src/generated/types/stake_state_v2.rs +++ b/clients/rust/src/generated/types/stake_state_v2.rs @@ -5,16 +5,19 @@ //! //! -use { - crate::generated::types::{Meta, Stake, StakeFlags}, - borsh::{BorshDeserialize, BorshSerialize}, -}; +use crate::generated::types::Meta; +use crate::generated::types::Stake; +use crate::generated::types::StakeFlags; +use borsh::BorshSerialize; +use borsh::BorshDeserialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum StakeStateV2 { - Uninitialized, - Initialized(Meta), - Stake(Meta, Stake, StakeFlags), - RewardsPool, +Uninitialized, +Initialized(Meta), +Stake(Meta, Stake, StakeFlags), +RewardsPool, } + + diff --git a/clients/rust/src/generated/types/unix_timestamp.rs b/clients/rust/src/generated/types/unix_timestamp.rs index 62d0860b..25ce7a8b 100644 --- a/clients/rust/src/generated/types/unix_timestamp.rs +++ b/clients/rust/src/generated/types/unix_timestamp.rs @@ -5,4 +5,8 @@ //! //! + + pub type UnixTimestamp = i64; + + diff --git a/clients/rust/src/hooked/mod.rs b/clients/rust/src/hooked/mod.rs index 37365c36..c8f9b009 100644 --- a/clients/rust/src/hooked/mod.rs +++ b/clients/rust/src/hooked/mod.rs @@ -1,2 +1,3 @@ pub mod stake_state_account; + pub use stake_state_account::*; diff --git a/interface/idl.json b/interface/idl.json index a494a27f..711c7610 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -619,6 +619,10 @@ "name": "stake" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarRent111111111111111111111111111111111" + }, "docs": [ "Rent sysvar" ], @@ -682,6 +686,10 @@ "name": "stake" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, "docs": [ "Clock sysvar" ], @@ -772,6 +780,10 @@ "name": "vote" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, "docs": [ "Clock sysvar" ], @@ -781,6 +793,10 @@ "name": "clockSysvar" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarStakeHistory1111111111111111111111111" + }, "docs": [ "Stake history sysvar that carries stake warmup/cooldown history" ], @@ -920,6 +936,10 @@ "name": "recipient" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, "docs": [ "Clock sysvar" ], @@ -929,6 +949,10 @@ "name": "clockSysvar" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarStakeHistory1111111111111111111111111" + }, "docs": [ "Stake history sysvar that carries stake warmup/cooldown history" ], @@ -1004,6 +1028,10 @@ "name": "stake" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, "docs": [ "Clock sysvar" ], @@ -1124,6 +1152,10 @@ "name": "sourceStake" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, "docs": [ "Clock sysvar" ], @@ -1133,6 +1165,10 @@ "name": "clockSysvar" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarStakeHistory1111111111111111111111111" + }, "docs": [ "Stake history sysvar that carries stake warmup/cooldown history" ], @@ -1198,6 +1234,10 @@ "name": "base" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, "docs": [ "Clock sysvar" ], @@ -1328,6 +1368,10 @@ "name": "stake" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, "docs": [ "Clock sysvar" ], @@ -1420,6 +1464,10 @@ "name": "base" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarC1ock11111111111111111111111111111111" + }, "docs": [ "Clock sysvar" ], diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 3e8b6958..1339ddbe 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -46,7 +46,7 @@ pub enum StakeInstruction { /// and withdrawer transactions; [`Lockup`] carries information about /// withdrawal restrictions. #[codama(account(name = "stake", writable, docs = "Uninitialized stake account"))] - #[codama(account(name = "rent_sysvar", docs = "Rent sysvar"))] + #[codama(account(name = "rent_sysvar", docs = "Rent sysvar", default_value = sysvar("rent")))] Initialize { arg0: Authorized, arg1: Lockup }, /// Authorize a key to manage stake or withdrawal @@ -58,7 +58,7 @@ pub enum StakeInstruction { /// 3. Optional: `[SIGNER]` Lockup authority, if updating `StakeAuthorize::Withdrawer` before /// lockup expiration #[codama(account(name = "stake", writable, docs = "Stake account to be updated"))] - #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[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", @@ -89,10 +89,11 @@ pub enum StakeInstruction { name = "vote", docs = "Vote account to which this stake will be delegated" ))] - #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[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" + 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"))] @@ -135,10 +136,11 @@ pub enum StakeInstruction { docs = "Stake account from which to withdraw" ))] #[codama(account(name = "recipient", writable, docs = "Recipient account"))] - #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock")))] #[codama(account( name = "stake_history_sysvar", - docs = "Stake history sysvar that carries stake warmup/cooldown 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( @@ -160,7 +162,7 @@ pub enum StakeInstruction { writable, docs = "Delegated stake account to be deactivated" ))] - #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock")))] #[codama(account(name = "stake_authority", signer, docs = "Stake authority"))] Deactivate, @@ -214,10 +216,11 @@ pub enum StakeInstruction { writable, docs = "Source stake account for to merge. This account will be drained" ))] - #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock")))] #[codama(account( name = "stake_history_sysvar", - docs = "Stake history sysvar that carries stake warmup/cooldown 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, @@ -236,7 +239,7 @@ pub enum StakeInstruction { signer, docs = "Base key of stake or withdraw authority" ))] - #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock")))] #[codama(account( name = "lockup_authority", optional, @@ -276,7 +279,7 @@ pub enum StakeInstruction { /// 4. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration #[codama(account(name = "stake", writable, docs = "Stake account to be updated"))] - #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[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", @@ -309,7 +312,7 @@ pub enum StakeInstruction { signer, docs = "Base key of stake or withdraw authority" ))] - #[codama(account(name = "clock_sysvar", docs = "Clock sysvar"))] + #[codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock")))] #[codama(account( name = "new_authority", signer, diff --git a/scripts/generate-clients.mts b/scripts/generate-clients.mts index d8750f34..e74532ec 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -39,24 +39,6 @@ codama.update( codama.update(c.unwrapInstructionArgsDefinedTypesVisitor()); codama.update(c.flattenInstructionDataArgumentsVisitor()); -// Set default values for sysvar accounts (the proper Codama way) -codama.update( - c.setInstructionAccountDefaultValuesVisitor([ - { - account: 'clockSysvar', - defaultValue: c.publicKeyValueNode('SysvarC1ock11111111111111111111111111111111'), - }, - { - account: 'rentSysvar', - defaultValue: c.publicKeyValueNode('SysvarRent111111111111111111111111111111111'), - }, - { - account: /^stake[Hh]istory/, - defaultValue: c.publicKeyValueNode('SysvarStakeHistory1111111111111111111111111'), - }, - ]) -); - // Add type aliases for semantic external types codama.update( c.bottomUpTransformerVisitor([ From 8331188c0b60524bf6a01f3fb7aa6aea833de5a3 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:17:52 +0000 Subject: [PATCH 18/27] featurize codama --- .github/workflows/main.yml | 4 + Cargo.toml | 2 +- Makefile | 3 + clients/rust/src/generated/errors/mod.rs | 7 +- clients/rust/src/generated/errors/stake.rs | 8 +- .../src/generated/instructions/authorize.rs | 738 +++++++------- .../instructions/authorize_checked.rs | 798 +++++++-------- .../authorize_checked_with_seed.rs | 872 +++++++++-------- .../instructions/authorize_with_seed.rs | 822 ++++++++-------- .../src/generated/instructions/deactivate.rs | 572 +++++------ .../instructions/deactivate_delinquent.rs | 568 +++++------ .../generated/instructions/delegate_stake.rs | 799 +++++++-------- .../instructions/get_minimum_delegation.rs | 330 ++++--- .../src/generated/instructions/initialize.rs | 574 +++++------ .../instructions/initialize_checked.rs | 652 +++++++------ .../rust/src/generated/instructions/merge.rs | 751 ++++++++------- .../rust/src/generated/instructions/mod.rs | 59 +- .../generated/instructions/move_lamports.rs | 637 ++++++------ .../src/generated/instructions/move_stake.rs | 637 ++++++------ .../src/generated/instructions/set_lockup.rs | 605 ++++++------ .../instructions/set_lockup_checked.rs | 664 +++++++------ .../rust/src/generated/instructions/split.rs | 627 ++++++------ .../src/generated/instructions/withdraw.rs | 906 +++++++++--------- clients/rust/src/generated/mod.rs | 12 +- clients/rust/src/generated/programs.rs | 6 +- .../rust/src/generated/types/authorized.rs | 23 +- .../rust/src/generated/types/delegation.rs | 26 +- clients/rust/src/generated/types/epoch.rs | 4 - clients/rust/src/generated/types/lockup.rs | 23 +- clients/rust/src/generated/types/meta.rs | 16 +- clients/rust/src/generated/types/mod.rs | 39 +- clients/rust/src/generated/types/stake.rs | 13 +- .../src/generated/types/stake_authorize.rs | 17 +- .../rust/src/generated/types/stake_flags.rs | 7 +- .../rust/src/generated/types/stake_state.rs | 18 +- .../src/generated/types/stake_state_v2.rs | 19 +- .../src/generated/types/unix_timestamp.rs | 4 - interface/Cargo.toml | 10 +- .../{build.rs => src/bin/generate-idl.rs} | 23 +- interface/src/error.rs | 145 ++- interface/src/instruction.rs | 507 ++++++---- interface/src/lib.rs | 3 +- interface/src/stake_flags.rs | 3 +- interface/src/state.rs | 33 +- 44 files changed, 6715 insertions(+), 5871 deletions(-) rename interface/{build.rs => src/bin/generate-idl.rs} (63%) 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.toml b/Cargo.toml index 6b8cd32a..131a1e33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ 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] 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/rust/src/generated/errors/mod.rs b/clients/rust/src/generated/errors/mod.rs index 19db3500..7f6b2f81 100644 --- a/clients/rust/src/generated/errors/mod.rs +++ b/clients/rust/src/generated/errors/mod.rs @@ -5,7 +5,6 @@ //! //! - pub(crate) mod stake; - - pub use self::stake::StakeError; - +pub(crate) mod stake; + +pub use self::stake::StakeError; diff --git a/clients/rust/src/generated/errors/stake.rs b/clients/rust/src/generated/errors/stake.rs index 37a23244..cae66e42 100644 --- a/clients/rust/src/generated/errors/stake.rs +++ b/clients/rust/src/generated/errors/stake.rs @@ -5,8 +5,7 @@ //! //! -use num_derive::FromPrimitive; -use thiserror::Error; +use {num_derive::FromPrimitive, thiserror::Error}; #[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] pub enum StakeError { @@ -44,7 +43,9 @@ pub enum StakeError { #[error("Stake account is not delegated to the provided vote account")] VoteAddressMismatch = 0xA, /// 11 - Stake account has not been delinquent for the minimum epochs required for deactivation - #[error("Stake account has not been delinquent for the minimum epochs required for deactivation")] + #[error( + "Stake account has not been delinquent for the minimum epochs required for deactivation" + )] MinimumDelinquentEpochsForDeactivationNotMet = 0xB, /// 12 - Delegation amount is less than the minimum #[error("Delegation amount is less than the minimum")] @@ -74,4 +75,3 @@ impl solana_program::decode_error::DecodeError for StakeError { "StakeError" } } - diff --git a/clients/rust/src/generated/instructions/authorize.rs b/clients/rust/src/generated/instructions/authorize.rs index e655d88c..badf148d 100644 --- a/clients/rust/src/generated/instructions/authorize.rs +++ b/clients/rust/src/generated/instructions/authorize.rs @@ -5,443 +5,475 @@ //! //! -use solana_program::pubkey::Pubkey; -use crate::generated::types::StakeAuthorize; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::StakeAuthorize, + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; /// Accounts. #[derive(Debug)] pub struct Authorize { - /// Stake account to be updated - - - - pub stake: solana_program::pubkey::Pubkey, - /// Clock sysvar - - - - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// The stake or withdraw authority - - - - pub authority: solana_program::pubkey::Pubkey, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option, - } + /// Stake account to be updated + pub stake: solana_program::pubkey::Pubkey, + /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// The stake or withdraw authority + pub authority: solana_program::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 { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction( + &self, + args: AuthorizeInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( self.clock_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, - true - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&AuthorizeInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct AuthorizeInstructionData { - discriminator: u32, - } +pub struct AuthorizeInstructionData { + discriminator: u32, +} impl AuthorizeInstructionData { - pub fn new() -> Self { - Self { - discriminator: 1, - } - } + pub fn new() -> Self { + Self { discriminator: 1 } + } } impl Default for AuthorizeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct AuthorizeInstructionArgs { - pub arg0: Pubkey, - pub arg1: StakeAuthorize, - } - +pub struct AuthorizeInstructionArgs { + pub arg0: Pubkey, + pub arg1: StakeAuthorize, +} /// Instruction builder for `Authorize`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) - /// 2. `[signer]` authority - /// 3. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 2. `[signer]` authority +/// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeBuilder { - stake: Option, - clock_sysvar: Option, - authority: Option, - lockup_authority: Option, - arg0: Option, - arg1: Option, - __remaining_accounts: Vec, + stake: Option, + clock_sysvar: Option, + authority: Option, + lockup_authority: Option, + arg0: Option, + arg1: Option, + __remaining_accounts: Vec, } impl AuthorizeBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be updated -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account to be updated + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` -/// Clock sysvar -#[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` + /// Clock sysvar + #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self + self.clock_sysvar = Some(clock_sysvar); + self } - /// The stake or withdraw authority -#[inline(always)] + /// The stake or withdraw authority + #[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self + self.authority = Some(authority); + self } - /// `[optional account]` -/// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration -#[inline(always)] - pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { - self.lockup_authority = lockup_authority; - self + /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; + self } - #[inline(always)] - pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { + #[inline(always)] + pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { self.arg0 = Some(arg0); self - } - #[inline(always)] - pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { + } + #[inline(always)] + pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { self.arg1 = Some(arg1); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = Authorize { - stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!("SysvarC1ock11111111111111111111111111111111")), - authority: self.authority.expect("authority is not set"), - lockup_authority: self.lockup_authority, - }; - let args = AuthorizeInstructionArgs { - arg0: self.arg0.clone().expect("arg0 is not set"), - arg1: self.arg1.clone().expect("arg1 is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - - /// `authorize` CPI accounts. - pub struct AuthorizeCpiAccounts<'a, 'b> { - /// Stake account to be updated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = Authorize { + stake: self.stake.expect("stake is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), + authority: self.authority.expect("authority is not set"), + lockup_authority: self.lockup_authority, + }; + let args = AuthorizeInstructionArgs { + arg0: self.arg0.clone().expect("arg0 is not set"), + arg1: self.arg1.clone().expect("arg1 is not set"), + }; - - - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - } +/// `authorize` CPI accounts. +pub struct AuthorizeCpiAccounts<'a, 'b> { + /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account to be updated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority - - - - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - accounts: AuthorizeCpiAccounts<'a, 'b>, - args: AuthorizeInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - clock_sysvar: accounts.clock_sysvar, - authority: accounts.authority, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(4+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: AuthorizeCpiAccounts<'a, 'b>, + args: AuthorizeInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + clock_sysvar: accounts.clock_sysvar, + authority: accounts.authority, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, - true - )); - if let Some(lockup_authority) = self.lockup_authority { + true, + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); - } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.authority.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `Authorize` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` clock_sysvar - /// 2. `[signer]` authority - /// 3. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[]` clock_sysvar +/// 2. `[signer]` authority +/// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AuthorizeCpiBuilderInstruction { - __program: program, - stake: None, - clock_sysvar: None, - authority: None, - lockup_authority: None, - arg0: None, - arg1: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be updated -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(AuthorizeCpiBuilderInstruction { + __program: program, + stake: None, + clock_sysvar: None, + authority: None, + lockup_authority: None, + arg0: None, + arg1: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account to be updated + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Clock sysvar -#[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self + /// Clock sysvar + #[inline(always)] + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::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 { - self.instruction.authority = Some(authority); - self + /// The stake or withdraw authority + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self } - /// `[optional account]` -/// 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>>) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self + /// `[optional account]` + /// 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>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self } - #[inline(always)] - pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { + #[inline(always)] + pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { self.instruction.arg0 = Some(arg0); self - } - #[inline(always)] - pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { + } + #[inline(always)] + pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { self.instruction.arg1 = Some(arg1); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = AuthorizeInstructionArgs { - arg0: self.instruction.arg0.clone().expect("arg0 is not set"), - arg1: self.instruction.arg1.clone().expect("arg1 is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = AuthorizeInstructionArgs { + arg0: self.instruction.arg0.clone().expect("arg0 is not set"), + arg1: self.instruction.arg1.clone().expect("arg1 is not set"), + }; let instruction = AuthorizeCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - arg0: Option, - arg1: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + arg0: Option, + arg1: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 0b48ffc9..a7998ef5 100644 --- a/clients/rust/src/generated/instructions/authorize_checked.rs +++ b/clients/rust/src/generated/instructions/authorize_checked.rs @@ -5,471 +5,507 @@ //! //! -use crate::generated::types::StakeAuthorize; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::StakeAuthorize, + borsh::{BorshDeserialize, BorshSerialize}, +}; /// Accounts. #[derive(Debug)] pub struct AuthorizeChecked { - /// Stake account to be updated - - - - pub stake: solana_program::pubkey::Pubkey, - /// Clock sysvar - - - - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// The stake or withdraw authority - - - - pub authority: solana_program::pubkey::Pubkey, - /// The new stake or withdraw authority - - - - pub new_authority: solana_program::pubkey::Pubkey, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option, - } + /// Stake account to be updated + pub stake: solana_program::pubkey::Pubkey, + /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// The stake or withdraw authority + pub authority: solana_program::pubkey::Pubkey, + /// The new stake or withdraw authority + pub new_authority: solana_program::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 { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction( + &self, + args: AuthorizeCheckedInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( self.clock_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.new_authority, - true - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&AuthorizeCheckedInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct AuthorizeCheckedInstructionData { - discriminator: u32, - } +pub struct AuthorizeCheckedInstructionData { + discriminator: u32, +} impl AuthorizeCheckedInstructionData { - pub fn new() -> Self { - Self { - discriminator: 10, - } - } + pub fn new() -> Self { + Self { discriminator: 10 } + } } impl Default for AuthorizeCheckedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct AuthorizeCheckedInstructionArgs { - pub stake_authorize: StakeAuthorize, - } - +pub struct AuthorizeCheckedInstructionArgs { + pub stake_authorize: StakeAuthorize, +} /// Instruction builder for `AuthorizeChecked`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) - /// 2. `[signer]` authority - /// 3. `[signer]` new_authority - /// 4. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 2. `[signer]` authority +/// 3. `[signer]` new_authority +/// 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_authorize: Option, - __remaining_accounts: Vec, + stake: Option, + clock_sysvar: Option, + authority: Option, + new_authority: Option, + lockup_authority: Option, + stake_authorize: Option, + __remaining_accounts: Vec, } impl AuthorizeCheckedBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be updated -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account to be updated + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` -/// Clock sysvar -#[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` + /// Clock sysvar + #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self + self.clock_sysvar = Some(clock_sysvar); + self } - /// The stake or withdraw authority -#[inline(always)] + /// The stake or withdraw authority + #[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self + self.authority = Some(authority); + self } - /// The new stake or withdraw authority -#[inline(always)] + /// The new stake or withdraw authority + #[inline(always)] pub fn new_authority(&mut self, new_authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.new_authority = Some(new_authority); - self + self.new_authority = Some(new_authority); + self } - /// `[optional account]` -/// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration -#[inline(always)] - pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { - self.lockup_authority = lockup_authority; - self + /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; + self } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.stake_authorize = Some(stake_authorize); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = AuthorizeChecked { - stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!("SysvarC1ock11111111111111111111111111111111")), - authority: self.authority.expect("authority is not set"), - new_authority: self.new_authority.expect("new_authority is not set"), - lockup_authority: self.lockup_authority, - }; - let args = AuthorizeCheckedInstructionArgs { - stake_authorize: self.stake_authorize.clone().expect("stake_authorize is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = AuthorizeChecked { + stake: self.stake.expect("stake is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), + authority: self.authority.expect("authority is not set"), + new_authority: self.new_authority.expect("new_authority is not set"), + lockup_authority: self.lockup_authority, + }; + let args = AuthorizeCheckedInstructionArgs { + stake_authorize: self + .stake_authorize + .clone() + .expect("stake_authorize is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } - /// `authorize_checked` CPI accounts. - pub struct AuthorizeCheckedCpiAccounts<'a, 'b> { - /// Stake account to be updated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority - - - - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The new stake or withdraw authority - - - - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - } +/// `authorize_checked` CPI accounts. +pub struct AuthorizeCheckedCpiAccounts<'a, 'b> { + /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority + pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account to be updated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake or withdraw authority - - - - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The new stake or withdraw authority - - - - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority + pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - accounts: AuthorizeCheckedCpiAccounts<'a, 'b>, - args: AuthorizeCheckedInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - clock_sysvar: accounts.clock_sysvar, - authority: accounts.authority, - new_authority: accounts.new_authority, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(5+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: AuthorizeCheckedCpiAccounts<'a, 'b>, + args: AuthorizeCheckedInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + clock_sysvar: accounts.clock_sysvar, + authority: accounts.authority, + new_authority: accounts.new_authority, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.new_authority.key, - true - )); - if let Some(lockup_authority) = self.lockup_authority { + true, + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); - } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.new_authority.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.authority.clone()); + account_infos.push(self.new_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `AuthorizeChecked` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` clock_sysvar - /// 2. `[signer]` authority - /// 3. `[signer]` new_authority - /// 4. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[]` clock_sysvar +/// 2. `[signer]` authority +/// 3. `[signer]` new_authority +/// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeCheckedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AuthorizeCheckedCpiBuilderInstruction { - __program: program, - stake: None, - clock_sysvar: None, - authority: None, - new_authority: None, - lockup_authority: None, - stake_authorize: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be updated -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(AuthorizeCheckedCpiBuilderInstruction { + __program: program, + stake: None, + clock_sysvar: None, + authority: None, + new_authority: None, + lockup_authority: None, + stake_authorize: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account to be updated + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Clock sysvar -#[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self + /// Clock sysvar + #[inline(always)] + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::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 { - self.instruction.authority = Some(authority); - self + /// The stake or withdraw authority + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self } - /// The new stake or withdraw authority -#[inline(always)] - pub fn new_authority(&mut self, new_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.new_authority = Some(new_authority); - self + /// The new stake or withdraw authority + #[inline(always)] + pub fn new_authority( + &mut self, + new_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.new_authority = Some(new_authority); + self } - /// `[optional account]` -/// 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>>) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self + /// `[optional account]` + /// 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>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.instruction.stake_authorize = Some(stake_authorize); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = AuthorizeCheckedInstructionArgs { - stake_authorize: self.instruction.stake_authorize.clone().expect("stake_authorize is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = AuthorizeCheckedInstructionArgs { + stake_authorize: self + .instruction + .stake_authorize + .clone() + .expect("stake_authorize is not set"), + }; let instruction = AuthorizeCheckedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - new_authority: self.instruction.new_authority.expect("new_authority is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + new_authority: self + .instruction + .new_authority + .expect("new_authority is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - stake_authorize: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + stake_authorize: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 ca4b42da..796f5ebb 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -5,504 +5,550 @@ //! //! -use crate::generated::types::StakeAuthorize; -use solana_program::pubkey::Pubkey; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::StakeAuthorize, + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; /// Accounts. #[derive(Debug)] pub struct AuthorizeCheckedWithSeed { - /// Stake account to be updated - - - - pub stake: solana_program::pubkey::Pubkey, - /// Base key of stake or withdraw authority - - - - pub base: solana_program::pubkey::Pubkey, - /// Clock sysvar - - - - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// The new stake or withdraw authority - - - - pub new_authority: solana_program::pubkey::Pubkey, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option, - } + /// Stake account to be updated + pub stake: solana_program::pubkey::Pubkey, + /// Base key of stake or withdraw authority + pub base: solana_program::pubkey::Pubkey, + /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// The new stake or withdraw authority + pub new_authority: solana_program::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 { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( - self.base, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn instruction( + &self, + args: AuthorizeCheckedWithSeedInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( + self.base, true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.new_authority, - true - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } - } + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&AuthorizeCheckedWithSeedInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct AuthorizeCheckedWithSeedInstructionData { - discriminator: u32, - } +pub struct AuthorizeCheckedWithSeedInstructionData { + discriminator: u32, +} impl AuthorizeCheckedWithSeedInstructionData { - pub fn new() -> Self { - Self { - discriminator: 11, - } - } + pub fn new() -> Self { + Self { discriminator: 11 } + } } impl Default for AuthorizeCheckedWithSeedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct AuthorizeCheckedWithSeedInstructionArgs { - pub stake_authorize: StakeAuthorize, - pub authority_seed: String, - pub authority_owner: Pubkey, - } - +pub struct AuthorizeCheckedWithSeedInstructionArgs { + pub stake_authorize: StakeAuthorize, + pub authority_seed: String, + pub authority_owner: Pubkey, +} /// Instruction builder for `AuthorizeCheckedWithSeed`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[signer]` base - /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) - /// 3. `[signer]` new_authority - /// 4. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[signer]` base +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 3. `[signer]` new_authority +/// 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_authorize: Option, - authority_seed: Option, - authority_owner: Option, - __remaining_accounts: Vec, + 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, } impl AuthorizeCheckedWithSeedBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be updated -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account to be updated + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Base key of stake or withdraw authority -#[inline(always)] + /// Base key of stake or withdraw authority + #[inline(always)] pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { - self.base = Some(base); - self + self.base = Some(base); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` -/// Clock sysvar -#[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` + /// Clock sysvar + #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self + self.clock_sysvar = Some(clock_sysvar); + self } - /// The new stake or withdraw authority -#[inline(always)] + /// The new stake or withdraw authority + #[inline(always)] pub fn new_authority(&mut self, new_authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.new_authority = Some(new_authority); - self - } - /// `[optional account]` -/// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration -#[inline(always)] - pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { - self.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.new_authority = Some(new_authority); + self + } + /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.stake_authorize = Some(stake_authorize); self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { self.authority_seed = Some(authority_seed); self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { self.authority_owner = Some(authority_owner); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - 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!("SysvarC1ock11111111111111111111111111111111")), - new_authority: self.new_authority.expect("new_authority is not set"), - lockup_authority: self.lockup_authority, - }; - let args = AuthorizeCheckedWithSeedInstructionArgs { - stake_authorize: self.stake_authorize.clone().expect("stake_authorize is not set"), - authority_seed: self.authority_seed.clone().expect("authority_seed is not set"), - authority_owner: self.authority_owner.clone().expect("authority_owner is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + 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!( + "SysvarC1ock11111111111111111111111111111111" + )), + new_authority: self.new_authority.expect("new_authority is not set"), + lockup_authority: self.lockup_authority, + }; + let args = AuthorizeCheckedWithSeedInstructionArgs { + stake_authorize: self + .stake_authorize + .clone() + .expect("stake_authorize is not set"), + authority_seed: self + .authority_seed + .clone() + .expect("authority_seed is not set"), + authority_owner: self + .authority_owner + .clone() + .expect("authority_owner is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } - /// `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>, - /// Base key of stake or withdraw authority - - - - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The new stake or withdraw authority - - - - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - } +/// `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>, + /// Base key of stake or withdraw authority + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority + pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account to be updated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base key of stake or withdraw authority - - - - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The new stake or withdraw authority - - - - pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority + pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - accounts: AuthorizeCheckedWithSeedCpiAccounts<'a, 'b>, - args: AuthorizeCheckedWithSeedInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - base: accounts.base, - clock_sysvar: accounts.clock_sysvar, - new_authority: accounts.new_authority, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(5+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: AuthorizeCheckedWithSeedCpiAccounts<'a, 'b>, + args: AuthorizeCheckedWithSeedInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + base: accounts.base, + clock_sysvar: accounts.clock_sysvar, + new_authority: accounts.new_authority, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.base.key, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.new_authority.key, - true - )); - if let Some(lockup_authority) = self.lockup_authority { + true, + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); - } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.base.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.new_authority.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.base.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.new_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `AuthorizeCheckedWithSeed` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[signer]` base - /// 2. `[]` clock_sysvar - /// 3. `[signer]` new_authority - /// 4. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[signer]` base +/// 2. `[]` clock_sysvar +/// 3. `[signer]` new_authority +/// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AuthorizeCheckedWithSeedCpiBuilderInstruction { - __program: program, - stake: None, - base: None, - clock_sysvar: None, - new_authority: None, - lockup_authority: None, - stake_authorize: None, - authority_seed: None, - authority_owner: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be updated -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(AuthorizeCheckedWithSeedCpiBuilderInstruction { + __program: program, + stake: None, + base: None, + clock_sysvar: None, + new_authority: None, + lockup_authority: None, + stake_authorize: None, + authority_seed: None, + authority_owner: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account to be updated + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Base key of stake or withdraw authority -#[inline(always)] + /// Base key of stake or withdraw authority + #[inline(always)] pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base = Some(base); - self - } - /// Clock sysvar -#[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self - } - /// The new stake or withdraw authority -#[inline(always)] - pub fn new_authority(&mut self, new_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.new_authority = Some(new_authority); - self - } - /// `[optional account]` -/// 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>>) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + self.instruction.base = Some(base); + self + } + /// Clock sysvar + #[inline(always)] + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self + } + /// The new stake or withdraw authority + #[inline(always)] + pub fn new_authority( + &mut self, + new_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.new_authority = Some(new_authority); + self + } + /// `[optional account]` + /// 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>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.instruction.stake_authorize = Some(stake_authorize); self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { self.instruction.authority_seed = Some(authority_seed); self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { self.instruction.authority_owner = Some(authority_owner); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = AuthorizeCheckedWithSeedInstructionArgs { - stake_authorize: self.instruction.stake_authorize.clone().expect("stake_authorize is not set"), - authority_seed: self.instruction.authority_seed.clone().expect("authority_seed is not set"), - authority_owner: self.instruction.authority_owner.clone().expect("authority_owner is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = AuthorizeCheckedWithSeedInstructionArgs { + stake_authorize: self + .instruction + .stake_authorize + .clone() + .expect("stake_authorize is not set"), + authority_seed: self + .instruction + .authority_seed + .clone() + .expect("authority_seed is not set"), + authority_owner: self + .instruction + .authority_owner + .clone() + .expect("authority_owner is not set"), + }; let instruction = AuthorizeCheckedWithSeedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - base: self.instruction.base.expect("base is not set"), - - clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), - - new_authority: self.instruction.new_authority.expect("new_authority is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + base: self.instruction.base.expect("base is not set"), + + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), + + new_authority: self + .instruction + .new_authority + .expect("new_authority is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - 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)>, + __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>>, + 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, + )>, } - diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index 101de675..beb781f3 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -5,475 +5,531 @@ //! //! -use solana_program::pubkey::Pubkey; -use crate::generated::types::StakeAuthorize; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::StakeAuthorize, + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; /// Accounts. #[derive(Debug)] pub struct AuthorizeWithSeed { - /// Stake account to be updated - - - - pub stake: solana_program::pubkey::Pubkey, - /// Base key of stake or withdraw authority - - - - pub base: solana_program::pubkey::Pubkey, - /// Clock sysvar - - - - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option, - } + /// Stake account to be updated + pub stake: solana_program::pubkey::Pubkey, + /// Base key of stake or withdraw authority + pub base: solana_program::pubkey::Pubkey, + /// Clock sysvar + pub clock_sysvar: solana_program::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 { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( - self.base, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn instruction( + &self, + args: AuthorizeWithSeedInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( + self.base, true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } - } + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&AuthorizeWithSeedInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct AuthorizeWithSeedInstructionData { - discriminator: u32, - } +pub struct AuthorizeWithSeedInstructionData { + discriminator: u32, +} impl AuthorizeWithSeedInstructionData { - pub fn new() -> Self { - Self { - discriminator: 8, - } - } + pub fn new() -> Self { + Self { discriminator: 8 } + } } impl Default for AuthorizeWithSeedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct AuthorizeWithSeedInstructionArgs { - pub new_authorized_pubkey: Pubkey, - pub stake_authorize: StakeAuthorize, - pub authority_seed: String, - pub authority_owner: Pubkey, - } - +pub struct AuthorizeWithSeedInstructionArgs { + pub new_authorized_pubkey: Pubkey, + pub stake_authorize: StakeAuthorize, + pub authority_seed: String, + pub authority_owner: Pubkey, +} /// Instruction builder for `AuthorizeWithSeed`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[signer]` base - /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) - /// 3. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[signer]` base +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeWithSeedBuilder { - 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, + 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, } impl AuthorizeWithSeedBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be updated -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account to be updated + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Base key of stake or withdraw authority -#[inline(always)] + /// Base key of stake or withdraw authority + #[inline(always)] pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { - self.base = Some(base); - self + self.base = Some(base); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` -/// Clock sysvar -#[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` + /// Clock sysvar + #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self - } - /// `[optional account]` -/// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration -#[inline(always)] - pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { - self.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); + self + } + /// `[optional account]` + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { self.new_authorized_pubkey = Some(new_authorized_pubkey); self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.stake_authorize = Some(stake_authorize); self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { self.authority_seed = Some(authority_seed); self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { self.authority_owner = Some(authority_owner); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - 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!("SysvarC1ock11111111111111111111111111111111")), - lockup_authority: self.lockup_authority, - }; - let args = AuthorizeWithSeedInstructionArgs { - new_authorized_pubkey: self.new_authorized_pubkey.clone().expect("new_authorized_pubkey is not set"), - stake_authorize: self.stake_authorize.clone().expect("stake_authorize is not set"), - authority_seed: self.authority_seed.clone().expect("authority_seed is not set"), - authority_owner: self.authority_owner.clone().expect("authority_owner is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - - /// `authorize_with_seed` CPI accounts. - pub struct AuthorizeWithSeedCpiAccounts<'a, 'b> { - /// Stake account to be updated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base key of stake or withdraw authority - - - - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + 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!( + "SysvarC1ock11111111111111111111111111111111" + )), + lockup_authority: self.lockup_authority, + }; + let args = AuthorizeWithSeedInstructionArgs { + new_authorized_pubkey: self + .new_authorized_pubkey + .clone() + .expect("new_authorized_pubkey is not set"), + stake_authorize: self + .stake_authorize + .clone() + .expect("stake_authorize is not set"), + authority_seed: self + .authority_seed + .clone() + .expect("authority_seed is not set"), + authority_owner: self + .authority_owner + .clone() + .expect("authority_owner is not set"), + }; - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - } +/// `authorize_with_seed` CPI accounts. +pub struct AuthorizeWithSeedCpiAccounts<'a, 'b> { + /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account to be updated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base key of stake or withdraw authority - - - - pub base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be updated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - accounts: AuthorizeWithSeedCpiAccounts<'a, 'b>, - args: AuthorizeWithSeedInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - base: accounts.base, - clock_sysvar: accounts.clock_sysvar, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(4+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: AuthorizeWithSeedCpiAccounts<'a, 'b>, + args: AuthorizeWithSeedInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + base: accounts.base, + clock_sysvar: accounts.clock_sysvar, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.base.key, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false - )); - if let Some(lockup_authority) = self.lockup_authority { + false, + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); - } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.base.clone()); - account_infos.push(self.clock_sysvar.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.base.clone()); + account_infos.push(self.clock_sysvar.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `AuthorizeWithSeed` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[signer]` base - /// 2. `[]` clock_sysvar - /// 3. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[signer]` base +/// 2. `[]` clock_sysvar +/// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeWithSeedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AuthorizeWithSeedCpiBuilderInstruction { - __program: program, - stake: None, - base: None, - clock_sysvar: None, - lockup_authority: None, - new_authorized_pubkey: None, - stake_authorize: None, - authority_seed: None, - authority_owner: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be updated -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(AuthorizeWithSeedCpiBuilderInstruction { + __program: program, + stake: None, + base: None, + clock_sysvar: None, + lockup_authority: None, + new_authorized_pubkey: None, + stake_authorize: None, + authority_seed: None, + authority_owner: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account to be updated + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Base key of stake or withdraw authority -#[inline(always)] + /// Base key of stake or withdraw authority + #[inline(always)] pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base = Some(base); - self - } - /// Clock sysvar -#[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self - } - /// `[optional account]` -/// 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>>) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { + self.instruction.base = Some(base); + self + } + /// Clock sysvar + #[inline(always)] + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self + } + /// `[optional account]` + /// 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>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { self.instruction.new_authorized_pubkey = Some(new_authorized_pubkey); self - } - #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { + } + #[inline(always)] + pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.instruction.stake_authorize = Some(stake_authorize); self - } - #[inline(always)] - pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { + } + #[inline(always)] + pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self { self.instruction.authority_seed = Some(authority_seed); self - } - #[inline(always)] - pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { + } + #[inline(always)] + pub fn authority_owner(&mut self, authority_owner: Pubkey) -> &mut Self { self.instruction.authority_owner = Some(authority_owner); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = AuthorizeWithSeedInstructionArgs { - new_authorized_pubkey: self.instruction.new_authorized_pubkey.clone().expect("new_authorized_pubkey is not set"), - stake_authorize: self.instruction.stake_authorize.clone().expect("stake_authorize is not set"), - authority_seed: self.instruction.authority_seed.clone().expect("authority_seed is not set"), - authority_owner: self.instruction.authority_owner.clone().expect("authority_owner is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = AuthorizeWithSeedInstructionArgs { + new_authorized_pubkey: self + .instruction + .new_authorized_pubkey + .clone() + .expect("new_authorized_pubkey is not set"), + stake_authorize: self + .instruction + .stake_authorize + .clone() + .expect("stake_authorize is not set"), + authority_seed: self + .instruction + .authority_seed + .clone() + .expect("authority_seed is not set"), + authority_owner: self + .instruction + .authority_owner + .clone() + .expect("authority_owner is not set"), + }; let instruction = AuthorizeWithSeedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - base: self.instruction.base.expect("base is not set"), - - clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + base: self.instruction.base.expect("base is not set"), + + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - 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)>, + __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>>, + 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, + )>, } - diff --git a/clients/rust/src/generated/instructions/deactivate.rs b/clients/rust/src/generated/instructions/deactivate.rs index eb1af646..52d6fcb7 100644 --- a/clients/rust/src/generated/instructions/deactivate.rs +++ b/clients/rust/src/generated/instructions/deactivate.rs @@ -5,339 +5,373 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Deactivate { - /// Delegated stake account to be deactivated - - - - pub stake: solana_program::pubkey::Pubkey, - /// Clock sysvar - - - - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake authority - - - - pub stake_authority: solana_program::pubkey::Pubkey, - } + /// Delegated stake account to be deactivated + pub stake: solana_program::pubkey::Pubkey, + /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, +} impl Deactivate { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::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( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::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( self.clock_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, - true - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DeactivateInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&DeactivateInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct DeactivateInstructionData { - discriminator: u32, - } +pub struct DeactivateInstructionData { + discriminator: u32, +} impl DeactivateInstructionData { - pub fn new() -> Self { - Self { - discriminator: 5, - } - } + pub fn new() -> Self { + Self { discriminator: 5 } + } } impl Default for DeactivateInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } - - /// Instruction builder for `Deactivate`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) - /// 2. `[signer]` stake_authority +/// 0. `[writable]` stake +/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 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 to be deactivated -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Delegated stake account to be deactivated + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` -/// Clock sysvar -#[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` + /// Clock sysvar + #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - 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 { - self.stake_authority = Some(stake_authority); - self + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: solana_program::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 { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = Deactivate { - stake: self.stake.expect("stake is not set"), - clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!("SysvarC1ock11111111111111111111111111111111")), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - - /// `deactivate` CPI accounts. - pub struct DeactivateCpiAccounts<'a, 'b> { - /// Delegated stake account to be deactivated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = Deactivate { + stake: self.stake.expect("stake is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } +} - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `deactivate` CPI accounts. +pub struct DeactivateCpiAccounts<'a, 'b> { + /// Delegated stake account to be deactivated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::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 to be deactivated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - } + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Delegated stake account to be deactivated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, +} impl<'a, 'b> DeactivateCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: DeactivateCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - clock_sysvar: accounts.clock_sysvar, - stake_authority: accounts.stake_authority, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: DeactivateCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + clock_sysvar: accounts.clock_sysvar, + stake_authority: accounts.stake_authority, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `Deactivate` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` clock_sysvar - /// 2. `[signer]` stake_authority +/// 0. `[writable]` stake +/// 1. `[]` clock_sysvar +/// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct DeactivateCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DeactivateCpiBuilderInstruction { - __program: program, - stake: None, - clock_sysvar: None, - stake_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Delegated stake account to be deactivated -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(DeactivateCpiBuilderInstruction { + __program: program, + stake: None, + clock_sysvar: None, + stake_authority: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Delegated stake account to be deactivated + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self + } + /// Clock sysvar + #[inline(always)] + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self + } + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self } - /// Clock sysvar -#[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self } - /// Stake authority -#[inline(always)] - pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let instruction = DeactivateCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), - - stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), + + stake_authority: self + .instruction + .stake_authority + .expect("stake_authority is not set"), + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 8fec5ee0..8bdf283b 100644 --- a/clients/rust/src/generated/instructions/deactivate_delinquent.rs +++ b/clients/rust/src/generated/instructions/deactivate_delinquent.rs @@ -5,338 +5,370 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct DeactivateDelinquent { - /// Delegated stake account - - - - pub stake: solana_program::pubkey::Pubkey, - /// Delinquent vote account for the delegated stake account - - - - pub delinquent_vote: solana_program::pubkey::Pubkey, - /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs - - - - pub reference_vote: solana_program::pubkey::Pubkey, - } + /// Delegated stake account + pub stake: solana_program::pubkey::Pubkey, + /// Delinquent vote account for the delegated stake account + pub delinquent_vote: solana_program::pubkey::Pubkey, + /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs + pub reference_vote: solana_program::pubkey::Pubkey, +} impl DeactivateDelinquent { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::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( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::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( self.delinquent_vote, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.reference_vote, - false - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DeactivateDelinquentInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&DeactivateDelinquentInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct DeactivateDelinquentInstructionData { - discriminator: u32, - } +pub struct DeactivateDelinquentInstructionData { + discriminator: u32, +} impl DeactivateDelinquentInstructionData { - pub fn new() -> Self { - Self { - discriminator: 14, - } - } + pub fn new() -> Self { + Self { discriminator: 14 } + } } impl Default for DeactivateDelinquentInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } - - /// Instruction builder for `DeactivateDelinquent`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` delinquent_vote - /// 2. `[]` reference_vote +/// 0. `[writable]` stake +/// 1. `[]` delinquent_vote +/// 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 { - pub fn new() -> Self { - Self::default() - } - /// Delegated stake account -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Delegated stake account + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Delinquent vote account for the delegated stake account -#[inline(always)] - pub fn delinquent_vote(&mut self, delinquent_vote: solana_program::pubkey::Pubkey) -> &mut Self { - self.delinquent_vote = Some(delinquent_vote); - self + /// Delinquent vote account for the delegated stake account + #[inline(always)] + pub fn delinquent_vote( + &mut self, + delinquent_vote: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.delinquent_vote = Some(delinquent_vote); + self } - /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs -#[inline(always)] + /// 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 { - self.reference_vote = Some(reference_vote); - 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 { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = DeactivateDelinquent { - stake: self.stake.expect("stake is not set"), - delinquent_vote: self.delinquent_vote.expect("delinquent_vote is not set"), - reference_vote: self.reference_vote.expect("reference_vote is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - - /// `deactivate_delinquent` CPI accounts. - pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { - /// Delegated stake account - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Delinquent vote account for the delegated stake account + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = DeactivateDelinquent { + stake: self.stake.expect("stake is not set"), + delinquent_vote: self.delinquent_vote.expect("delinquent_vote is not set"), + reference_vote: self.reference_vote.expect("reference_vote is not set"), + }; - - - pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Reference vote account that has voted at least once in the last `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } +} - - - pub reference_vote: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `deactivate_delinquent` CPI accounts. +pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { + /// Delegated stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Delinquent vote account for the delegated stake account + pub delinquent_vote: &'b solana_program::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_program::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>, - /// Delegated stake account - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Delinquent vote account for the delegated stake account - - - - pub delinquent_vote: &'b solana_program::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_program::account_info::AccountInfo<'a>, - } + /// 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>, + /// Delinquent vote account for the delegated stake account + pub delinquent_vote: &'b solana_program::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_program::account_info::AccountInfo<'a>, +} impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: DeactivateDelinquentCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - delinquent_vote: accounts.delinquent_vote, - reference_vote: accounts.reference_vote, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: DeactivateDelinquentCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + delinquent_vote: accounts.delinquent_vote, + reference_vote: accounts.reference_vote, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.delinquent_vote.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.reference_vote.key, - false - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.delinquent_vote.clone()); - account_infos.push(self.reference_vote.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.delinquent_vote.clone()); + account_infos.push(self.reference_vote.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `DeactivateDelinquent` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` delinquent_vote - /// 2. `[]` reference_vote +/// 0. `[writable]` stake +/// 1. `[]` delinquent_vote +/// 2. `[]` reference_vote #[derive(Clone, Debug)] pub struct DeactivateDelinquentCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DeactivateDelinquentCpiBuilderInstruction { - __program: program, - stake: None, - delinquent_vote: None, - reference_vote: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Delegated stake account -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(DeactivateDelinquentCpiBuilderInstruction { + __program: program, + stake: None, + delinquent_vote: None, + reference_vote: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Delegated stake account + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self + } + /// 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>, + ) -> &mut Self { + self.instruction.delinquent_vote = Some(delinquent_vote); + self + } + /// 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>, + ) -> &mut Self { + self.instruction.reference_vote = Some(reference_vote); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self } - /// 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>) -> &mut Self { - self.instruction.delinquent_vote = Some(delinquent_vote); - self + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self } - /// 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>) -> &mut Self { - self.instruction.reference_vote = Some(reference_vote); - self + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let instruction = DeactivateDelinquentCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - delinquent_vote: self.instruction.delinquent_vote.expect("delinquent_vote is not set"), - - reference_vote: self.instruction.reference_vote.expect("reference_vote is not set"), - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + delinquent_vote: self + .instruction + .delinquent_vote + .expect("delinquent_vote is not set"), + + reference_vote: self + .instruction + .reference_vote + .expect("reference_vote is not set"), + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 1ae96234..59a55c45 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -5,475 +5,492 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct DelegateStake { - /// Initialized stake account to be delegated - - - - pub stake: solana_program::pubkey::Pubkey, - /// Vote account to which this stake will be delegated - - - - pub vote: solana_program::pubkey::Pubkey, - /// Clock sysvar - - - - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar that carries stake warmup/cooldown history - - - - pub stake_history: solana_program::pubkey::Pubkey, - /// Unused account, formerly the stake config - - - - pub unused: solana_program::pubkey::Pubkey, - /// Stake authority - - - - pub stake_authority: solana_program::pubkey::Pubkey, - } + /// Initialized stake account to be delegated + pub stake: solana_program::pubkey::Pubkey, + /// Vote account to which this stake will be delegated + pub vote: solana_program::pubkey::Pubkey, + /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: solana_program::pubkey::Pubkey, + /// Unused account, formerly the stake config + pub unused: solana_program::pubkey::Pubkey, + /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, +} impl DelegateStake { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::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( - self.vote, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::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( + self.vote, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_history, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.unused, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, - true - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DelegateStakeInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&DelegateStakeInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct DelegateStakeInstructionData { - discriminator: u32, - } +pub struct DelegateStakeInstructionData { + discriminator: u32, +} impl DelegateStakeInstructionData { - pub fn new() -> Self { - Self { - discriminator: 2, - } - } + pub fn new() -> Self { + Self { discriminator: 2 } + } } impl Default for DelegateStakeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } - - /// Instruction builder for `DelegateStake`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` vote - /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) - /// 3. `[optional]` stake_history (default to `SysvarStakeHistory1111111111111111111111111`) - /// 4. `[]` unused - /// 5. `[signer]` stake_authority +/// 0. `[writable]` stake +/// 1. `[]` vote +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 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 { - pub fn new() -> Self { - Self::default() - } - /// Initialized stake account to be delegated -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Initialized stake account to be delegated + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Vote account to which this stake will be delegated -#[inline(always)] + /// Vote account to which this stake will be delegated + #[inline(always)] pub fn vote(&mut self, vote: solana_program::pubkey::Pubkey) -> &mut Self { - self.vote = Some(vote); - self + self.vote = Some(vote); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` -/// Clock sysvar -#[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` + /// Clock sysvar + #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self + self.clock_sysvar = Some(clock_sysvar); + self } - /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` -/// Stake history sysvar that carries stake warmup/cooldown history -#[inline(always)] + /// `[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 { - self.stake_history = Some(stake_history); - self + self.stake_history = Some(stake_history); + self } - /// Unused account, formerly the stake config -#[inline(always)] + /// Unused account, formerly the stake config + #[inline(always)] pub fn unused(&mut self, unused: solana_program::pubkey::Pubkey) -> &mut Self { - self.unused = Some(unused); - self + self.unused = Some(unused); + self + } + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: solana_program::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 { + self.__remaining_accounts.push(account); + self } - /// Stake authority -#[inline(always)] - pub fn stake_authority(&mut self, stake_authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake_authority = Some(stake_authority); - self + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + 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!( + "SysvarC1ock11111111111111111111111111111111" + )), + stake_history: self.stake_history.unwrap_or(solana_program::pubkey!( + "SysvarStakeHistory1111111111111111111111111" + )), + unused: self.unused.expect("unused is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - 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!("SysvarC1ock11111111111111111111111111111111")), - stake_history: self.stake_history.unwrap_or(solana_program::pubkey!("SysvarStakeHistory1111111111111111111111111")), - unused: self.unused.expect("unused is not set"), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } } - /// `delegate_stake` CPI accounts. - pub struct DelegateStakeCpiAccounts<'a, 'b> { - /// Initialized stake account to be delegated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Vote account to which this stake will be delegated - - - - pub vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - - - - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Unused account, formerly the stake config - - - - pub unused: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `delegate_stake` CPI accounts. +pub struct DelegateStakeCpiAccounts<'a, 'b> { + /// Initialized stake account to be delegated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Vote account to which this stake will be delegated + pub vote: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + /// Unused account, formerly the stake config + pub unused: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::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>, - /// Initialized stake account to be delegated - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Vote account to which this stake will be delegated - - - - pub vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - - - - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Unused account, formerly the stake config - - - - pub unused: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - } + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Initialized stake account to be delegated + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Vote account to which this stake will be delegated + pub vote: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + /// Unused account, formerly the stake config + pub unused: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, +} impl<'a, 'b> DelegateStakeCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: DelegateStakeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - vote: accounts.vote, - clock_sysvar: accounts.clock_sysvar, - stake_history: accounts.stake_history, - unused: accounts.unused, - stake_authority: accounts.stake_authority, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(6+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: DelegateStakeCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + vote: accounts.vote, + clock_sysvar: accounts.clock_sysvar, + stake_history: accounts.stake_history, + unused: accounts.unused, + stake_authority: accounts.stake_authority, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.vote.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_history.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.unused.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.vote.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history.clone()); - account_infos.push(self.unused.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.vote.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.stake_history.clone()); + account_infos.push(self.unused.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `DelegateStake` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` vote - /// 2. `[]` clock_sysvar - /// 3. `[]` stake_history - /// 4. `[]` unused - /// 5. `[signer]` stake_authority +/// 0. `[writable]` stake +/// 1. `[]` vote +/// 2. `[]` clock_sysvar +/// 3. `[]` stake_history +/// 4. `[]` unused +/// 5. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct DelegateStakeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DelegateStakeCpiBuilderInstruction { - __program: program, - stake: None, - vote: None, - clock_sysvar: None, - stake_history: None, - unused: None, - stake_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Initialized stake account to be delegated -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(DelegateStakeCpiBuilderInstruction { + __program: program, + stake: None, + vote: None, + clock_sysvar: None, + stake_history: None, + unused: None, + stake_authority: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Initialized stake account to be delegated + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Vote account to which this stake will be delegated -#[inline(always)] + /// 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 { - self.instruction.vote = Some(vote); - self + self.instruction.vote = Some(vote); + self + } + /// Clock sysvar + #[inline(always)] + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self + } + /// 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>, + ) -> &mut Self { + self.instruction.stake_history = Some(stake_history); + self } - /// Clock sysvar -#[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self + /// Unused account, formerly the stake config + #[inline(always)] + pub fn unused( + &mut self, + unused: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.unused = Some(unused); + self } - /// 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>) -> &mut Self { - self.instruction.stake_history = Some(stake_history); - self + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - /// Unused account, formerly the stake config -#[inline(always)] - pub fn unused(&mut self, unused: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.unused = Some(unused); - self + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self } - /// Stake authority -#[inline(always)] - pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = DelegateStakeCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - vote: self.instruction.vote.expect("vote is not set"), - - clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), - - stake_history: self.instruction.stake_history.expect("stake_history is not set"), - - unused: self.instruction.unused.expect("unused is not set"), - - stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + vote: self.instruction.vote.expect("vote is not set"), + + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), + + stake_history: self + .instruction + .stake_history + .expect("stake_history is not set"), + + unused: self.instruction.unused.expect("unused is not set"), + + stake_authority: self + .instruction + .stake_authority + .expect("stake_authority is not set"), + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 c3ade7a4..d510e2cb 100644 --- a/clients/rust/src/generated/instructions/get_minimum_delegation.rs +++ b/clients/rust/src/generated/instructions/get_minimum_delegation.rs @@ -5,147 +5,160 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] -pub struct GetMinimumDelegation { - } +pub struct GetMinimumDelegation {} impl GetMinimumDelegation { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity( remaining_accounts.len()); + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::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(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } - } + let data = borsh::to_vec(&GetMinimumDelegationInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct GetMinimumDelegationInstructionData { - discriminator: u32, - } +pub struct GetMinimumDelegationInstructionData { + discriminator: u32, +} impl GetMinimumDelegationInstructionData { - pub fn new() -> Self { - Self { - discriminator: 13, - } - } + pub fn new() -> Self { + Self { discriminator: 13 } + } } impl Default for GetMinimumDelegationInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } - - /// Instruction builder for `GetMinimumDelegation`. /// /// ### Accounts: /// #[derive(Clone, Debug, Default)] pub struct GetMinimumDelegationBuilder { - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl GetMinimumDelegationBuilder { - pub fn new() -> Self { - Self::default() - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = GetMinimumDelegation { - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} + pub fn new() -> Self { + Self::default() + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = GetMinimumDelegation {}; + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } +} /// `get_minimum_delegation` CPI instruction. pub struct GetMinimumDelegationCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - } + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, +} impl<'a, 'b> GetMinimumDelegationCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - ) -> Self { - Self { - __program: program, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity( remaining_accounts.len()); + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + Self { __program: program } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(remaining_accounts.len()); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } } /// Instruction builder for `GetMinimumDelegation` via CPI. @@ -154,50 +167,75 @@ impl<'a, 'b> GetMinimumDelegationCpi<'a, 'b> { /// #[derive(Clone, Debug)] pub struct GetMinimumDelegationCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> GetMinimumDelegationCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(GetMinimumDelegationCpiBuilderInstruction { - __program: program, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(GetMinimumDelegationCpiBuilderInstruction { + __program: program, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = GetMinimumDelegationCpi { - __program: self.instruction.__program, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[derive(Clone, Debug)] struct GetMinimumDelegationCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 dcd86f3a..24bc81f5 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -5,345 +5,385 @@ //! //! -use crate::generated::types::Authorized; -use crate::generated::types::Lockup; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::{Authorized, Lockup}, + borsh::{BorshDeserialize, BorshSerialize}, +}; /// Accounts. #[derive(Debug)] pub struct Initialize { - /// Uninitialized stake account - - - - pub stake: solana_program::pubkey::Pubkey, - /// Rent sysvar - - - - pub rent_sysvar: solana_program::pubkey::Pubkey, - } + /// Uninitialized stake account + pub stake: solana_program::pubkey::Pubkey, + /// Rent sysvar + pub rent_sysvar: solana_program::pubkey::Pubkey, +} impl Initialize { - pub fn instruction(&self, args: InitializeInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction( + &self, + args: InitializeInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( 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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct InitializeInstructionData { - discriminator: u32, - } +pub struct InitializeInstructionData { + discriminator: u32, +} impl InitializeInstructionData { - pub fn new() -> Self { - Self { - discriminator: 0, - } - } + pub fn new() -> Self { + Self { discriminator: 0 } + } } impl Default for InitializeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct InitializeInstructionArgs { - pub arg0: Authorized, - pub arg1: Lockup, - } - +pub struct InitializeInstructionArgs { + pub arg0: Authorized, + pub arg1: Lockup, +} /// Instruction builder for `Initialize`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) +/// 0. `[writable]` stake +/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct InitializeBuilder { - stake: Option, - rent_sysvar: Option, - arg0: Option, - arg1: Option, - __remaining_accounts: Vec, + stake: Option, + rent_sysvar: Option, + arg0: Option, + arg1: Option, + __remaining_accounts: Vec, } impl InitializeBuilder { - pub fn new() -> Self { - Self::default() - } - /// Uninitialized stake account -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Uninitialized stake account + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` -/// Rent sysvar -#[inline(always)] + /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` + /// Rent sysvar + #[inline(always)] pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent_sysvar = Some(rent_sysvar); - self + self.rent_sysvar = Some(rent_sysvar); + self } - #[inline(always)] - pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { + #[inline(always)] + pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { self.arg0 = Some(arg0); self - } - #[inline(always)] - pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { + } + #[inline(always)] + pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { self.arg1 = Some(arg1); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = Initialize { - stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!("SysvarRent111111111111111111111111111111111")), - }; - let args = InitializeInstructionArgs { - arg0: self.arg0.clone().expect("arg0 is not set"), - arg1: self.arg1.clone().expect("arg1 is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - - /// `initialize` CPI accounts. - pub struct InitializeCpiAccounts<'a, 'b> { - /// Uninitialized stake account + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = Initialize { + stake: self.stake.expect("stake is not set"), + rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarRent111111111111111111111111111111111" + )), + }; + let args = InitializeInstructionArgs { + arg0: self.arg0.clone().expect("arg0 is not set"), + arg1: self.arg1.clone().expect("arg1 is not set"), + }; - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} - - - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `initialize` CPI accounts. +pub struct InitializeCpiAccounts<'a, 'b> { + /// Uninitialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Rent sysvar + pub rent_sysvar: &'b solana_program::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>, - /// Uninitialized stake account - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar - - - - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Rent sysvar + pub rent_sysvar: &'b solana_program::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>, - accounts: InitializeCpiAccounts<'a, 'b>, - args: InitializeInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - rent_sysvar: accounts.rent_sysvar, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(2+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: InitializeCpiAccounts<'a, 'b>, + args: InitializeInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + rent_sysvar: accounts.rent_sysvar, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.rent_sysvar.key, - false - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.rent_sysvar.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.rent_sysvar.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `Initialize` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` rent_sysvar +/// 0. `[writable]` stake +/// 1. `[]` rent_sysvar #[derive(Clone, Debug)] pub struct InitializeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCpiBuilderInstruction { - __program: program, - stake: None, - rent_sysvar: None, - arg0: None, - arg1: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Uninitialized stake account -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(InitializeCpiBuilderInstruction { + __program: program, + stake: None, + rent_sysvar: None, + arg0: None, + arg1: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Uninitialized stake account + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// Rent sysvar -#[inline(always)] - pub fn rent_sysvar(&mut self, rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent_sysvar = Some(rent_sysvar); - self + /// Rent sysvar + #[inline(always)] + pub fn rent_sysvar( + &mut self, + rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.rent_sysvar = Some(rent_sysvar); + self } - #[inline(always)] - pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { + #[inline(always)] + pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { self.instruction.arg0 = Some(arg0); self - } - #[inline(always)] - pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { + } + #[inline(always)] + pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { self.instruction.arg1 = Some(arg1); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = InitializeInstructionArgs { - arg0: self.instruction.arg0.clone().expect("arg0 is not set"), - arg1: self.instruction.arg1.clone().expect("arg1 is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = InitializeInstructionArgs { + arg0: self.instruction.arg0.clone().expect("arg0 is not set"), + arg1: self.instruction.arg1.clone().expect("arg1 is not set"), + }; let instruction = InitializeCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - rent_sysvar: self.instruction.rent_sysvar.expect("rent_sysvar is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + rent_sysvar: self + .instruction + .rent_sysvar + .expect("rent_sysvar is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - arg0: Option, - arg1: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + arg0: Option, + arg1: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 be4a4185..4dc23f24 100644 --- a/clients/rust/src/generated/instructions/initialize_checked.rs +++ b/clients/rust/src/generated/instructions/initialize_checked.rs @@ -5,383 +5,417 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct InitializeChecked { - /// Uninitialized stake account - - - - pub stake: solana_program::pubkey::Pubkey, - /// Rent sysvar - - - - pub rent_sysvar: solana_program::pubkey::Pubkey, - /// The stake authority - - - - pub stake_authority: solana_program::pubkey::Pubkey, - /// The withdraw authority - - - - pub withdraw_authority: solana_program::pubkey::Pubkey, - } + /// Uninitialized stake account + pub stake: solana_program::pubkey::Pubkey, + /// Rent sysvar + pub rent_sysvar: solana_program::pubkey::Pubkey, + /// The stake authority + pub stake_authority: solana_program::pubkey::Pubkey, + /// The withdraw authority + pub withdraw_authority: solana_program::pubkey::Pubkey, +} impl InitializeChecked { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::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( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::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( self.rent_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.withdraw_authority, - true - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeCheckedInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&InitializeCheckedInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct InitializeCheckedInstructionData { - discriminator: u32, - } +pub struct InitializeCheckedInstructionData { + discriminator: u32, +} impl InitializeCheckedInstructionData { - pub fn new() -> Self { - Self { - discriminator: 9, - } - } + pub fn new() -> Self { + Self { discriminator: 9 } + } } impl Default for InitializeCheckedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } - - /// Instruction builder for `InitializeChecked`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` rent_sysvar - /// 2. `[]` stake_authority - /// 3. `[signer]` withdraw_authority +/// 0. `[writable]` stake +/// 1. `[]` rent_sysvar +/// 2. `[]` stake_authority +/// 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 { - pub fn new() -> Self { - Self::default() - } - /// Uninitialized stake account -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Uninitialized stake account + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Rent sysvar -#[inline(always)] + /// Rent sysvar + #[inline(always)] pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent_sysvar = Some(rent_sysvar); - 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 { - self.stake_authority = Some(stake_authority); - self + /// The stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: solana_program::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 { - self.withdraw_authority = Some(withdraw_authority); - self + /// The withdraw authority + #[inline(always)] + pub fn withdraw_authority( + &mut self, + withdraw_authority: solana_program::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 { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = InitializeChecked { - stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.expect("rent_sysvar is not set"), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - withdraw_authority: self.withdraw_authority.expect("withdraw_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - - /// `initialize_checked` CPI accounts. - pub struct InitializeCheckedCpiAccounts<'a, 'b> { - /// Uninitialized stake account - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar - - - - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake authority + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = InitializeChecked { + stake: self.stake.expect("stake is not set"), + rent_sysvar: self.rent_sysvar.expect("rent_sysvar is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + withdraw_authority: self + .withdraw_authority + .expect("withdraw_authority is not set"), + }; - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The withdraw authority + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } +} - - - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `initialize_checked` CPI accounts. +pub struct InitializeCheckedCpiAccounts<'a, 'b> { + /// Uninitialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Rent sysvar + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The withdraw authority + pub withdraw_authority: &'b solana_program::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>, - /// Uninitialized stake account - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Rent sysvar - - - - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake authority - - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The withdraw authority - - - - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - } + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Rent sysvar + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The withdraw authority + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, +} impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: InitializeCheckedCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - rent_sysvar: accounts.rent_sysvar, - stake_authority: accounts.stake_authority, - withdraw_authority: accounts.withdraw_authority, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(4+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: InitializeCheckedCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + rent_sysvar: accounts.rent_sysvar, + stake_authority: accounts.stake_authority, + withdraw_authority: accounts.withdraw_authority, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.rent_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.withdraw_authority.key, - true - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.rent_sysvar.clone()); - account_infos.push(self.stake_authority.clone()); - account_infos.push(self.withdraw_authority.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.rent_sysvar.clone()); + account_infos.push(self.stake_authority.clone()); + account_infos.push(self.withdraw_authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `InitializeChecked` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[]` rent_sysvar - /// 2. `[]` stake_authority - /// 3. `[signer]` withdraw_authority +/// 0. `[writable]` stake +/// 1. `[]` rent_sysvar +/// 2. `[]` stake_authority +/// 3. `[signer]` withdraw_authority #[derive(Clone, Debug)] pub struct InitializeCheckedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCheckedCpiBuilderInstruction { - __program: program, - stake: None, - rent_sysvar: None, - stake_authority: None, - withdraw_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Uninitialized stake account -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(InitializeCheckedCpiBuilderInstruction { + __program: program, + stake: None, + rent_sysvar: None, + stake_authority: None, + withdraw_authority: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Uninitialized stake account + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self + } + /// Rent sysvar + #[inline(always)] + pub fn rent_sysvar( + &mut self, + rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.rent_sysvar = Some(rent_sysvar); + self } - /// Rent sysvar -#[inline(always)] - pub fn rent_sysvar(&mut self, rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent_sysvar = Some(rent_sysvar); - self + /// The stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - /// The stake authority -#[inline(always)] - pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// The withdraw authority + #[inline(always)] + pub fn withdraw_authority( + &mut self, + withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.withdraw_authority = Some(withdraw_authority); + self } - /// The withdraw authority -#[inline(always)] - pub fn withdraw_authority(&mut self, withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.withdraw_authority = Some(withdraw_authority); - self + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = InitializeCheckedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - rent_sysvar: self.instruction.rent_sysvar.expect("rent_sysvar is not set"), - - stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), - - withdraw_authority: self.instruction.withdraw_authority.expect("withdraw_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + rent_sysvar: self + .instruction + .rent_sysvar + .expect("rent_sysvar is not set"), + + stake_authority: self + .instruction + .stake_authority + .expect("stake_authority is not set"), + + withdraw_authority: self + .instruction + .withdraw_authority + .expect("withdraw_authority is not set"), + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 5d372623..5f2feda7 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -5,430 +5,475 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Merge { - /// Destination stake account for the merge - - - - pub destination_stake: solana_program::pubkey::Pubkey, - /// Source stake account for to merge. This account will be drained - - - - pub source_stake: solana_program::pubkey::Pubkey, - /// Clock sysvar - - - - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar that carries stake warmup/cooldown history - - - - pub stake_history_sysvar: solana_program::pubkey::Pubkey, - /// Stake authority - - - - pub stake_authority: solana_program::pubkey::Pubkey, - } + /// Destination stake account for the merge + pub destination_stake: solana_program::pubkey::Pubkey, + /// Source stake account for to merge. This account will be drained + pub source_stake: solana_program::pubkey::Pubkey, + /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history_sysvar: solana_program::pubkey::Pubkey, + /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, +} impl Merge { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(5+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( self.destination_stake, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.source_stake, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_history_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, - true - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MergeInstructionData::new()).unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let data = borsh::to_vec(&MergeInstructionData::new()).unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct MergeInstructionData { - discriminator: u32, - } +pub struct MergeInstructionData { + discriminator: u32, +} impl MergeInstructionData { - pub fn new() -> Self { - Self { - discriminator: 7, - } - } + pub fn new() -> Self { + Self { discriminator: 7 } + } } impl Default for MergeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } - - /// Instruction builder for `Merge`. /// /// ### Accounts: /// - /// 0. `[writable]` destination_stake - /// 1. `[writable]` source_stake - /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) - /// 3. `[optional]` stake_history_sysvar (default to `SysvarStakeHistory1111111111111111111111111`) - /// 4. `[signer]` stake_authority +/// 0. `[writable]` destination_stake +/// 1. `[writable]` source_stake +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 3. `[optional]` stake_history_sysvar (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_sysvar: Option, - stake_authority: Option, - __remaining_accounts: Vec, + destination_stake: Option, + source_stake: Option, + clock_sysvar: Option, + stake_history_sysvar: Option, + stake_authority: Option, + __remaining_accounts: Vec, } impl MergeBuilder { - pub fn new() -> Self { - Self::default() - } - /// Destination stake account for the merge -#[inline(always)] - pub fn destination_stake(&mut self, destination_stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.destination_stake = Some(destination_stake); - self + pub fn new() -> Self { + Self::default() + } + /// Destination stake account for the merge + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.destination_stake = Some(destination_stake); + self } - /// Source stake account for to merge. This account will be drained -#[inline(always)] + /// 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 { - self.source_stake = Some(source_stake); - self + self.source_stake = Some(source_stake); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` -/// Clock sysvar -#[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` + /// Clock sysvar + #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self + self.clock_sysvar = Some(clock_sysvar); + self + } + /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` + /// Stake history sysvar that carries stake warmup/cooldown history + #[inline(always)] + pub fn stake_history_sysvar( + &mut self, + stake_history_sysvar: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_history_sysvar = Some(stake_history_sysvar); + self + } + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: solana_program::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 { + self.__remaining_accounts.push(account); + self } - /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` -/// Stake history sysvar that carries stake warmup/cooldown history -#[inline(always)] - pub fn stake_history_sysvar(&mut self, stake_history_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake_history_sysvar = Some(stake_history_sysvar); - self + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::instruction::AccountMeta], + ) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self } - /// Stake authority -#[inline(always)] - pub fn stake_authority(&mut self, stake_authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake_authority = Some(stake_authority); - self + #[allow(clippy::clone_on_copy)] + pub fn instruction(&self) -> solana_program::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!( + "SysvarC1ock11111111111111111111111111111111" + )), + stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarStakeHistory1111111111111111111111111" + )), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - 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!("SysvarC1ock11111111111111111111111111111111")), - stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!("SysvarStakeHistory1111111111111111111111111")), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } } - /// `merge` CPI accounts. - pub struct MergeCpiAccounts<'a, 'b> { - /// Destination stake account for the merge - - - - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Source stake account for to merge. This account will be drained - - - - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - - - - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `merge` CPI accounts. +pub struct MergeCpiAccounts<'a, 'b> { + /// Destination stake account for the merge + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Source stake account for to merge. This account will be drained + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::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 for the merge - - - - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Source stake account for to merge. This account will be drained - - - - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - - - - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - } + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Destination stake account for the merge + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Source stake account for to merge. This account will be drained + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, +} impl<'a, 'b> MergeCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: MergeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - destination_stake: accounts.destination_stake, - source_stake: accounts.source_stake, - clock_sysvar: accounts.clock_sysvar, - stake_history_sysvar: accounts.stake_history_sysvar, - stake_authority: accounts.stake_authority, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(5+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MergeCpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + destination_stake: accounts.destination_stake, + source_stake: accounts.source_stake, + clock_sysvar: accounts.clock_sysvar, + stake_history_sysvar: accounts.stake_history_sysvar, + stake_authority: accounts.stake_authority, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( *self.destination_stake.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.source_stake.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_history_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.destination_stake.clone()); - account_infos.push(self.source_stake.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history_sysvar.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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 instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.stake_history_sysvar.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `Merge` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` destination_stake - /// 1. `[writable]` source_stake - /// 2. `[]` clock_sysvar - /// 3. `[]` stake_history_sysvar - /// 4. `[signer]` stake_authority +/// 0. `[writable]` destination_stake +/// 1. `[writable]` source_stake +/// 2. `[]` clock_sysvar +/// 3. `[]` stake_history_sysvar +/// 4. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MergeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> MergeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MergeCpiBuilderInstruction { - __program: program, - destination_stake: None, - source_stake: None, - clock_sysvar: None, - stake_history_sysvar: None, - stake_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Destination stake account for the merge -#[inline(always)] - pub fn destination_stake(&mut self, destination_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.destination_stake = Some(destination_stake); - self + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MergeCpiBuilderInstruction { + __program: program, + destination_stake: None, + source_stake: None, + clock_sysvar: None, + stake_history_sysvar: None, + stake_authority: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Destination stake account for the merge + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.destination_stake = Some(destination_stake); + self } - /// 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>) -> &mut Self { - self.instruction.source_stake = Some(source_stake); - self + /// 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>, + ) -> &mut Self { + self.instruction.source_stake = Some(source_stake); + self } - /// Clock sysvar -#[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self + /// Clock sysvar + #[inline(always)] + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self } - /// Stake history sysvar that carries stake warmup/cooldown history -#[inline(always)] - pub fn stake_history_sysvar(&mut self, stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake_history_sysvar = Some(stake_history_sysvar); - self + /// Stake history sysvar that carries stake warmup/cooldown history + #[inline(always)] + pub fn stake_history_sysvar( + &mut self, + stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_history_sysvar = Some(stake_history_sysvar); + self } - /// Stake authority -#[inline(always)] - pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { let instruction = MergeCpi { - __program: self.instruction.__program, - - destination_stake: self.instruction.destination_stake.expect("destination_stake is not set"), - - source_stake: self.instruction.source_stake.expect("source_stake is not set"), - - clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), - - stake_history_sysvar: self.instruction.stake_history_sysvar.expect("stake_history_sysvar is not set"), - - stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + destination_stake: self + .instruction + .destination_stake + .expect("destination_stake is not set"), + + source_stake: self + .instruction + .source_stake + .expect("source_stake is not set"), + + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), + + stake_history_sysvar: self + .instruction + .stake_history_sysvar + .expect("stake_history_sysvar is not set"), + + stake_authority: self + .instruction + .stake_authority + .expect("stake_authority is not set"), + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, } - diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index bd880fc0..718e3494 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -5,39 +5,28 @@ //! //! - pub(crate) mod r#authorize; - pub(crate) mod r#authorize_checked; - pub(crate) mod r#authorize_checked_with_seed; - pub(crate) mod r#authorize_with_seed; - pub(crate) mod r#deactivate; - pub(crate) mod r#deactivate_delinquent; - pub(crate) mod r#delegate_stake; - pub(crate) mod r#get_minimum_delegation; - pub(crate) mod r#initialize; - pub(crate) mod r#initialize_checked; - pub(crate) mod r#merge; - pub(crate) mod r#move_lamports; - pub(crate) mod r#move_stake; - pub(crate) mod r#set_lockup; - pub(crate) mod r#set_lockup_checked; - pub(crate) mod r#split; - pub(crate) mod r#withdraw; - - pub use self::r#authorize::*; - pub use self::r#authorize_checked::*; - pub use self::r#authorize_checked_with_seed::*; - pub use self::r#authorize_with_seed::*; - pub use self::r#deactivate::*; - pub use self::r#deactivate_delinquent::*; - pub use self::r#delegate_stake::*; - pub use self::r#get_minimum_delegation::*; - pub use self::r#initialize::*; - pub use self::r#initialize_checked::*; - pub use self::r#merge::*; - pub use self::r#move_lamports::*; - pub use self::r#move_stake::*; - pub use self::r#set_lockup::*; - pub use self::r#set_lockup_checked::*; - pub use self::r#split::*; - pub use self::r#withdraw::*; +pub(crate) mod r#authorize; +pub(crate) mod r#authorize_checked; +pub(crate) mod r#authorize_checked_with_seed; +pub(crate) mod r#authorize_with_seed; +pub(crate) mod r#deactivate; +pub(crate) mod r#deactivate_delinquent; +pub(crate) mod r#delegate_stake; +pub(crate) mod r#get_minimum_delegation; +pub(crate) mod r#initialize; +pub(crate) mod r#initialize_checked; +pub(crate) mod r#merge; +pub(crate) mod r#move_lamports; +pub(crate) mod r#move_stake; +pub(crate) mod r#set_lockup; +pub(crate) mod r#set_lockup_checked; +pub(crate) mod r#split; +pub(crate) mod r#withdraw; +pub use self::{ + r#authorize::*, r#authorize_checked::*, r#authorize_checked_with_seed::*, + r#authorize_with_seed::*, r#deactivate::*, r#deactivate_delinquent::*, r#delegate_stake::*, + r#get_minimum_delegation::*, r#initialize::*, r#initialize_checked::*, r#merge::*, + r#move_lamports::*, r#move_stake::*, r#set_lockup::*, r#set_lockup_checked::*, r#split::*, + r#withdraw::*, +}; diff --git a/clients/rust/src/generated/instructions/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs index c2f80f32..cc30b72c 100644 --- a/clients/rust/src/generated/instructions/move_lamports.rs +++ b/clients/rust/src/generated/instructions/move_lamports.rs @@ -5,371 +5,420 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct MoveLamports { - /// Active or inactive source stake account - - - - pub source_stake: solana_program::pubkey::Pubkey, - /// Mergeable destination stake account - - - - pub destination_stake: solana_program::pubkey::Pubkey, - /// Stake authority - - - - pub stake_authority: solana_program::pubkey::Pubkey, - } + /// Active or inactive source stake account + pub source_stake: solana_program::pubkey::Pubkey, + /// Mergeable destination stake account + pub destination_stake: solana_program::pubkey::Pubkey, + /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, +} impl MoveLamports { - pub fn instruction(&self, args: MoveLamportsInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn instruction( + &self, + args: MoveLamportsInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( self.source_stake, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.destination_stake, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&MoveLamportsInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct MoveLamportsInstructionData { - discriminator: u32, - } +pub struct MoveLamportsInstructionData { + discriminator: u32, +} impl MoveLamportsInstructionData { - pub fn new() -> Self { - Self { - discriminator: 17, - } - } + pub fn new() -> Self { + Self { discriminator: 17 } + } } impl Default for MoveLamportsInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct MoveLamportsInstructionArgs { - pub args: u64, - } - +pub struct MoveLamportsInstructionArgs { + pub args: u64, +} /// Instruction builder for `MoveLamports`. /// /// ### Accounts: /// - /// 0. `[writable]` source_stake - /// 1. `[writable]` destination_stake - /// 2. `[signer]` stake_authority +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake +/// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveLamportsBuilder { - source_stake: Option, - destination_stake: Option, - stake_authority: Option, - args: Option, - __remaining_accounts: Vec, + source_stake: Option, + destination_stake: Option, + stake_authority: Option, + args: Option, + __remaining_accounts: Vec, } impl MoveLamportsBuilder { - pub fn new() -> Self { - Self::default() - } - /// Active or inactive source stake account -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Active or inactive source stake account + #[inline(always)] pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.source_stake = Some(source_stake); - 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 { - self.destination_stake = Some(destination_stake); - self + /// Mergeable destination stake account + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: solana_program::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 { - self.stake_authority = Some(stake_authority); - self + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_authority = Some(stake_authority); + self } - #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { self.args = Some(args); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = MoveLamports { - source_stake: self.source_stake.expect("source_stake is not set"), - destination_stake: self.destination_stake.expect("destination_stake is not set"), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - let args = MoveLamportsInstructionArgs { - args: self.args.clone().expect("args is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - - /// `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>, - /// Mergeable destination stake account + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = MoveLamports { + source_stake: self.source_stake.expect("source_stake is not set"), + destination_stake: self + .destination_stake + .expect("destination_stake is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + let args = MoveLamportsInstructionArgs { + args: self.args.clone().expect("args is not set"), + }; - - - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `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>, + /// Mergeable destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::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>, - /// Active or inactive source stake account - - - - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Mergeable destination stake account - - - - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Active or inactive source stake account + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Mergeable destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::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>, - accounts: MoveLamportsCpiAccounts<'a, 'b>, - args: MoveLamportsInstructionArgs, - ) -> Self { - Self { - __program: program, - source_stake: accounts.source_stake, - destination_stake: accounts.destination_stake, - stake_authority: accounts.stake_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MoveLamportsCpiAccounts<'a, 'b>, + args: MoveLamportsInstructionArgs, + ) -> Self { + Self { + __program: program, + source_stake: accounts.source_stake, + destination_stake: accounts.destination_stake, + stake_authority: accounts.stake_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( *self.source_stake.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.destination_stake.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.source_stake.clone()); - account_infos.push(self.destination_stake.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `MoveLamports` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` source_stake - /// 1. `[writable]` destination_stake - /// 2. `[signer]` stake_authority +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake +/// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MoveLamportsCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MoveLamportsCpiBuilderInstruction { - __program: program, - source_stake: None, - destination_stake: None, - stake_authority: None, - args: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Active or inactive source stake account -#[inline(always)] - pub fn source_stake(&mut self, source_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.source_stake = Some(source_stake); - self + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MoveLamportsCpiBuilderInstruction { + __program: program, + source_stake: None, + destination_stake: None, + stake_authority: None, + args: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } } - /// Mergeable destination stake account -#[inline(always)] - pub fn destination_stake(&mut self, destination_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.destination_stake = Some(destination_stake); - self + /// Active or inactive source stake account + #[inline(always)] + pub fn source_stake( + &mut self, + source_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.source_stake = Some(source_stake); + self } - /// Stake authority -#[inline(always)] - pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// Mergeable destination stake account + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.destination_stake = Some(destination_stake); + self } - #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self + } + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { self.instruction.args = Some(args); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = MoveLamportsInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = MoveLamportsInstructionArgs { + args: self.instruction.args.clone().expect("args is not set"), + }; let instruction = MoveLamportsCpi { - __program: self.instruction.__program, - - source_stake: self.instruction.source_stake.expect("source_stake is not set"), - - destination_stake: self.instruction.destination_stake.expect("destination_stake is not set"), - - stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + source_stake: self + .instruction + .source_stake + .expect("source_stake is not set"), + + destination_stake: self + .instruction + .destination_stake + .expect("destination_stake is not set"), + + stake_authority: self + .instruction + .stake_authority + .expect("stake_authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - args: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + args: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 d596ec5b..c8953253 100644 --- a/clients/rust/src/generated/instructions/move_stake.rs +++ b/clients/rust/src/generated/instructions/move_stake.rs @@ -5,371 +5,420 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct MoveStake { - /// Active source stake account - - - - pub source_stake: solana_program::pubkey::Pubkey, - /// Active or inactive destination stake account - - - - pub destination_stake: solana_program::pubkey::Pubkey, - /// Stake authority - - - - pub stake_authority: solana_program::pubkey::Pubkey, - } + /// Active source stake account + pub source_stake: solana_program::pubkey::Pubkey, + /// Active or inactive destination stake account + pub destination_stake: solana_program::pubkey::Pubkey, + /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, +} impl MoveStake { - pub fn instruction(&self, args: MoveStakeInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn instruction( + &self, + args: MoveStakeInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( self.source_stake, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.destination_stake, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&MoveStakeInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct MoveStakeInstructionData { - discriminator: u32, - } +pub struct MoveStakeInstructionData { + discriminator: u32, +} impl MoveStakeInstructionData { - pub fn new() -> Self { - Self { - discriminator: 16, - } - } + pub fn new() -> Self { + Self { discriminator: 16 } + } } impl Default for MoveStakeInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct MoveStakeInstructionArgs { - pub args: u64, - } - +pub struct MoveStakeInstructionArgs { + pub args: u64, +} /// Instruction builder for `MoveStake`. /// /// ### Accounts: /// - /// 0. `[writable]` source_stake - /// 1. `[writable]` destination_stake - /// 2. `[signer]` stake_authority +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake +/// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MoveStakeBuilder { - source_stake: Option, - destination_stake: Option, - stake_authority: Option, - args: Option, - __remaining_accounts: Vec, + source_stake: Option, + destination_stake: Option, + stake_authority: Option, + args: Option, + __remaining_accounts: Vec, } impl MoveStakeBuilder { - pub fn new() -> Self { - Self::default() - } - /// Active source stake account -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Active source stake account + #[inline(always)] pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.source_stake = Some(source_stake); - 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 { - self.destination_stake = Some(destination_stake); - self + /// Active or inactive destination stake account + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: solana_program::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 { - self.stake_authority = Some(stake_authority); - self + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_authority = Some(stake_authority); + self } - #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { self.args = Some(args); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = MoveStake { - source_stake: self.source_stake.expect("source_stake is not set"), - destination_stake: self.destination_stake.expect("destination_stake is not set"), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - let args = MoveStakeInstructionArgs { - args: self.args.clone().expect("args is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - - /// `move_stake` CPI accounts. - pub struct MoveStakeCpiAccounts<'a, 'b> { - /// Active source stake account - - - - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Active or inactive destination stake account + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = MoveStake { + source_stake: self.source_stake.expect("source_stake is not set"), + destination_stake: self + .destination_stake + .expect("destination_stake is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + let args = MoveStakeInstructionArgs { + args: self.args.clone().expect("args is not set"), + }; - - - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `move_stake` CPI accounts. +pub struct MoveStakeCpiAccounts<'a, 'b> { + /// Active source stake account + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Active or inactive destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::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>, - /// Active source stake account - - - - pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Active or inactive destination stake account - - - - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Active source stake account + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Active or inactive destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::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>, - accounts: MoveStakeCpiAccounts<'a, 'b>, - args: MoveStakeInstructionArgs, - ) -> Self { - Self { - __program: program, - source_stake: accounts.source_stake, - destination_stake: accounts.destination_stake, - stake_authority: accounts.stake_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MoveStakeCpiAccounts<'a, 'b>, + args: MoveStakeInstructionArgs, + ) -> Self { + Self { + __program: program, + source_stake: accounts.source_stake, + destination_stake: accounts.destination_stake, + stake_authority: accounts.stake_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( *self.source_stake.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.destination_stake.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.source_stake.clone()); - account_infos.push(self.destination_stake.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `MoveStake` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` source_stake - /// 1. `[writable]` destination_stake - /// 2. `[signer]` stake_authority +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake +/// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MoveStakeCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MoveStakeCpiBuilderInstruction { - __program: program, - source_stake: None, - destination_stake: None, - stake_authority: None, - args: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Active source stake account -#[inline(always)] - pub fn source_stake(&mut self, source_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.source_stake = Some(source_stake); - self + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MoveStakeCpiBuilderInstruction { + __program: program, + source_stake: None, + destination_stake: None, + stake_authority: None, + args: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } } - /// Active or inactive destination stake account -#[inline(always)] - pub fn destination_stake(&mut self, destination_stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.destination_stake = Some(destination_stake); - self + /// Active source stake account + #[inline(always)] + pub fn source_stake( + &mut self, + source_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.source_stake = Some(source_stake); + self } - /// Stake authority -#[inline(always)] - pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// Active or inactive destination stake account + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.destination_stake = Some(destination_stake); + self } - #[inline(always)] - pub fn args(&mut self, args: u64) -> &mut Self { + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self + } + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { self.instruction.args = Some(args); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = MoveStakeInstructionArgs { - args: self.instruction.args.clone().expect("args is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = MoveStakeInstructionArgs { + args: self.instruction.args.clone().expect("args is not set"), + }; let instruction = MoveStakeCpi { - __program: self.instruction.__program, - - source_stake: self.instruction.source_stake.expect("source_stake is not set"), - - destination_stake: self.instruction.destination_stake.expect("destination_stake is not set"), - - stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + source_stake: self + .instruction + .source_stake + .expect("source_stake is not set"), + + destination_stake: self + .instruction + .destination_stake + .expect("destination_stake is not set"), + + stake_authority: self + .instruction + .stake_authority + .expect("stake_authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - args: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + args: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 2df65570..d3cb0b62 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -5,367 +5,402 @@ //! //! -use crate::generated::types::UnixTimestamp; -use crate::generated::types::Epoch; -use solana_program::pubkey::Pubkey; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::{Epoch, UnixTimestamp}, + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; /// Accounts. #[derive(Debug)] pub struct SetLockup { - /// Initialized stake account - - - - pub stake: solana_program::pubkey::Pubkey, - /// Lockup authority or withdraw authority - - - - pub authority: solana_program::pubkey::Pubkey, - } + /// Initialized stake account + pub stake: solana_program::pubkey::Pubkey, + /// Lockup authority or withdraw authority + pub authority: solana_program::pubkey::Pubkey, +} impl SetLockup { - pub fn instruction(&self, args: SetLockupInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction( + &self, + args: SetLockupInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( 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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&SetLockupInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct SetLockupInstructionData { - discriminator: u32, - } +pub struct SetLockupInstructionData { + discriminator: u32, +} impl SetLockupInstructionData { - pub fn new() -> Self { - Self { - discriminator: 6, - } - } + pub fn new() -> Self { + Self { discriminator: 6 } + } } impl Default for SetLockupInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[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 custodian: Option, - } - +pub struct SetLockupInstructionArgs { + pub unix_timestamp: Option, + pub epoch: Option, + pub custodian: Option, +} /// Instruction builder for `SetLockup`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[signer]` authority +/// 0. `[writable]` stake +/// 1. `[signer]` authority #[derive(Clone, Debug, Default)] pub struct SetLockupBuilder { - stake: Option, - authority: Option, - unix_timestamp: Option, - epoch: Option, - custodian: Option, - __remaining_accounts: Vec, + stake: Option, + authority: Option, + unix_timestamp: Option, + epoch: Option, + custodian: Option, + __remaining_accounts: Vec, } impl SetLockupBuilder { - pub fn new() -> Self { - Self::default() - } - /// Initialized stake account -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Initialized stake account + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Lockup authority or withdraw authority -#[inline(always)] + /// Lockup authority or withdraw authority + #[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self + self.authority = Some(authority); + self } - /// `[optional argument]` -#[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: UnixTimestamp) -> &mut Self { + /// `[optional argument]` + #[inline(always)] + 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: Epoch) -> &mut Self { + } + /// `[optional argument]` + #[inline(always)] + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.epoch = Some(epoch); self - } - /// `[optional argument]` -#[inline(always)] - pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { + } + /// `[optional argument]` + #[inline(always)] + pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { self.custodian = Some(custodian); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = SetLockup { - stake: self.stake.expect("stake is not set"), - authority: self.authority.expect("authority is not set"), - }; - let args = SetLockupInstructionArgs { - unix_timestamp: self.unix_timestamp.clone(), - epoch: self.epoch.clone(), - custodian: self.custodian.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - - /// `set_lockup` CPI accounts. - pub struct SetLockupCpiAccounts<'a, 'b> { - /// Initialized stake account + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = SetLockup { + stake: self.stake.expect("stake is not set"), + authority: self.authority.expect("authority is not set"), + }; + let args = SetLockupInstructionArgs { + unix_timestamp: self.unix_timestamp.clone(), + epoch: self.epoch.clone(), + custodian: self.custodian.clone(), + }; - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} - - - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `set_lockup` CPI accounts. +pub struct SetLockupCpiAccounts<'a, 'b> { + /// Initialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority or withdraw authority + pub authority: &'b solana_program::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>, - /// Initialized stake account - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority - - - - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Initialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority or withdraw authority + pub authority: &'b solana_program::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>, - accounts: SetLockupCpiAccounts<'a, 'b>, - args: SetLockupInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - authority: accounts.authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(2+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: SetLockupCpiAccounts<'a, 'b>, + args: SetLockupInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + authority: accounts.authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, - true - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.authority.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `SetLockup` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[signer]` authority +/// 0. `[writable]` stake +/// 1. `[signer]` authority #[derive(Clone, Debug)] pub struct SetLockupCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetLockupCpiBuilderInstruction { - __program: program, - stake: None, - authority: None, - unix_timestamp: None, - epoch: None, - custodian: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Initialized stake account -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(SetLockupCpiBuilderInstruction { + __program: program, + stake: None, + authority: None, + unix_timestamp: None, + epoch: None, + custodian: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Initialized stake account + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - 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 { - self.instruction.authority = Some(authority); - self + /// Lockup authority or withdraw authority + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self } - /// `[optional argument]` -#[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: UnixTimestamp) -> &mut Self { + /// `[optional argument]` + #[inline(always)] + 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: Epoch) -> &mut Self { + } + /// `[optional argument]` + #[inline(always)] + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.instruction.epoch = Some(epoch); self - } - /// `[optional argument]` -#[inline(always)] - pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { + } + /// `[optional argument]` + #[inline(always)] + pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { self.instruction.custodian = Some(custodian); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = SetLockupInstructionArgs { - unix_timestamp: self.instruction.unix_timestamp.clone(), - epoch: self.instruction.epoch.clone(), - custodian: self.instruction.custodian.clone(), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = SetLockupInstructionArgs { + unix_timestamp: self.instruction.unix_timestamp.clone(), + epoch: self.instruction.epoch.clone(), + custodian: self.instruction.custodian.clone(), + }; let instruction = SetLockupCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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, - custodian: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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, + custodian: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 8b20d922..121a94f8 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -5,401 +5,433 @@ //! //! -use crate::generated::types::UnixTimestamp; -use crate::generated::types::Epoch; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::{Epoch, UnixTimestamp}, + borsh::{BorshDeserialize, BorshSerialize}, +}; /// Accounts. #[derive(Debug)] pub struct SetLockupChecked { - /// Initialized stake account - - - - pub stake: solana_program::pubkey::Pubkey, - /// Lockup authority or withdraw authority - - - - pub authority: solana_program::pubkey::Pubkey, - /// New lockup authority - - - - pub new_authority: Option, - } + /// Initialized stake account + pub stake: solana_program::pubkey::Pubkey, + /// Lockup authority or withdraw authority + pub authority: solana_program::pubkey::Pubkey, + /// New lockup authority + pub new_authority: Option, +} impl SetLockupChecked { - pub fn instruction(&self, args: SetLockupCheckedInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction( + &self, + args: SetLockupCheckedInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( self.authority, - true - )); - if let Some(new_authority) = self.new_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + if let Some(new_authority) = self.new_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&SetLockupCheckedInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct SetLockupCheckedInstructionData { - discriminator: u32, - } +pub struct SetLockupCheckedInstructionData { + discriminator: u32, +} impl SetLockupCheckedInstructionData { - pub fn new() -> Self { - Self { - discriminator: 12, - } - } + pub fn new() -> Self { + Self { discriminator: 12 } + } } impl Default for SetLockupCheckedInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[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 struct SetLockupCheckedInstructionArgs { + pub unix_timestamp: Option, + pub epoch: Option, +} /// Instruction builder for `SetLockupChecked`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[signer]` authority - /// 2. `[signer, optional]` new_authority +/// 0. `[writable]` stake +/// 1. `[signer]` authority +/// 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 { - pub fn new() -> Self { - Self::default() - } - /// Initialized stake account -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Initialized stake account + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Lockup authority or withdraw authority -#[inline(always)] + /// Lockup authority or withdraw authority + #[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self + self.authority = Some(authority); + self } - /// `[optional account]` -/// New lockup authority -#[inline(always)] - pub fn new_authority(&mut self, new_authority: Option) -> &mut Self { - self.new_authority = new_authority; - self + /// `[optional account]` + /// New lockup authority + #[inline(always)] + 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: UnixTimestamp) -> &mut Self { + /// `[optional argument]` + #[inline(always)] + 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: Epoch) -> &mut Self { + } + /// `[optional argument]` + #[inline(always)] + 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 { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = SetLockupChecked { - stake: self.stake.expect("stake is not set"), - authority: self.authority.expect("authority is not set"), - new_authority: self.new_authority, - }; - let args = SetLockupCheckedInstructionArgs { - unix_timestamp: self.unix_timestamp.clone(), - epoch: self.epoch.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - - /// `set_lockup_checked` CPI accounts. - pub struct SetLockupCheckedCpiAccounts<'a, 'b> { - /// Initialized stake account - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = SetLockupChecked { + stake: self.stake.expect("stake is not set"), + authority: self.authority.expect("authority is not set"), + new_authority: self.new_authority, + }; + let args = SetLockupCheckedInstructionArgs { + unix_timestamp: self.unix_timestamp.clone(), + epoch: self.epoch.clone(), + }; - - - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// New lockup authority + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} - - - pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - } +/// `set_lockup_checked` CPI accounts. +pub struct SetLockupCheckedCpiAccounts<'a, 'b> { + /// Initialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// New lockup authority + pub new_authority: Option<&'b solana_program::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>, - /// Initialized stake account - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority or withdraw authority - - - - pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// New lockup authority - - - - pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Initialized stake account + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority or withdraw authority + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// New lockup authority + pub new_authority: Option<&'b solana_program::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>, - accounts: SetLockupCheckedCpiAccounts<'a, 'b>, - args: SetLockupCheckedInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - authority: accounts.authority, - new_authority: accounts.new_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: SetLockupCheckedCpiAccounts<'a, 'b>, + args: SetLockupCheckedInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + authority: accounts.authority, + new_authority: accounts.new_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, - true - )); - if let Some(new_authority) = self.new_authority { + true, + )); + if let Some(new_authority) = self.new_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *new_authority.key, - true, + *new_authority.key, + true, )); - } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.authority.clone()); - if let Some(new_authority) = self.new_authority { - account_infos.push(new_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.authority.clone()); + if let Some(new_authority) = self.new_authority { + account_infos.push(new_authority.clone()); + } + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `SetLockupChecked` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[signer]` authority - /// 2. `[signer, optional]` new_authority +/// 0. `[writable]` stake +/// 1. `[signer]` authority +/// 2. `[signer, optional]` new_authority #[derive(Clone, Debug)] pub struct SetLockupCheckedCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetLockupCheckedCpiBuilderInstruction { - __program: program, - stake: None, - authority: None, - new_authority: None, - unix_timestamp: None, - epoch: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Initialized stake account -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(SetLockupCheckedCpiBuilderInstruction { + __program: program, + stake: None, + authority: None, + new_authority: None, + unix_timestamp: None, + epoch: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Initialized stake account + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake = Some(stake); - 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 { - self.instruction.authority = Some(authority); - self + /// Lockup authority or withdraw authority + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self } - /// `[optional account]` -/// New lockup authority -#[inline(always)] - pub fn new_authority(&mut self, new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>) -> &mut Self { - self.instruction.new_authority = new_authority; - self + /// `[optional account]` + /// New lockup authority + #[inline(always)] + pub fn new_authority( + &mut self, + new_authority: Option<&'b solana_program::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: UnixTimestamp) -> &mut Self { + /// `[optional argument]` + #[inline(always)] + 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: Epoch) -> &mut Self { + } + /// `[optional argument]` + #[inline(always)] + pub fn epoch(&mut self, epoch: Epoch) -> &mut Self { self.instruction.epoch = Some(epoch); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = SetLockupCheckedInstructionArgs { - unix_timestamp: self.instruction.unix_timestamp.clone(), - epoch: self.instruction.epoch.clone(), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = SetLockupCheckedInstructionArgs { + unix_timestamp: self.instruction.unix_timestamp.clone(), + epoch: self.instruction.epoch.clone(), + }; let instruction = SetLockupCheckedCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - new_authority: self.instruction.new_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + new_authority: self.instruction.new_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 08a440a6..36701c29 100644 --- a/clients/rust/src/generated/instructions/split.rs +++ b/clients/rust/src/generated/instructions/split.rs @@ -5,371 +5,412 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Split { - /// Stake account to be split; must be in the Initialized or Stake state - - - - pub stake: solana_program::pubkey::Pubkey, - /// Uninitialized stake account that will take the split-off amount - - - - pub split_stake: solana_program::pubkey::Pubkey, - /// Stake authority - - - - pub stake_authority: solana_program::pubkey::Pubkey, - } + /// Stake account to be split; must be in the Initialized or Stake state + pub stake: solana_program::pubkey::Pubkey, + /// Uninitialized stake account that will take the split-off amount + pub split_stake: solana_program::pubkey::Pubkey, + /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, +} impl Split { - pub fn instruction(&self, args: SplitInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction( + &self, + args: SplitInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( self.split_stake, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&SplitInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } } - } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct SplitInstructionData { - discriminator: u32, - } +pub struct SplitInstructionData { + discriminator: u32, +} impl SplitInstructionData { - pub fn new() -> Self { - Self { - discriminator: 3, - } - } + pub fn new() -> Self { + Self { discriminator: 3 } + } } impl Default for SplitInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct SplitInstructionArgs { - pub lamports: u64, - } - +pub struct SplitInstructionArgs { + pub lamports: u64, +} /// Instruction builder for `Split`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[writable]` split_stake - /// 2. `[signer]` stake_authority +/// 0. `[writable]` stake +/// 1. `[writable]` split_stake +/// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct SplitBuilder { - stake: Option, - split_stake: Option, - stake_authority: Option, - lamports: Option, - __remaining_accounts: Vec, + stake: Option, + split_stake: Option, + stake_authority: Option, + lamports: Option, + __remaining_accounts: Vec, } impl SplitBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account to be split; must be in the Initialized or Stake state -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// 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 { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Uninitialized stake account that will take the split-off amount -#[inline(always)] + /// 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 { - self.split_stake = Some(split_stake); - 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 { - self.stake_authority = Some(stake_authority); - self + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_authority = Some(stake_authority); + self } - #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { + #[inline(always)] + pub fn lamports(&mut self, lamports: u64) -> &mut Self { self.lamports = Some(lamports); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - let accounts = Split { - stake: self.stake.expect("stake is not set"), - split_stake: self.split_stake.expect("split_stake is not set"), - stake_authority: self.stake_authority.expect("stake_authority is not set"), - }; - let args = SplitInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - - /// `split` CPI accounts. - pub struct SplitCpiAccounts<'a, 'b> { - /// Stake account to be split; must be in the Initialized or Stake state - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Uninitialized stake account that will take the split-off amount + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = Split { + stake: self.stake.expect("stake is not set"), + split_stake: self.split_stake.expect("split_stake is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + let args = SplitInstructionArgs { + lamports: self.lamports.clone().expect("lamports is not set"), + }; - - - pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `split` CPI accounts. +pub struct SplitCpiAccounts<'a, 'b> { + /// Stake account to be split; must be in the Initialized or Stake state + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account that will take the split-off amount + pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::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; must be in the Initialized or Stake state - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Uninitialized stake account that will take the split-off amount - - - - pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority - - - - pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account to be split; must be in the Initialized or Stake state + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account that will take the split-off amount + pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::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>, - accounts: SplitCpiAccounts<'a, 'b>, - args: SplitInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - split_stake: accounts.split_stake, - stake_authority: accounts.stake_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(3+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: SplitCpiAccounts<'a, 'b>, + args: SplitInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + split_stake: accounts.split_stake, + stake_authority: accounts.stake_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.split_stake.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_authority.key, - true - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.split_stake.clone()); - account_infos.push(self.stake_authority.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.split_stake.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `Split` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[writable]` split_stake - /// 2. `[signer]` stake_authority +/// 0. `[writable]` stake +/// 1. `[writable]` split_stake +/// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct SplitCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> SplitCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SplitCpiBuilderInstruction { - __program: program, - stake: None, - split_stake: None, - stake_authority: None, - lamports: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account to be split; must be in the Initialized or Stake state -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(SplitCpiBuilderInstruction { + __program: program, + stake: None, + split_stake: None, + stake_authority: None, + lamports: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// 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 { - self.instruction.stake = Some(stake); - self + self.instruction.stake = Some(stake); + self } - /// 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>) -> &mut Self { - self.instruction.split_stake = Some(split_stake); - self + /// 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>, + ) -> &mut Self { + self.instruction.split_stake = Some(split_stake); + self } - /// Stake authority -#[inline(always)] - pub fn stake_authority(&mut self, stake_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake_authority = Some(stake_authority); - self + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self } - #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { + #[inline(always)] + pub fn lamports(&mut self, lamports: u64) -> &mut Self { self.instruction.lamports = Some(lamports); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = SplitInstructionArgs { - lamports: self.instruction.lamports.clone().expect("lamports is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = SplitInstructionArgs { + lamports: self + .instruction + .lamports + .clone() + .expect("lamports is not set"), + }; let instruction = SplitCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - split_stake: self.instruction.split_stake.expect("split_stake is not set"), - - stake_authority: self.instruction.stake_authority.expect("stake_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + split_stake: self + .instruction + .split_stake + .expect("split_stake is not set"), + + stake_authority: self + .instruction + .stake_authority + .expect("stake_authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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>>, - lamports: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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>>, + lamports: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::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 a2052b1b..b23a8c10 100644 --- a/clients/rust/src/generated/instructions/withdraw.rs +++ b/clients/rust/src/generated/instructions/withdraw.rs @@ -5,516 +5,554 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. #[derive(Debug)] pub struct Withdraw { - /// Stake account from which to withdraw - - - - pub stake: solana_program::pubkey::Pubkey, - /// Recipient account - - - - pub recipient: solana_program::pubkey::Pubkey, - /// Clock sysvar - - - - pub clock_sysvar: solana_program::pubkey::Pubkey, - /// Stake history sysvar that carries stake warmup/cooldown history - - - - pub stake_history_sysvar: solana_program::pubkey::Pubkey, - /// Withdraw authority - - - - pub withdraw_authority: solana_program::pubkey::Pubkey, - /// Lockup authority, if before lockup expiration - - - - pub lockup_authority: Option, - } + /// Stake account from which to withdraw + pub stake: solana_program::pubkey::Pubkey, + /// Recipient account + pub recipient: solana_program::pubkey::Pubkey, + /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history_sysvar: solana_program::pubkey::Pubkey, + /// Withdraw authority + pub withdraw_authority: solana_program::pubkey::Pubkey, + /// Lockup authority, if before lockup expiration + pub lockup_authority: Option, +} impl Withdraw { - pub fn instruction(&self, args: WithdrawInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[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 { - 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( + pub fn instruction( + &self, + args: WithdrawInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.clock_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_history_sysvar, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.withdraw_authority, - true - )); - if let Some(lockup_authority) = self.lockup_authority { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::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(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - } - } + )); + } + accounts.extend_from_slice(remaining_accounts); + let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); + let mut args = borsh::to_vec(&args).unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct WithdrawInstructionData { - discriminator: u32, - } +pub struct WithdrawInstructionData { + discriminator: u32, +} impl WithdrawInstructionData { - pub fn new() -> Self { - Self { - discriminator: 4, - } - } + pub fn new() -> Self { + Self { discriminator: 4 } + } } impl Default for WithdrawInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - pub struct WithdrawInstructionArgs { - pub lamports: u64, - } - +pub struct WithdrawInstructionArgs { + pub lamports: u64, +} /// Instruction builder for `Withdraw`. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[writable]` recipient - /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) - /// 3. `[optional]` stake_history_sysvar (default to `SysvarStakeHistory1111111111111111111111111`) - /// 4. `[signer]` withdraw_authority - /// 5. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[writable]` recipient +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 3. `[optional]` stake_history_sysvar (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_sysvar: Option, - withdraw_authority: Option, - lockup_authority: Option, - lamports: Option, - __remaining_accounts: Vec, + stake: Option, + recipient: Option, + clock_sysvar: Option, + stake_history_sysvar: Option, + withdraw_authority: Option, + lockup_authority: Option, + lamports: Option, + __remaining_accounts: Vec, } impl WithdrawBuilder { - pub fn new() -> Self { - Self::default() - } - /// Stake account from which to withdraw -#[inline(always)] + pub fn new() -> Self { + Self::default() + } + /// Stake account from which to withdraw + #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake = Some(stake); - self + self.stake = Some(stake); + self } - /// Recipient account -#[inline(always)] + /// Recipient account + #[inline(always)] pub fn recipient(&mut self, recipient: solana_program::pubkey::Pubkey) -> &mut Self { - self.recipient = Some(recipient); - self + self.recipient = Some(recipient); + self } - /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` -/// Clock sysvar -#[inline(always)] + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` + /// Clock sysvar + #[inline(always)] pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock_sysvar = Some(clock_sysvar); - self - } - /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` -/// Stake history sysvar that carries stake warmup/cooldown history -#[inline(always)] - pub fn stake_history_sysvar(&mut self, stake_history_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake_history_sysvar = Some(stake_history_sysvar); - self - } - /// Withdraw authority -#[inline(always)] - pub fn withdraw_authority(&mut self, withdraw_authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.withdraw_authority = Some(withdraw_authority); - self - } - /// `[optional account]` -/// Lockup authority, if before lockup expiration -#[inline(always)] - pub fn lockup_authority(&mut self, lockup_authority: Option) -> &mut Self { - self.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); + self + } + /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` + /// Stake history sysvar that carries stake warmup/cooldown history + #[inline(always)] + pub fn stake_history_sysvar( + &mut self, + stake_history_sysvar: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_history_sysvar = Some(stake_history_sysvar); + self + } + /// Withdraw authority + #[inline(always)] + pub fn withdraw_authority( + &mut self, + withdraw_authority: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.withdraw_authority = Some(withdraw_authority); + self + } + /// `[optional account]` + /// Lockup authority, if before lockup expiration + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn lamports(&mut self, lamports: u64) -> &mut Self { self.lamports = Some(lamports); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::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 { - 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!("SysvarC1ock11111111111111111111111111111111")), - stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!("SysvarStakeHistory1111111111111111111111111")), - withdraw_authority: self.withdraw_authority.expect("withdraw_authority is not set"), - lockup_authority: self.lockup_authority, - }; - let args = WithdrawInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + 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!( + "SysvarC1ock11111111111111111111111111111111" + )), + stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarStakeHistory1111111111111111111111111" + )), + withdraw_authority: self + .withdraw_authority + .expect("withdraw_authority is not set"), + lockup_authority: self.lockup_authority, + }; + let args = WithdrawInstructionArgs { + lamports: self.lamports.clone().expect("lamports is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } - /// `withdraw` CPI accounts. - pub struct WithdrawCpiAccounts<'a, 'b> { - /// Stake account from which to withdraw - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Recipient account - - - - pub recipient: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - - - - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Withdraw authority - - - - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if before lockup expiration - - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - } +/// `withdraw` CPI accounts. +pub struct WithdrawCpiAccounts<'a, 'b> { + /// Stake account from which to withdraw + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Recipient account + pub recipient: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Withdraw authority + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - /// Stake account from which to withdraw - - - - pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Recipient account - - - - pub recipient: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar - - - - pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake history sysvar that carries stake warmup/cooldown history - - - - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Withdraw authority - - - - pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority, if before lockup expiration - - - - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account from which to withdraw + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Recipient account + pub recipient: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake history sysvar that carries stake warmup/cooldown history + pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Withdraw authority + pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority, if before lockup expiration + pub lockup_authority: Option<&'b solana_program::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>, - accounts: WithdrawCpiAccounts<'a, 'b>, - args: WithdrawInstructionArgs, - ) -> Self { - Self { - __program: program, - stake: accounts.stake, - recipient: accounts.recipient, - clock_sysvar: accounts.clock_sysvar, - stake_history_sysvar: accounts.stake_history_sysvar, - withdraw_authority: accounts.withdraw_authority, - lockup_authority: accounts.lockup_authority, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[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 { - let mut accounts = Vec::with_capacity(6+ remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: WithdrawCpiAccounts<'a, 'b>, + args: WithdrawInstructionArgs, + ) -> Self { + Self { + __program: program, + stake: accounts.stake, + recipient: accounts.recipient, + clock_sysvar: accounts.clock_sysvar, + stake_history_sysvar: accounts.stake_history_sysvar, + withdraw_authority: accounts.withdraw_authority, + lockup_authority: accounts.lockup_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[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 { + 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( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.recipient.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.clock_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.stake_history_sysvar.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.withdraw_authority.key, - true - )); - if let Some(lockup_authority) = self.lockup_authority { + true, + )); + if let Some(lockup_authority) = self.lockup_authority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *lockup_authority.key, - true, + *lockup_authority.key, + true, )); - } - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::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(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.stake.clone()); - account_infos.push(self.recipient.clone()); - account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history_sysvar.clone()); - account_infos.push(self.withdraw_authority.clone()); - if let Some(lockup_authority) = self.lockup_authority { - account_infos.push(lockup_authority.clone()); } - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::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(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.recipient.clone()); + account_infos.push(self.clock_sysvar.clone()); + account_infos.push(self.stake_history_sysvar.clone()); + account_infos.push(self.withdraw_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `Withdraw` via CPI. /// /// ### Accounts: /// - /// 0. `[writable]` stake - /// 1. `[writable]` recipient - /// 2. `[]` clock_sysvar - /// 3. `[]` stake_history_sysvar - /// 4. `[signer]` withdraw_authority - /// 5. `[signer, optional]` lockup_authority +/// 0. `[writable]` stake +/// 1. `[writable]` recipient +/// 2. `[]` clock_sysvar +/// 3. `[]` stake_history_sysvar +/// 4. `[signer]` withdraw_authority +/// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct WithdrawCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawCpiBuilderInstruction { - __program: program, - stake: None, - recipient: None, - clock_sysvar: None, - stake_history_sysvar: None, - withdraw_authority: None, - lockup_authority: None, - lamports: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - /// Stake account from which to withdraw -#[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(WithdrawCpiBuilderInstruction { + __program: program, + stake: None, + recipient: None, + clock_sysvar: None, + stake_history_sysvar: None, + withdraw_authority: None, + lockup_authority: None, + lamports: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Stake account from which to withdraw + #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::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 { - self.instruction.recipient = Some(recipient); - self - } - /// Clock sysvar -#[inline(always)] - pub fn clock_sysvar(&mut self, clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock_sysvar = Some(clock_sysvar); - self - } - /// Stake history sysvar that carries stake warmup/cooldown history -#[inline(always)] - pub fn stake_history_sysvar(&mut self, stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.stake_history_sysvar = Some(stake_history_sysvar); - self - } - /// Withdraw authority -#[inline(always)] - pub fn withdraw_authority(&mut self, withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.withdraw_authority = Some(withdraw_authority); - self - } - /// `[optional account]` -/// Lockup authority, if before lockup expiration -#[inline(always)] - pub fn lockup_authority(&mut self, lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>) -> &mut Self { - self.instruction.lockup_authority = lockup_authority; - self - } - #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &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 { + self.instruction.recipient = Some(recipient); + self + } + /// Clock sysvar + #[inline(always)] + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); + self + } + /// Stake history sysvar that carries stake warmup/cooldown history + #[inline(always)] + pub fn stake_history_sysvar( + &mut self, + stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_history_sysvar = Some(stake_history_sysvar); + self + } + /// Withdraw authority + #[inline(always)] + pub fn withdraw_authority( + &mut self, + withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.withdraw_authority = Some(withdraw_authority); + self + } + /// `[optional account]` + /// Lockup authority, if before lockup expiration + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn lamports(&mut self, lamports: u64) -> &mut Self { self.instruction.lamports = Some(lamports); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::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 { - let args = WithdrawInstructionArgs { - lamports: self.instruction.lamports.clone().expect("lamports is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = WithdrawInstructionArgs { + lamports: self + .instruction + .lamports + .clone() + .expect("lamports is not set"), + }; let instruction = WithdrawCpi { - __program: self.instruction.__program, - - stake: self.instruction.stake.expect("stake is not set"), - - recipient: self.instruction.recipient.expect("recipient is not set"), - - clock_sysvar: self.instruction.clock_sysvar.expect("clock_sysvar is not set"), - - stake_history_sysvar: self.instruction.stake_history_sysvar.expect("stake_history_sysvar is not set"), - - withdraw_authority: self.instruction.withdraw_authority.expect("withdraw_authority is not set"), - - lockup_authority: self.instruction.lockup_authority, - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + stake: self.instruction.stake.expect("stake is not set"), + + recipient: self.instruction.recipient.expect("recipient is not set"), + + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), + + stake_history_sysvar: self + .instruction + .stake_history_sysvar + .expect("stake_history_sysvar is not set"), + + withdraw_authority: self + .instruction + .withdraw_authority + .expect("withdraw_authority is not set"), + + lockup_authority: self.instruction.lockup_authority, + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[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_sysvar: 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>>, - lamports: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __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_sysvar: 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>>, + lamports: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, } - diff --git a/clients/rust/src/generated/mod.rs b/clients/rust/src/generated/mod.rs index 22d4f515..93378cfd 100644 --- a/clients/rust/src/generated/mod.rs +++ b/clients/rust/src/generated/mod.rs @@ -5,9 +5,9 @@ //! //! - pub mod errors; - pub mod instructions; - pub mod programs; - pub mod types; - - pub(crate) use programs::*; +pub mod errors; +pub mod instructions; +pub mod programs; +pub mod types; + +pub(crate) use programs::*; diff --git a/clients/rust/src/generated/programs.rs b/clients/rust/src/generated/programs.rs index 087bb7ec..e3286ac3 100644 --- a/clients/rust/src/generated/programs.rs +++ b/clients/rust/src/generated/programs.rs @@ -7,7 +7,5 @@ use solana_program::{pubkey, pubkey::Pubkey}; - - /// `stake` program ID. - pub const STAKE_ID: Pubkey = pubkey!("Stake11111111111111111111111111111111111111"); - +/// `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 8b291610..e6406ae9 100644 --- a/clients/rust/src/generated/types/authorized.rs +++ b/clients/rust/src/generated/types/authorized.rs @@ -5,17 +5,22 @@ //! //! -use solana_program::pubkey::Pubkey; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Authorized { -#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] -pub staker: Pubkey, -#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] -pub withdrawer: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub staker: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub withdrawer: Pubkey, } - - diff --git a/clients/rust/src/generated/types/delegation.rs b/clients/rust/src/generated/types/delegation.rs index fdb95eca..6099f376 100644 --- a/clients/rust/src/generated/types/delegation.rs +++ b/clients/rust/src/generated/types/delegation.rs @@ -5,20 +5,22 @@ //! //! -use solana_program::pubkey::Pubkey; -use crate::generated::types::Epoch; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::Epoch, + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Delegation { -#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] -pub voter_pubkey: Pubkey, -pub stake: u64, -pub activation_epoch: Epoch, -pub deactivation_epoch: Epoch, -pub warmup_cooldown_rate: f64, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub voter_pubkey: Pubkey, + pub stake: 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 index a9686c89..0060ad16 100644 --- a/clients/rust/src/generated/types/epoch.rs +++ b/clients/rust/src/generated/types/epoch.rs @@ -5,8 +5,4 @@ //! //! - - pub type Epoch = u64; - - diff --git a/clients/rust/src/generated/types/lockup.rs b/clients/rust/src/generated/types/lockup.rs index 76cf4b06..8b364f93 100644 --- a/clients/rust/src/generated/types/lockup.rs +++ b/clients/rust/src/generated/types/lockup.rs @@ -5,19 +5,20 @@ //! //! -use crate::generated::types::UnixTimestamp; -use crate::generated::types::Epoch; -use solana_program::pubkey::Pubkey; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::{Epoch, UnixTimestamp}, + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Lockup { -pub unix_timestamp: UnixTimestamp, -pub epoch: Epoch, -#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] -pub custodian: Pubkey, + pub unix_timestamp: UnixTimestamp, + pub epoch: Epoch, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub custodian: Pubkey, } - - diff --git a/clients/rust/src/generated/types/meta.rs b/clients/rust/src/generated/types/meta.rs index ee68f54d..3bca5fb1 100644 --- a/clients/rust/src/generated/types/meta.rs +++ b/clients/rust/src/generated/types/meta.rs @@ -5,17 +5,15 @@ //! //! -use crate::generated::types::Authorized; -use crate::generated::types::Lockup; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::{Authorized, Lockup}, + borsh::{BorshDeserialize, BorshSerialize}, +}; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Meta { -pub rent_exempt_reserve: u64, -pub authorized: Authorized, -pub lockup: Lockup, + pub rent_exempt_reserve: u64, + pub authorized: Authorized, + pub lockup: Lockup, } - - diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index 85d63fb4..052ebd93 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -5,27 +5,20 @@ //! //! - 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; - 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::*; - pub use self::r#delegation::*; - pub use self::r#epoch::*; - pub use self::r#lockup::*; - pub use self::r#meta::*; - pub use self::r#stake::*; - pub use self::r#stake_authorize::*; - pub use self::r#stake_flags::*; - pub use self::r#stake_state::*; - pub use self::r#stake_state_v2::*; - pub use self::r#unix_timestamp::*; +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; +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#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/stake.rs b/clients/rust/src/generated/types/stake.rs index 460b3b35..0ca55fda 100644 --- a/clients/rust/src/generated/types/stake.rs +++ b/clients/rust/src/generated/types/stake.rs @@ -5,15 +5,14 @@ //! //! -use crate::generated::types::Delegation; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::Delegation, + borsh::{BorshDeserialize, BorshSerialize}, +}; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Stake { -pub delegation: Delegation, -pub credits_observed: u64, + pub delegation: Delegation, + pub credits_observed: u64, } - - diff --git a/clients/rust/src/generated/types/stake_authorize.rs b/clients/rust/src/generated/types/stake_authorize.rs index cac2b03c..aef2f6a0 100644 --- a/clients/rust/src/generated/types/stake_authorize.rs +++ b/clients/rust/src/generated/types/stake_authorize.rs @@ -5,15 +5,16 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; -use num_derive::FromPrimitive; +use { + borsh::{BorshDeserialize, BorshSerialize}, + num_derive::FromPrimitive, +}; -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq, Copy, PartialOrd, Hash, FromPrimitive)] +#[derive( + BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq, Copy, PartialOrd, Hash, FromPrimitive, +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum StakeAuthorize { -Staker, -Withdrawer, + Staker, + Withdrawer, } - - diff --git a/clients/rust/src/generated/types/stake_flags.rs b/clients/rust/src/generated/types/stake_flags.rs index 93f96caf..234dea08 100644 --- a/clients/rust/src/generated/types/stake_flags.rs +++ b/clients/rust/src/generated/types/stake_flags.rs @@ -5,13 +5,10 @@ //! //! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct StakeFlags { -pub bits: u8, + pub bits: u8, } - - diff --git a/clients/rust/src/generated/types/stake_state.rs b/clients/rust/src/generated/types/stake_state.rs index e096251a..0125ac5f 100644 --- a/clients/rust/src/generated/types/stake_state.rs +++ b/clients/rust/src/generated/types/stake_state.rs @@ -5,18 +5,16 @@ //! //! -use crate::generated::types::Meta; -use crate::generated::types::Stake; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::{Meta, Stake}, + borsh::{BorshDeserialize, BorshSerialize}, +}; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum StakeState { -Uninitialized, -Initialized(Meta), -Stake(Meta, Stake), -RewardsPool, + Uninitialized, + Initialized(Meta), + Stake(Meta, Stake), + RewardsPool, } - - diff --git a/clients/rust/src/generated/types/stake_state_v2.rs b/clients/rust/src/generated/types/stake_state_v2.rs index 42424678..4d997448 100644 --- a/clients/rust/src/generated/types/stake_state_v2.rs +++ b/clients/rust/src/generated/types/stake_state_v2.rs @@ -5,19 +5,16 @@ //! //! -use crate::generated::types::Meta; -use crate::generated::types::Stake; -use crate::generated::types::StakeFlags; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use { + crate::generated::types::{Meta, Stake, StakeFlags}, + borsh::{BorshDeserialize, BorshSerialize}, +}; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum StakeStateV2 { -Uninitialized, -Initialized(Meta), -Stake(Meta, Stake, StakeFlags), -RewardsPool, + Uninitialized, + Initialized(Meta), + Stake(Meta, Stake, StakeFlags), + RewardsPool, } - - diff --git a/clients/rust/src/generated/types/unix_timestamp.rs b/clients/rust/src/generated/types/unix_timestamp.rs index 25ce7a8b..62d0860b 100644 --- a/clients/rust/src/generated/types/unix_timestamp.rs +++ b/clients/rust/src/generated/types/unix_timestamp.rs @@ -5,8 +5,4 @@ //! //! - - pub type UnixTimestamp = i64; - - diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 1e631874..1fc98cf4 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -18,8 +18,8 @@ program-id = "Stake11111111111111111111111111111111111111" [dependencies] borsh = { version = "1.5.7", features = ["derive", "unstable__schema"], optional = true } -codama = "0.6.4" -codama-macros = "0.6.4" +codama = { version = "0.6.4", optional = true } +codama-macros = { version = "0.6.4", optional = true } num-traits = "0.2" serde = { version = "1.0.210", optional = true } serde_derive = { version = "1.0.210", optional = true } @@ -34,9 +34,8 @@ solana-system-interface = "2.0.0" solana-sysvar = { version = "3.0.0", optional = true } solana-sysvar-id = { version = "3.0.0", optional = true } -[build-dependencies] -codama = "0.6.4" -serde_json = "1.0" +[target.'cfg(not(target_os = "solana"))'.dependencies] +serde_json = { version = "1.0", optional = true } [dev-dependencies] anyhow = "1" @@ -73,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/build.rs b/interface/src/bin/generate-idl.rs similarity index 63% rename from interface/build.rs rename to interface/src/bin/generate-idl.rs index 251381f3..f1df8977 100644 --- a/interface/build.rs +++ b/interface/src/bin/generate-idl.rs @@ -1,20 +1,12 @@ -//! Codama IDL build script. - +//! Codama IDL generation binary. +#[cfg(feature = "codama")] use { codama::Codama, std::{env, fs, path::Path}, }; -fn main() { - println!("cargo:rerun-if-changed=src/"); - println!("cargo:rerun-if-env-changed=GENERATE_IDL"); - - if let Err(e) = generate_idl() { - println!("cargo:warning=Failed to generate IDL: {}", e) - } -} - -fn generate_idl() -> Result<(), Box> { +#[cfg(feature = "codama")] +fn main() -> Result<(), Box> { // Generate IDL. let manifest_dir = env::var("CARGO_MANIFEST_DIR")?; let crate_path = Path::new(&manifest_dir); @@ -30,6 +22,11 @@ fn generate_idl() -> Result<(), Box> { let idl_path = Path::new(&manifest_dir).join("idl.json"); fs::write(&idl_path, formatted_json)?; - println!("cargo:warning=IDL written to: {}", idl_path.display()); + 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 fb6a5354..a31e689a 100644 --- a/interface/src/error.rs +++ b/interface/src/error.rs @@ -1,11 +1,13 @@ +#[cfg(feature = "codama")] +use codama_macros::CodamaErrors; use { - codama_macros::CodamaErrors, num_traits::{FromPrimitive, ToPrimitive}, solana_program_error::ProgramError, }; /// Reasons the Stake might have had an error. -#[derive(CodamaErrors, Clone, Debug, PartialEq, Eq)] +#[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", @@ -14,102 +16,153 @@ use { pub enum StakeError { // 0 /// Not enough credits to redeem. - #[codama(error(code = 0, message = "Not enough credits to redeem"))] + #[cfg_attr( + feature = "codama", + codama(error(code = 0, message = "Not enough credits to redeem")) + )] NoCreditsToRedeem, /// Lockup has not yet expired. - #[codama(error(code = 1, message = "Lockup has not yet expired"))] + #[cfg_attr( + feature = "codama", + codama(error(code = 1, message = "Lockup has not yet expired")) + )] LockupInForce, /// Stake already deactivated. - #[codama(error(code = 2, message = "Stake already deactivated"))] + #[cfg_attr( + feature = "codama", + codama(error(code = 2, message = "Stake already deactivated")) + )] AlreadyDeactivated, /// One re-delegation permitted per epoch. - #[codama(error(code = 3, message = "One re-delegation permitted per epoch"))] + #[cfg_attr( + feature = "codama", + codama(error(code = 3, message = "One re-delegation permitted per epoch")) + )] TooSoonToRedelegate, /// Split amount is more than is staked. - #[codama(error(code = 4, message = "Split amount is more than is staked"))] + #[cfg_attr( + feature = "codama", + codama(error(code = 4, message = "Split amount is more than is staked")) + )] InsufficientStake, // 5 /// Stake account with transient stake cannot be merged. - #[codama(error( - code = 5, - message = "Stake account with transient stake cannot be merged" - ))] + #[cfg_attr( + feature = "codama", + codama(error( + code = 5, + message = "Stake account with transient stake cannot be merged" + )) + )] MergeTransientStake, /// Stake account merge failed due to different authority, lockups or state. - #[codama(error( - code = 6, - message = "Stake account merge failed due to different authority, lockups or state" - ))] + #[cfg_attr( + feature = "codama", + codama(error( + code = 6, + message = "Stake account merge failed due to different authority, lockups or state" + )) + )] MergeMismatch, /// Custodian address not present. - #[codama(error(code = 7, message = "Custodian address not present"))] + #[cfg_attr( + feature = "codama", + codama(error(code = 7, message = "Custodian address not present")) + )] CustodianMissing, /// Custodian signature not present. - #[codama(error(code = 8, message = "Custodian signature not present"))] + #[cfg_attr( + feature = "codama", + codama(error(code = 8, message = "Custodian signature not present")) + )] CustodianSignatureMissing, /// Insufficient voting activity in the reference vote account. - #[codama(error( - code = 9, - message = "Insufficient voting activity in the reference vote account" - ))] + #[cfg_attr( + feature = "codama", + codama(error( + code = 9, + message = "Insufficient voting activity in the reference vote account" + )) + )] InsufficientReferenceVotes, // 10 /// Stake account is not delegated to the provided vote account. - #[codama(error( - code = 10, - message = "Stake account is not delegated to the provided vote account" - ))] + #[cfg_attr( + feature = "codama", + codama(error( + code = 10, + 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. - #[codama(error( - code = 11, - message = "Stake account has not been delinquent for the minimum epochs required for deactivation" - ))] + #[cfg_attr( + feature = "codama", + codama(error( + code = 11, + message = "Stake account has not been delinquent for the minimum epochs required for deactivation" + )) + )] MinimumDelinquentEpochsForDeactivationNotMet, /// Delegation amount is less than the minimum. - #[codama(error(code = 12, message = "Delegation amount is less than the minimum"))] + #[cfg_attr( + feature = "codama", + codama(error(code = 12, message = "Delegation amount is less than the minimum")) + )] InsufficientDelegation, /// Stake account with transient or inactive stake cannot be redelegated. - #[codama(error( - code = 13, - message = "Stake account with transient or inactive stake cannot be redelegated" - ))] + #[cfg_attr( + feature = "codama", + codama(error( + code = 13, + message = "Stake account with transient or inactive stake cannot be redelegated" + )) + )] RedelegateTransientOrInactiveStake, /// Stake redelegation to the same vote account is not permitted. - #[codama(error( - code = 14, - message = "Stake redelegation to the same vote account is not permitted" - ))] + #[cfg_attr( + feature = "codama", + codama(error( + code = 14, + message = "Stake redelegation to the same vote account is not permitted" + )) + )] RedelegateToSameVoteAccount, // 15 /// Redelegated stake must be fully activated before deactivation. - #[codama(error( - code = 15, - message = "Redelegated stake must be fully activated before deactivation" - ))] + #[cfg_attr( + feature = "codama", + codama(error( + code = 15, + message = "Redelegated stake must be fully activated before deactivation" + )) + )] RedelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted, /// Stake action is not permitted while the epoch rewards period is active. - #[codama(error( - code = 16, - message = "Stake action is not permitted while the epoch rewards period is active" - ))] + #[cfg_attr( + feature = "codama", + codama(error( + code = 16, + 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 1339ddbe..1206ea48 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -3,9 +3,10 @@ // 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}, - codama_macros::{codama, CodamaInstructions, CodamaType}, solana_clock::{Epoch, UnixTimestamp}, solana_pubkey::Pubkey, }; @@ -30,7 +31,8 @@ const RENT_ID: Pubkey = Pubkey::from_str_const("SysvarRent1111111111111111111111 const STAKE_HISTORY_ID: Pubkey = Pubkey::from_str_const("SysvarStakeHistory1111111111111111111111111"); -#[derive(CodamaInstructions, Debug, PartialEq, Eq, Clone)] +#[cfg_attr(feature = "codama", derive(CodamaInstructions))] +#[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) @@ -45,8 +47,11 @@ pub enum StakeInstruction { /// [`Authorized`] carries pubkeys that must sign staker transactions /// and withdrawer transactions; [`Lockup`] carries information about /// withdrawal restrictions. - #[codama(account(name = "stake", writable, docs = "Uninitialized stake account"))] - #[codama(account(name = "rent_sysvar", docs = "Rent sysvar", default_value = sysvar("rent")))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Uninitialized stake account")) + )] + #[cfg_attr(feature = "codama", codama(account(name = "rent_sysvar", docs = "Rent sysvar", default_value = sysvar("rent"))))] Initialize { arg0: Authorized, arg1: Lockup }, /// Authorize a key to manage stake or withdrawal @@ -57,15 +62,24 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` The stake or withdraw authority /// 3. Optional: `[SIGNER]` Lockup authority, if updating `StakeAuthorize::Withdrawer` before /// lockup expiration - #[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" - ))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Stake account to be updated")) + )] + #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] + #[cfg_attr( + feature = "codama", + codama(account(name = "authority", signer, docs = "The stake or withdraw authority")) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + )) + )] Authorize { arg0: Pubkey, arg1: StakeAuthorize }, /// Delegate a stake to a particular vote account @@ -80,23 +94,35 @@ 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. - #[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( + #[cfg_attr( + feature = "codama", + codama(account( + name = "stake", + writable, + docs = "Initialized stake account to be delegated" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "vote", + docs = "Vote account to which this stake will be delegated" + )) + )] + #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] + #[cfg_attr(feature = "codama", 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"))] + )))] + #[cfg_attr( + feature = "codama", + codama(account(name = "unused", docs = "Unused account, formerly the stake config")) + )] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] DelegateStake, /// Split `u64` tokens and stake off a stake account into another stake account. @@ -105,17 +131,26 @@ 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 - #[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"))] + #[cfg_attr( + feature = "codama", + codama(account( + name = "stake", + writable, + docs = "Stake account to be split; must be in the Initialized or Stake state" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "split_stake", + writable, + docs = "Uninitialized stake account that will take the split-off amount" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] Split { lamports: u64 }, /// Withdraw unstaked lamports from the stake account @@ -130,25 +165,37 @@ pub enum StakeInstruction { /// /// The `u64` is the portion of the stake account balance to be withdrawn, /// must be `<= StakeAccount.lamports - staked_lamports`. - #[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( + #[cfg_attr( + feature = "codama", + codama(account( + name = "stake", + writable, + docs = "Stake account from which to withdraw" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account(name = "recipient", writable, docs = "Recipient account")) + )] + #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] + #[cfg_attr(feature = "codama", codama(account( name = "stake_history_sysvar", 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" - ))] + )))] + #[cfg_attr( + feature = "codama", + codama(account(name = "withdraw_authority", signer, docs = "Withdraw authority")) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if before lockup expiration" + )) + )] Withdraw { lamports: u64 }, /// Deactivates the stake in the account @@ -157,13 +204,19 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Delegated stake account /// 1. `[]` Clock sysvar /// 2. `[SIGNER]` Stake authority - #[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"))] + #[cfg_attr( + feature = "codama", + codama(account( + name = "stake", + writable, + docs = "Delegated stake account to be deactivated" + )) + )] + #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] Deactivate, /// Set stake lockup @@ -174,12 +227,18 @@ pub enum StakeInstruction { /// # Account references /// 0. `[WRITE]` Initialized stake account /// 1. `[SIGNER]` Lockup authority or withdraw authority - #[codama(account(name = "stake", writable, docs = "Initialized stake account"))] - #[codama(account( - name = "authority", - signer, - docs = "Lockup authority or withdraw authority" - ))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Initialized stake account")) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "authority", + signer, + docs = "Lockup authority or withdraw authority" + )) + )] SetLockup { lockup_args: LockupArgs }, /// Merge two stake accounts. @@ -206,23 +265,32 @@ pub enum StakeInstruction { /// 2. `[]` Clock sysvar /// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history /// 4. `[SIGNER]` Stake authority - #[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( + #[cfg_attr( + feature = "codama", + codama(account( + name = "destination_stake", + writable, + docs = "Destination stake account for the merge" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "source_stake", + writable, + docs = "Source stake account for to merge. This account will be drained" + )) + )] + #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] + #[cfg_attr(feature = "codama", codama(account( name = "stake_history_sysvar", docs = "Stake history sysvar that carries stake warmup/cooldown history", default_value = sysvar("stake_history") - ))] - #[codama(account(name = "stake_authority", signer, docs = "Stake authority"))] + )))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] Merge, /// Authorize a key to manage stake or withdrawal with a derived key @@ -233,19 +301,28 @@ pub enum StakeInstruction { /// 2. `[]` Clock sysvar /// 3. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration - #[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" - ))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Stake account to be updated")) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "base", + signer, + docs = "Base key of stake or withdraw authority" + )) + )] + #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] + #[cfg_attr( + feature = "codama", + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + )) + )] AuthorizeWithSeed { authorize_with_seed_args: AuthorizeWithSeedArgs, }, @@ -260,10 +337,22 @@ pub enum StakeInstruction { /// 1. `[]` Rent sysvar /// 2. `[]` The stake authority /// 3. `[SIGNER]` The withdraw authority - #[codama(account(name = "stake", writable, docs = "Uninitialized stake account"))] - #[codama(account(name = "rent_sysvar", docs = "Rent sysvar"))] - #[codama(account(name = "stake_authority", docs = "The stake authority"))] - #[codama(account(name = "withdraw_authority", signer, docs = "The withdraw authority"))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Uninitialized stake account")) + )] + #[cfg_attr( + feature = "codama", + codama(account(name = "rent_sysvar", docs = "Rent sysvar")) + )] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake_authority", docs = "The stake authority")) + )] + #[cfg_attr( + feature = "codama", + codama(account(name = "withdraw_authority", signer, docs = "The withdraw authority")) + )] InitializeChecked, /// Authorize a key to manage stake or withdrawal @@ -278,20 +367,32 @@ pub enum StakeInstruction { /// 3. `[SIGNER]` The new stake or withdraw authority /// 4. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration - #[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" - ))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Stake account to be updated")) + )] + #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] + #[cfg_attr( + feature = "codama", + codama(account(name = "authority", signer, docs = "The stake or withdraw authority")) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "new_authority", + signer, + docs = "The new stake or withdraw authority" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + )) + )] AuthorizeChecked { stake_authorize: StakeAuthorize }, /// Authorize a key to manage stake or withdrawal with a derived key @@ -306,24 +407,36 @@ pub enum StakeInstruction { /// 3. `[SIGNER]` The new stake or withdraw authority /// 4. Optional: `[SIGNER]` Lockup authority, if updating [`StakeAuthorize::Withdrawer`] /// before lockup expiration - #[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" - ))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Stake account to be updated")) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "base", + signer, + docs = "Base key of stake or withdraw authority" + )) + )] + #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] + #[cfg_attr( + feature = "codama", + codama(account( + name = "new_authority", + signer, + docs = "The new stake or withdraw authority" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "lockup_authority", + optional, + signer, + docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" + )) + )] AuthorizeCheckedWithSeed { authorize_checked_with_seed_args: AuthorizeCheckedWithSeedArgs, }, @@ -340,18 +453,27 @@ pub enum StakeInstruction { /// 0. `[WRITE]` Initialized stake account /// 1. `[SIGNER]` Lockup authority or withdraw authority /// 2. Optional: `[SIGNER]` New lockup authority - #[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" - ))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Initialized stake account")) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "authority", + signer, + docs = "Lockup authority or withdraw authority" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "new_authority", + optional, + signer, + docs = "New lockup authority" + )) + )] SetLockupChecked { lockup_checked_args: LockupCheckedArgs, }, @@ -379,15 +501,24 @@ pub enum StakeInstruction { /// 1. `[]` Delinquent vote account for the delegated stake account /// 2. `[]` Reference vote account that has voted at least once in the last /// `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs - #[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" - ))] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake", writable, docs = "Delegated stake account")) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "delinquent_vote", + docs = "Delinquent vote account for the delegated stake account" + )) + )] + #[cfg_attr( + feature = "codama", + 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. @@ -433,13 +564,22 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of the stake to move, which may be the entire delegation - #[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"))] + #[cfg_attr( + feature = "codama", + codama(account(name = "sourceStake", writable, docs = "Active source stake account")) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "destinationStake", + writable, + docs = "Active or inactive destination stake account" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] // sadly named `args` to avoid breaking users of old IDL MoveStake { args: u64 }, @@ -456,23 +596,33 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of available lamports to move - #[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"))] + #[cfg_attr( + feature = "codama", + codama(account( + name = "source_stake", + writable, + docs = "Active or inactive source stake account" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account( + name = "destination_stake", + writable, + docs = "Mergeable destination stake account" + )) + )] + #[cfg_attr( + feature = "codama", + codama(account(name = "stake_authority", signer, docs = "Stake authority")) + )] // sadly named `args` to avoid breaking users of old IDL MoveLamports { args: u64 }, } -#[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] -#[codama(name = "lockupParams")] +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] +#[cfg_attr(feature = "codama", codama(name = "lockupParams"))] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) @@ -483,8 +633,9 @@ pub struct LockupArgs { pub custodian: Option, } -#[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] -#[codama(name = "lockupCheckedParams")] +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] +#[cfg_attr(feature = "codama", codama(name = "lockupCheckedParams"))] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) @@ -494,8 +645,9 @@ pub struct LockupCheckedArgs { pub epoch: Option, } -#[derive(CodamaType, Debug, PartialEq, Eq, Clone)] -#[codama(name = "authorizeWithSeedParams")] +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[derive(Debug, PartialEq, Eq, Clone)] +#[cfg_attr(feature = "codama", codama(name = "authorizeWithSeedParams"))] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) @@ -507,8 +659,9 @@ pub struct AuthorizeWithSeedArgs { pub authority_owner: Pubkey, } -#[derive(CodamaType, Debug, PartialEq, Eq, Clone)] -#[codama(name = "authorizeCheckedWithSeedParams")] +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[derive(Debug, PartialEq, Eq, Clone)] +#[cfg_attr(feature = "codama", codama(name = "authorizeCheckedWithSeedParams"))] #[cfg_attr( feature = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) diff --git a/interface/src/lib.rs b/interface/src/lib.rs index 76315784..edfd08b3 100644 --- a/interface/src/lib.rs +++ b/interface/src/lib.rs @@ -14,8 +14,9 @@ pub mod state; pub mod sysvar; pub mod tools; +#[cfg(feature = "codama")] use codama_macros::codama; -#[codama(name = "stake")] +#[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 daef514f..05ad9053 100644 --- a/interface/src/stake_flags.rs +++ b/interface/src/stake_flags.rs @@ -2,7 +2,8 @@ use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; /// Additional flags for stake state. -#[derive(codama_macros::CodamaType, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Debug)] +#[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", diff --git a/interface/src/state.rs b/interface/src/state.rs index 6dbf6272..13ec0b34 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, @@ -13,7 +15,6 @@ use { stake_flags::StakeFlags, stake_history::{StakeHistoryEntry, StakeHistoryGetEntry}, }, - codama_macros::{codama, CodamaType}, solana_clock::{Clock, Epoch, UnixTimestamp}, solana_instruction::error::InstructionError, solana_pubkey::Pubkey, @@ -80,7 +81,8 @@ macro_rules! impl_borsh_stake_state { } }; } -#[derive(CodamaType, Debug, Default, PartialEq, Clone, Copy)] +#[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 = "serde", @@ -91,7 +93,7 @@ macro_rules! impl_borsh_stake_state { since = "1.17.0", note = "Please use `StakeStateV2` instead, and match the third `StakeFlags` field when matching `StakeStateV2::Stake` to resolve any breakage. For example, `if let StakeState::Stake(meta, stake)` becomes `if let StakeStateV2::Stake(meta, stake, _stake_flags)`." )] -#[codama(enum_discriminator(size = number(u32)))] +#[cfg_attr(feature = "codama", codama(enum_discriminator(size = number(u32))))] pub enum StakeState { #[default] Uninitialized, @@ -142,14 +144,15 @@ impl StakeState { } } -#[derive(CodamaType, Debug, Default, PartialEq, Clone, Copy)] +#[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 = "serde", derive(serde_derive::Deserialize, serde_derive::Serialize) )] #[allow(clippy::large_enum_variant)] -#[codama(enum_discriminator(size = number(u32)))] +#[cfg_attr(feature = "codama", codama(enum_discriminator(size = number(u32))))] pub enum StakeStateV2 { #[default] Uninitialized, @@ -262,19 +265,21 @@ impl StakeStateV2 { } } -#[derive(CodamaType, Debug, PartialEq, Eq, Clone, Copy)] +#[cfg_attr(feature = "codama", derive(CodamaType))] +#[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) )] -#[codama(enum_discriminator(size = number(u32)))] +#[cfg_attr(feature = "codama", codama(enum_discriminator(size = number(u32))))] pub enum StakeAuthorize { Staker, Withdrawer, } -#[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] +#[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", @@ -305,7 +310,8 @@ impl Lockup { } } -#[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] +#[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", @@ -387,7 +393,8 @@ impl Authorized { } } -#[derive(CodamaType, Default, Debug, PartialEq, Eq, Clone, Copy)] +#[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", @@ -441,7 +448,8 @@ impl Meta { } } -#[derive(CodamaType, Debug, PartialEq, Clone, Copy)] +#[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", @@ -680,7 +688,8 @@ impl Delegation { } } -#[derive(CodamaType, Debug, Default, PartialEq, Clone, Copy)] +#[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", From 3ec54ab684a200507c1cb3d03ef0ecd0e884f91a Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:28:07 +0000 Subject: [PATCH 19/27] spellcheck --- scripts/solana.dic | 1 + 1 file changed, 1 insertion(+) 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 From a7e1cf7ca8190d8fe943e2c6650bc48e69a4ab52 Mon Sep 17 00:00:00 2001 From: Peter Keay <96253492+rustopian@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:36:38 +0000 Subject: [PATCH 20/27] re-sync (#209) --- Cargo.lock | 96 ++-- clients/js/pnpm-lock.yaml | 118 ++--- interface/Cargo.toml | 2 +- package.json | 6 +- pnpm-lock.yaml | 482 ++++++++++-------- program/Cargo.toml | 2 +- program/src/helpers/delegate.rs | 42 -- program/src/processor.rs | 35 +- .../tests/fixtures/solana_stake_program.so | 1 - 9 files changed, 392 insertions(+), 392 deletions(-) delete mode 120000 program/tests/fixtures/solana_stake_program.so diff --git a/Cargo.lock b/Cargo.lock index 1ea003ed..f36e293c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -143,7 +143,7 @@ dependencies = [ "solana-secp256k1-recover 3.0.0", "solana-sha256-hasher 3.0.0", "solana-stable-layout 3.0.0", - "solana-stake-interface 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-stake-interface 2.0.1", "solana-svm-callback", "solana-svm-feature-set", "solana-svm-log-collector", @@ -3033,7 +3033,7 @@ dependencies = [ "solana-rent 3.0.0", "solana-sdk-ids 3.0.0", "solana-slot-hashes 3.0.0", - "solana-stake-interface 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-stake-interface 2.0.1", "solana-stake-program 3.0.10", "solana-svm-callback", "solana-svm-log-collector", @@ -6448,7 +6448,7 @@ dependencies = [ "solana-sbpf", "solana-sdk-ids 3.0.0", "solana-slot-hashes 3.0.0", - "solana-stake-interface 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-stake-interface 2.0.1", "solana-svm-callback", "solana-svm-feature-set", "solana-svm-log-collector", @@ -6510,7 +6510,7 @@ dependencies = [ "solana-sdk-ids 3.0.0", "solana-signer", "solana-stable-layout 3.0.0", - "solana-stake-interface 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-stake-interface 2.0.1", "solana-svm", "solana-svm-log-collector", "solana-svm-timings", @@ -6883,7 +6883,7 @@ dependencies = [ "solana-signer", "solana-slot-hashes 3.0.0", "solana-slot-history 3.0.0", - "solana-stake-interface 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-stake-interface 2.0.1", "solana-stake-program 3.0.10", "solana-svm", "solana-svm-callback", @@ -7337,6 +7337,26 @@ dependencies = [ [[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", + "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", +] + +[[package]] +name = "solana-stake-interface" +version = "2.0.2" dependencies = [ "anyhow", "assert_matches", @@ -7360,7 +7380,7 @@ dependencies = [ "solana-program-error 3.0.0", "solana-pubkey 3.0.0", "solana-sdk-ids 3.0.0", - "solana-stake-interface 2.0.1", + "solana-stake-interface 2.0.2", "solana-system-interface 2.0.0", "solana-sysvar 3.0.0", "solana-sysvar-id 3.0.0", @@ -7371,28 +7391,37 @@ dependencies = [ ] [[package]] -name = "solana-stake-interface" -version = "2.0.1" +name = "solana-stake-program" +version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f912ae679b683365348dea482dbd9468d22ff258b554fd36e3d3683c2122e3" +checksum = "06f174d24c78d8874c4c28cb855bfe87f720c7e40362ea1b856c4a65abdc6209" dependencies = [ - "borsh 1.5.7", - "num-traits", - "serde", - "serde_derive", + "agave-feature-set", + "bincode", + "log", + "solana-account 3.2.0", + "solana-bincode 3.0.0", "solana-clock 3.0.0", - "solana-cpi 3.0.0", + "solana-config-interface", + "solana-genesis-config", "solana-instruction 3.0.0", - "solana-program-error 3.0.0", + "solana-native-token 3.0.0", + "solana-packet", + "solana-program-runtime", "solana-pubkey 3.0.0", - "solana-system-interface 2.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.0.0", + "solana-stake-interface 2.0.1", + "solana-svm-log-collector", + "solana-svm-type-overrides", "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-transaction-context", + "solana-vote-interface 3.0.0", ] [[package]] name = "solana-stake-program" -version = "1.0.0" +version = "4.0.0" dependencies = [ "agave-feature-set", "arbitrary", @@ -7422,7 +7451,7 @@ dependencies = [ "solana-sdk-ids 3.0.0", "solana-signature", "solana-signer", - "solana-stake-interface 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-stake-interface 2.0.1", "solana-svm-log-collector", "solana-system-interface 2.0.0", "solana-sysvar 3.0.0", @@ -7432,35 +7461,6 @@ dependencies = [ "test-case", ] -[[package]] -name = "solana-stake-program" -version = "3.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06f174d24c78d8874c4c28cb855bfe87f720c7e40362ea1b856c4a65abdc6209" -dependencies = [ - "agave-feature-set", - "bincode", - "log", - "solana-account 3.2.0", - "solana-bincode 3.0.0", - "solana-clock 3.0.0", - "solana-config-interface", - "solana-genesis-config", - "solana-instruction 3.0.0", - "solana-native-token 3.0.0", - "solana-packet", - "solana-program-runtime", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-stake-interface 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-svm-log-collector", - "solana-svm-type-overrides", - "solana-sysvar 3.0.0", - "solana-transaction-context", - "solana-vote-interface 3.0.0", -] - [[package]] name = "solana-streamer" version = "3.0.10" diff --git a/clients/js/pnpm-lock.yaml b/clients/js/pnpm-lock.yaml index b7a295a9..798d6279 100644 --- a/clients/js/pnpm-lock.yaml +++ b/clients/js/pnpm-lock.yaml @@ -37,13 +37,13 @@ importers: version: 3.6.2 rimraf: specifier: ^6.0.1 - version: 6.1.0 + version: 6.1.2 tsup: specifier: ^8.1.2 - version: 8.5.1(typescript@5.9.3)(yaml@2.8.1) + version: 8.5.1(typescript@5.9.3)(yaml@2.8.2) typedoc: specifier: ^0.28.14 - version: 0.28.14(typescript@5.9.3) + version: 0.28.15(typescript@5.9.3) typescript: specifier: ^5.5.3 version: 5.9.3 @@ -234,8 +234,8 @@ packages: resolution: {integrity: sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@gerrit0/mini-shiki@3.13.1': - resolution: {integrity: sha512-fDWM5QQc70jwBIt/WYMybdyXdyBmoJe7r1hpM+V/bHnyla79sygVDK2/LlVxIPc4n5FA3B5Wzt7AQH2+psNphg==} + '@gerrit0/mini-shiki@3.17.1': + resolution: {integrity: sha512-u7gBnLsvhyVpwR4G8LcSHDlPn8Hg8zNeuzzR4+p2AxvQrQ+BDGo/mLMCpo58VFiIbl8+ie42fqunDclZ4RxNWw==} '@humanwhocodes/config-array@0.13.0': resolution: {integrity: sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==} @@ -422,17 +422,17 @@ packages: '@sec-ant/readable-stream@0.4.1': resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==} - '@shikijs/engine-oniguruma@3.13.0': - resolution: {integrity: sha512-O42rBGr4UDSlhT2ZFMxqM7QzIU+IcpoTMzb3W7AlziI1ZF7R8eS2M0yt5Ry35nnnTX/LTLXFPUjRFCIW+Operg==} + '@shikijs/engine-oniguruma@3.18.0': + resolution: {integrity: sha512-15+O2iy+nYU/IdiBIExXuK0JJABa/8tdnRDODBmLhdygQ43aCuipN5N9vTfS8jvkMByHMR09b5jtX2la0CCoOA==} - '@shikijs/langs@3.13.0': - resolution: {integrity: sha512-672c3WAETDYHwrRP0yLy3W1QYB89Hbpj+pO4KhxK6FzIrDI2FoEXNiNCut6BQmEApYLfuYfpgOZaqbY+E9b8wQ==} + '@shikijs/langs@3.18.0': + resolution: {integrity: sha512-Deq7ZoYBtimN0M8pD5RU5TKz7DhUSTPtQOBuJpMxPDDJ+MJ7nT90DEmhDM2V0Nzp6DjfTAd+Z7ibpzr8arWqiA==} - '@shikijs/themes@3.13.0': - resolution: {integrity: sha512-Vxw1Nm1/Od8jyA7QuAenaV78BG2nSr3/gCGdBkLpfLscddCkzkL36Q5b67SrLLfvAJTOUzW39x4FHVCFriPVgg==} + '@shikijs/themes@3.18.0': + resolution: {integrity: sha512-wzg6vNniXC5J4ChNBJJIZFTWxmrERJMWknehmM++0OAKJqZ41WpnO7PmPOumvMsUaL1SC08Nb/JVdaJd2aTsZg==} - '@shikijs/types@3.13.0': - resolution: {integrity: sha512-oM9P+NCFri/mmQ8LoFGVfVyemm5Hi27330zuOBp0annwJdKH1kOLndw3zCtAVDehPLg9fKqoEx3Ht/wNZxolfw==} + '@shikijs/types@3.18.0': + resolution: {integrity: sha512-YLmpuroH06TpvqRXKR0YqlI0nQ56c8+BO/m9A9ht36WRdxmML4ivUsnpXuJU7PiClLRD2M66ilY2YJ0KE+8q7A==} '@shikijs/vscode-textmate@10.0.2': resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==} @@ -1288,14 +1288,13 @@ packages: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} - glob@10.4.5: - resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} + glob@10.5.0: + resolution: {integrity: sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==} hasBin: true - glob@11.0.3: - resolution: {integrity: sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==} + glob@13.0.0: + resolution: {integrity: sha512-tvZgpqk6fz4BaNZ66ZsRaZnbHvP/jG3uKJvAZOwEVUL4RTA5nJeeLYfyN9/VA8NX/V3IBG+hkeuGpKjvELkVhA==} engines: {node: 20 || >=22} - hasBin: true glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} @@ -1415,10 +1414,6 @@ packages: jackspeak@3.4.3: resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} - jackspeak@4.1.1: - resolution: {integrity: sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==} - engines: {node: 20 || >=22} - joycon@3.1.1: resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} engines: {node: '>=10'} @@ -1644,8 +1639,8 @@ packages: resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} engines: {node: '>=16 || 14 >=14.18'} - path-scurry@2.0.0: - resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==} + path-scurry@2.0.1: + resolution: {integrity: sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==} engines: {node: 20 || >=22} path-type@4.0.0: @@ -1756,8 +1751,8 @@ packages: deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true - rimraf@6.1.0: - resolution: {integrity: sha512-DxdlA1bdNzkZK7JiNWH+BAx1x4tEJWoTofIopFo6qWUU94jYrFZ0ubY05TqH3nWPJ1nKa1JWVFDINZ3fnrle/A==} + rimraf@6.1.2: + resolution: {integrity: sha512-cFCkPslJv7BAXJsYlK1dZsbP8/ZNLkCAQ0bi1hf5EKX2QHegmDFEFA6QhuYJlk7UDdc+02JjO80YSOrWPpw06g==} engines: {node: 20 || >=22} hasBin: true @@ -1948,8 +1943,8 @@ packages: resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==} engines: {node: '>=10'} - typedoc@0.28.14: - resolution: {integrity: sha512-ftJYPvpVfQvFzpkoSfHLkJybdA/geDJ8BGQt/ZnkkhnBYoYW6lBgPQXu6vqLxO4X75dA55hX8Af847H5KXlEFA==} + typedoc@0.28.15: + resolution: {integrity: sha512-mw2/2vTL7MlT+BVo43lOsufkkd2CJO4zeOSuWQQsiXoV2VuEn7f6IZp2jsUDPmBMABpgR0R5jlcJ2OGEFYmkyg==} engines: {node: '>= 18', pnpm: '>= 10'} hasBin: true peerDependencies: @@ -2030,8 +2025,8 @@ packages: resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} engines: {node: '>=18'} - yaml@2.8.1: - resolution: {integrity: sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==} + yaml@2.8.2: + resolution: {integrity: sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==} engines: {node: '>= 14.6'} hasBin: true @@ -2164,12 +2159,12 @@ snapshots: '@eslint/js@8.57.1': {} - '@gerrit0/mini-shiki@3.13.1': + '@gerrit0/mini-shiki@3.17.1': dependencies: - '@shikijs/engine-oniguruma': 3.13.0 - '@shikijs/langs': 3.13.0 - '@shikijs/themes': 3.13.0 - '@shikijs/types': 3.13.0 + '@shikijs/engine-oniguruma': 3.18.0 + '@shikijs/langs': 3.18.0 + '@shikijs/themes': 3.18.0 + '@shikijs/types': 3.18.0 '@shikijs/vscode-textmate': 10.0.2 '@humanwhocodes/config-array@0.13.0': @@ -2321,20 +2316,20 @@ snapshots: '@sec-ant/readable-stream@0.4.1': {} - '@shikijs/engine-oniguruma@3.13.0': + '@shikijs/engine-oniguruma@3.18.0': dependencies: - '@shikijs/types': 3.13.0 + '@shikijs/types': 3.18.0 '@shikijs/vscode-textmate': 10.0.2 - '@shikijs/langs@3.13.0': + '@shikijs/langs@3.18.0': dependencies: - '@shikijs/types': 3.13.0 + '@shikijs/types': 3.18.0 - '@shikijs/themes@3.13.0': + '@shikijs/themes@3.18.0': dependencies: - '@shikijs/types': 3.13.0 + '@shikijs/types': 3.18.0 - '@shikijs/types@3.13.0': + '@shikijs/types@3.18.0': dependencies: '@shikijs/vscode-textmate': 10.0.2 '@types/hast': 3.0.4 @@ -2878,7 +2873,7 @@ snapshots: async-sema: 3.1.1 bindings: 1.5.0 estree-walker: 2.0.2 - glob: 10.4.5 + glob: 10.5.0 graceful-fs: 4.2.11 node-gyp-build: 4.8.4 picomatch: 4.0.3 @@ -3412,7 +3407,7 @@ snapshots: dependencies: is-glob: 4.0.3 - glob@10.4.5: + glob@10.5.0: dependencies: foreground-child: 3.3.1 jackspeak: 3.4.3 @@ -3421,14 +3416,11 @@ snapshots: package-json-from-dist: 1.0.1 path-scurry: 1.11.1 - glob@11.0.3: + glob@13.0.0: dependencies: - foreground-child: 3.3.1 - jackspeak: 4.1.1 minimatch: 10.1.1 minipass: 7.1.2 - package-json-from-dist: 1.0.1 - path-scurry: 2.0.0 + path-scurry: 2.0.1 glob@7.2.3: dependencies: @@ -3532,10 +3524,6 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 - jackspeak@4.1.1: - dependencies: - '@isaacs/cliui': 8.0.2 - joycon@3.1.1: {} js-string-escape@1.0.1: {} @@ -3733,7 +3721,7 @@ snapshots: lru-cache: 10.4.3 minipass: 7.1.2 - path-scurry@2.0.0: + path-scurry@2.0.1: dependencies: lru-cache: 11.2.2 minipass: 7.1.2 @@ -3762,11 +3750,11 @@ snapshots: dependencies: irregular-plurals: 3.5.0 - postcss-load-config@6.0.1(yaml@2.8.1): + postcss-load-config@6.0.1(yaml@2.8.2): dependencies: lilconfig: 3.1.3 optionalDependencies: - yaml: 2.8.1 + yaml: 2.8.2 prelude-ls@1.2.1: {} @@ -3802,9 +3790,9 @@ snapshots: dependencies: glob: 7.2.3 - rimraf@6.1.0: + rimraf@6.1.2: dependencies: - glob: 11.0.3 + glob: 13.0.0 package-json-from-dist: 1.0.1 rollup@4.53.2: @@ -3906,7 +3894,7 @@ snapshots: dependencies: '@jridgewell/gen-mapping': 0.3.13 commander: 4.1.1 - glob: 10.4.5 + glob: 10.5.0 lines-and-columns: 1.2.4 mz: 2.7.0 pirates: 4.0.7 @@ -3968,7 +3956,7 @@ snapshots: tslib@1.14.1: {} - tsup@8.5.1(typescript@5.9.3)(yaml@2.8.1): + tsup@8.5.1(typescript@5.9.3)(yaml@2.8.2): dependencies: bundle-require: 5.1.0(esbuild@0.27.0) cac: 6.7.14 @@ -3979,7 +3967,7 @@ snapshots: fix-dts-default-cjs-exports: 1.0.1 joycon: 3.1.1 picocolors: 1.1.1 - postcss-load-config: 6.0.1(yaml@2.8.1) + postcss-load-config: 6.0.1(yaml@2.8.2) resolve-from: 5.0.0 rollup: 4.53.2 source-map: 0.7.6 @@ -4008,14 +3996,14 @@ snapshots: type-fest@0.20.2: {} - typedoc@0.28.14(typescript@5.9.3): + typedoc@0.28.15(typescript@5.9.3): dependencies: - '@gerrit0/mini-shiki': 3.13.1 + '@gerrit0/mini-shiki': 3.17.1 lunr: 2.3.9 markdown-it: 14.1.0 minimatch: 9.0.5 typescript: 5.9.3 - yaml: 2.8.1 + yaml: 2.8.2 typescript@5.9.3: {} @@ -4071,7 +4059,7 @@ snapshots: yallist@5.0.0: {} - yaml@2.8.1: {} + yaml@2.8.2: {} yargs-parser@21.1.1: {} diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 1fc98cf4..10971a71 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-stake-interface" -version = "2.0.1" +version = "2.0.2" description = "Instructions and constructors for the Stake program" readme = "README.md" authors = { workspace = true } diff --git a/package.json b/package.json index 20eb5cc7..4b818f27 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,12 @@ "generate:clients": "tsx ./scripts/generate-clients.mts && (cd clients/js && pnpm format:fix)" }, "devDependencies": { - "@codama/nodes-from-anchor": "^1.2.9", + "@codama/nodes-from-anchor": "^1.3.6", "@codama/renderers-js": "^1.4", "@codama/renderers-rust": "~1.0", "@iarna/toml": "^2.2.5", - "codama": "^1.3", - "tsx": "^4.19.2", + "codama": "^1.4", + "tsx": "^4.21.0", "typescript": "^5.9.3", "zx": "^8.8.5" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 424aacf3..3d99adc3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: devDependencies: '@codama/nodes-from-anchor': - specifier: ^1.2.9 - version: 1.2.9(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) + specifier: ^1.3.6 + version: 1.3.6(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) @@ -21,11 +21,11 @@ importers: specifier: ^2.2.5 version: 2.2.5 codama: - specifier: ^1.3 - version: 1.3.7 + specifier: ^1.4 + version: 1.4.4 tsx: - specifier: ^4.19.2 - version: 4.20.6 + specifier: ^4.21.0 + version: 4.21.0 typescript: specifier: ^5.9.3 version: 5.9.3 @@ -35,8 +35,8 @@ importers: packages: - '@codama/cli@1.3.5': - resolution: {integrity: sha512-UgJGaTK2TXnbRcnCgReKqcDFjU941XZTvA0qbSiFH0Njrwb0kcLkKirMKwdyDaCHry7QcybzIKbp4ErrwqExMA==} + '@codama/cli@1.4.3': + resolution: {integrity: sha512-I6EdKY0e/6OFQpPgwa+qnts/dpWESIXRg0Zmwd6LR7WIL+6tOV1MYMbhrkYCGxxp1N0zkEiMShc9U6m7wj8oew==} hasBin: true '@codama/errors@1.2.8': @@ -47,14 +47,21 @@ packages: resolution: {integrity: sha512-96BF8agDVc2vAgL4qw1lZZfuJ7XBefdzTBk2VOUnOhdMQiLb0QhJCC4BH88OcL+rZXQdet4pk7Qwarj1I1GFKg==} hasBin: true + '@codama/errors@1.4.4': + resolution: {integrity: sha512-XC86H5X+zGTi0cSRKLc+wFkeXNsvnh+ttOgVnVHIljmXOJWbUt9wXhKding3UftipLWwlHPuoswERJ0vS0mO2A==} + 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/nodes-from-anchor@1.2.9': - resolution: {integrity: sha512-n+53VumtguLeSzGWZLpJqWRqs+r8NkWb1w8Ci0AuWQ6Qwfbbk9LknUg1XkqpgZZuq2Hh/Xoy28yHBl2JeIXi3w==} + '@codama/node-types@1.4.4': + resolution: {integrity: sha512-uUeIz34Id/TTAMi4k5OVl9FByM/PawnlNIIVqgpooH9AS0UlniICZ+KJ/mdHZidJs/AGo6bSRoOPS1BLtMajyw==} + + '@codama/nodes-from-anchor@1.3.6': + resolution: {integrity: sha512-614DZS9H5gW16Rkeu0ES8BHnDvbd8M9FLqPWnp9QUE0b+wCvWB36yZiRylJ4fw8gRDSc+FR7C2i3NXKycpvBEg==} '@codama/nodes@1.2.8': resolution: {integrity: sha512-tCi7KErG2ChQr5n3Nj3dwciFmUo3O8RQ+S4Qv23w1zvYLaGwhEvdg3KRtgCGEI0wr9uvm2QtTBM670kdLntZiQ==} @@ -62,6 +69,9 @@ packages: '@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/renderers-core@1.0.10': resolution: {integrity: sha512-7NwoyP2j1cZKgHCrd1RRn891gtxpZeiXNSP3aCFdVsRPW8dDNUL1sJ1SNOF9ILHfNP77clCBtL3eoZIFdeNQAg==} @@ -75,8 +85,8 @@ packages: '@codama/renderers-rust@1.0.16': resolution: {integrity: sha512-pFHwHN6X4Yuk26Yfh+VT9Ps1i/QEjuK3EoT8BpsCTATOk6ntJNqyD5aQngG2lE4KWx3uQrCYYbQEAN4vG6v+EA==} - '@codama/validators@1.3.7': - resolution: {integrity: sha512-OxuPhIPcuqSLmwDTcl9+VyEq6mwsLLqVXtQjgQgjEpr0IO/KAV9RG98Ye2yoK21jEVGDnzN9jsSQVHysRfpMMA==} + '@codama/validators@1.4.4': + resolution: {integrity: sha512-IbSOrfoR4R5oKs3euydfujCbJoOAr/ngjsvJ4VQM2Q/bTOcfdlsG3NvJF0ny/yq1Jvmi8Su9cl1pzDCumJpHAA==} '@codama/visitors-core@1.2.8': resolution: {integrity: sha512-sYmZT2Z6Goacgr/HrAhjLSGtu2Udcal10tEfYN8ZJBXs34PGPu0oWOC8kFx7CxvmAvt/6mw8NhKIPtg/UaIKHw==} @@ -84,161 +94,164 @@ packages: '@codama/visitors-core@1.3.7': resolution: {integrity: sha512-B1JnzhRDJiLxewha/F3YzeEp8Zrtd7eKiGNJFJHSPufAnIVm2lQUDaKS+OrAOHnSRmRKIAVdzfpFpdz6EM0N6Q==} - '@codama/visitors@1.3.7': - resolution: {integrity: sha512-pIVK84G4dquvDXmr0q9GACcwDROw7DOBz0Kk/qt837FsKYr37xc6nU2LIguXu8QVIFOHBZk1HVAb7/S0eo/dqg==} + '@codama/visitors-core@1.4.4': + resolution: {integrity: sha512-vk/4tczViAUHa7c8PF7FxN+JWbuTcDB0pIdrDbbO6eBPKDPQGZCUCEp6rXIYBVxfO129jWrNf2+CuyYre/c/vA==} - '@esbuild/aix-ppc64@0.25.10': - resolution: {integrity: sha512-0NFWnA+7l41irNuaSVlLfgNT12caWJVLzp5eAVhZ0z1qpxbockccEt3s+149rE64VUI3Ml2zt8Nv5JVc4QXTsw==} + '@codama/visitors@1.4.4': + resolution: {integrity: sha512-3w2aRNvGV6/rXTfRDynXR82zoAqX0P4tlfQ/zT4I4Bby4xTobKgDZLyAstodmA0D878eKW7sMg4Gb1m1R5dOig==} + + '@esbuild/aix-ppc64@0.27.0': + resolution: {integrity: sha512-KuZrd2hRjz01y5JK9mEBSD3Vj3mbCvemhT466rSuJYeE/hjuBrHfjjcjMdTm/sz7au+++sdbJZJmuBwQLuw68A==} engines: {node: '>=18'} cpu: [ppc64] os: [aix] - '@esbuild/android-arm64@0.25.10': - resolution: {integrity: sha512-LSQa7eDahypv/VO6WKohZGPSJDq5OVOo3UoFR1E4t4Gj1W7zEQMUhI+lo81H+DtB+kP+tDgBp+M4oNCwp6kffg==} + '@esbuild/android-arm64@0.27.0': + resolution: {integrity: sha512-CC3vt4+1xZrs97/PKDkl0yN7w8edvU2vZvAFGD16n9F0Cvniy5qvzRXjfO1l94efczkkQE6g1x0i73Qf5uthOQ==} engines: {node: '>=18'} cpu: [arm64] os: [android] - '@esbuild/android-arm@0.25.10': - resolution: {integrity: sha512-dQAxF1dW1C3zpeCDc5KqIYuZ1tgAdRXNoZP7vkBIRtKZPYe2xVr/d3SkirklCHudW1B45tGiUlz2pUWDfbDD4w==} + '@esbuild/android-arm@0.27.0': + resolution: {integrity: sha512-j67aezrPNYWJEOHUNLPj9maeJte7uSMM6gMoxfPC9hOg8N02JuQi/T7ewumf4tNvJadFkvLZMlAq73b9uwdMyQ==} engines: {node: '>=18'} cpu: [arm] os: [android] - '@esbuild/android-x64@0.25.10': - resolution: {integrity: sha512-MiC9CWdPrfhibcXwr39p9ha1x0lZJ9KaVfvzA0Wxwz9ETX4v5CHfF09bx935nHlhi+MxhA63dKRRQLiVgSUtEg==} + '@esbuild/android-x64@0.27.0': + resolution: {integrity: sha512-wurMkF1nmQajBO1+0CJmcN17U4BP6GqNSROP8t0X/Jiw2ltYGLHpEksp9MpoBqkrFR3kv2/te6Sha26k3+yZ9Q==} engines: {node: '>=18'} cpu: [x64] os: [android] - '@esbuild/darwin-arm64@0.25.10': - resolution: {integrity: sha512-JC74bdXcQEpW9KkV326WpZZjLguSZ3DfS8wrrvPMHgQOIEIG/sPXEN/V8IssoJhbefLRcRqw6RQH2NnpdprtMA==} + '@esbuild/darwin-arm64@0.27.0': + resolution: {integrity: sha512-uJOQKYCcHhg07DL7i8MzjvS2LaP7W7Pn/7uA0B5S1EnqAirJtbyw4yC5jQ5qcFjHK9l6o/MX9QisBg12kNkdHg==} engines: {node: '>=18'} cpu: [arm64] os: [darwin] - '@esbuild/darwin-x64@0.25.10': - resolution: {integrity: sha512-tguWg1olF6DGqzws97pKZ8G2L7Ig1vjDmGTwcTuYHbuU6TTjJe5FXbgs5C1BBzHbJ2bo1m3WkQDbWO2PvamRcg==} + '@esbuild/darwin-x64@0.27.0': + resolution: {integrity: sha512-8mG6arH3yB/4ZXiEnXof5MK72dE6zM9cDvUcPtxhUZsDjESl9JipZYW60C3JGreKCEP+p8P/72r69m4AZGJd5g==} engines: {node: '>=18'} cpu: [x64] os: [darwin] - '@esbuild/freebsd-arm64@0.25.10': - resolution: {integrity: sha512-3ZioSQSg1HT2N05YxeJWYR+Libe3bREVSdWhEEgExWaDtyFbbXWb49QgPvFH8u03vUPX10JhJPcz7s9t9+boWg==} + '@esbuild/freebsd-arm64@0.27.0': + resolution: {integrity: sha512-9FHtyO988CwNMMOE3YIeci+UV+x5Zy8fI2qHNpsEtSF83YPBmE8UWmfYAQg6Ux7Gsmd4FejZqnEUZCMGaNQHQw==} engines: {node: '>=18'} cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-x64@0.25.10': - resolution: {integrity: sha512-LLgJfHJk014Aa4anGDbh8bmI5Lk+QidDmGzuC2D+vP7mv/GeSN+H39zOf7pN5N8p059FcOfs2bVlrRr4SK9WxA==} + '@esbuild/freebsd-x64@0.27.0': + resolution: {integrity: sha512-zCMeMXI4HS/tXvJz8vWGexpZj2YVtRAihHLk1imZj4efx1BQzN76YFeKqlDr3bUWI26wHwLWPd3rwh6pe4EV7g==} engines: {node: '>=18'} cpu: [x64] os: [freebsd] - '@esbuild/linux-arm64@0.25.10': - resolution: {integrity: sha512-5luJWN6YKBsawd5f9i4+c+geYiVEw20FVW5x0v1kEMWNq8UctFjDiMATBxLvmmHA4bf7F6hTRaJgtghFr9iziQ==} + '@esbuild/linux-arm64@0.27.0': + resolution: {integrity: sha512-AS18v0V+vZiLJyi/4LphvBE+OIX682Pu7ZYNsdUHyUKSoRwdnOsMf6FDekwoAFKej14WAkOef3zAORJgAtXnlQ==} engines: {node: '>=18'} cpu: [arm64] os: [linux] - '@esbuild/linux-arm@0.25.10': - resolution: {integrity: sha512-oR31GtBTFYCqEBALI9r6WxoU/ZofZl962pouZRTEYECvNF/dtXKku8YXcJkhgK/beU+zedXfIzHijSRapJY3vg==} + '@esbuild/linux-arm@0.27.0': + resolution: {integrity: sha512-t76XLQDpxgmq2cNXKTVEB7O7YMb42atj2Re2Haf45HkaUpjM2J0UuJZDuaGbPbamzZ7bawyGFUkodL+zcE+jvQ==} engines: {node: '>=18'} cpu: [arm] os: [linux] - '@esbuild/linux-ia32@0.25.10': - resolution: {integrity: sha512-NrSCx2Kim3EnnWgS4Txn0QGt0Xipoumb6z6sUtl5bOEZIVKhzfyp/Lyw4C1DIYvzeW/5mWYPBFJU3a/8Yr75DQ==} + '@esbuild/linux-ia32@0.27.0': + resolution: {integrity: sha512-Mz1jxqm/kfgKkc/KLHC5qIujMvnnarD9ra1cEcrs7qshTUSksPihGrWHVG5+osAIQ68577Zpww7SGapmzSt4Nw==} engines: {node: '>=18'} cpu: [ia32] os: [linux] - '@esbuild/linux-loong64@0.25.10': - resolution: {integrity: sha512-xoSphrd4AZda8+rUDDfD9J6FUMjrkTz8itpTITM4/xgerAZZcFW7Dv+sun7333IfKxGG8gAq+3NbfEMJfiY+Eg==} + '@esbuild/linux-loong64@0.27.0': + resolution: {integrity: sha512-QbEREjdJeIreIAbdG2hLU1yXm1uu+LTdzoq1KCo4G4pFOLlvIspBm36QrQOar9LFduavoWX2msNFAAAY9j4BDg==} engines: {node: '>=18'} cpu: [loong64] os: [linux] - '@esbuild/linux-mips64el@0.25.10': - resolution: {integrity: sha512-ab6eiuCwoMmYDyTnyptoKkVS3k8fy/1Uvq7Dj5czXI6DF2GqD2ToInBI0SHOp5/X1BdZ26RKc5+qjQNGRBelRA==} + '@esbuild/linux-mips64el@0.27.0': + resolution: {integrity: sha512-sJz3zRNe4tO2wxvDpH/HYJilb6+2YJxo/ZNbVdtFiKDufzWq4JmKAiHy9iGoLjAV7r/W32VgaHGkk35cUXlNOg==} engines: {node: '>=18'} cpu: [mips64el] os: [linux] - '@esbuild/linux-ppc64@0.25.10': - resolution: {integrity: sha512-NLinzzOgZQsGpsTkEbdJTCanwA5/wozN9dSgEl12haXJBzMTpssebuXR42bthOF3z7zXFWH1AmvWunUCkBE4EA==} + '@esbuild/linux-ppc64@0.27.0': + resolution: {integrity: sha512-z9N10FBD0DCS2dmSABDBb5TLAyF1/ydVb+N4pi88T45efQ/w4ohr/F/QYCkxDPnkhkp6AIpIcQKQ8F0ANoA2JA==} engines: {node: '>=18'} cpu: [ppc64] os: [linux] - '@esbuild/linux-riscv64@0.25.10': - resolution: {integrity: sha512-FE557XdZDrtX8NMIeA8LBJX3dC2M8VGXwfrQWU7LB5SLOajfJIxmSdyL/gU1m64Zs9CBKvm4UAuBp5aJ8OgnrA==} + '@esbuild/linux-riscv64@0.27.0': + resolution: {integrity: sha512-pQdyAIZ0BWIC5GyvVFn5awDiO14TkT/19FTmFcPdDec94KJ1uZcmFs21Fo8auMXzD4Tt+diXu1LW1gHus9fhFQ==} engines: {node: '>=18'} cpu: [riscv64] os: [linux] - '@esbuild/linux-s390x@0.25.10': - resolution: {integrity: sha512-3BBSbgzuB9ajLoVZk0mGu+EHlBwkusRmeNYdqmznmMc9zGASFjSsxgkNsqmXugpPk00gJ0JNKh/97nxmjctdew==} + '@esbuild/linux-s390x@0.27.0': + resolution: {integrity: sha512-hPlRWR4eIDDEci953RI1BLZitgi5uqcsjKMxwYfmi4LcwyWo2IcRP+lThVnKjNtk90pLS8nKdroXYOqW+QQH+w==} engines: {node: '>=18'} cpu: [s390x] os: [linux] - '@esbuild/linux-x64@0.25.10': - resolution: {integrity: sha512-QSX81KhFoZGwenVyPoberggdW1nrQZSvfVDAIUXr3WqLRZGZqWk/P4T8p2SP+de2Sr5HPcvjhcJzEiulKgnxtA==} + '@esbuild/linux-x64@0.27.0': + resolution: {integrity: sha512-1hBWx4OUJE2cab++aVZ7pObD6s+DK4mPGpemtnAORBvb5l/g5xFGk0vc0PjSkrDs0XaXj9yyob3d14XqvnQ4gw==} engines: {node: '>=18'} cpu: [x64] os: [linux] - '@esbuild/netbsd-arm64@0.25.10': - resolution: {integrity: sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==} + '@esbuild/netbsd-arm64@0.27.0': + resolution: {integrity: sha512-6m0sfQfxfQfy1qRuecMkJlf1cIzTOgyaeXaiVaaki8/v+WB+U4hc6ik15ZW6TAllRlg/WuQXxWj1jx6C+dfy3w==} engines: {node: '>=18'} cpu: [arm64] os: [netbsd] - '@esbuild/netbsd-x64@0.25.10': - resolution: {integrity: sha512-7RTytDPGU6fek/hWuN9qQpeGPBZFfB4zZgcz2VK2Z5VpdUxEI8JKYsg3JfO0n/Z1E/6l05n0unDCNc4HnhQGig==} + '@esbuild/netbsd-x64@0.27.0': + resolution: {integrity: sha512-xbbOdfn06FtcJ9d0ShxxvSn2iUsGd/lgPIO2V3VZIPDbEaIj1/3nBBe1AwuEZKXVXkMmpr6LUAgMkLD/4D2PPA==} engines: {node: '>=18'} cpu: [x64] os: [netbsd] - '@esbuild/openbsd-arm64@0.25.10': - resolution: {integrity: sha512-5Se0VM9Wtq797YFn+dLimf2Zx6McttsH2olUBsDml+lm0GOCRVebRWUvDtkY4BWYv/3NgzS8b/UM3jQNh5hYyw==} + '@esbuild/openbsd-arm64@0.27.0': + resolution: {integrity: sha512-fWgqR8uNbCQ/GGv0yhzttj6sU/9Z5/Sv/VGU3F5OuXK6J6SlriONKrQ7tNlwBrJZXRYk5jUhuWvF7GYzGguBZQ==} engines: {node: '>=18'} cpu: [arm64] os: [openbsd] - '@esbuild/openbsd-x64@0.25.10': - resolution: {integrity: sha512-XkA4frq1TLj4bEMB+2HnI0+4RnjbuGZfet2gs/LNs5Hc7D89ZQBHQ0gL2ND6Lzu1+QVkjp3x1gIcPKzRNP8bXw==} + '@esbuild/openbsd-x64@0.27.0': + resolution: {integrity: sha512-aCwlRdSNMNxkGGqQajMUza6uXzR/U0dIl1QmLjPtRbLOx3Gy3otfFu/VjATy4yQzo9yFDGTxYDo1FfAD9oRD2A==} engines: {node: '>=18'} cpu: [x64] os: [openbsd] - '@esbuild/openharmony-arm64@0.25.10': - resolution: {integrity: sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==} + '@esbuild/openharmony-arm64@0.27.0': + resolution: {integrity: sha512-nyvsBccxNAsNYz2jVFYwEGuRRomqZ149A39SHWk4hV0jWxKM0hjBPm3AmdxcbHiFLbBSwG6SbpIcUbXjgyECfA==} engines: {node: '>=18'} cpu: [arm64] os: [openharmony] - '@esbuild/sunos-x64@0.25.10': - resolution: {integrity: sha512-fswk3XT0Uf2pGJmOpDB7yknqhVkJQkAQOcW/ccVOtfx05LkbWOaRAtn5SaqXypeKQra1QaEa841PgrSL9ubSPQ==} + '@esbuild/sunos-x64@0.27.0': + resolution: {integrity: sha512-Q1KY1iJafM+UX6CFEL+F4HRTgygmEW568YMqDA5UV97AuZSm21b7SXIrRJDwXWPzr8MGr75fUZPV67FdtMHlHA==} engines: {node: '>=18'} cpu: [x64] os: [sunos] - '@esbuild/win32-arm64@0.25.10': - resolution: {integrity: sha512-ah+9b59KDTSfpaCg6VdJoOQvKjI33nTaQr4UluQwW7aEwZQsbMCfTmfEO4VyewOxx4RaDT/xCy9ra2GPWmO7Kw==} + '@esbuild/win32-arm64@0.27.0': + resolution: {integrity: sha512-W1eyGNi6d+8kOmZIwi/EDjrL9nxQIQ0MiGqe/AWc6+IaHloxHSGoeRgDRKHFISThLmsewZ5nHFvGFWdBYlgKPg==} engines: {node: '>=18'} cpu: [arm64] os: [win32] - '@esbuild/win32-ia32@0.25.10': - resolution: {integrity: sha512-QHPDbKkrGO8/cz9LKVnJU22HOi4pxZnZhhA2HYHez5Pz4JeffhDjf85E57Oyco163GnzNCVkZK0b/n4Y0UHcSw==} + '@esbuild/win32-ia32@0.27.0': + resolution: {integrity: sha512-30z1aKL9h22kQhilnYkORFYt+3wp7yZsHWus+wSKAJR8JtdfI76LJ4SBdMsCopTR3z/ORqVu5L1vtnHZWVj4cQ==} engines: {node: '>=18'} cpu: [ia32] os: [win32] - '@esbuild/win32-x64@0.25.10': - resolution: {integrity: sha512-9KpxSVFCu0iK1owoez6aC/s/EdUQLDN3adTxGCqxMVhrPDj6bt5dbrHDXUuq+Bs2vATFBBrQS5vdQ/Ed2P+nbw==} + '@esbuild/win32-x64@0.27.0': + resolution: {integrity: sha512-aIitBcjQeyOhMTImhLZmtxfdOcuNRpwlPNmlFKPcHQYPhEssw75Cl1TSXJXpMkzaua9FUetx/4OQKq7eJul5Cg==} engines: {node: '>=18'} cpu: [x64] os: [win32] @@ -246,9 +259,9 @@ packages: '@iarna/toml@2.2.5': resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} - '@noble/hashes@1.8.0': - resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==} - engines: {node: ^14.21.3 || >=16} + '@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==} @@ -256,20 +269,20 @@ packages: peerDependencies: typescript: '>=5' - '@solana/codecs-core@3.0.3': - resolution: {integrity: sha512-emKykJ3h1DmnDOY29Uv9eJXP8E/FHzvlUBJ6te+5EbKdFjj7vdlKYPfDxOI6iGdXTY+YC/ELtbNBh6QwF2uEDQ==} + '@solana/codecs-core@4.0.0': + resolution: {integrity: sha512-28kNUsyIlhU3MO3/7ZLDqeJf2YAm32B4tnTjl5A9HrbBqsTZ+upT/RzxZGP1MMm7jnPuIKCMwmTpsyqyR6IUpw==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5.3.3' - '@solana/codecs-core@4.0.0': - resolution: {integrity: sha512-28kNUsyIlhU3MO3/7ZLDqeJf2YAm32B4tnTjl5A9HrbBqsTZ+upT/RzxZGP1MMm7jnPuIKCMwmTpsyqyR6IUpw==} + '@solana/codecs-core@5.0.0': + resolution: {integrity: sha512-rCG2d8OaamVF2/J//YyCgDqNJpUytVVltw9C8mJtEz5c6Se/LR6BFuG8g4xeJswq/ab4RFk5/HFdgbvNjKgQjA==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5.3.3' - '@solana/codecs-data-structures@3.0.3': - resolution: {integrity: sha512-R15cLp8riJvToXziW8lP6AMSwsztGhEnwgyGmll32Mo0Yjq+hduW2/fJrA/TJs6tA/OgTzMQjlxgk009EqZHCw==} + '@solana/codecs-data-structures@5.0.0': + resolution: {integrity: sha512-y503Pqmv0LHcfcf0vQJGaxDvydQJbyCo8nK3nxn56EhFj5lBQ1NWb3WvTd83epigwuZurW2MhJARrpikfhQglQ==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5.3.3' @@ -280,14 +293,14 @@ packages: peerDependencies: typescript: '>=5' - '@solana/codecs-numbers@3.0.3': - resolution: {integrity: sha512-pfXkH9J0glrM8qj6389GAn30+cJOxzXLR2FsPOHCUMXrqLhGjMMZAWhsQkpOQ37SGc/7EiQsT/gmyGC7gxHqJQ==} + '@solana/codecs-numbers@4.0.0': + resolution: {integrity: sha512-z9zpjtcwzqT9rbkKVZpkWB5/0V7+6YRKs6BccHkGJlaDx8Pe/+XOvPi2rEdXPqrPd9QWb5Xp1iBfcgaDMyiOiA==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5.3.3' - '@solana/codecs-numbers@4.0.0': - resolution: {integrity: sha512-z9zpjtcwzqT9rbkKVZpkWB5/0V7+6YRKs6BccHkGJlaDx8Pe/+XOvPi2rEdXPqrPd9QWb5Xp1iBfcgaDMyiOiA==} + '@solana/codecs-numbers@5.0.0': + resolution: {integrity: sha512-a2+skRLuUK02f/XFe4L0e1+wHCyfK25PkyseFps1v1l4pvevukFwth/EhSyrs6w5CsTJRVoR7MuE3E00PM4egw==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5.3.3' @@ -299,22 +312,22 @@ packages: fastestsmallesttextencoderdecoder: ^1.0.22 typescript: '>=5' - '@solana/codecs-strings@3.0.3': - resolution: {integrity: sha512-VHBXnnTVtcQ1j+7Vrz+qSYo38no+jiHRdGnhFspRXEHNJbllzwKqgBE7YN3qoIXH+MKxgJUcwO5KHmdzf8Wn2A==} + '@solana/codecs-strings@4.0.0': + resolution: {integrity: sha512-XvyD+sQ1zyA0amfxbpoFZsucLoe+yASQtDiLUGMDg5TZ82IHE3B7n82jE8d8cTAqi0HgqQiwU13snPhvg1O0Ow==} engines: {node: '>=20.18.0'} peerDependencies: fastestsmallesttextencoderdecoder: ^1.0.22 typescript: '>=5.3.3' - '@solana/codecs-strings@4.0.0': - resolution: {integrity: sha512-XvyD+sQ1zyA0amfxbpoFZsucLoe+yASQtDiLUGMDg5TZ82IHE3B7n82jE8d8cTAqi0HgqQiwU13snPhvg1O0Ow==} + '@solana/codecs-strings@5.0.0': + resolution: {integrity: sha512-ALkRwpV8bGR6qjAYw0YXZwp2YI4wzvKOJGmx04Ut8gMdbaUx7qOcJkhEQKI6ZVC3lAWSIS1N1wGccUZDwvfKxw==} engines: {node: '>=20.18.0'} peerDependencies: fastestsmallesttextencoderdecoder: ^1.0.22 typescript: '>=5.3.3' - '@solana/codecs@3.0.3': - resolution: {integrity: sha512-GOHwTlIQsCoJx9Ryr6cEf0FHKAQ7pY4aO4xgncAftrv0lveTQ1rPP2inQ1QT0gJllsIa8nwbfXAADs9nNJxQDA==} + '@solana/codecs@5.0.0': + resolution: {integrity: sha512-KOw0gFUSBxIMDWLJ3AkVFkEci91dw0Rpx3C6y83Our7fSW+SEP8vRZklCElieYR85LHVB1QIEhoeHR7rc+Ifkw==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5.3.3' @@ -326,22 +339,22 @@ packages: peerDependencies: typescript: '>=5' - '@solana/errors@3.0.3': - resolution: {integrity: sha512-1l84xJlHNva6io62PcYfUamwWlc0eM95nHgCrKX0g0cLoC6D6QHYPCEbEVkR+C5UtP9JDgyQM8MFiv+Ei5tO9Q==} + '@solana/errors@4.0.0': + resolution: {integrity: sha512-3YEtvcMvtcnTl4HahqLt0VnaGVf7vVWOnt6/uPky5e0qV6BlxDSbGkbBzttNjxLXHognV0AQi3pjvrtfUnZmbg==} engines: {node: '>=20.18.0'} hasBin: true peerDependencies: typescript: '>=5.3.3' - '@solana/errors@4.0.0': - resolution: {integrity: sha512-3YEtvcMvtcnTl4HahqLt0VnaGVf7vVWOnt6/uPky5e0qV6BlxDSbGkbBzttNjxLXHognV0AQi3pjvrtfUnZmbg==} + '@solana/errors@5.0.0': + resolution: {integrity: sha512-gTuhzO6E+ydfAAzqmqdPcvFyJwAzFKKIrqtnZPpgAuomcPYu+HSo0tuwSM/cTX0djmHt+GoOsf/julph+nvs2w==} engines: {node: '>=20.18.0'} hasBin: true peerDependencies: typescript: '>=5.3.3' - '@solana/options@3.0.3': - resolution: {integrity: sha512-jarsmnQ63RN0JPC5j9sgUat07NrL9PC71XU7pUItd6LOHtu4+wJMio3l5mT0DHVfkfbFLL6iI6+QmXSVhTNF3g==} + '@solana/options@5.0.0': + resolution: {integrity: sha512-ezHVBFb9FXVSn8LUVRD2tLb6fejU0x8KtGEYyCYh0J0pQuXSITV0IQCjcEopvu/ZxWdXOJyzjvmymnhz90on5A==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5.3.3' @@ -380,8 +393,8 @@ packages: resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} - codama@1.3.7: - resolution: {integrity: sha512-+pUJrvSG3bO4QvfcWfc14p3sklzHRB/lV4gjnXPhyb7T6nCFwYpNWv6/bFuqQyUSgSNI1n3tst/I9EhoPXOjbw==} + codama@1.4.4: + resolution: {integrity: sha512-DpS9XRftrck13FRbSh6hR8V+loAPdtuuFRKixKyAahdR1R4T/EJJ9G78JqBfVXow+4lJ1NKhNlvHKKEJPaE+FQ==} hasBin: true commander@12.1.0: @@ -392,14 +405,14 @@ packages: resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==} engines: {node: '>=18'} - commander@14.0.0: - resolution: {integrity: sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA==} - engines: {node: '>=20'} - commander@14.0.1: resolution: {integrity: sha512-2JkV3gUZUVrbNA+1sjBOYLsMZ5cEEl8GTFP2a4AVz5hvasAMCQ1D2l2le/cX+pV4N6ZU17zjUahLpIXRrnWL8A==} engines: {node: '>=20'} + commander@14.0.2: + resolution: {integrity: sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==} + engines: {node: '>=20'} + commander@5.1.0: resolution: {integrity: sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==} engines: {node: '>= 6'} @@ -424,8 +437,8 @@ packages: resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==} engines: {node: '>= 0.4'} - esbuild@0.25.10: - resolution: {integrity: sha512-9RiGKvCwaqxO2owP61uQ4BgNborAQskMR6QusfWzQqv7AZOg5oGehdY2pRJMTKuwxd1IDBP4rSbI5lHzU7SMsQ==} + esbuild@0.27.0: + resolution: {integrity: sha512-jd0f4NHbD6cALCyGElNpGAOtWxSq46l9X/sWB0Nzd5er4Kz2YTm+Vl0qKFT9KUJvD8+fiO8AvoHhFvEatfVixA==} engines: {node: '>=18'} hasBin: true @@ -452,8 +465,8 @@ packages: resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} engines: {node: '>= 0.4'} - get-tsconfig@4.12.0: - resolution: {integrity: sha512-LScr2aNr2FbjAjZh2C6X6BxRx1/x+aTDExct/xyq2XKbYOiG5c0aK7pMsSuyc0brz3ibr/lbQiHD9jzt4lccJw==} + get-tsconfig@4.13.0: + resolution: {integrity: sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==} gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} @@ -528,8 +541,8 @@ packages: sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} - tsx@4.20.6: - resolution: {integrity: sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==} + tsx@4.21.0: + resolution: {integrity: sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==} engines: {node: '>=18.0.0'} hasBin: true @@ -545,12 +558,12 @@ packages: snapshots: - '@codama/cli@1.3.5': + '@codama/cli@1.4.3': dependencies: - '@codama/nodes': 1.3.7 - '@codama/visitors': 1.3.7 - '@codama/visitors-core': 1.3.7 - commander: 14.0.1 + '@codama/nodes': 1.4.4 + '@codama/visitors': 1.4.4 + '@codama/visitors-core': 1.4.4 + commander: 14.0.2 picocolors: 1.1.1 prompts: 2.4.2 @@ -566,17 +579,25 @@ snapshots: 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/node-types@1.2.8': {} '@codama/node-types@1.3.7': {} - '@codama/nodes-from-anchor@1.2.9(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': + '@codama/node-types@1.4.4': {} + + '@codama/nodes-from-anchor@1.3.6(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': dependencies: - '@codama/errors': 1.3.7 - '@codama/nodes': 1.3.7 - '@codama/visitors': 1.3.7 - '@noble/hashes': 1.8.0 - '@solana/codecs': 3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) + '@codama/errors': 1.4.4 + '@codama/nodes': 1.4.4 + '@codama/visitors': 1.4.4 + '@noble/hashes': 2.0.1 + '@solana/codecs': 5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) transitivePeerDependencies: - fastestsmallesttextencoderdecoder - typescript @@ -591,6 +612,11 @@ snapshots: '@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/renderers-core@1.0.10': dependencies: '@codama/errors': 1.2.8 @@ -628,11 +654,11 @@ snapshots: - fastestsmallesttextencoderdecoder - typescript - '@codama/validators@1.3.7': + '@codama/validators@1.4.4': dependencies: - '@codama/errors': 1.3.7 - '@codama/nodes': 1.3.7 - '@codama/visitors-core': 1.3.7 + '@codama/errors': 1.4.4 + '@codama/nodes': 1.4.4 + '@codama/visitors-core': 1.4.4 '@codama/visitors-core@1.2.8': dependencies: @@ -646,114 +672,120 @@ snapshots: '@codama/nodes': 1.3.7 json-stable-stringify: 1.3.0 - '@codama/visitors@1.3.7': + '@codama/visitors-core@1.4.4': dependencies: - '@codama/errors': 1.3.7 - '@codama/nodes': 1.3.7 - '@codama/visitors-core': 1.3.7 + '@codama/errors': 1.4.4 + '@codama/nodes': 1.4.4 + json-stable-stringify: 1.3.0 + + '@codama/visitors@1.4.4': + dependencies: + '@codama/errors': 1.4.4 + '@codama/nodes': 1.4.4 + '@codama/visitors-core': 1.4.4 - '@esbuild/aix-ppc64@0.25.10': + '@esbuild/aix-ppc64@0.27.0': optional: true - '@esbuild/android-arm64@0.25.10': + '@esbuild/android-arm64@0.27.0': optional: true - '@esbuild/android-arm@0.25.10': + '@esbuild/android-arm@0.27.0': optional: true - '@esbuild/android-x64@0.25.10': + '@esbuild/android-x64@0.27.0': optional: true - '@esbuild/darwin-arm64@0.25.10': + '@esbuild/darwin-arm64@0.27.0': optional: true - '@esbuild/darwin-x64@0.25.10': + '@esbuild/darwin-x64@0.27.0': optional: true - '@esbuild/freebsd-arm64@0.25.10': + '@esbuild/freebsd-arm64@0.27.0': optional: true - '@esbuild/freebsd-x64@0.25.10': + '@esbuild/freebsd-x64@0.27.0': optional: true - '@esbuild/linux-arm64@0.25.10': + '@esbuild/linux-arm64@0.27.0': optional: true - '@esbuild/linux-arm@0.25.10': + '@esbuild/linux-arm@0.27.0': optional: true - '@esbuild/linux-ia32@0.25.10': + '@esbuild/linux-ia32@0.27.0': optional: true - '@esbuild/linux-loong64@0.25.10': + '@esbuild/linux-loong64@0.27.0': optional: true - '@esbuild/linux-mips64el@0.25.10': + '@esbuild/linux-mips64el@0.27.0': optional: true - '@esbuild/linux-ppc64@0.25.10': + '@esbuild/linux-ppc64@0.27.0': optional: true - '@esbuild/linux-riscv64@0.25.10': + '@esbuild/linux-riscv64@0.27.0': optional: true - '@esbuild/linux-s390x@0.25.10': + '@esbuild/linux-s390x@0.27.0': optional: true - '@esbuild/linux-x64@0.25.10': + '@esbuild/linux-x64@0.27.0': optional: true - '@esbuild/netbsd-arm64@0.25.10': + '@esbuild/netbsd-arm64@0.27.0': optional: true - '@esbuild/netbsd-x64@0.25.10': + '@esbuild/netbsd-x64@0.27.0': optional: true - '@esbuild/openbsd-arm64@0.25.10': + '@esbuild/openbsd-arm64@0.27.0': optional: true - '@esbuild/openbsd-x64@0.25.10': + '@esbuild/openbsd-x64@0.27.0': optional: true - '@esbuild/openharmony-arm64@0.25.10': + '@esbuild/openharmony-arm64@0.27.0': optional: true - '@esbuild/sunos-x64@0.25.10': + '@esbuild/sunos-x64@0.27.0': optional: true - '@esbuild/win32-arm64@0.25.10': + '@esbuild/win32-arm64@0.27.0': optional: true - '@esbuild/win32-ia32@0.25.10': + '@esbuild/win32-ia32@0.27.0': optional: true - '@esbuild/win32-x64@0.25.10': + '@esbuild/win32-x64@0.27.0': optional: true '@iarna/toml@2.2.5': {} - '@noble/hashes@1.8.0': {} + '@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@3.0.3(typescript@5.9.3)': + '@solana/codecs-core@4.0.0(typescript@5.9.3)': dependencies: - '@solana/errors': 3.0.3(typescript@5.9.3) + '@solana/errors': 4.0.0(typescript@5.9.3) typescript: 5.9.3 - '@solana/codecs-core@4.0.0(typescript@5.9.3)': + '@solana/codecs-core@5.0.0(typescript@5.9.3)': dependencies: - '@solana/errors': 4.0.0(typescript@5.9.3) + '@solana/errors': 5.0.0(typescript@5.9.3) typescript: 5.9.3 - '@solana/codecs-data-structures@3.0.3(typescript@5.9.3)': + '@solana/codecs-data-structures@5.0.0(typescript@5.9.3)': dependencies: - '@solana/codecs-core': 3.0.3(typescript@5.9.3) - '@solana/codecs-numbers': 3.0.3(typescript@5.9.3) - '@solana/errors': 3.0.3(typescript@5.9.3) + '@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)': @@ -762,18 +794,18 @@ snapshots: '@solana/errors': 2.0.0-rc.4(typescript@5.9.3) typescript: 5.9.3 - '@solana/codecs-numbers@3.0.3(typescript@5.9.3)': - dependencies: - '@solana/codecs-core': 3.0.3(typescript@5.9.3) - '@solana/errors': 3.0.3(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) '@solana/errors': 4.0.0(typescript@5.9.3) typescript: 5.9.3 + '@solana/codecs-numbers@5.0.0(typescript@5.9.3)': + dependencies: + '@solana/codecs-core': 5.0.0(typescript@5.9.3) + '@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) @@ -782,14 +814,6 @@ snapshots: fastestsmallesttextencoderdecoder: 1.0.22 typescript: 5.9.3 - '@solana/codecs-strings@3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': - dependencies: - '@solana/codecs-core': 3.0.3(typescript@5.9.3) - '@solana/codecs-numbers': 3.0.3(typescript@5.9.3) - '@solana/errors': 3.0.3(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) @@ -798,13 +822,21 @@ snapshots: fastestsmallesttextencoderdecoder: 1.0.22 typescript: 5.9.3 - '@solana/codecs@3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': + '@solana/codecs-strings@5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': dependencies: - '@solana/codecs-core': 3.0.3(typescript@5.9.3) - '@solana/codecs-data-structures': 3.0.3(typescript@5.9.3) - '@solana/codecs-numbers': 3.0.3(typescript@5.9.3) - '@solana/codecs-strings': 3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - '@solana/options': 3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) + '@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) + 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 @@ -815,25 +847,25 @@ snapshots: commander: 12.1.0 typescript: 5.9.3 - '@solana/errors@3.0.3(typescript@5.9.3)': + '@solana/errors@4.0.0(typescript@5.9.3)': dependencies: chalk: 5.6.2 - commander: 14.0.0 + commander: 14.0.1 typescript: 5.9.3 - '@solana/errors@4.0.0(typescript@5.9.3)': + '@solana/errors@5.0.0(typescript@5.9.3)': dependencies: chalk: 5.6.2 commander: 14.0.1 typescript: 5.9.3 - '@solana/options@3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': + '@solana/options@5.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': dependencies: - '@solana/codecs-core': 3.0.3(typescript@5.9.3) - '@solana/codecs-data-structures': 3.0.3(typescript@5.9.3) - '@solana/codecs-numbers': 3.0.3(typescript@5.9.3) - '@solana/codecs-strings': 3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - '@solana/errors': 3.0.3(typescript@5.9.3) + '@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 @@ -873,22 +905,22 @@ snapshots: chalk@5.6.2: {} - codama@1.3.7: + codama@1.4.4: dependencies: - '@codama/cli': 1.3.5 - '@codama/errors': 1.3.7 - '@codama/nodes': 1.3.7 - '@codama/validators': 1.3.7 - '@codama/visitors': 1.3.7 + '@codama/cli': 1.4.3 + '@codama/errors': 1.4.4 + '@codama/nodes': 1.4.4 + '@codama/validators': 1.4.4 + '@codama/visitors': 1.4.4 commander@12.1.0: {} commander@13.1.0: {} - commander@14.0.0: {} - commander@14.0.1: {} + commander@14.0.2: {} + commander@5.1.0: {} define-data-property@1.1.4: @@ -911,34 +943,34 @@ snapshots: dependencies: es-errors: 1.3.0 - esbuild@0.25.10: + esbuild@0.27.0: optionalDependencies: - '@esbuild/aix-ppc64': 0.25.10 - '@esbuild/android-arm': 0.25.10 - '@esbuild/android-arm64': 0.25.10 - '@esbuild/android-x64': 0.25.10 - '@esbuild/darwin-arm64': 0.25.10 - '@esbuild/darwin-x64': 0.25.10 - '@esbuild/freebsd-arm64': 0.25.10 - '@esbuild/freebsd-x64': 0.25.10 - '@esbuild/linux-arm': 0.25.10 - '@esbuild/linux-arm64': 0.25.10 - '@esbuild/linux-ia32': 0.25.10 - '@esbuild/linux-loong64': 0.25.10 - '@esbuild/linux-mips64el': 0.25.10 - '@esbuild/linux-ppc64': 0.25.10 - '@esbuild/linux-riscv64': 0.25.10 - '@esbuild/linux-s390x': 0.25.10 - '@esbuild/linux-x64': 0.25.10 - '@esbuild/netbsd-arm64': 0.25.10 - '@esbuild/netbsd-x64': 0.25.10 - '@esbuild/openbsd-arm64': 0.25.10 - '@esbuild/openbsd-x64': 0.25.10 - '@esbuild/openharmony-arm64': 0.25.10 - '@esbuild/sunos-x64': 0.25.10 - '@esbuild/win32-arm64': 0.25.10 - '@esbuild/win32-ia32': 0.25.10 - '@esbuild/win32-x64': 0.25.10 + '@esbuild/aix-ppc64': 0.27.0 + '@esbuild/android-arm': 0.27.0 + '@esbuild/android-arm64': 0.27.0 + '@esbuild/android-x64': 0.27.0 + '@esbuild/darwin-arm64': 0.27.0 + '@esbuild/darwin-x64': 0.27.0 + '@esbuild/freebsd-arm64': 0.27.0 + '@esbuild/freebsd-x64': 0.27.0 + '@esbuild/linux-arm': 0.27.0 + '@esbuild/linux-arm64': 0.27.0 + '@esbuild/linux-ia32': 0.27.0 + '@esbuild/linux-loong64': 0.27.0 + '@esbuild/linux-mips64el': 0.27.0 + '@esbuild/linux-ppc64': 0.27.0 + '@esbuild/linux-riscv64': 0.27.0 + '@esbuild/linux-s390x': 0.27.0 + '@esbuild/linux-x64': 0.27.0 + '@esbuild/netbsd-arm64': 0.27.0 + '@esbuild/netbsd-x64': 0.27.0 + '@esbuild/openbsd-arm64': 0.27.0 + '@esbuild/openbsd-x64': 0.27.0 + '@esbuild/openharmony-arm64': 0.27.0 + '@esbuild/sunos-x64': 0.27.0 + '@esbuild/win32-arm64': 0.27.0 + '@esbuild/win32-ia32': 0.27.0 + '@esbuild/win32-x64': 0.27.0 fastestsmallesttextencoderdecoder@1.0.22: {} @@ -978,7 +1010,7 @@ snapshots: dunder-proto: 1.0.1 es-object-atoms: 1.1.1 - get-tsconfig@4.12.0: + get-tsconfig@4.13.0: dependencies: resolve-pkg-maps: 1.0.0 @@ -1048,10 +1080,10 @@ snapshots: sisteransi@1.0.5: {} - tsx@4.20.6: + tsx@4.21.0: dependencies: - esbuild: 0.25.10 - get-tsconfig: 4.12.0 + esbuild: 0.27.0 + get-tsconfig: 4.13.0 optionalDependencies: fsevents: 2.3.3 diff --git a/program/Cargo.toml b/program/Cargo.toml index 4d1737f6..ab99cd58 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-stake-program" -version = "1.0.0" +version = "4.0.0" description = "Solana BPF Stake Program" authors = ["Anza Maintainers "] repository = "https://github.com/solana-program/stake-program" diff --git a/program/src/helpers/delegate.rs b/program/src/helpers/delegate.rs index 2d30671c..194a34e0 100644 --- a/program/src/helpers/delegate.rs +++ b/program/src/helpers/delegate.rs @@ -1,5 +1,4 @@ use { - crate::PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH, solana_account_info::AccountInfo, solana_clock::Epoch, solana_program_error::ProgramError, @@ -7,7 +6,6 @@ use { solana_stake_interface::{ error::StakeError, state::{Delegation, Meta, Stake}, - sysvar::stake_history::StakeHistorySysvar, }, }; @@ -29,46 +27,6 @@ pub(crate) fn new_stake( } } -pub(crate) fn redelegate_stake( - stake: &mut Stake, - stake_lamports: u64, - voter_pubkey: &Pubkey, - credits_observed: u64, - epoch: Epoch, - stake_history: &StakeHistorySysvar, -) -> Result<(), ProgramError> { - // If stake is currently active: - if stake.stake( - epoch, - stake_history, - PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH, - ) != 0 - { - // If pubkey of new voter is the same as current, - // and we are scheduled to start deactivating this epoch, - // we rescind deactivation - if stake.delegation.voter_pubkey == *voter_pubkey - && epoch == stake.delegation.deactivation_epoch - { - stake.delegation.deactivation_epoch = u64::MAX; - return Ok(()); - } else { - // can't redelegate to another pubkey if stake is active. - return Err(StakeError::TooSoonToRedelegate.into()); - } - } - // Either the stake is freshly activated, is active but has been - // deactivated this epoch, or has fully de-activated. - // Redelegation implies either re-activation or un-deactivation - - stake.delegation.stake = stake_lamports; - stake.delegation.activation_epoch = epoch; - stake.delegation.deactivation_epoch = u64::MAX; - stake.delegation.voter_pubkey = *voter_pubkey; - stake.credits_observed = credits_observed; - Ok(()) -} - /// Ensure the stake delegation amount is valid. This checks that the account /// meets the minimum balance requirements of delegated stake. If not, return /// an error. diff --git a/program/src/processor.rs b/program/src/processor.rs index c046d86d..d9033c11 100644 --- a/program/src/processor.rs +++ b/program/src/processor.rs @@ -404,22 +404,45 @@ impl Processor { ) } StakeStateV2::Stake(meta, mut stake, flags) => { + // Only the staker may (re)delegate meta.authorized .check(&signers, StakeAuthorize::Staker) .map_err(to_program_error)?; + // Compute the maximum stake allowed to (re)delegate let ValidatedDelegatedInfo { stake_amount } = validate_delegated_amount(stake_account_info, &meta)?; - redelegate_stake( - &mut stake, - stake_amount, - vote_account_info.key, - vote_state.credits(), + // Get current activation status at this epoch + let effective_stake = stake.delegation.stake( clock.epoch, stake_history, - )?; + PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH, + ); + + if effective_stake == 0 { + // The stake has no effective voting power this epoch. This means it is either: + // 1. Inactive (fully cooled down after a previous deactivation) + // 2. Still activating (was delegated for the first time this epoch) + stake = new_stake( + stake_amount, + vote_account_info.key, + vote_state.credits(), + clock.epoch, + ); + } else if clock.epoch == stake.delegation.deactivation_epoch + && stake.delegation.voter_pubkey == *vote_account_info.key + { + if stake_amount < stake.delegation.stake { + return Err(StakeError::InsufficientDelegation.into()); + } + stake.delegation.deactivation_epoch = u64::MAX; + } else { + // Not a valid state for redelegation + return Err(StakeError::TooSoonToRedelegate.into()); + } + // Persist the updated stake state back to the account. set_stake_state(stake_account_info, &StakeStateV2::Stake(meta, stake, flags)) } _ => Err(ProgramError::InvalidAccountData), diff --git a/program/tests/fixtures/solana_stake_program.so b/program/tests/fixtures/solana_stake_program.so deleted file mode 120000 index 75ba6f30..00000000 --- a/program/tests/fixtures/solana_stake_program.so +++ /dev/null @@ -1 +0,0 @@ -../../../target/deploy/solana_stake_program.so \ No newline at end of file From f636e75754b690a9f641d3b3580495f2815c1cd6 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:38:06 +0000 Subject: [PATCH 21/27] update idl after re-sync --- interface/idl.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/idl.json b/interface/idl.json index 711c7610..a72578cd 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -1842,7 +1842,7 @@ "name": "solanaStakeInterface", "pdas": [], "publicKey": "Stake11111111111111111111111111111111111111", - "version": "2.0.1" + "version": "2.0.2" }, "standard": "codama", "version": "1.0.0" From 3faa2c74c1312ec43e7024b12023bbb2d5d1147b Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Thu, 4 Dec 2025 18:14:15 +0000 Subject: [PATCH 22/27] use named tuple fields --- Cargo.lock | 55 ++++------ .../instructions/initializeChecked.ts | 12 +- .../js/src/generated/instructions/split.ts | 10 +- .../js/src/generated/instructions/withdraw.ts | 48 ++++---- .../instructions/initialize_checked.rs | 7 +- .../rust/src/generated/instructions/split.rs | 24 ++-- .../src/generated/instructions/withdraw.rs | 69 ++++++------ clients/rust/src/hooked/mod.rs | 1 - interface/Cargo.toml | 4 +- interface/idl.json | 18 +-- interface/src/instruction.rs | 103 +++++++++--------- scripts/generate-clients.mts | 1 - 12 files changed, 168 insertions(+), 184 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f36e293c..a634a424 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -942,9 +942,8 @@ dependencies = [ [[package]] name = "codama" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c46db268f2c816f7a6834c0fff1fc0320450ef5d81975bbf0a6eeb52ef9c93ca" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "codama-errors", "codama-korok-plugins", @@ -958,9 +957,8 @@ dependencies = [ [[package]] name = "codama-attributes" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "404f1560d84ee21be65bedc9a25ab1e8a41a862aaaa9e31b3f7e909cd0f8bbdf" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "codama-errors", "codama-nodes", @@ -973,9 +971,8 @@ dependencies = [ [[package]] name = "codama-errors" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e56c7fdd1cfabadd8f2535b3901dc5bce44dffd2299ac4249285a95d9922840" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "cargo_toml", "proc-macro2", @@ -986,9 +983,8 @@ dependencies = [ [[package]] name = "codama-korok-plugins" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7463a0931cfd90ae69f681aca23e7e93e0e6bc2dad1028e11c9051803ad6567f" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "codama-errors", "codama-korok-visitors", @@ -997,9 +993,8 @@ dependencies = [ [[package]] name = "codama-korok-visitors" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ad5f926bb3ea0ebe38992f4395dfb87363323083939b7a09560878503322e3c" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "cargo_toml", "codama-attributes", @@ -1013,9 +1008,8 @@ dependencies = [ [[package]] name = "codama-koroks" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8816dac083eeafabfec24b23553a504fe349f6eedf4c387679f73a501cfe8710" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "codama-attributes", "codama-errors", @@ -1029,9 +1023,8 @@ dependencies = [ [[package]] name = "codama-macros" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2545c465cfe9f0ff96f33c8b7ef58db212e307afaff56e5274379e2b9b3f9e7e" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "codama-attributes", "codama-errors", @@ -1044,9 +1037,8 @@ dependencies = [ [[package]] name = "codama-nodes" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f6df08db9a0a16da729816c8de1ad670efb300683955abd7b0de07899c3486d" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "codama-errors", "codama-nodes-derive", @@ -1057,9 +1049,8 @@ dependencies = [ [[package]] name = "codama-nodes-derive" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238404cfc7c05c8f62207a909be22e4840f27f69cce61ee940ce1e27a346c797" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "codama-errors", "codama-syn-helpers", @@ -1071,9 +1062,8 @@ dependencies = [ [[package]] name = "codama-stores" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f60573db8f7b599b4028ecfeebf86cfc3291d157c05e43872e0dc80a5fad009" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "cargo_toml", "codama-errors", @@ -1083,9 +1073,8 @@ dependencies = [ [[package]] name = "codama-syn-helpers" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cf58f8fea7cc924b4c91e55536a5c77a1fce2059905c8f05d167cb4ec3bced" +version = "0.6.5" +source = "git+https://github.com/rustopian/codama-rs?branch=custom-tuple-arg-names#e9631325427ba7f43ed04ab438a3a52ac901cd1e" dependencies = [ "codama-errors", "derive_more", diff --git a/clients/js/src/generated/instructions/initializeChecked.ts b/clients/js/src/generated/instructions/initializeChecked.ts index 1941ac0a..4b733d9e 100644 --- a/clients/js/src/generated/instructions/initializeChecked.ts +++ b/clients/js/src/generated/instructions/initializeChecked.ts @@ -40,7 +40,9 @@ export function getInitializeCheckedDiscriminatorBytes() { export type InitializeCheckedInstruction< TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | AccountMeta = string, - TAccountRentSysvar extends string | AccountMeta = string, + TAccountRentSysvar extends + | string + | AccountMeta = 'SysvarRent111111111111111111111111111111111', TAccountStakeAuthority extends string | AccountMeta = string, TAccountWithdrawAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], @@ -99,7 +101,7 @@ export type InitializeCheckedInput< /** Uninitialized stake account */ stake: Address; /** Rent sysvar */ - rentSysvar: Address; + rentSysvar?: Address; /** The stake authority */ stakeAuthority: Address; /** The withdraw authority */ @@ -145,6 +147,12 @@ export function getInitializeCheckedInstruction< ResolvedAccount >; + // Resolve default values. + if (!accounts.rentSysvar.value) { + accounts.rentSysvar.value = + 'SysvarRent111111111111111111111111111111111' as Address<'SysvarRent111111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted'); return Object.freeze({ accounts: [ diff --git a/clients/js/src/generated/instructions/split.ts b/clients/js/src/generated/instructions/split.ts index a10b8e3b..7095c7a3 100644 --- a/clients/js/src/generated/instructions/split.ts +++ b/clients/js/src/generated/instructions/split.ts @@ -62,15 +62,15 @@ export type SplitInstruction< ] >; -export type SplitInstructionData = { discriminator: number; lamports: bigint }; +export type SplitInstructionData = { discriminator: number; args: bigint }; -export type SplitInstructionDataArgs = { lamports: number | bigint }; +export type SplitInstructionDataArgs = { args: number | bigint }; export function getSplitInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['lamports', getU64Encoder()], + ['args', getU64Encoder()], ]), (value) => ({ ...value, discriminator: SPLIT_DISCRIMINATOR }) ); @@ -79,7 +79,7 @@ export function getSplitInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['lamports', getU64Decoder()], + ['args', getU64Decoder()], ]); } @@ -104,7 +104,7 @@ export type SplitInput< splitStake: Address; /** Stake authority */ stakeAuthority: TransactionSigner; - lamports: SplitInstructionDataArgs['lamports']; + args: SplitInstructionDataArgs['args']; }; export function getSplitInstruction< diff --git a/clients/js/src/generated/instructions/withdraw.ts b/clients/js/src/generated/instructions/withdraw.ts index cbeacf61..e19c0b77 100644 --- a/clients/js/src/generated/instructions/withdraw.ts +++ b/clients/js/src/generated/instructions/withdraw.ts @@ -46,7 +46,7 @@ export type WithdrawInstruction< TAccountClockSysvar extends | string | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', - TAccountStakeHistorySysvar extends + TAccountStakeHistory extends | string | AccountMeta = 'SysvarStakeHistory1111111111111111111111111', TAccountWithdrawAuthority extends string | AccountMeta = string, @@ -68,9 +68,9 @@ export type WithdrawInstruction< TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, - TAccountStakeHistorySysvar extends string - ? ReadonlyAccount - : TAccountStakeHistorySysvar, + TAccountStakeHistory extends string + ? ReadonlyAccount + : TAccountStakeHistory, TAccountWithdrawAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -87,18 +87,15 @@ export type WithdrawInstruction< ] >; -export type WithdrawInstructionData = { - discriminator: number; - lamports: bigint; -}; +export type WithdrawInstructionData = { discriminator: number; args: bigint }; -export type WithdrawInstructionDataArgs = { lamports: number | bigint }; +export type WithdrawInstructionDataArgs = { args: number | bigint }; export function getWithdrawInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['lamports', getU64Encoder()], + ['args', getU64Encoder()], ]), (value) => ({ ...value, discriminator: WITHDRAW_DISCRIMINATOR }) ); @@ -107,7 +104,7 @@ export function getWithdrawInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['lamports', getU64Decoder()], + ['args', getU64Decoder()], ]); } @@ -125,7 +122,7 @@ export type WithdrawInput< TAccountStake extends string = string, TAccountRecipient extends string = string, TAccountClockSysvar extends string = string, - TAccountStakeHistorySysvar extends string = string, + TAccountStakeHistory extends string = string, TAccountWithdrawAuthority extends string = string, TAccountLockupAuthority extends string = string, > = { @@ -136,19 +133,19 @@ export type WithdrawInput< /** Clock sysvar */ clockSysvar?: Address; /** Stake history sysvar that carries stake warmup/cooldown history */ - stakeHistorySysvar?: Address; + stakeHistory?: Address; /** Withdraw authority */ withdrawAuthority: TransactionSigner; /** Lockup authority, if before lockup expiration */ lockupAuthority?: TransactionSigner; - lamports: WithdrawInstructionDataArgs['lamports']; + args: WithdrawInstructionDataArgs['args']; }; export function getWithdrawInstruction< TAccountStake extends string, TAccountRecipient extends string, TAccountClockSysvar extends string, - TAccountStakeHistorySysvar extends string, + TAccountStakeHistory extends string, TAccountWithdrawAuthority extends string, TAccountLockupAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, @@ -157,7 +154,7 @@ export function getWithdrawInstruction< TAccountStake, TAccountRecipient, TAccountClockSysvar, - TAccountStakeHistorySysvar, + TAccountStakeHistory, TAccountWithdrawAuthority, TAccountLockupAuthority >, @@ -167,7 +164,7 @@ export function getWithdrawInstruction< TAccountStake, TAccountRecipient, TAccountClockSysvar, - TAccountStakeHistorySysvar, + TAccountStakeHistory, TAccountWithdrawAuthority, TAccountLockupAuthority > { @@ -179,10 +176,7 @@ export function getWithdrawInstruction< stake: { value: input.stake ?? null, isWritable: true }, recipient: { value: input.recipient ?? null, isWritable: true }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, - stakeHistorySysvar: { - value: input.stakeHistorySysvar ?? null, - isWritable: false, - }, + stakeHistory: { value: input.stakeHistory ?? null, isWritable: false }, withdrawAuthority: { value: input.withdrawAuthority ?? null, isWritable: false, @@ -205,8 +199,8 @@ export function getWithdrawInstruction< accounts.clockSysvar.value = 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; } - if (!accounts.stakeHistorySysvar.value) { - accounts.stakeHistorySysvar.value = + if (!accounts.stakeHistory.value) { + accounts.stakeHistory.value = 'SysvarStakeHistory1111111111111111111111111' as Address<'SysvarStakeHistory1111111111111111111111111'>; } @@ -216,7 +210,7 @@ export function getWithdrawInstruction< getAccountMeta(accounts.stake), getAccountMeta(accounts.recipient), getAccountMeta(accounts.clockSysvar), - getAccountMeta(accounts.stakeHistorySysvar), + getAccountMeta(accounts.stakeHistory), getAccountMeta(accounts.withdrawAuthority), getAccountMeta(accounts.lockupAuthority), ].filter((x: T | undefined): x is T => x !== undefined), @@ -229,7 +223,7 @@ export function getWithdrawInstruction< TAccountStake, TAccountRecipient, TAccountClockSysvar, - TAccountStakeHistorySysvar, + TAccountStakeHistory, TAccountWithdrawAuthority, TAccountLockupAuthority >); @@ -248,7 +242,7 @@ export type ParsedWithdrawInstruction< /** Clock sysvar */ clockSysvar: TAccountMetas[2]; /** Stake history sysvar that carries stake warmup/cooldown history */ - stakeHistorySysvar: TAccountMetas[3]; + stakeHistory: TAccountMetas[3]; /** Withdraw authority */ withdrawAuthority: TAccountMetas[4]; /** Lockup authority, if before lockup expiration */ @@ -287,7 +281,7 @@ export function parseWithdrawInstruction< stake: getNextAccount(), recipient: getNextAccount(), clockSysvar: getNextAccount(), - stakeHistorySysvar: getNextAccount(), + stakeHistory: getNextAccount(), withdrawAuthority: getNextAccount(), lockupAuthority: getNextOptionalAccount(), }, diff --git a/clients/rust/src/generated/instructions/initialize_checked.rs b/clients/rust/src/generated/instructions/initialize_checked.rs index 4dc23f24..929046f7 100644 --- a/clients/rust/src/generated/instructions/initialize_checked.rs +++ b/clients/rust/src/generated/instructions/initialize_checked.rs @@ -79,7 +79,7 @@ impl Default for InitializeCheckedInstructionData { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` rent_sysvar +/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) /// 2. `[]` stake_authority /// 3. `[signer]` withdraw_authority #[derive(Clone, Debug, Default)] @@ -101,6 +101,7 @@ impl InitializeCheckedBuilder { 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 { @@ -147,7 +148,9 @@ impl InitializeCheckedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = InitializeChecked { stake: self.stake.expect("stake is not set"), - rent_sysvar: self.rent_sysvar.expect("rent_sysvar is not set"), + rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarRent111111111111111111111111111111111" + )), stake_authority: self.stake_authority.expect("stake_authority is not set"), withdraw_authority: self .withdraw_authority diff --git a/clients/rust/src/generated/instructions/split.rs b/clients/rust/src/generated/instructions/split.rs index 36701c29..0e76388b 100644 --- a/clients/rust/src/generated/instructions/split.rs +++ b/clients/rust/src/generated/instructions/split.rs @@ -77,7 +77,7 @@ impl Default for SplitInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SplitInstructionArgs { - pub lamports: u64, + pub args: u64, } /// Instruction builder for `Split`. @@ -92,7 +92,7 @@ pub struct SplitBuilder { stake: Option, split_stake: Option, stake_authority: Option, - lamports: Option, + args: Option, __remaining_accounts: Vec, } @@ -122,8 +122,8 @@ impl SplitBuilder { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.args = Some(args); self } /// Add an additional account to the instruction. @@ -152,7 +152,7 @@ impl SplitBuilder { stake_authority: self.stake_authority.expect("stake_authority is not set"), }; let args = SplitInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), + args: self.args.clone().expect("args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -295,7 +295,7 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { stake: None, split_stake: None, stake_authority: None, - lamports: None, + args: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -325,8 +325,8 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.instruction.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.instruction.args = Some(args); self } /// Add an additional account to the instruction. @@ -371,11 +371,7 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = SplitInstructionArgs { - lamports: self - .instruction - .lamports - .clone() - .expect("lamports is not set"), + args: self.instruction.args.clone().expect("args is not set"), }; let instruction = SplitCpi { __program: self.instruction.__program, @@ -406,7 +402,7 @@ struct SplitCpiBuilderInstruction<'a, 'b> { 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>>, - lamports: Option, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/withdraw.rs b/clients/rust/src/generated/instructions/withdraw.rs index b23a8c10..cf712994 100644 --- a/clients/rust/src/generated/instructions/withdraw.rs +++ b/clients/rust/src/generated/instructions/withdraw.rs @@ -17,7 +17,7 @@ pub struct Withdraw { /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: solana_program::pubkey::Pubkey, + pub stake_history: solana_program::pubkey::Pubkey, /// Withdraw authority pub withdraw_authority: solana_program::pubkey::Pubkey, /// Lockup authority, if before lockup expiration @@ -50,7 +50,7 @@ impl Withdraw { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.stake_history_sysvar, + self.stake_history, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -97,7 +97,7 @@ impl Default for WithdrawInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WithdrawInstructionArgs { - pub lamports: u64, + pub args: u64, } /// Instruction builder for `Withdraw`. @@ -107,7 +107,7 @@ pub struct WithdrawInstructionArgs { /// 0. `[writable]` stake /// 1. `[writable]` recipient /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[optional]` stake_history_sysvar (default to `SysvarStakeHistory1111111111111111111111111`) +/// 3. `[optional]` stake_history (default to `SysvarStakeHistory1111111111111111111111111`) /// 4. `[signer]` withdraw_authority /// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] @@ -115,10 +115,10 @@ pub struct WithdrawBuilder { stake: Option, recipient: Option, clock_sysvar: Option, - stake_history_sysvar: Option, + stake_history: Option, withdraw_authority: Option, lockup_authority: Option, - lamports: Option, + args: Option, __remaining_accounts: Vec, } @@ -148,11 +148,8 @@ impl WithdrawBuilder { /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] - pub fn stake_history_sysvar( - &mut self, - stake_history_sysvar: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.stake_history_sysvar = Some(stake_history_sysvar); + pub fn stake_history(&mut self, stake_history: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake_history = Some(stake_history); self } /// Withdraw authority @@ -175,8 +172,8 @@ impl WithdrawBuilder { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.args = Some(args); self } /// Add an additional account to the instruction. @@ -205,7 +202,7 @@ impl WithdrawBuilder { clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), - stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!( + stake_history: self.stake_history.unwrap_or(solana_program::pubkey!( "SysvarStakeHistory1111111111111111111111111" )), withdraw_authority: self @@ -214,7 +211,7 @@ impl WithdrawBuilder { lockup_authority: self.lockup_authority, }; let args = WithdrawInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), + args: self.args.clone().expect("args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -230,7 +227,7 @@ pub struct WithdrawCpiAccounts<'a, 'b> { /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, /// Withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, /// Lockup authority, if before lockup expiration @@ -248,7 +245,7 @@ pub struct WithdrawCpi<'a, 'b> { /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, /// Withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, /// Lockup authority, if before lockup expiration @@ -268,7 +265,7 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { stake: accounts.stake, recipient: accounts.recipient, clock_sysvar: accounts.clock_sysvar, - stake_history_sysvar: accounts.stake_history_sysvar, + stake_history: accounts.stake_history, withdraw_authority: accounts.withdraw_authority, lockup_authority: accounts.lockup_authority, __args: args, @@ -321,7 +318,7 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.stake_history_sysvar.key, + *self.stake_history.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -355,7 +352,7 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { account_infos.push(self.stake.clone()); account_infos.push(self.recipient.clone()); account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history_sysvar.clone()); + account_infos.push(self.stake_history.clone()); account_infos.push(self.withdraw_authority.clone()); if let Some(lockup_authority) = self.lockup_authority { account_infos.push(lockup_authority.clone()); @@ -379,7 +376,7 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { /// 0. `[writable]` stake /// 1. `[writable]` recipient /// 2. `[]` clock_sysvar -/// 3. `[]` stake_history_sysvar +/// 3. `[]` stake_history /// 4. `[signer]` withdraw_authority /// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] @@ -394,10 +391,10 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { stake: None, recipient: None, clock_sysvar: None, - stake_history_sysvar: None, + stake_history: None, withdraw_authority: None, lockup_authority: None, - lamports: None, + args: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -428,11 +425,11 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { } /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] - pub fn stake_history_sysvar( + pub fn stake_history( &mut self, - stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + stake_history: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.stake_history_sysvar = Some(stake_history_sysvar); + self.instruction.stake_history = Some(stake_history); self } /// Withdraw authority @@ -455,8 +452,8 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.instruction.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.instruction.args = Some(args); self } /// Add an additional account to the instruction. @@ -501,11 +498,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = WithdrawInstructionArgs { - lamports: self - .instruction - .lamports - .clone() - .expect("lamports is not set"), + args: self.instruction.args.clone().expect("args is not set"), }; let instruction = WithdrawCpi { __program: self.instruction.__program, @@ -519,10 +512,10 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { .clock_sysvar .expect("clock_sysvar is not set"), - stake_history_sysvar: self + stake_history: self .instruction - .stake_history_sysvar - .expect("stake_history_sysvar is not set"), + .stake_history + .expect("stake_history is not set"), withdraw_authority: self .instruction @@ -545,10 +538,10 @@ struct WithdrawCpiBuilderInstruction<'a, 'b> { 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_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>>, - lamports: Option, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/hooked/mod.rs b/clients/rust/src/hooked/mod.rs index c8f9b009..37365c36 100644 --- a/clients/rust/src/hooked/mod.rs +++ b/clients/rust/src/hooked/mod.rs @@ -1,3 +1,2 @@ pub mod stake_state_account; - pub use stake_state_account::*; diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 10971a71..45fba718 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -18,8 +18,8 @@ program-id = "Stake11111111111111111111111111111111111111" [dependencies] borsh = { version = "1.5.7", features = ["derive", "unstable__schema"], optional = true } -codama = { version = "0.6.4", optional = true } -codama-macros = { version = "0.6.4", optional = true } +codama = { version = "0.6.5", git = "https://github.com/rustopian/codama-rs", branch = "custom-tuple-arg-names", optional = true } +codama-macros = { version = "0.6.5", git = "https://github.com/rustopian/codama-rs", branch = "custom-tuple-arg-names", optional = true } num-traits = "0.2" serde = { version = "1.0.210", optional = true } serde_derive = { version = "1.0.210", optional = true } diff --git a/interface/idl.json b/interface/idl.json index a72578cd..83496d8f 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -897,7 +897,7 @@ }, { "kind": "instructionArgumentNode", - "name": "lamports", + "name": "args", "type": { "endian": "le", "format": "u64", @@ -959,7 +959,7 @@ "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", - "name": "stakeHistorySysvar" + "name": "stakeHistory" }, { "docs": [ @@ -998,7 +998,7 @@ }, { "kind": "instructionArgumentNode", - "name": "lamports", + "name": "args", "type": { "endian": "le", "format": "u64", @@ -1114,7 +1114,7 @@ }, { "kind": "instructionArgumentNode", - "name": "lockupArgs", + "name": "arg0", "type": { "kind": "definedTypeLinkNode", "name": "lockupArgs" @@ -1274,7 +1274,7 @@ }, { "kind": "instructionArgumentNode", - "name": "authorizeWithSeedArgs", + "name": "arg0", "type": { "kind": "definedTypeLinkNode", "name": "authorizeWithSeedArgs" @@ -1303,6 +1303,10 @@ "name": "stake" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "SysvarRent111111111111111111111111111111111" + }, "docs": [ "Rent sysvar" ], @@ -1513,7 +1517,7 @@ }, { "kind": "instructionArgumentNode", - "name": "authorizeCheckedWithSeedArgs", + "name": "arg0", "type": { "kind": "definedTypeLinkNode", "name": "authorizeCheckedWithSeedArgs" @@ -1578,7 +1582,7 @@ }, { "kind": "instructionArgumentNode", - "name": "lockupCheckedArgs", + "name": "arg0", "type": { "kind": "definedTypeLinkNode", "name": "lockupCheckedArgs" diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 1206ea48..cf992031 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -52,7 +52,11 @@ pub enum StakeInstruction { codama(account(name = "stake", writable, docs = "Uninitialized stake account")) )] #[cfg_attr(feature = "codama", codama(account(name = "rent_sysvar", docs = "Rent sysvar", default_value = sysvar("rent"))))] - Initialize { arg0: Authorized, arg1: Lockup }, + // backwards compatibility with old IDL demands auto `arg0` and `arg1` names + Initialize( + Authorized, + Lockup, + ), /// Authorize a key to manage stake or withdrawal /// @@ -80,7 +84,11 @@ pub enum StakeInstruction { docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" )) )] - Authorize { arg0: Pubkey, arg1: StakeAuthorize }, + // backwards compatibility with old IDL demands auto `arg0` and `arg1` names + Authorize( + Pubkey, + StakeAuthorize, + ), /// Delegate a stake to a particular vote account /// @@ -151,7 +159,11 @@ pub enum StakeInstruction { feature = "codama", codama(account(name = "stake_authority", signer, docs = "Stake authority")) )] - Split { lamports: u64 }, + // 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 /// @@ -179,7 +191,7 @@ pub enum StakeInstruction { )] #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] #[cfg_attr(feature = "codama", codama(account( - name = "stake_history_sysvar", + name = "stake_history", docs = "Stake history sysvar that carries stake warmup/cooldown history", default_value = sysvar("stake_history") )))] @@ -196,7 +208,11 @@ pub enum StakeInstruction { docs = "Lockup authority, if before lockup expiration" )) )] - Withdraw { lamports: u64 }, + // backwards compatibility with old IDL demands old `args` name + Withdraw( + #[cfg_attr(feature = "codama", codama(name = "args"))] + u64, + ), /// Deactivates the stake in the account /// @@ -239,7 +255,7 @@ pub enum StakeInstruction { docs = "Lockup authority or withdraw authority" )) )] - SetLockup { lockup_args: LockupArgs }, + SetLockup(LockupArgs), /// Merge two stake accounts. /// @@ -323,9 +339,7 @@ pub enum StakeInstruction { docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" )) )] - AuthorizeWithSeed { - authorize_with_seed_args: AuthorizeWithSeedArgs, - }, + AuthorizeWithSeed(AuthorizeWithSeedArgs), /// Initialize a stake with authorization information /// @@ -343,7 +357,7 @@ pub enum StakeInstruction { )] #[cfg_attr( feature = "codama", - codama(account(name = "rent_sysvar", docs = "Rent sysvar")) + codama(account(name = "rent_sysvar", docs = "Rent sysvar", default_value = sysvar("rent"))) )] #[cfg_attr( feature = "codama", @@ -393,7 +407,10 @@ pub enum StakeInstruction { docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" )) )] - AuthorizeChecked { stake_authorize: StakeAuthorize }, + AuthorizeChecked( + #[cfg_attr(feature = "codama", codama(name = "stakeAuthorize"))] + StakeAuthorize, + ), /// Authorize a key to manage stake or withdrawal with a derived key /// @@ -437,9 +454,7 @@ pub enum StakeInstruction { docs = "Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration" )) )] - AuthorizeCheckedWithSeed { - authorize_checked_with_seed_args: AuthorizeCheckedWithSeedArgs, - }, + AuthorizeCheckedWithSeed(AuthorizeCheckedWithSeedArgs), /// Set stake lockup /// @@ -474,9 +489,9 @@ pub enum StakeInstruction { docs = "New lockup authority" )) )] - SetLockupChecked { - lockup_checked_args: LockupCheckedArgs, - }, + SetLockupChecked( + LockupCheckedArgs, + ), /// Get the minimum stake delegation, in lamports /// @@ -581,7 +596,10 @@ pub enum StakeInstruction { codama(account(name = "stake_authority", signer, docs = "Stake authority")) )] // sadly named `args` to avoid breaking users of old IDL - MoveStake { args: u64 }, + MoveStake( + #[cfg_attr(feature = "codama", codama(name = "args"))] + u64, + ), /// Move unstaked lamports between accounts with the same authorities and lockups, using Staker /// authority. @@ -617,7 +635,10 @@ pub enum StakeInstruction { codama(account(name = "stake_authority", signer, docs = "Stake authority")) )] // sadly named `args` to avoid breaking users of old IDL - MoveLamports { args: u64 }, + MoveLamports( + #[cfg_attr(feature = "codama", codama(name = "args"))] + u64, + ), } #[cfg_attr(feature = "codama", derive(CodamaType))] @@ -676,10 +697,7 @@ pub struct AuthorizeCheckedWithSeedArgs { pub fn initialize(stake_pubkey: &Pubkey, authorized: &Authorized, lockup: &Lockup) -> Instruction { Instruction::new_with_bincode( ID, - &StakeInstruction::Initialize { - arg0: *authorized, - arg1: *lockup, - }, + &StakeInstruction::Initialize(*authorized, *lockup), vec![ AccountMeta::new(*stake_pubkey, false), AccountMeta::new_readonly(RENT_ID, false), @@ -800,7 +818,7 @@ fn _split( AccountMeta::new_readonly(*authorized_pubkey, true), ]; - Instruction::new_with_bincode(ID, &StakeInstruction::Split { lamports }, account_metas) + Instruction::new_with_bincode(ID, &StakeInstruction::Split(lamports), account_metas) } #[cfg(feature = "bincode")] @@ -939,10 +957,7 @@ pub fn authorize( Instruction::new_with_bincode( ID, - &StakeInstruction::Authorize { - arg0: *new_authorized_pubkey, - arg1: stake_authorize, - }, + &StakeInstruction::Authorize(*new_authorized_pubkey, stake_authorize), account_metas, ) } @@ -968,7 +983,7 @@ pub fn authorize_checked( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeChecked { stake_authorize }, + &StakeInstruction::AuthorizeChecked(stake_authorize), account_metas, ) } @@ -1002,9 +1017,7 @@ pub fn authorize_with_seed( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeWithSeed { - authorize_with_seed_args: args, - }, + &StakeInstruction::AuthorizeWithSeed(args), account_metas, ) } @@ -1038,9 +1051,7 @@ pub fn authorize_checked_with_seed( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeCheckedWithSeed { - authorize_checked_with_seed_args: args, - }, + &StakeInstruction::AuthorizeCheckedWithSeed(args), account_metas, ) } @@ -1083,7 +1094,7 @@ pub fn withdraw( account_metas.push(AccountMeta::new_readonly(*custodian_pubkey, true)); } - Instruction::new_with_bincode(ID, &StakeInstruction::Withdraw { lamports }, account_metas) + Instruction::new_with_bincode(ID, &StakeInstruction::Withdraw(lamports), account_metas) } #[cfg(feature = "bincode")] @@ -1108,9 +1119,7 @@ pub fn set_lockup( ]; Instruction::new_with_bincode( ID, - &StakeInstruction::SetLockup { - lockup_args: *lockup, - }, + &StakeInstruction::SetLockup(*lockup), account_metas, ) } @@ -1135,9 +1144,7 @@ pub fn set_lockup_checked( } Instruction::new_with_bincode( ID, - &StakeInstruction::SetLockupChecked { - lockup_checked_args: lockup_checked, - }, + &StakeInstruction::SetLockupChecked(lockup_checked), account_metas, ) } @@ -1242,11 +1249,7 @@ pub fn move_stake( AccountMeta::new_readonly(*authorized_pubkey, true), ]; - Instruction::new_with_bincode( - ID, - &StakeInstruction::MoveStake { args: lamports }, - account_metas, - ) + Instruction::new_with_bincode(ID, &StakeInstruction::MoveStake(lamports), account_metas) } #[cfg(feature = "bincode")] @@ -1262,11 +1265,7 @@ pub fn move_lamports( AccountMeta::new_readonly(*authorized_pubkey, true), ]; - Instruction::new_with_bincode( - ID, - &StakeInstruction::MoveLamports { args: lamports }, - account_metas, - ) + Instruction::new_with_bincode(ID, &StakeInstruction::MoveLamports(lamports), account_metas) } #[cfg(feature = "bincode")] diff --git a/scripts/generate-clients.mts b/scripts/generate-clients.mts index e74532ec..15714949 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -116,7 +116,6 @@ codama.update( }, { // Use omitted optional account strategy for all instructions. - // + fix discriminator u8 -> u32. select: '[instructionNode]', transform: (node) => { c.assertIsNode(node, 'instructionNode'); From af32b99d6880e317c363f32e1ad3ae82bf8b44fc Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Thu, 4 Dec 2025 18:16:09 +0000 Subject: [PATCH 23/27] revert changed account name --- .../js/src/generated/instructions/merge.ts | 35 +++++++-------- .../rust/src/generated/instructions/merge.rs | 45 +++++++++---------- interface/idl.json | 2 +- interface/src/instruction.rs | 2 +- 4 files changed, 39 insertions(+), 45 deletions(-) diff --git a/clients/js/src/generated/instructions/merge.ts b/clients/js/src/generated/instructions/merge.ts index 43bd15ec..f792d606 100644 --- a/clients/js/src/generated/instructions/merge.ts +++ b/clients/js/src/generated/instructions/merge.ts @@ -44,7 +44,7 @@ export type MergeInstruction< TAccountClockSysvar extends | string | AccountMeta = 'SysvarC1ock11111111111111111111111111111111', - TAccountStakeHistorySysvar extends + TAccountStakeHistory extends | string | AccountMeta = 'SysvarStakeHistory1111111111111111111111111', TAccountStakeAuthority extends string | AccountMeta = string, @@ -62,9 +62,9 @@ export type MergeInstruction< TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, - TAccountStakeHistorySysvar extends string - ? ReadonlyAccount - : TAccountStakeHistorySysvar, + TAccountStakeHistory extends string + ? ReadonlyAccount + : TAccountStakeHistory, TAccountStakeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -102,7 +102,7 @@ export type MergeInput< TAccountDestinationStake extends string = string, TAccountSourceStake extends string = string, TAccountClockSysvar extends string = string, - TAccountStakeHistorySysvar extends string = string, + TAccountStakeHistory extends string = string, TAccountStakeAuthority extends string = string, > = { /** Destination stake account for the merge */ @@ -112,7 +112,7 @@ export type MergeInput< /** Clock sysvar */ clockSysvar?: Address; /** Stake history sysvar that carries stake warmup/cooldown history */ - stakeHistorySysvar?: Address; + stakeHistory?: Address; /** Stake authority */ stakeAuthority: TransactionSigner; }; @@ -121,7 +121,7 @@ export function getMergeInstruction< TAccountDestinationStake extends string, TAccountSourceStake extends string, TAccountClockSysvar extends string, - TAccountStakeHistorySysvar extends string, + TAccountStakeHistory extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( @@ -129,7 +129,7 @@ export function getMergeInstruction< TAccountDestinationStake, TAccountSourceStake, TAccountClockSysvar, - TAccountStakeHistorySysvar, + TAccountStakeHistory, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } @@ -138,7 +138,7 @@ export function getMergeInstruction< TAccountDestinationStake, TAccountSourceStake, TAccountClockSysvar, - TAccountStakeHistorySysvar, + TAccountStakeHistory, TAccountStakeAuthority > { // Program address. @@ -152,10 +152,7 @@ export function getMergeInstruction< }, sourceStake: { value: input.sourceStake ?? null, isWritable: true }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, - stakeHistorySysvar: { - value: input.stakeHistorySysvar ?? null, - isWritable: false, - }, + stakeHistory: { value: input.stakeHistory ?? null, isWritable: false }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -168,8 +165,8 @@ export function getMergeInstruction< accounts.clockSysvar.value = 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; } - if (!accounts.stakeHistorySysvar.value) { - accounts.stakeHistorySysvar.value = + if (!accounts.stakeHistory.value) { + accounts.stakeHistory.value = 'SysvarStakeHistory1111111111111111111111111' as Address<'SysvarStakeHistory1111111111111111111111111'>; } @@ -179,7 +176,7 @@ export function getMergeInstruction< getAccountMeta(accounts.destinationStake), getAccountMeta(accounts.sourceStake), getAccountMeta(accounts.clockSysvar), - getAccountMeta(accounts.stakeHistorySysvar), + getAccountMeta(accounts.stakeHistory), getAccountMeta(accounts.stakeAuthority), ], data: getMergeInstructionDataEncoder().encode({}), @@ -189,7 +186,7 @@ export function getMergeInstruction< TAccountDestinationStake, TAccountSourceStake, TAccountClockSysvar, - TAccountStakeHistorySysvar, + TAccountStakeHistory, TAccountStakeAuthority >); } @@ -207,7 +204,7 @@ export type ParsedMergeInstruction< /** Clock sysvar */ clockSysvar: TAccountMetas[2]; /** Stake history sysvar that carries stake warmup/cooldown history */ - stakeHistorySysvar: TAccountMetas[3]; + stakeHistory: TAccountMetas[3]; /** Stake authority */ stakeAuthority: TAccountMetas[4]; }; @@ -238,7 +235,7 @@ export function parseMergeInstruction< destinationStake: getNextAccount(), sourceStake: getNextAccount(), clockSysvar: getNextAccount(), - stakeHistorySysvar: getNextAccount(), + stakeHistory: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getMergeInstructionDataDecoder().decode(instruction.data), diff --git a/clients/rust/src/generated/instructions/merge.rs b/clients/rust/src/generated/instructions/merge.rs index 5f2feda7..97986f90 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -17,7 +17,7 @@ pub struct Merge { /// Clock sysvar pub clock_sysvar: solana_program::pubkey::Pubkey, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: solana_program::pubkey::Pubkey, + pub stake_history: solana_program::pubkey::Pubkey, /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -45,7 +45,7 @@ impl Merge { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.stake_history_sysvar, + self.stake_history, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -88,14 +88,14 @@ impl Default for MergeInstructionData { /// 0. `[writable]` destination_stake /// 1. `[writable]` source_stake /// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[optional]` stake_history_sysvar (default to `SysvarStakeHistory1111111111111111111111111`) +/// 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_sysvar: Option, + stake_history: Option, stake_authority: Option, __remaining_accounts: Vec, } @@ -129,11 +129,8 @@ impl MergeBuilder { /// `[optional account, default to 'SysvarStakeHistory1111111111111111111111111']` /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] - pub fn stake_history_sysvar( - &mut self, - stake_history_sysvar: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.stake_history_sysvar = Some(stake_history_sysvar); + pub fn stake_history(&mut self, stake_history: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake_history = Some(stake_history); self } /// Stake authority @@ -173,7 +170,7 @@ impl MergeBuilder { clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( "SysvarC1ock11111111111111111111111111111111" )), - stake_history_sysvar: self.stake_history_sysvar.unwrap_or(solana_program::pubkey!( + stake_history: self.stake_history.unwrap_or(solana_program::pubkey!( "SysvarStakeHistory1111111111111111111111111" )), stake_authority: self.stake_authority.expect("stake_authority is not set"), @@ -192,7 +189,7 @@ pub struct MergeCpiAccounts<'a, 'b> { /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -208,7 +205,7 @@ pub struct MergeCpi<'a, 'b> { /// Clock sysvar pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -223,7 +220,7 @@ impl<'a, 'b> MergeCpi<'a, 'b> { destination_stake: accounts.destination_stake, source_stake: accounts.source_stake, clock_sysvar: accounts.clock_sysvar, - stake_history_sysvar: accounts.stake_history_sysvar, + stake_history: accounts.stake_history, stake_authority: accounts.stake_authority, } } @@ -274,7 +271,7 @@ impl<'a, 'b> MergeCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.stake_history_sysvar.key, + *self.stake_history.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -300,7 +297,7 @@ impl<'a, 'b> MergeCpi<'a, 'b> { account_infos.push(self.destination_stake.clone()); account_infos.push(self.source_stake.clone()); account_infos.push(self.clock_sysvar.clone()); - account_infos.push(self.stake_history_sysvar.clone()); + account_infos.push(self.stake_history.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -321,7 +318,7 @@ impl<'a, 'b> MergeCpi<'a, 'b> { /// 0. `[writable]` destination_stake /// 1. `[writable]` source_stake /// 2. `[]` clock_sysvar -/// 3. `[]` stake_history_sysvar +/// 3. `[]` stake_history /// 4. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MergeCpiBuilder<'a, 'b> { @@ -335,7 +332,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { destination_stake: None, source_stake: None, clock_sysvar: None, - stake_history_sysvar: None, + stake_history: None, stake_authority: None, __remaining_accounts: Vec::new(), }); @@ -370,11 +367,11 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { } /// Stake history sysvar that carries stake warmup/cooldown history #[inline(always)] - pub fn stake_history_sysvar( + pub fn stake_history( &mut self, - stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + stake_history: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.stake_history_sysvar = Some(stake_history_sysvar); + self.instruction.stake_history = Some(stake_history); self } /// Stake authority @@ -445,10 +442,10 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { .clock_sysvar .expect("clock_sysvar is not set"), - stake_history_sysvar: self + stake_history: self .instruction - .stake_history_sysvar - .expect("stake_history_sysvar is not set"), + .stake_history + .expect("stake_history is not set"), stake_authority: self .instruction @@ -468,7 +465,7 @@ struct MergeCpiBuilderInstruction<'a, 'b> { 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_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>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/interface/idl.json b/interface/idl.json index 83496d8f..b329bed8 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -1175,7 +1175,7 @@ "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", - "name": "stakeHistorySysvar" + "name": "stakeHistory" }, { "docs": [ diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index cf992031..2484db9b 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -299,7 +299,7 @@ pub enum StakeInstruction { )] #[cfg_attr(feature = "codama", codama(account(name = "clock_sysvar", docs = "Clock sysvar", default_value = sysvar("clock"))))] #[cfg_attr(feature = "codama", codama(account( - name = "stake_history_sysvar", + name = "stake_history", docs = "Stake history sysvar that carries stake warmup/cooldown history", default_value = sysvar("stake_history") )))] From cdfbd82aedaa61a2079960e856166c50d0bc0619 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Thu, 4 Dec 2025 18:30:18 +0000 Subject: [PATCH 24/27] fmt --- interface/src/instruction.rs | 43 ++++++++---------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 2484db9b..533deeb4 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -53,10 +53,7 @@ pub enum StakeInstruction { )] #[cfg_attr(feature = "codama", 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, - ), + Initialize(Authorized, Lockup), /// Authorize a key to manage stake or withdrawal /// @@ -85,10 +82,7 @@ pub enum StakeInstruction { )) )] // backwards compatibility with old IDL demands auto `arg0` and `arg1` names - Authorize( - Pubkey, - StakeAuthorize, - ), + Authorize(Pubkey, StakeAuthorize), /// Delegate a stake to a particular vote account /// @@ -160,10 +154,7 @@ pub enum StakeInstruction { 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, - ), + Split(#[cfg_attr(feature = "codama", codama(name = "args"))] u64), /// Withdraw unstaked lamports from the stake account /// @@ -209,10 +200,7 @@ pub enum StakeInstruction { )) )] // backwards compatibility with old IDL demands old `args` name - Withdraw( - #[cfg_attr(feature = "codama", codama(name = "args"))] - u64, - ), + Withdraw(#[cfg_attr(feature = "codama", codama(name = "args"))] u64), /// Deactivates the stake in the account /// @@ -408,8 +396,7 @@ pub enum StakeInstruction { )) )] AuthorizeChecked( - #[cfg_attr(feature = "codama", codama(name = "stakeAuthorize"))] - StakeAuthorize, + #[cfg_attr(feature = "codama", codama(name = "stakeAuthorize"))] StakeAuthorize, ), /// Authorize a key to manage stake or withdrawal with a derived key @@ -489,9 +476,7 @@ pub enum StakeInstruction { docs = "New lockup authority" )) )] - SetLockupChecked( - LockupCheckedArgs, - ), + SetLockupChecked(LockupCheckedArgs), /// Get the minimum stake delegation, in lamports /// @@ -596,10 +581,7 @@ pub enum StakeInstruction { 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, - ), + MoveStake(#[cfg_attr(feature = "codama", codama(name = "args"))] u64), /// Move unstaked lamports between accounts with the same authorities and lockups, using Staker /// authority. @@ -635,10 +617,7 @@ pub enum StakeInstruction { 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, - ), + MoveLamports(#[cfg_attr(feature = "codama", codama(name = "args"))] u64), } #[cfg_attr(feature = "codama", derive(CodamaType))] @@ -1117,11 +1096,7 @@ pub fn set_lockup( AccountMeta::new(*stake_pubkey, false), AccountMeta::new_readonly(*custodian_pubkey, true), ]; - Instruction::new_with_bincode( - ID, - &StakeInstruction::SetLockup(*lockup), - account_metas, - ) + Instruction::new_with_bincode(ID, &StakeInstruction::SetLockup(*lockup), account_metas) } #[cfg(feature = "bincode")] From acad1ac80b7a5eb83797f4ee700dcf1a7552c773 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Tue, 9 Dec 2025 11:19:12 +0400 Subject: [PATCH 25/27] update codama renderers-rust ver --- Cargo.lock | 2009 +++++------------ Cargo.toml | 2 +- clients/rust/Cargo.toml | 6 +- clients/rust/src/generated/errors/stake.rs | 12 +- .../src/generated/instructions/authorize.rs | 188 +- .../instructions/authorize_checked.rs | 201 +- .../authorize_checked_with_seed.rs | 204 +- .../instructions/authorize_with_seed.rs | 186 +- .../src/generated/instructions/deactivate.rs | 155 +- .../instructions/deactivate_delinquent.rs | 157 +- .../generated/instructions/delegate_stake.rs | 214 +- .../instructions/get_minimum_delegation.rs | 95 +- .../src/generated/instructions/initialize.rs | 147 +- .../instructions/initialize_checked.rs | 180 +- .../rust/src/generated/instructions/merge.rs | 191 +- .../generated/instructions/move_lamports.rs | 161 +- .../src/generated/instructions/move_stake.rs | 164 +- .../src/generated/instructions/set_lockup.rs | 150 +- .../instructions/set_lockup_checked.rs | 166 +- .../rust/src/generated/instructions/split.rs | 166 +- .../src/generated/instructions/withdraw.rs | 230 +- clients/rust/src/generated/programs.rs | 2 +- .../rust/src/generated/types/authorized.rs | 2 +- .../rust/src/generated/types/delegation.rs | 2 +- clients/rust/src/generated/types/lockup.rs | 2 +- .../rust/src/hooked/stake_state_account.rs | 6 +- interface/src/instruction.rs | 8 +- package.json | 2 +- pnpm-lock.yaml | 161 +- program/Cargo.toml | 2 +- program/src/processor.rs | 270 ++- program/tests/interface.rs | 54 + program/tests/stake_instruction.rs | 82 - rust-toolchain.toml | 2 +- 34 files changed, 2147 insertions(+), 3432 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a634a424..5fb2497b 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" @@ -865,7 +820,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88da5a13c620b4ca0078845707ea9c3faf11edbc3ffd8497d11d686211cd1ac0" dependencies = [ "serde", - "toml 0.8.20", + "toml", ] [[package]] @@ -1134,26 +1089,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" @@ -3002,34 +2937,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", ] @@ -3039,7 +2974,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", ] @@ -3050,9 +2985,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", ] @@ -3062,11 +2997,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]] @@ -3239,7 +3174,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", @@ -3542,15 +3477,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 0.5.11", -] - [[package]] name = "proc-macro-crate" version = "3.2.0" @@ -4599,19 +4525,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" @@ -4623,12 +4536,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]] @@ -4642,24 +4555,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" @@ -4668,9 +4568,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]] @@ -4706,31 +4606,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", @@ -4744,7 +4644,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", @@ -4753,30 +4653,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]] @@ -4789,21 +4672,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]] @@ -4821,22 +4695,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", @@ -4851,16 +4725,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", ] @@ -4874,37 +4748,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" @@ -4913,18 +4776,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]] @@ -4938,18 +4790,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" @@ -4957,7 +4797,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", ] @@ -4972,27 +4812,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]] @@ -5004,23 +4834,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", ] @@ -5037,9 +4867,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", ] @@ -5055,8 +4885,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", @@ -5076,8 +4906,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", @@ -5099,17 +4929,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", @@ -5122,7 +4952,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", @@ -5135,32 +4965,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]] @@ -5171,9 +4988,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]] @@ -5215,16 +5032,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", ] @@ -5234,9 +5051,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]] @@ -5257,12 +5074,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]] @@ -5283,7 +5100,7 @@ dependencies = [ "solana-measure", "solana-metrics", "solana-time-utils", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", "tokio", ] @@ -5297,51 +5114,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" 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]] @@ -5353,26 +5156,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" @@ -5398,8 +5186,8 @@ checksum = "e1419197f1c06abf760043f6d64ba9d79a03ad5a43f18c7586471937122094da" dependencies = [ "bytemuck", "bytemuck_derive", - "solana-instruction 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-instruction", + "solana-sdk-ids", ] [[package]] @@ -5412,20 +5200,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" @@ -5435,9 +5209,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]] @@ -5448,20 +5222,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]] @@ -5472,30 +5233,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]] @@ -5506,38 +5246,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" @@ -5547,14 +5268,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]] @@ -5568,17 +5289,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" @@ -5644,19 +5354,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", @@ -5672,24 +5382,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" @@ -5705,14 +5397,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]] @@ -5725,24 +5417,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" @@ -5750,14 +5424,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]] @@ -5769,24 +5443,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]] @@ -5796,27 +5453,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]] @@ -5826,7 +5471,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", ] @@ -5841,26 +5486,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" @@ -5869,9 +5501,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]] @@ -5887,62 +5519,18 @@ dependencies = [ ] [[package]] -name = "solana-loader-v2-interface" -version = "2.2.1" +name = "solana-loader-v3-interface" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8ab08006dad78ae7cd30df8eea0539e207d08d91eaefb3e1d49a446e1c49654" +checksum = "dee44c9b1328c5c712c68966fb8de07b47f3e7bac006e74ddd1bb053d3e46e5d" 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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee44c9b1328c5c712c68966fb8de07b47f3e7bac006e74ddd1bb053d3e46e5d" -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]] @@ -5954,10 +5542,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]] @@ -5968,17 +5556,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", @@ -6004,29 +5592,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" @@ -6039,12 +5604,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]] @@ -6058,35 +5623,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" @@ -6120,20 +5670,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" @@ -6142,10 +5678,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]] @@ -6154,10 +5690,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]] @@ -6195,13 +5731,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", ] @@ -6224,7 +5760,7 @@ checksum = "794ff76c70d6f4c5d9c86c626069225c0066043405c0c9d6b96f00c8525dade5" dependencies = [ "ark-bn254", "light-poseidon", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "thiserror 2.0.17", ] @@ -6237,125 +5773,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]] @@ -6364,17 +5792,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]] @@ -6383,22 +5801,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]] @@ -6407,7 +5810,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]] @@ -6423,20 +5826,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", @@ -6445,9 +5848,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", ] @@ -6466,81 +5869,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" @@ -6566,8 +5943,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", @@ -6597,13 +5974,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", ] @@ -6627,19 +6004,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" @@ -6648,9 +6012,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]] @@ -6682,21 +6046,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", @@ -6717,10 +6081,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", ] @@ -6731,14 +6095,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", ] @@ -6754,14 +6118,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", @@ -6813,79 +6177,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", @@ -6914,22 +6278,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" @@ -6953,34 +6311,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]] @@ -7009,17 +6346,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" @@ -7027,7 +6353,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", ] @@ -7039,8 +6365,8 @@ checksum = "445d8e12592631d76fc4dc57858bae66c9fd7cc838c306c62a472547fc9d0ce6" dependencies = [ "bytemuck", "openssl", - "solana-instruction 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-instruction", + "solana-sdk-ids", ] [[package]] @@ -7074,14 +6400,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", @@ -7100,15 +6426,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" @@ -7118,17 +6435,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" @@ -7136,19 +6442,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]] @@ -7158,19 +6453,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" @@ -7188,7 +6474,7 @@ checksum = "94953e22ca28fe4541a3447d6baeaf519cc4ddc063253bfa673b721f34c136bb" dependencies = [ "solana-hard-forks", "solana-hash 3.1.0", - "solana-sha256-hasher 3.0.0", + "solana-sha256-hasher", ] [[package]] @@ -7202,7 +6488,7 @@ dependencies = [ "serde", "serde-big-array", "serde_derive", - "solana-sanitize 3.0.0", + "solana-sanitize", ] [[package]] @@ -7211,22 +6497,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]] @@ -7238,21 +6511,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]] @@ -7264,18 +6524,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]] @@ -7284,8 +6534,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]] @@ -7293,54 +6543,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]] @@ -7350,7 +6583,7 @@ dependencies = [ "anyhow", "assert_matches", "bincode", - "borsh 1.5.7", + "borsh", "codama", "codama-macros", "num-traits", @@ -7358,21 +6591,21 @@ dependencies = [ "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", @@ -7388,22 +6621,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", ] @@ -7419,32 +6652,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", @@ -7485,13 +6718,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", @@ -7510,24 +6743,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", @@ -7535,10 +6768,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", ] @@ -7549,10 +6782,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]] @@ -7584,7 +6817,7 @@ checksum = "62606f820fe99b72ee8e26b8e20eed3c2ccc2f6e3146f537c4cb22a442c69170" dependencies = [ "eager", "enum-iterator", - "solana-pubkey 3.0.0", + "solana-pubkey", ] [[package]] @@ -7594,9 +6827,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", ] @@ -7610,22 +6843,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" @@ -7635,10 +6852,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]] @@ -7651,20 +6868,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", ] @@ -7676,50 +6893,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" @@ -7731,37 +6911,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]] @@ -7770,8 +6940,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]] @@ -7788,7 +6958,7 @@ checksum = "213b0b783dc59c113821478ab18da70b7b143ef69b194b7975fcdda20372130c" dependencies = [ "rustls 0.23.32", "solana-keypair", - "solana-pubkey 3.0.0", + "solana-pubkey", "solana-signer", "x509-parser", ] @@ -7807,14 +6977,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", @@ -7822,7 +6992,7 @@ dependencies = [ "solana-signature", "solana-signer", "solana-transaction", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", "tokio", ] @@ -7838,7 +7008,7 @@ dependencies = [ "lru", "quinn", "rustls 0.23.32", - "solana-clock 3.0.0", + "solana-clock", "solana-connection-cache", "solana-keypair", "solana-measure", @@ -7865,15 +7035,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]] @@ -7886,23 +7056,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]] @@ -7914,7 +7074,7 @@ dependencies = [ "serde", "serde_derive", "solana-instruction-error", - "solana-sanitize 3.0.0", + "solana-sanitize", ] [[package]] @@ -7929,7 +7089,7 @@ dependencies = [ "rand 0.8.5", "solana-packet", "solana-perf", - "solana-short-vec 3.0.0", + "solana-short-vec", "solana-signature", ] @@ -7947,14 +7107,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", ] @@ -7969,7 +7129,7 @@ dependencies = [ "solana-keypair", "solana-net-utils", "solana-streamer", - "solana-transaction-error 3.0.0", + "solana-transaction-error", "thiserror 2.0.17", "tokio", ] @@ -7981,7 +7141,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", @@ -7999,8 +7159,8 @@ dependencies = [ "semver", "serde", "serde_derive", - "solana-sanitize 3.0.0", - "solana-serde-varint 3.0.0", + "solana-sanitize", + "solana-serde-varint", ] [[package]] @@ -8013,16 +7173,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", @@ -8031,30 +7191,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" @@ -8068,17 +7204,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]] @@ -8094,17 +7230,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]] @@ -8120,20 +7256,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", @@ -8150,9 +7286,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", ] @@ -8181,9 +7317,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", @@ -8204,9 +7340,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", ] @@ -8234,9 +7370,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", @@ -8272,7 +7408,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "233df81b75ab99b42f002b5cdd6e65a7505ffa930624f7096a7580a56765e9cf" dependencies = [ "bytemuck", - "solana-pubkey 3.0.0", + "solana-pubkey", ] [[package]] @@ -8724,15 +7860,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "toml" version = "0.8.20" diff --git a/Cargo.toml b/Cargo.toml index 131a1e33..ac4fc77c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ check-cfg = [ ] [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/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index debc9be8..a967ce4b 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -16,7 +16,11 @@ 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 = "^3.0" 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 badf148d..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, + pub clock_sysvar: solana_pubkey::Pubkey, /// The stake or withdraw authority - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option, + 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,20 +126,20 @@ 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 } /// 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 } @@ -140,7 +148,7 @@ impl AuthorizeBuilder { #[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>, + 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>, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + 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>, + 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>, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + 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,17 +352,14 @@ 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 } /// 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 } @@ -379,7 +368,7 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { #[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 a7998ef5..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, + pub new_authority: solana_pubkey::Pubkey, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option, + 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,26 +134,26 @@ 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 } @@ -151,7 +162,7 @@ impl AuthorizeCheckedBuilder { #[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>, + pub new_authority: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + 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>, + pub new_authority: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + 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,7 +390,7 @@ 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 @@ -408,7 +400,7 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { #[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 796f5ebb..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, + pub new_authority: solana_pubkey::Pubkey, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option, + 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,26 +140,26 @@ 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 } @@ -155,7 +168,7 @@ impl AuthorizeCheckedWithSeedBuilder { #[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>, + pub new_authority: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + 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>, + pub new_authority: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + 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,7 +418,7 @@ 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 @@ -429,7 +428,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { #[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 beb781f3..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, + pub clock_sysvar: solana_pubkey::Pubkey, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option, + 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,20 +134,20 @@ 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 } @@ -143,7 +156,7 @@ impl AuthorizeWithSeedBuilder { #[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>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + 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>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// Lockup authority, if updating `StakeAuthorize::Withdrawer` before lockup expiration - pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + 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,7 +394,7 @@ 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 @@ -405,7 +404,7 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { #[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 52d6fcb7..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 to be deactivated - 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, /// 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,10 +82,10 @@ 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 { @@ -89,32 +94,26 @@ impl DeactivateBuilder { } /// 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"), @@ -144,28 +143,28 @@ impl DeactivateBuilder { /// `deactivate` CPI accounts. pub struct DeactivateCpiAccounts<'a, 'b> { /// Delegated stake account to be deactivated - 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>, /// 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>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Delegated stake account to be deactivated - 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>, /// 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, @@ -277,7 +263,7 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { } /// 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 8bdf283b..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, + pub stake: solana_pubkey::Pubkey, /// Delinquent vote account for the delegated stake account - pub delinquent_vote: solana_program::pubkey::Pubkey, + 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_program::pubkey::Pubkey, + 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 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 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>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Delinquent vote account for the delegated stake account - pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, + 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_program::account_info::AccountInfo<'a>, + 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>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Delinquent vote account for the delegated stake account - pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, + 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_program::account_info::AccountInfo<'a>, + 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,7 +264,7 @@ 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 } @@ -282,7 +272,7 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { #[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 @@ -291,7 +281,7 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { #[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 59a55c45..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, + pub clock_sysvar: solana_pubkey::Pubkey, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: solana_program::pubkey::Pubkey, + 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 { @@ -97,13 +102,13 @@ impl Default for DelegateStakeInstructionData { /// 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,51 +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 } /// `[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 } @@ -164,20 +163,20 @@ 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.unwrap_or(solana_program::pubkey!( + stake_history: self.stake_history.unwrap_or(solana_pubkey::pubkey!( "SysvarStakeHistory1111111111111111111111111" )), unused: self.unused.expect("unused is not set"), @@ -191,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>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + 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>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + 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 { @@ -238,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, @@ -322,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) } } } @@ -345,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, @@ -360,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 } @@ -374,7 +360,7 @@ 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 @@ -383,17 +369,14 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { #[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 } @@ -401,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 @@ -410,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 { @@ -426,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 @@ -438,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, @@ -480,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 97986f90..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 for the merge - pub destination_stake: solana_program::pubkey::Pubkey, + pub destination_stake: solana_pubkey::Pubkey, /// Source stake account for to merge. This account will be drained - pub source_stake: solana_program::pubkey::Pubkey, + pub source_stake: solana_pubkey::Pubkey, /// Clock sysvar - pub clock_sysvar: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_pubkey::Pubkey, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: solana_program::pubkey::Pubkey, + 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 { @@ -92,12 +99,12 @@ impl Default for MergeInstructionData { /// 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 { @@ -106,48 +113,39 @@ impl MergeBuilder { } /// 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 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 } /// `[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 } @@ -155,22 +153,22 @@ 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.unwrap_or(solana_program::pubkey!( + stake_history: self.stake_history.unwrap_or(solana_pubkey::pubkey!( "SysvarStakeHistory1111111111111111111111111" )), stake_authority: self.stake_authority.expect("stake_authority is not set"), @@ -183,36 +181,36 @@ impl MergeBuilder { /// `merge` CPI accounts. pub struct MergeCpiAccounts<'a, 'b> { /// Destination stake account for the merge - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + 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_program::account_info::AccountInfo<'a>, + pub source_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 history sysvar that carries stake warmup/cooldown history - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + 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>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Destination stake account for the merge - pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + 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_program::account_info::AccountInfo<'a>, + pub source_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 history sysvar that carries stake warmup/cooldown history - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + 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 { @@ -225,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, @@ -304,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) } } } @@ -326,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, @@ -342,7 +330,7 @@ impl<'a, 'b> MergeCpiBuilder<'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 @@ -351,7 +339,7 @@ impl<'a, 'b> MergeCpiBuilder<'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 @@ -360,7 +348,7 @@ 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 @@ -369,7 +357,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { #[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 @@ -378,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 @@ -387,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 { @@ -403,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 @@ -415,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, @@ -461,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 d3cb0b62..2d03c567 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -8,45 +8,43 @@ 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, @@ -64,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 { @@ -80,6 +82,12 @@ pub struct SetLockupInstructionArgs { 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: @@ -88,12 +96,12 @@ pub struct SetLockupInstructionArgs { /// 1. `[signer]` authority #[derive(Clone, Debug, Default)] pub struct SetLockupBuilder { - stake: Option, - authority: Option, + stake: Option, + authority: Option, unix_timestamp: Option, epoch: Option, custodian: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl SetLockupBuilder { @@ -102,13 +110,13 @@ 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 } @@ -132,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 } @@ -143,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"), @@ -167,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 { @@ -198,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, @@ -264,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) } } } @@ -283,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, @@ -297,16 +289,13 @@ 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 } @@ -332,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 { @@ -348,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 @@ -360,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(), @@ -391,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>>, + __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 121a94f8..90e33a22 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -10,50 +10,51 @@ use { 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, @@ -71,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 { @@ -86,6 +91,12 @@ pub struct SetLockupCheckedInstructionArgs { pub epoch: Option, } +impl SetLockupCheckedInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `SetLockupChecked`. /// /// ### Accounts: @@ -95,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, + stake: Option, + authority: Option, + new_authority: Option, unix_timestamp: Option, epoch: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl SetLockupCheckedBuilder { @@ -109,23 +120,20 @@ 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 } @@ -143,10 +151,7 @@ impl SetLockupCheckedBuilder { } /// 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,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"), @@ -178,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 { @@ -214,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, @@ -289,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) } } } @@ -309,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, @@ -323,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 } @@ -341,7 +330,7 @@ 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 @@ -362,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 { @@ -378,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 @@ -390,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(), @@ -422,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>>, + __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 0e76388b..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; must be in the Initialized or Stake state - pub stake: solana_program::pubkey::Pubkey, + pub stake: solana_pubkey::Pubkey, /// Uninitialized stake account that will take the split-off amount - pub split_stake: solana_program::pubkey::Pubkey, + 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,11 +97,11 @@ 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 { @@ -102,22 +110,19 @@ impl SplitBuilder { } /// 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 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"), @@ -162,30 +164,30 @@ impl SplitBuilder { /// `split` CPI accounts. pub struct SplitCpiAccounts<'a, 'b> { /// Stake account to be split; must be in the Initialized or Stake state - pub stake: &'b solana_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Uninitialized stake account that will take the split-off amount - pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + 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>, + 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_program::account_info::AccountInfo<'a>, + pub stake: &'b solana_account_info::AccountInfo<'a>, /// Uninitialized stake account that will take the split-off amount - pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + 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, @@ -302,7 +291,7 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { } /// 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 } @@ -310,7 +299,7 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { #[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 cf712994..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, + pub clock_sysvar: solana_pubkey::Pubkey, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: solana_program::pubkey::Pubkey, + pub stake_history: solana_pubkey::Pubkey, /// Withdraw authority - pub withdraw_authority: solana_program::pubkey::Pubkey, + pub withdraw_authority: solana_pubkey::Pubkey, /// Lockup authority, if before lockup expiration - pub lockup_authority: Option, + 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: @@ -112,14 +117,14 @@ pub struct WithdrawInstructionArgs { /// 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,36 +133,33 @@ 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 } /// `[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 } @@ -166,7 +168,7 @@ impl WithdrawBuilder { #[inline(always)] pub fn lockup_authority( &mut self, - lockup_authority: Option, + lockup_authority: Option, ) -> &mut Self { self.lockup_authority = lockup_authority; self @@ -178,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 } @@ -189,20 +188,20 @@ 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.unwrap_or(solana_program::pubkey!( + stake_history: self.stake_history.unwrap_or(solana_pubkey::pubkey!( "SysvarStakeHistory1111111111111111111111111" )), withdraw_authority: self @@ -221,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>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_history: &'b solana_account_info::AccountInfo<'a>, /// Withdraw authority - pub withdraw_authority: &'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_program::account_info::AccountInfo<'a>>, + 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>, + pub clock_sysvar: &'b solana_account_info::AccountInfo<'a>, /// Stake history sysvar that carries stake warmup/cooldown history - pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, + pub stake_history: &'b solana_account_info::AccountInfo<'a>, /// Withdraw authority - pub withdraw_authority: &'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_program::account_info::AccountInfo<'a>>, + 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 { @@ -272,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, @@ -362,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) } } } @@ -385,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, @@ -401,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 } @@ -418,7 +401,7 @@ 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 @@ -427,7 +410,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { #[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 @@ -436,7 +419,7 @@ 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 @@ -446,7 +429,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { #[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 @@ -460,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 { @@ -476,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 @@ -488,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"), }; @@ -534,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 6099f376..67195f5d 100644 --- a/clients/rust/src/generated/types/delegation.rs +++ b/clients/rust/src/generated/types/delegation.rs @@ -8,7 +8,7 @@ use { crate::generated::types::Epoch, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, + solana_pubkey::Pubkey, }; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] diff --git a/clients/rust/src/generated/types/lockup.rs b/clients/rust/src/generated/types/lockup.rs index 8b364f93..906b9fa7 100644 --- a/clients/rust/src/generated/types/lockup.rs +++ b/clients/rust/src/generated/types/lockup.rs @@ -8,7 +8,7 @@ use { crate::generated::types::{Epoch, UnixTimestamp}, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, + solana_pubkey::Pubkey, }; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)] 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/interface/src/instruction.rs b/interface/src/instruction.rs index 533deeb4..e6e83365 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -31,12 +31,16 @@ const RENT_ID: Pubkey = Pubkey::from_str_const("SysvarRent1111111111111111111111 const STAKE_HISTORY_ID: Pubkey = Pubkey::from_str_const("SysvarStakeHistory1111111111111111111111111"); -#[cfg_attr(feature = "codama", derive(CodamaInstructions))] -#[derive(Debug, PartialEq, Eq, Clone)] +// NOTE the stake program is in the process of removing dependence on all sysvars +// once this version of the program is live on all clusters, we can remove them here +// namely, from all doc comments in `StakeInstruction` and in all instruction builders +// we may also remove all use of and reference to the stake config account #[cfg_attr( 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 /// diff --git a/package.json b/package.json index 4b818f27..48c64bf7 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "devDependencies": { "@codama/nodes-from-anchor": "^1.3.6", "@codama/renderers-js": "^1.4", - "@codama/renderers-rust": "~1.0", + "@codama/renderers-rust": "1.2.9", "@iarna/toml": "^2.2.5", "codama": "^1.4", "tsx": "^4.21.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3d99adc3..1ebcab7f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: 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,10 +39,6 @@ packages: resolution: {integrity: sha512-I6EdKY0e/6OFQpPgwa+qnts/dpWESIXRg0Zmwd6LR7WIL+6tOV1MYMbhrkYCGxxp1N0zkEiMShc9U6m7wj8oew==} 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 @@ -51,9 +47,6 @@ packages: resolution: {integrity: sha512-XC86H5X+zGTi0cSRKLc+wFkeXNsvnh+ttOgVnVHIljmXOJWbUt9wXhKding3UftipLWwlHPuoswERJ0vS0mO2A==} hasBin: true - '@codama/node-types@1.2.8': - resolution: {integrity: sha512-PEvPLMN3QGJvkwsQ7R9DmAtdazQXN0RD9WYlmHyeiR4nathV0qy9nZGFDoRh5nbNfPkbeLTgL5o3zAoeeRP6GQ==} - '@codama/node-types@1.3.7': resolution: {integrity: sha512-L9UTFfoeki5t+BYJAa4OMsqBPpbMbx8YJQar+55mYcjwGlJsKJW7mRfLYvwEFkCUYyLdNva40OVmTf88jccZCA==} @@ -63,34 +56,29 @@ packages: '@codama/nodes-from-anchor@1.3.6': resolution: {integrity: sha512-614DZS9H5gW16Rkeu0ES8BHnDvbd8M9FLqPWnp9QUE0b+wCvWB36yZiRylJ4fw8gRDSc+FR7C2i3NXKycpvBEg==} - '@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/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.4.4': resolution: {integrity: sha512-IbSOrfoR4R5oKs3euydfujCbJoOAr/ngjsvJ4VQM2Q/bTOcfdlsG3NvJF0ny/yq1Jvmi8Su9cl1pzDCumJpHAA==} - '@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==} @@ -263,12 +251,6 @@ packages: 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'} @@ -287,12 +269,6 @@ packages: 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 +281,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'} @@ -332,13 +301,6 @@ packages: 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'} @@ -377,18 +339,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 +351,6 @@ packages: resolution: {integrity: sha512-DpS9XRftrck13FRbSh6hR8V+loAPdtuuFRKixKyAahdR1R4T/EJJ9G78JqBfVXow+4lJ1NKhNlvHKKEJPaE+FQ==} 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 +432,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,12 +509,6 @@ 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 @@ -585,8 +521,6 @@ snapshots: commander: 14.0.2 picocolors: 1.1.1 - '@codama/node-types@1.2.8': {} - '@codama/node-types@1.3.7': {} '@codama/node-types@1.4.4': {} @@ -602,11 +536,6 @@ snapshots: - fastestsmallesttextencoderdecoder - typescript - '@codama/nodes@1.2.8': - dependencies: - '@codama/errors': 1.2.8 - '@codama/node-types': 1.2.8 - '@codama/nodes@1.3.7': dependencies: '@codama/errors': 1.3.7 @@ -617,18 +546,18 @@ snapshots: '@codama/errors': 1.4.4 '@codama/node-types': 1.4.4 - '@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 +570,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,12 +589,6 @@ snapshots: '@codama/nodes': 1.4.4 '@codama/visitors-core': 1.4.4 - '@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 @@ -766,11 +689,6 @@ snapshots: '@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) @@ -788,12 +706,6 @@ snapshots: '@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 +718,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) @@ -841,12 +745,6 @@ snapshots: 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 @@ -891,18 +789,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.4.4: @@ -913,10 +804,6 @@ snapshots: '@codama/validators': 1.4.4 '@codama/visitors': 1.4.4 - commander@12.1.0: {} - - commander@13.1.0: {} - commander@14.0.1: {} commander@14.0.2: {} @@ -1028,14 +915,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/Cargo.toml b/program/Cargo.toml index ab99cd58..97c5ae46 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -21,6 +21,7 @@ solana-pubkey = "3.0.0" solana-rent = "3.0.0" solana-stake-interface = { version = "2", features = ["bincode", "borsh", "sysvar"] } solana-sysvar = "3.0.0" +solana-sysvar-id = "3.0.0" solana-vote-interface = { version = "4.0.4", features = ["bincode"] } [dev-dependencies] @@ -43,7 +44,6 @@ solana-signature = "3.0.0" solana-signer = "3.0.0" solana-svm-log-collector = "3.0.0" solana-system-interface = { version = "2.0.0", features = ["bincode"] } -solana-sysvar-id = "3.0.0" solana-transaction = "3.0.0" test-case = "3.3.1" diff --git a/program/src/processor.rs b/program/src/processor.rs index d9033c11..0026488c 100644 --- a/program/src/processor.rs +++ b/program/src/processor.rs @@ -18,7 +18,8 @@ use { sysvar::stake_history::StakeHistorySysvar, tools::{acceptable_reference_epoch_credits, eligible_for_deactivate_delinquent}, }, - solana_sysvar::{epoch_rewards::EpochRewards, Sysvar, SysvarSerialize}, + solana_sysvar::{epoch_rewards::EpochRewards, Sysvar}, + solana_sysvar_id::SysvarId, solana_vote_interface::{program as solana_vote_program, state::VoteStateV4}, std::{collections::HashSet, mem::MaybeUninit}, }; @@ -134,13 +135,13 @@ fn do_initialize( stake_account_info: &AccountInfo, authorized: Authorized, lockup: Lockup, - rent: &Rent, ) -> ProgramResult { if stake_account_info.data_len() != StakeStateV2::size_of() { return Err(ProgramError::InvalidAccountData); } if let StakeStateV2::Uninitialized = get_stake_state(stake_account_info)? { + let rent = Rent::get()?; let rent_exempt_reserve = rent.minimum_balance(stake_account_info.data_len()); if stake_account_info.lamports() >= rent_exempt_reserve { let stake_state = StakeStateV2::Initialized(Meta { @@ -164,8 +165,9 @@ fn do_authorize( new_authority: &Pubkey, authority_type: StakeAuthorize, custodian: Option<&Pubkey>, - clock: &Clock, ) -> ProgramResult { + let clock = &Clock::get()?; + match get_stake_state(stake_account_info)? { StakeStateV2::Initialized(mut meta) => { meta.authorized @@ -287,26 +289,36 @@ fn move_stake_or_lamports_shared_checks( Ok((source_merge_kind, destination_merge_kind)) } -// NOTE our usage of the accounts iter is idiosyncratic, in imitation of the native stake program -// native stake typically accumulates all signers from the accounts array indiscriminately -// each instruction processor also asserts a required number of instruction accounts -// but this is extremely ad hoc, essentially allowing any account to act as a signing authority -// when lengths are asserted in setup, accounts are retrieved via hardcoded index from InstructionContext -// but after control is passed to main processing functions, they are pulled from the TransactionContext +// NOTE Our usage of the accounts iter is nonstandard, in imitation of the Native Stake Program. +// Native Stake typically, but not always, accumulated signers from the accounts array indiscriminately. +// This essentially allowed any account to act as a stake account signing authority. +// Instruction processors also asserted a required number of instruction accounts, often fewer than the actual number. +// When lengths were asserted in setup, accounts were retrieved via hardcoded index from `InstructionContext`, +// but after control was passed to main processing functions, they were pulled from the `TransactionContext`. +// +// When porting to BPF, we reimplemented this behavior exactly, such that both programs would be consensus-compatible: +// * All transactions that would fail on one program also fail on the other. +// * All transactions that would succeed on one program also succeed on the other. +// * For successful transactions, all account state transitions are identical. +// Error codes and log output sometimes differed. // -// we aim to implement this behavior exactly, such that both programs are consensus compatible: -// * all transactions that would fail on one program also fail on the other -// * all transactions that would succeed on one program also succeed on the other -// * for successful transactions, all account state transitions are identical -// error codes and log output may differ +// Native Stake also accepted some sysvars as input accounts, but pulled others from `InvokeContext`. +// This was done for backwards compatibility, but the end result was highly inconsistent. // -// this is not strictly necessary, since the switchover will be feature-gated. so this is not a security issue -// mostly its so no one can blame the bpf switchover for breaking their usecase, even pathological ones +// BPF Stake implements a new, stricter, interface, and supports both by branching when necessary. +// This new interface asserts that authorities are present in expected positions, and that they are signers. +// Self-signed stake accounts are still supported; the key simply must be passed in twice. +// The new interface also requires no sysvar accounts, retrieving all sysvars by syscall. +// Thus, we can fall back to the old interface if we encounter the first old-interface sysvar. +// Each processor has its own special logic, but we annotate "invariant," "diverge," and "converge" to make the flow obvious. // -// in service to this end, all accounts iters are commented with how the native program uses them -// for accounts that should always, or almost always, exist, which the native program does not assert... -// ...we leave a commented-out `next_account_info()` call, to aid in a future refactor -// after the bpf switchover ships, we may update to strictly assert these accounts exist +// We do not modify `Split`, `SetLockup`, and `SetLockupChecked`, as it would be a breaking change. +// These instructions never accepted sysvar accounts, so there is no way to distinguish "old" from "new." +// However, we may make this change if we determine there are no legitimate mainnet users of the lax constraints. +// Eventually, we may be able to remove the old interface and move to standard positional accounts for all instructions. +// +// New interface signer checks may duplicate later signer hashset checks. This is intended and harmless. +// `ok()` account retrievals (lockup custodians) were, are, and will always be optional by design. pub struct Processor {} impl Processor { fn process_initialize( @@ -316,14 +328,11 @@ impl Processor { ) -> ProgramResult { let account_info_iter = &mut accounts.iter(); - // native asserts: 2 accounts (1 sysvar) + // invariant let stake_account_info = next_account_info(account_info_iter)?; - let rent_info = next_account_info(account_info_iter)?; - - let rent = &Rent::from_account_info(rent_info)?; // `get_stake_state()` is called unconditionally, which checks owner - do_initialize(stake_account_info, authorized, lockup, rent)?; + do_initialize(stake_account_info, authorized, lockup)?; Ok(()) } @@ -336,15 +345,24 @@ impl Processor { let signers = collect_signers(accounts); let account_info_iter = &mut accounts.iter(); - // native asserts: 3 accounts (1 sysvar) + // invariant let stake_account_info = next_account_info(account_info_iter)?; - let clock_info = next_account_info(account_info_iter)?; - let _stake_or_withdraw_authority_info = next_account_info(account_info_iter)?; - // other accounts - let option_lockup_authority_info = next_account_info(account_info_iter).ok(); + // diverge + { + let branch_account = next_account_info(account_info_iter)?; + if Clock::check_id(branch_account.key) { + let _stake_or_withdraw_authority_info = next_account_info(account_info_iter)?; + } else { + let stake_or_withdraw_authority_info = branch_account; + if !stake_or_withdraw_authority_info.is_signer { + return Err(ProgramError::MissingRequiredSignature); + } + } + } - let clock = &Clock::from_account_info(clock_info)?; + // converge + let option_lockup_authority_info = next_account_info(account_info_iter).ok(); let custodian = option_lockup_authority_info .filter(|a| a.is_signer) @@ -357,7 +375,6 @@ impl Processor { &new_authority, authority_type, custodian, - clock, )?; Ok(()) @@ -367,17 +384,26 @@ impl Processor { let signers = collect_signers(accounts); let account_info_iter = &mut accounts.iter(); - // native asserts: 5 accounts (2 sysvars + stake config) + // invariant let stake_account_info = next_account_info(account_info_iter)?; let vote_account_info = next_account_info(account_info_iter)?; - let clock_info = next_account_info(account_info_iter)?; - let _stake_history_info = next_account_info(account_info_iter)?; - let _stake_config_info = next_account_info(account_info_iter)?; - // other accounts - // let _stake_authority_info = next_account_info(account_info_iter); + // diverge + { + let branch_account = next_account_info(account_info_iter)?; + if Clock::check_id(branch_account.key) { + let _stake_history_info = next_account_info(account_info_iter)?; + let _stake_config_info = next_account_info(account_info_iter)?; + // let _stake_authority_info = next_account_info(account_info_iter); + } else { + let stake_authority_info = branch_account; + if !stake_authority_info.is_signer { + return Err(ProgramError::MissingRequiredSignature); + } + } + }; - let clock = &Clock::from_account_info(clock_info)?; + let clock = &Clock::get()?; let stake_history = &StakeHistorySysvar(clock.epoch); let vote_state = get_vote_state(vote_account_info)?; @@ -459,7 +485,8 @@ impl Processor { let source_stake_account_info = next_account_info(account_info_iter)?; let destination_stake_account_info = next_account_info(account_info_iter)?; - // other accounts + // NOTE we cannot check this account without a breaking change + // we may decide to enforce this if the pattern is not used on mainnet // let _stake_authority_info = next_account_info(account_info_iter); let clock = Clock::get()?; @@ -625,17 +652,29 @@ impl Processor { fn process_withdraw(accounts: &[AccountInfo], withdraw_lamports: u64) -> ProgramResult { let account_info_iter = &mut accounts.iter(); - // native asserts: 5 accounts (2 sysvars) + // invariant let source_stake_account_info = next_account_info(account_info_iter)?; let destination_info = next_account_info(account_info_iter)?; - let clock_info = next_account_info(account_info_iter)?; - let _stake_history_info = next_account_info(account_info_iter)?; - let withdraw_authority_info = next_account_info(account_info_iter)?; - // other accounts + // diverge + let withdraw_authority_info = { + let branch_account = next_account_info(account_info_iter)?; + if Clock::check_id(branch_account.key) { + let _stake_history_info = next_account_info(account_info_iter)?; + next_account_info(account_info_iter)? + } else { + let withdraw_authority_info = branch_account; + if !withdraw_authority_info.is_signer { + return Err(ProgramError::MissingRequiredSignature); + } + withdraw_authority_info + } + }; + + // converge let option_lockup_authority_info = next_account_info(account_info_iter).ok(); - let clock = &Clock::from_account_info(clock_info)?; + let clock = &Clock::get()?; let stake_history = &StakeHistorySysvar(clock.epoch); if source_stake_account_info.key == destination_info.key { @@ -731,14 +770,23 @@ impl Processor { let signers = collect_signers(accounts); let account_info_iter = &mut accounts.iter(); - // native asserts: 2 accounts (1 sysvar) + // invariant let stake_account_info = next_account_info(account_info_iter)?; - let clock_info = next_account_info(account_info_iter)?; - // other accounts - // let _stake_authority_info = next_account_info(account_info_iter); + // diverge + { + let branch_account = next_account_info(account_info_iter)?; + if Clock::check_id(branch_account.key) { + // let _stake_authority_info = next_account_info(account_info_iter); + } else { + let stake_authority_info = branch_account; + if !stake_authority_info.is_signer { + return Err(ProgramError::MissingRequiredSignature); + } + } + } - let clock = &Clock::from_account_info(clock_info)?; + let clock = &Clock::get()?; match get_stake_state(stake_account_info)? { StakeStateV2::Stake(meta, mut stake, stake_flags) => { @@ -766,7 +814,8 @@ impl Processor { // native asserts: 1 account let stake_account_info = next_account_info(account_info_iter)?; - // other accounts + // NOTE we cannot check this account without a breaking change + // we may decide to enforce this if the pattern is not used on mainnet // let _old_withdraw_or_lockup_authority_info = next_account_info(account_info_iter); let clock = Clock::get()?; @@ -781,16 +830,25 @@ impl Processor { let signers = collect_signers(accounts); let account_info_iter = &mut accounts.iter(); - // native asserts: 4 accounts (2 sysvars) + // invariant let destination_stake_account_info = next_account_info(account_info_iter)?; let source_stake_account_info = next_account_info(account_info_iter)?; - let clock_info = next_account_info(account_info_iter)?; - let _stake_history_info = next_account_info(account_info_iter)?; - // other accounts - // let _stake_authority_info = next_account_info(account_info_iter); + // diverge + { + let branch_account = next_account_info(account_info_iter)?; + if Clock::check_id(branch_account.key) { + let _stake_history_info = next_account_info(account_info_iter)?; + // let _stake_authority_info = next_account_info(account_info_iter); + } else { + let stake_authority_info = branch_account; + if !stake_authority_info.is_signer { + return Err(ProgramError::MissingRequiredSignature); + } + } + } - let clock = &Clock::from_account_info(clock_info)?; + let clock = &Clock::get()?; let stake_history = &StakeHistorySysvar(clock.epoch); if source_stake_account_info.key == destination_stake_account_info.key { @@ -844,15 +902,19 @@ impl Processor { ) -> ProgramResult { let account_info_iter = &mut accounts.iter(); - // native asserts: 3 accounts (1 sysvar) + // invariant let stake_account_info = next_account_info(account_info_iter)?; let stake_or_withdraw_authority_base_info = next_account_info(account_info_iter)?; - let clock_info = next_account_info(account_info_iter)?; - - // other accounts - let option_lockup_authority_info = next_account_info(account_info_iter).ok(); - let clock = &Clock::from_account_info(clock_info)?; + // diverge + let option_lockup_authority_info = { + let branch_account = next_account_info(account_info_iter).ok(); + if branch_account.is_some_and(|account| Clock::check_id(account.key)) { + next_account_info(account_info_iter).ok() + } else { + branch_account + } + }; let (mut signers, custodian) = collect_signers_checked(None, option_lockup_authority_info)?; @@ -871,7 +933,6 @@ impl Processor { &authorize_args.new_authorized_pubkey, authorize_args.stake_authorize, custodian, - clock, )?; Ok(()) @@ -880,13 +941,22 @@ impl Processor { fn process_initialize_checked(accounts: &[AccountInfo]) -> ProgramResult { let account_info_iter = &mut accounts.iter(); - // native asserts: 4 accounts (1 sysvar) + // invariant let stake_account_info = next_account_info(account_info_iter)?; - let rent_info = next_account_info(account_info_iter)?; - let stake_authority_info = next_account_info(account_info_iter)?; - let withdraw_authority_info = next_account_info(account_info_iter)?; - let rent = &Rent::from_account_info(rent_info)?; + // diverge + let stake_authority_info = { + let branch_account = next_account_info(account_info_iter)?; + if Rent::check_id(branch_account.key) { + next_account_info(account_info_iter)? + } else { + // we do not need to check this, withdraw_authority is the only signer + branch_account + } + }; + + // converge + let withdraw_authority_info = next_account_info(account_info_iter)?; if !withdraw_authority_info.is_signer { return Err(ProgramError::MissingRequiredSignature); @@ -898,7 +968,7 @@ impl Processor { }; // `get_stake_state()` is called unconditionally, which checks owner - do_initialize(stake_account_info, authorized, Lockup::default(), rent)?; + do_initialize(stake_account_info, authorized, Lockup::default())?; Ok(()) } @@ -910,16 +980,25 @@ impl Processor { let signers = collect_signers(accounts); let account_info_iter = &mut accounts.iter(); - // native asserts: 4 accounts (1 sysvar) + // invariant let stake_account_info = next_account_info(account_info_iter)?; - let clock_info = next_account_info(account_info_iter)?; - let _old_stake_or_withdraw_authority_info = next_account_info(account_info_iter)?; - let new_stake_or_withdraw_authority_info = next_account_info(account_info_iter)?; - // other accounts - let option_lockup_authority_info = next_account_info(account_info_iter).ok(); + // diverge + { + let branch_account = next_account_info(account_info_iter)?; + if Clock::check_id(branch_account.key) { + let _old_stake_or_withdraw_authority_info = next_account_info(account_info_iter)?; + } else { + let old_stake_or_withdraw_authority_info = branch_account; + if !old_stake_or_withdraw_authority_info.is_signer { + return Err(ProgramError::MissingRequiredSignature); + } + } + } - let clock = &Clock::from_account_info(clock_info)?; + // converge + let new_stake_or_withdraw_authority_info = next_account_info(account_info_iter)?; + let option_lockup_authority_info = next_account_info(account_info_iter).ok(); if !new_stake_or_withdraw_authority_info.is_signer { return Err(ProgramError::MissingRequiredSignature); @@ -936,7 +1015,6 @@ impl Processor { new_stake_or_withdraw_authority_info.key, authority_type, custodian, - clock, )?; Ok(()) @@ -948,16 +1026,26 @@ impl Processor { ) -> ProgramResult { let account_info_iter = &mut accounts.iter(); - // native asserts: 4 accounts (1 sysvar) + // invariant let stake_account_info = next_account_info(account_info_iter)?; let old_stake_or_withdraw_authority_base_info = next_account_info(account_info_iter)?; - let clock_info = next_account_info(account_info_iter)?; - let new_stake_or_withdraw_authority_info = next_account_info(account_info_iter)?; - // other accounts - let option_lockup_authority_info = next_account_info(account_info_iter).ok(); + // diverge + let new_stake_or_withdraw_authority_info = { + let branch_account = next_account_info(account_info_iter)?; + if Clock::check_id(branch_account.key) { + next_account_info(account_info_iter)? + } else { + let new_stake_or_withdraw_authority_info = branch_account; + if !new_stake_or_withdraw_authority_info.is_signer { + return Err(ProgramError::MissingRequiredSignature); + } + new_stake_or_withdraw_authority_info + } + }; - let clock = &Clock::from_account_info(clock_info)?; + // converge + let option_lockup_authority_info = next_account_info(account_info_iter).ok(); let (mut signers, custodian) = collect_signers_checked( Some(new_stake_or_withdraw_authority_info), @@ -979,7 +1067,6 @@ impl Processor { new_stake_or_withdraw_authority_info.key, authorize_args.stake_authorize, custodian, - clock, )?; Ok(()) @@ -995,7 +1082,8 @@ impl Processor { // native asserts: 1 account let stake_account_info = next_account_info(account_info_iter)?; - // other accounts + // NOTE we cannot check this account without a breaking change + // we may decide to enforce this if the pattern is not used on mainnet let _old_withdraw_or_lockup_authority_info = next_account_info(account_info_iter); let option_new_lockup_authority_info = next_account_info(account_info_iter).ok(); @@ -1024,7 +1112,7 @@ impl Processor { fn process_deactivate_delinquent(accounts: &[AccountInfo]) -> ProgramResult { let account_info_iter = &mut accounts.iter(); - // native asserts: 3 accounts + // invariant let stake_account_info = next_account_info(account_info_iter)?; let delinquent_vote_account_info = next_account_info(account_info_iter)?; let reference_vote_account_info = next_account_info(account_info_iter)?; @@ -1069,7 +1157,7 @@ impl Processor { fn process_move_stake(accounts: &[AccountInfo], lamports: u64) -> ProgramResult { let account_info_iter = &mut accounts.iter(); - // native asserts: 3 accounts + // invariant let source_stake_account_info = next_account_info(account_info_iter)?; let destination_stake_account_info = next_account_info(account_info_iter)?; let stake_authority_info = next_account_info(account_info_iter)?; @@ -1206,7 +1294,7 @@ impl Processor { fn process_move_lamports(accounts: &[AccountInfo], lamports: u64) -> ProgramResult { let account_info_iter = &mut accounts.iter(); - // native asserts: 3 accounts + // invariant let source_stake_account_info = next_account_info(account_info_iter)?; let destination_stake_account_info = next_account_info(account_info_iter)?; let stake_authority_info = next_account_info(account_info_iter)?; @@ -1325,8 +1413,6 @@ impl Processor { } #[allow(deprecated)] StakeInstruction::Redelegate => Err(ProgramError::InvalidInstructionData), - // NOTE we assume the program is going live after `move_stake_and_move_lamports_ixs` is - // activated StakeInstruction::MoveStake(lamports) => { msg!("Instruction: MoveStake"); Self::process_move_stake(accounts, lamports) diff --git a/program/tests/interface.rs b/program/tests/interface.rs index 0631e27a..b6e19527 100644 --- a/program/tests/interface.rs +++ b/program/tests/interface.rs @@ -1125,6 +1125,60 @@ fn test_no_use_dealloc() { } } +// the original stake interface passed in sysvars and stake config +// we no longer retrieve these via account info in any instruction processors +// since instruction builders still provide them, we test the program does not require them +// NOTE this function and all `_new_interface` tests can be deleted after the instruction builders are updated +#[allow(deprecated)] +fn is_stake_program_sysvar_or_config(pubkey: Pubkey) -> bool { + pubkey == Clock::id() + || pubkey == Rent::id() + || pubkey == StakeHistory::id() + || pubkey == solana_sdk_ids::stake::config::id() +} + +#[test] +fn test_all_success_new_interface() { + let mut env = Env::init(); + + for declaration in &*INSTRUCTION_DECLARATIONS { + let mut instruction = declaration.to_instruction(&mut env); + + instruction + .accounts + .retain(|account| !is_stake_program_sysvar_or_config(account.pubkey)); + + env.process_success(&instruction); + env.reset(); + } +} + +#[test] +fn test_no_signer_bypass_new_interface() { + let mut env = Env::init(); + + for declaration in &*INSTRUCTION_DECLARATIONS { + let mut instruction = declaration.to_instruction(&mut env); + + instruction + .accounts + .retain(|account| !is_stake_program_sysvar_or_config(account.pubkey)); + + let instruction = instruction; + + for i in 0..instruction.accounts.len() { + if !instruction.accounts[i].is_signer { + continue; + } + + let mut instruction = instruction.clone(); + instruction.accounts[i].is_signer = false; + env.process_fail(&instruction); + env.reset(); + } + } +} + // this prints ballpark compute unit costs suitable for insertion in README.md // run with `cargo test --test interface show_compute_usage -- --nocapture --ignored` #[test] diff --git a/program/tests/stake_instruction.rs b/program/tests/stake_instruction.rs index 8aa9fd5a..58df8118 100644 --- a/program/tests/stake_instruction.rs +++ b/program/tests/stake_instruction.rs @@ -492,8 +492,6 @@ fn test_stake_process_instruction_decode_bail() { let rent_address = rent::id(); let rent = Rent::default(); let rent_account = create_account_shared_data_for_test(&rent); - let rewards_address = rewards::id(); - let rewards_account = create_account_shared_data_for_test(&rewards::Rewards::new(0.0)); let stake_history_address = StakeHistory::id(); let stake_history_account = create_account_shared_data_for_test(&StakeHistory::default()); let vote_address = Pubkey::new_unique(); @@ -521,23 +519,6 @@ fn test_stake_process_instruction_decode_bail() { Err(ProgramError::NotEnoughAccountKeys), ); - // no account for rent - process_instruction( - &mollusk, - &serialize(&StakeInstruction::Initialize( - Authorized::default(), - Lockup::default(), - )) - .unwrap(), - vec![(stake_address, stake_account.clone())], - vec![AccountMeta { - pubkey: stake_address, - is_signer: false, - is_writable: true, - }], - Err(ProgramError::NotEnoughAccountKeys), - ); - // fails to deserialize stake state process_instruction( &mollusk, @@ -632,46 +613,6 @@ fn test_stake_process_instruction_decode_bail() { Err(ProgramError::InvalidAccountData), ); - // Tests 3rd keyed account is of correct type (Clock instead of rewards) in withdraw - process_instruction( - &mollusk, - &serialize(&StakeInstruction::Withdraw(withdrawal_amount)).unwrap(), - vec![ - (stake_address, stake_account.clone()), - (vote_address, vote_account.clone()), - (rewards_address, rewards_account.clone()), - (stake_history_address, stake_history_account), - ], - vec![ - AccountMeta { - pubkey: stake_address, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: vote_address, - is_signer: false, - is_writable: false, - }, - AccountMeta { - pubkey: rewards_address, - is_signer: false, - is_writable: false, - }, - AccountMeta { - pubkey: stake_history_address, - is_signer: false, - is_writable: false, - }, - AccountMeta { - pubkey: stake_address, - is_signer: true, - is_writable: false, - }, - ], - Err(ProgramError::InvalidArgument), - ); - // Tests correct number of accounts are provided in withdraw process_instruction( &mollusk, @@ -685,29 +626,6 @@ fn test_stake_process_instruction_decode_bail() { Err(ProgramError::NotEnoughAccountKeys), ); - // Tests 2nd keyed account is of correct type (Clock instead of rewards) in deactivate - process_instruction( - &mollusk, - &serialize(&StakeInstruction::Deactivate).unwrap(), - vec![ - (stake_address, stake_account.clone()), - (rewards_address, rewards_account), - ], - vec![ - AccountMeta { - pubkey: stake_address, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: rewards_address, - is_signer: false, - is_writable: false, - }, - ], - Err(ProgramError::InvalidArgument), - ); - // Tests correct number of accounts are provided in deactivate process_instruction( &mollusk, 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" From 8ec4ab818c3e4445b734dc8be57df392ca9907a7 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Tue, 9 Dec 2025 13:49:04 +0400 Subject: [PATCH 26/27] crate serialization features --- clients/rust/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index a967ce4b..2419fefa 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -11,7 +11,7 @@ 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 } @@ -20,7 +20,7 @@ solana-account-info = "^3.0" solana-cpi = "^3.0" solana-instruction = "^3.0" solana-program-error = "^3.0" -solana-pubkey = "^3.0" +solana-pubkey = { version = "^3.0", features = ["borsh", "serde"] } thiserror = "2.0" [dev-dependencies] From 2f8f4382120ee0407a6e17b6ebe0c49580fd3705 Mon Sep 17 00:00:00 2001 From: rustopian <96253492+rustopian@users.noreply.github.com> Date: Tue, 9 Dec 2025 14:51:27 +0400 Subject: [PATCH 27/27] Initialize tests, basic helper framework --- Cargo.lock | 1 + program/Cargo.toml | 1 + program/tests/helpers/context.rs | 115 +++++++ program/tests/helpers/instruction_builders.rs | 86 ++++++ program/tests/helpers/lifecycle.rs | 31 ++ program/tests/helpers/mod.rs | 7 + program/tests/helpers/utils.rs | 65 ++++ program/tests/initialize.rs | 284 ++++++++++++++++++ 8 files changed, 590 insertions(+) create mode 100644 program/tests/helpers/context.rs create mode 100644 program/tests/helpers/instruction_builders.rs create mode 100644 program/tests/helpers/lifecycle.rs create mode 100644 program/tests/helpers/mod.rs create mode 100644 program/tests/helpers/utils.rs create mode 100644 program/tests/initialize.rs diff --git a/Cargo.lock b/Cargo.lock index 5fb2497b..e2f069cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6673,6 +6673,7 @@ dependencies = [ "solana-sdk-ids", "solana-signature", "solana-signer", + "solana-stake-client", "solana-stake-interface 2.0.1", "solana-svm-log-collector", "solana-system-interface", diff --git a/program/Cargo.toml b/program/Cargo.toml index 97c5ae46..4249cd06 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -19,6 +19,7 @@ solana-program-entrypoint = "3.0.0" solana-program-error = "3.0.0" solana-pubkey = "3.0.0" solana-rent = "3.0.0" +solana-stake-client = { version = "0.0.0", path = "../clients/rust" } solana-stake-interface = { version = "2", features = ["bincode", "borsh", "sysvar"] } solana-sysvar = "3.0.0" solana-sysvar-id = "3.0.0" diff --git a/program/tests/helpers/context.rs b/program/tests/helpers/context.rs new file mode 100644 index 00000000..85b8e188 --- /dev/null +++ b/program/tests/helpers/context.rs @@ -0,0 +1,115 @@ +use { + super::{ + instruction_builders::InstructionExecution, + lifecycle::StakeLifecycle, + utils::{add_sysvars, STAKE_RENT_EXEMPTION}, + }, + mollusk_svm::{result::Check, Mollusk}, + solana_account::AccountSharedData, + solana_instruction::Instruction, + solana_pubkey::Pubkey, + solana_stake_program::id, +}; + +/// Builder for creating stake accounts with customizable parameters +pub struct StakeAccountBuilder { + lifecycle: StakeLifecycle, +} + +impl StakeAccountBuilder { + pub fn build(self) -> (Pubkey, AccountSharedData) { + let stake_pubkey = Pubkey::new_unique(); + let account = self.lifecycle.create_uninitialized_account(); + (stake_pubkey, account) + } +} + +/// Consolidated test context for stake account tests +pub struct StakeTestContext { + pub mollusk: Mollusk, + pub rent_exempt_reserve: u64, + pub staker: Pubkey, + pub withdrawer: Pubkey, +} + +impl StakeTestContext { + /// Create a new test context with all standard setup + pub fn new() -> Self { + let mollusk = Mollusk::new(&id(), "solana_stake_program"); + + Self { + mollusk, + rent_exempt_reserve: STAKE_RENT_EXEMPTION, + staker: Pubkey::new_unique(), + withdrawer: Pubkey::new_unique(), + } + } + + /// Create a stake account builder for the specified lifecycle stage + /// + /// Example: + /// ``` + /// let (stake, account) = ctx + /// .stake_account(StakeLifecycle::Uninitialized) + /// .build(); + /// ``` + pub fn stake_account(&mut self, lifecycle: StakeLifecycle) -> StakeAccountBuilder { + StakeAccountBuilder { lifecycle } + } + + /// Process a Codama-generated instruction + /// + /// Returns an `InstructionExecution` builder for adding accounts, checks, and executing. + /// + /// Example: + /// ``` + /// ctx.process(initialize_instruction) + /// .account(stake, stake_account) + /// .checks(&[Check::success()]) + /// .execute(); + /// ``` + pub fn process(&self, instruction: Instruction) -> InstructionExecution<'_, '_> { + InstructionExecution::new(instruction, self) + } + + /// Process an instruction with optional missing signer testing + pub(crate) fn process_instruction_maybe_test_signers( + &self, + instruction: &Instruction, + accounts: Vec<(Pubkey, AccountSharedData)>, + checks: &[Check], + test_missing_signers: bool, + ) -> mollusk_svm::result::InstructionResult { + if test_missing_signers { + use solana_program_error::ProgramError; + + // Test that removing each signer causes failure + for i in 0..instruction.accounts.len() { + if instruction.accounts[i].is_signer { + let mut modified_instruction = instruction.clone(); + modified_instruction.accounts[i].is_signer = false; + + let accounts_with_sysvars = + add_sysvars(&self.mollusk, &modified_instruction, accounts.clone()); + + self.mollusk.process_and_validate_instruction( + &modified_instruction, + &accounts_with_sysvars, + &[Check::err(ProgramError::MissingRequiredSignature)], + ); + } + } + } + + // Process with all signers present + let accounts_with_sysvars = add_sysvars(&self.mollusk, instruction, accounts); + self.mollusk + .process_and_validate_instruction(instruction, &accounts_with_sysvars, checks) + } +} + +impl Default for StakeTestContext { + fn default() -> Self { + Self::new() + } +} diff --git a/program/tests/helpers/instruction_builders.rs b/program/tests/helpers/instruction_builders.rs new file mode 100644 index 00000000..0b213ade --- /dev/null +++ b/program/tests/helpers/instruction_builders.rs @@ -0,0 +1,86 @@ +use { + super::context::StakeTestContext, mollusk_svm::result::Check, + solana_account::AccountSharedData, solana_instruction::Instruction, solana_pubkey::Pubkey, + std::collections::HashMap, +}; + +/// Execution builder with account data, validation, and signer testing +pub struct InstructionExecution<'a, 'b> { + instruction: Instruction, + accounts: HashMap, + ctx: &'a StakeTestContext, + checks: Option<&'b [Check<'b>]>, + test_missing_signers: Option, // `None` runs if `Check::success` +} + +impl<'a, 'b> InstructionExecution<'a, 'b> { + pub(crate) fn new(instruction: Instruction, ctx: &'a StakeTestContext) -> Self { + Self { + instruction, + accounts: HashMap::new(), + ctx, + checks: None, + test_missing_signers: None, + } + } + + /// Add account data for a specific pubkey + #[inline(always)] + pub fn account(mut self, pubkey: Pubkey, data: AccountSharedData) -> Self { + self.accounts.insert(pubkey, data); + self + } + + /// Add multiple accounts at once from an iterator + #[allow(dead_code)] + #[inline(always)] + pub fn accounts( + mut self, + accounts: impl IntoIterator, + ) -> Self { + self.accounts.extend(accounts); + self + } + + pub fn checks(mut self, checks: &'b [Check<'b>]) -> Self { + self.checks = Some(checks); + self + } + + pub fn test_missing_signers(mut self, test: bool) -> Self { + self.test_missing_signers = Some(test); + self + } + + /// Executes the instruction. If `checks` is `None` or empty, uses `Check::success()`. + /// Fail-safe default: when `test_missing_signers` is `None`, runs the missing-signers + /// test (`true`). Callers must explicitly opt out with `.test_missing_signers(false)`. + pub fn execute(self) -> mollusk_svm::result::InstructionResult { + let default_checks = [Check::success()]; + let checks = match self.checks { + Some(c) if !c.is_empty() => c, + _ => &default_checks, + }; + + let test_missing_signers = self.test_missing_signers.unwrap_or(true); + + // Build account list from instruction account metas + let accounts_with_data: Vec<(Pubkey, AccountSharedData)> = self + .instruction + .accounts + .iter() + .filter_map(|meta| { + self.accounts + .get(&meta.pubkey) + .map(|data| (meta.pubkey, data.clone())) + }) + .collect(); + + self.ctx.process_instruction_maybe_test_signers( + &self.instruction, + accounts_with_data, + checks, + test_missing_signers, + ) + } +} diff --git a/program/tests/helpers/lifecycle.rs b/program/tests/helpers/lifecycle.rs new file mode 100644 index 00000000..c6a6729f --- /dev/null +++ b/program/tests/helpers/lifecycle.rs @@ -0,0 +1,31 @@ +use { + super::utils::STAKE_RENT_EXEMPTION, solana_account::AccountSharedData, + solana_stake_client::StakeStateAccount, solana_stake_interface::state::StakeStateV2, + solana_stake_program::id, +}; + +/// Lifecycle states for stake accounts in tests +#[allow(dead_code)] // TODO: remove once tests include all lifecycles +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +pub enum StakeLifecycle { + Uninitialized = 0, + Initialized, + Activating, + Active, + Deactivating, + Deactive, + Closed, +} + +impl StakeLifecycle { + /// Create an uninitialized stake account + pub fn create_uninitialized_account(self) -> AccountSharedData { + AccountSharedData::new_data_with_space( + STAKE_RENT_EXEMPTION, + &StakeStateV2::Uninitialized, + StakeStateAccount::size_of(), + &id(), + ) + .unwrap() + } +} diff --git a/program/tests/helpers/mod.rs b/program/tests/helpers/mod.rs new file mode 100644 index 00000000..ff09b000 --- /dev/null +++ b/program/tests/helpers/mod.rs @@ -0,0 +1,7 @@ +#![allow(clippy::arithmetic_side_effects)] +#![allow(dead_code)] + +pub mod context; +pub mod instruction_builders; +pub mod lifecycle; +pub mod utils; diff --git a/program/tests/helpers/utils.rs b/program/tests/helpers/utils.rs new file mode 100644 index 00000000..3bc0659b --- /dev/null +++ b/program/tests/helpers/utils.rs @@ -0,0 +1,65 @@ +use { + mollusk_svm::Mollusk, + solana_account::{Account, AccountSharedData}, + solana_instruction::Instruction, + solana_pubkey::Pubkey, + solana_rent::Rent, + solana_stake_interface::{stake_history::StakeHistory, state::StakeStateV2}, + solana_sysvar_id::SysvarId, + std::collections::HashMap, +}; + +// hardcoded for convenience +pub const STAKE_RENT_EXEMPTION: u64 = 2_282_880; + +#[test] +fn assert_stake_rent_exemption() { + assert_eq!( + Rent::default().minimum_balance(StakeStateV2::size_of()), + STAKE_RENT_EXEMPTION + ); +} + +/// Resolve all accounts for an instruction, including sysvars and instruction accounts +/// +/// This function re-serializes the stake history sysvar from mollusk.sysvars.stake_history +/// every time it's called, ensuring that any updates to the stake history are reflected in the accounts. +pub fn add_sysvars( + mollusk: &Mollusk, + instruction: &Instruction, + accounts: Vec<(Pubkey, AccountSharedData)>, +) -> Vec<(Pubkey, Account)> { + // Build a map of provided accounts + let mut account_map: HashMap = accounts + .into_iter() + .map(|(pk, acc)| (pk, acc.into())) + .collect(); + + // Now resolve all accounts from the instruction + let mut result = Vec::new(); + for account_meta in &instruction.accounts { + let key = account_meta.pubkey; + let account = if let Some(acc) = account_map.remove(&key) { + // Use the provided account + acc + } else if Rent::check_id(&key) { + mollusk.sysvars.keyed_account_for_rent_sysvar().1 + } else if solana_clock::Clock::check_id(&key) { + mollusk.sysvars.keyed_account_for_clock_sysvar().1 + } else if solana_epoch_schedule::EpochSchedule::check_id(&key) { + mollusk.sysvars.keyed_account_for_epoch_schedule_sysvar().1 + } else if solana_epoch_rewards::EpochRewards::check_id(&key) { + mollusk.sysvars.keyed_account_for_epoch_rewards_sysvar().1 + } else if StakeHistory::check_id(&key) { + // Re-serialize stake history from mollusk.sysvars.stake_history + mollusk.sysvars.keyed_account_for_stake_history_sysvar().1 + } else { + // Default empty account + Account::default() + }; + + result.push((key, account)); + } + + result +} diff --git a/program/tests/initialize.rs b/program/tests/initialize.rs new file mode 100644 index 00000000..3f083672 --- /dev/null +++ b/program/tests/initialize.rs @@ -0,0 +1,284 @@ +#![allow(clippy::arithmetic_side_effects)] + +mod helpers; + +use { + helpers::{context::StakeTestContext, lifecycle::StakeLifecycle}, + mollusk_svm::result::Check, + solana_account::{AccountSharedData, ReadableAccount}, + solana_program_error::ProgramError, + solana_pubkey::Pubkey, + solana_rent::Rent, + solana_stake_client::{ + instructions::{InitializeBuilder, InitializeCheckedBuilder}, + types::{Authorized, Lockup}, + StakeStateAccount, + }, + solana_stake_interface::state::StakeStateV2, + solana_stake_program::id, + test_case::test_case, +}; + +#[derive(Debug, Clone, Copy)] +enum InitializeVariant { + Initialize, + InitializeChecked, +} + +#[test_case(InitializeVariant::Initialize; "initialize")] +#[test_case(InitializeVariant::InitializeChecked; "initialize_checked")] +fn test_initialize(variant: InitializeVariant) { + let mut ctx = StakeTestContext::new(); + + let custodian = Pubkey::new_unique(); + + let authorized = Authorized { + staker: ctx.staker, + withdrawer: ctx.withdrawer, + }; + + // InitializeChecked always uses default lockup + let lockup = match variant { + InitializeVariant::Initialize => Lockup { + epoch: 1, + unix_timestamp: 0, + custodian, + }, + InitializeVariant::InitializeChecked => { + let default = solana_stake_interface::state::Lockup::default(); + Lockup { + epoch: default.epoch, + unix_timestamp: default.unix_timestamp, + custodian: default.custodian, + } + } + }; + + // Create an uninitialized stake account + let (stake, stake_account) = ctx.stake_account(StakeLifecycle::Uninitialized).build(); + + // Build instruction using Codama-generated builders + let instruction = match variant { + InitializeVariant::Initialize => InitializeBuilder::new() + .stake(stake) + .arg0(authorized.clone()) + .arg1(lockup.clone()) + .instruction(), + InitializeVariant::InitializeChecked => InitializeCheckedBuilder::new() + .stake(stake) + .stake_authority(authorized.staker) + .withdraw_authority(authorized.withdrawer) + .instruction(), + }; + + // Process the instruction + let result = ctx + .process(instruction) + .account(stake, stake_account) + .checks(&[ + Check::success(), + Check::all_rent_exempt(), + Check::account(&stake) + .lamports(ctx.rent_exempt_reserve) + .owner(&id()) + .space(StakeStateAccount::size_of()) + .build(), + ]) + .test_missing_signers(true) + .execute(); + + // Check that we see what we expect + let resulting_account: AccountSharedData = result.resulting_accounts[0].1.clone().into(); + let stake_state = StakeStateAccount::from_bytes(resulting_account.data()).unwrap(); + let meta = stake_state.meta().unwrap(); + assert_eq!(meta.authorized, authorized); + assert_eq!(meta.rent_exempt_reserve, ctx.rent_exempt_reserve); + assert_eq!(meta.lockup, lockup.clone()); + + // Attempting to initialize an already initialized stake account should fail + let instruction = match variant { + InitializeVariant::Initialize => InitializeBuilder::new() + .stake(stake) + .arg0(authorized) + .arg1(lockup.clone()) + .instruction(), + InitializeVariant::InitializeChecked => InitializeCheckedBuilder::new() + .stake(stake) + .stake_authority(ctx.staker) + .withdraw_authority(ctx.withdrawer) + .instruction(), + }; + + ctx.process(instruction) + .account(stake, resulting_account) + .checks(&[Check::err(ProgramError::InvalidAccountData)]) + .test_missing_signers(false) + .execute(); +} + +#[test_case(InitializeVariant::Initialize; "initialize")] +#[test_case(InitializeVariant::InitializeChecked; "initialize_checked")] +fn test_initialize_insufficient_funds(variant: InitializeVariant) { + let ctx = StakeTestContext::new(); + + let custodian = Pubkey::new_unique(); + let authorized = Authorized { + staker: ctx.staker, + withdrawer: ctx.withdrawer, + }; + let lockup = match variant { + InitializeVariant::Initialize => Lockup { + epoch: 1, + unix_timestamp: 0, + custodian, + }, + InitializeVariant::InitializeChecked => Lockup { + epoch: 0, + unix_timestamp: 0, + custodian: Pubkey::default(), + }, + }; + + // Create account with insufficient lamports + let stake_account = Pubkey::new_unique(); + let stake_account_data = AccountSharedData::new_data_with_space( + ctx.rent_exempt_reserve / 2, // Not enough lamports + &StakeStateV2::Uninitialized, + StakeStateAccount::size_of(), + &id(), + ) + .unwrap(); + + let instruction = match variant { + InitializeVariant::Initialize => InitializeBuilder::new() + .stake(stake_account) + .arg0(authorized) + .arg1(lockup) + .instruction(), + InitializeVariant::InitializeChecked => InitializeCheckedBuilder::new() + .stake(stake_account) + .stake_authority(ctx.staker) + .withdraw_authority(ctx.withdrawer) + .instruction(), + }; + + ctx.process(instruction) + .account(stake_account, stake_account_data) + .checks(&[Check::err(ProgramError::InsufficientFunds)]) + .test_missing_signers(false) + .execute(); +} + +#[test_case(InitializeVariant::Initialize; "initialize")] +#[test_case(InitializeVariant::InitializeChecked; "initialize_checked")] +fn test_initialize_incorrect_size_larger(variant: InitializeVariant) { + let ctx = StakeTestContext::new(); + + // Original program_test.rs uses double rent instead of just + // increasing the size by 1. This behavior remains (makes no difference here). + let rent_exempt_reserve = Rent::default().minimum_balance(StakeStateAccount::size_of() * 2); + + let custodian = Pubkey::new_unique(); + let authorized = Authorized { + staker: ctx.staker, + withdrawer: ctx.withdrawer, + }; + let lockup = match variant { + InitializeVariant::Initialize => Lockup { + epoch: 1, + unix_timestamp: 0, + custodian, + }, + InitializeVariant::InitializeChecked => Lockup { + epoch: 0, + unix_timestamp: 0, + custodian: Pubkey::default(), + }, + }; + + // Create account with wrong size + let stake_account = Pubkey::new_unique(); + let stake_account_data = AccountSharedData::new_data_with_space( + rent_exempt_reserve, + &StakeStateV2::Uninitialized, + StakeStateAccount::size_of() + 1, // Too large + &id(), + ) + .unwrap(); + + let instruction = match variant { + InitializeVariant::Initialize => InitializeBuilder::new() + .stake(stake_account) + .arg0(authorized) + .arg1(lockup) + .instruction(), + InitializeVariant::InitializeChecked => InitializeCheckedBuilder::new() + .stake(stake_account) + .stake_authority(ctx.staker) + .withdraw_authority(ctx.withdrawer) + .instruction(), + }; + + ctx.process(instruction) + .account(stake_account, stake_account_data) + .checks(&[Check::err(ProgramError::InvalidAccountData)]) + .test_missing_signers(false) + .execute(); +} + +#[test_case(InitializeVariant::Initialize; "initialize")] +#[test_case(InitializeVariant::InitializeChecked; "initialize_checked")] +fn test_initialize_incorrect_size_smaller(variant: InitializeVariant) { + let ctx = StakeTestContext::new(); + + // Original program_test.rs uses rent for size instead of + // rent for size - 1. This behavior remains (makes no difference here). + let rent_exempt_reserve = Rent::default().minimum_balance(StakeStateAccount::size_of()); + + let custodian = Pubkey::new_unique(); + let authorized = Authorized { + staker: ctx.staker, + withdrawer: ctx.withdrawer, + }; + let lockup = match variant { + InitializeVariant::Initialize => Lockup { + epoch: 1, + unix_timestamp: 0, + custodian, + }, + InitializeVariant::InitializeChecked => Lockup { + epoch: 0, + unix_timestamp: 0, + custodian: Pubkey::default(), + }, + }; + + // Create account with wrong size + let stake_account = Pubkey::new_unique(); + let stake_account_data = AccountSharedData::new_data_with_space( + rent_exempt_reserve, + &StakeStateV2::Uninitialized, + StakeStateAccount::size_of() - 1, // Too small + &id(), + ) + .unwrap(); + + let instruction = match variant { + InitializeVariant::Initialize => InitializeBuilder::new() + .stake(stake_account) + .arg0(authorized) + .arg1(lockup) + .instruction(), + InitializeVariant::InitializeChecked => InitializeCheckedBuilder::new() + .stake(stake_account) + .stake_authority(ctx.staker) + .withdraw_authority(ctx.withdrawer) + .instruction(), + }; + + ctx.process(instruction) + .account(stake_account, stake_account_data) + .checks(&[Check::err(ProgramError::InvalidAccountData)]) + .test_missing_signers(false) + .execute(); +}