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/clients/js/src/generated/instructions/authorize.ts b/clients/js/src/generated/instructions/authorize.ts index fd9c0d12..26ca3296 100644 --- a/clients/js/src/generated/instructions/authorize.ts +++ b/clients/js/src/generated/instructions/authorize.ts @@ -48,9 +48,7 @@ export function getAuthorizeDiscriminatorBytes() { 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 @@ -129,13 +127,9 @@ 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']; @@ -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..8db194e0 100644 --- a/clients/js/src/generated/instructions/authorizeChecked.ts +++ b/clients/js/src/generated/instructions/authorizeChecked.ts @@ -46,9 +46,7 @@ export function getAuthorizeCheckedDiscriminatorBytes() { 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 @@ -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..faf70df9 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, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -37,10 +31,10 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getStakeAuthorizeDecoder, - getStakeAuthorizeEncoder, - type StakeAuthorize, - type StakeAuthorizeArgs, + getAuthorizeCheckedWithSeedParamsDecoder, + getAuthorizeCheckedWithSeedParamsEncoder, + type AuthorizeCheckedWithSeedParams, + type AuthorizeCheckedWithSeedParamsArgs, } from '../types'; export const AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR = 11; @@ -53,9 +47,7 @@ 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', + TAccountClockSysvar extends string | AccountMeta = string, TAccountNewAuthority extends string | AccountMeta = string, TAccountLockupAuthority extends | string @@ -93,27 +85,21 @@ export type AuthorizeCheckedWithSeedInstruction< export type AuthorizeCheckedWithSeedInstructionData = { discriminator: number; - stakeAuthorize: StakeAuthorize; - authoritySeed: string; - authorityOwner: Address; + authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedParams; }; export type AuthorizeCheckedWithSeedInstructionDataArgs = { - stakeAuthorize: StakeAuthorizeArgs; - authoritySeed: string; - authorityOwner: Address; + authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedParamsArgs; }; export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['stakeAuthorize', getStakeAuthorizeEncoder()], [ - 'authoritySeed', - addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()), + 'authorizeCheckedWithSeedArgs', + getAuthorizeCheckedWithSeedParamsEncoder(), ], - ['authorityOwner', getAddressEncoder()], ]), (value) => ({ ...value, @@ -125,9 +111,10 @@ export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['stakeAuthorize', getStakeAuthorizeDecoder()], - ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], - ['authorityOwner', getAddressDecoder()], + [ + 'authorizeCheckedWithSeedArgs', + getAuthorizeCheckedWithSeedParamsDecoder(), + ], ]); } @@ -148,19 +135,12 @@ 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 */ + clockSysvar: Address; newAuthority: TransactionSigner; - /** Lockup authority */ lockupAuthority?: TransactionSigner; - stakeAuthorize: AuthorizeCheckedWithSeedInstructionDataArgs['stakeAuthorize']; - authoritySeed: AuthorizeCheckedWithSeedInstructionDataArgs['authoritySeed']; - authorityOwner: AuthorizeCheckedWithSeedInstructionDataArgs['authorityOwner']; + authorizeCheckedWithSeedArgs: AuthorizeCheckedWithSeedInstructionDataArgs['authorizeCheckedWithSeedArgs']; }; export function getAuthorizeCheckedWithSeedInstruction< @@ -209,12 +189,6 @@ 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: [ @@ -244,15 +218,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 */ clockSysvar: TAccountMetas[2]; - /** The new stake or withdraw authority */ newAuthority: TAccountMetas[3]; - /** Lockup authority */ lockupAuthority?: TAccountMetas[4] | undefined; }; data: AuthorizeCheckedWithSeedInstructionData; diff --git a/clients/js/src/generated/instructions/authorizeWithSeed.ts b/clients/js/src/generated/instructions/authorizeWithSeed.ts index 0f103252..764894d3 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, transformEncoder, type AccountMeta, type AccountSignerMeta, @@ -37,10 +31,10 @@ import { import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { - getStakeAuthorizeDecoder, - getStakeAuthorizeEncoder, - type StakeAuthorize, - type StakeAuthorizeArgs, + getAuthorizeWithSeedParamsDecoder, + getAuthorizeWithSeedParamsEncoder, + type AuthorizeWithSeedParams, + type AuthorizeWithSeedParamsArgs, } from '../types'; export const AUTHORIZE_WITH_SEED_DISCRIMINATOR = 8; @@ -53,9 +47,7 @@ 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', + TAccountClockSysvar extends string | AccountMeta = string, TAccountLockupAuthority extends | string | AccountMeta @@ -88,30 +80,18 @@ export type AuthorizeWithSeedInstruction< export type AuthorizeWithSeedInstructionData = { discriminator: number; - newAuthorizedPubkey: Address; - stakeAuthorize: StakeAuthorize; - authoritySeed: string; - authorityOwner: Address; + authorizeWithSeedArgs: AuthorizeWithSeedParams; }; export type AuthorizeWithSeedInstructionDataArgs = { - newAuthorizedPubkey: Address; - stakeAuthorize: StakeAuthorizeArgs; - authoritySeed: string; - authorityOwner: Address; + authorizeWithSeedArgs: AuthorizeWithSeedParamsArgs; }; export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['newAuthorizedPubkey', getAddressEncoder()], - ['stakeAuthorize', getStakeAuthorizeEncoder()], - [ - 'authoritySeed', - addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()), - ], - ['authorityOwner', getAddressEncoder()], + ['authorizeWithSeedArgs', getAuthorizeWithSeedParamsEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_WITH_SEED_DISCRIMINATOR }) ); @@ -120,10 +100,7 @@ export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['newAuthorizedPubkey', getAddressDecoder()], - ['stakeAuthorize', getStakeAuthorizeDecoder()], - ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], - ['authorityOwner', getAddressDecoder()], + ['authorizeWithSeedArgs', getAuthorizeWithSeedParamsDecoder()], ]); } @@ -143,18 +120,11 @@ 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 */ + clockSysvar: Address; lockupAuthority?: TransactionSigner; - newAuthorizedPubkey: AuthorizeWithSeedInstructionDataArgs['newAuthorizedPubkey']; - stakeAuthorize: AuthorizeWithSeedInstructionDataArgs['stakeAuthorize']; - authoritySeed: AuthorizeWithSeedInstructionDataArgs['authoritySeed']; - authorityOwner: AuthorizeWithSeedInstructionDataArgs['authorityOwner']; + authorizeWithSeedArgs: AuthorizeWithSeedInstructionDataArgs['authorizeWithSeedArgs']; }; export function getAuthorizeWithSeedInstruction< @@ -199,12 +169,6 @@ 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: [ @@ -232,13 +196,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 */ clockSysvar: TAccountMetas[2]; - /** Lockup authority */ lockupAuthority?: TAccountMetas[3] | undefined; }; data: AuthorizeWithSeedInstructionData; diff --git a/clients/js/src/generated/instructions/deactivate.ts b/clients/js/src/generated/instructions/deactivate.ts index c6d73b86..b7064b1d 100644 --- a/clients/js/src/generated/instructions/deactivate.ts +++ b/clients/js/src/generated/instructions/deactivate.ts @@ -40,9 +40,7 @@ export function getDeactivateDiscriminatorBytes() { 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 & @@ -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..5ff247a5 100644 --- a/clients/js/src/generated/instructions/deactivateDelinquent.ts +++ b/clients/js/src/generated/instructions/deactivateDelinquent.ts @@ -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..e0e1033b 100644 --- a/clients/js/src/generated/instructions/delegateStake.ts +++ b/clients/js/src/generated/instructions/delegateStake.ts @@ -41,10 +41,8 @@ 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, + TAccountClockSysvar extends string | AccountMeta = string, + TAccountStakeHistorySysvar extends string | AccountMeta = string, TAccountUnused extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], @@ -61,9 +59,9 @@ export type DelegateStakeInstruction< TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, - TAccountStakeHistory extends string - ? ReadonlyAccount - : TAccountStakeHistory, + TAccountStakeHistorySysvar extends string + ? ReadonlyAccount + : TAccountStakeHistorySysvar, TAccountUnused extends string ? ReadonlyAccount : TAccountUnused, @@ -104,21 +102,15 @@ export type DelegateStakeInput< TAccountStake extends string = string, TAccountVote extends string = string, TAccountClockSysvar extends string = string, - TAccountStakeHistory extends string = string, + TAccountStakeHistorySysvar extends string = string, 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 */ - stakeHistory: Address; - /** Unused account, formerly the stake config */ + clockSysvar: Address; + stakeHistorySysvar: Address; unused: Address; - /** Stake authority */ stakeAuthority: TransactionSigner; }; @@ -126,7 +118,7 @@ export function getDelegateStakeInstruction< TAccountStake extends string, TAccountVote extends string, TAccountClockSysvar extends string, - TAccountStakeHistory extends string, + TAccountStakeHistorySysvar extends string, TAccountUnused extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, @@ -135,7 +127,7 @@ export function getDelegateStakeInstruction< TAccountStake, TAccountVote, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountUnused, TAccountStakeAuthority >, @@ -145,7 +137,7 @@ export function getDelegateStakeInstruction< TAccountStake, TAccountVote, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountUnused, TAccountStakeAuthority > { @@ -157,7 +149,10 @@ 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 }, + stakeHistorySysvar: { + value: input.stakeHistorySysvar ?? null, + isWritable: false, + }, unused: { value: input.unused ?? null, isWritable: false }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; @@ -166,19 +161,13 @@ 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.stakeHistorySysvar), getAccountMeta(accounts.unused), getAccountMeta(accounts.stakeAuthority), ], @@ -189,7 +178,7 @@ export function getDelegateStakeInstruction< TAccountStake, TAccountVote, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountUnused, 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 */ + stakeHistorySysvar: TAccountMetas[3]; unused: TAccountMetas[4]; - /** Stake authority */ stakeAuthority: TAccountMetas[5]; }; data: DelegateStakeInstructionData; @@ -241,7 +224,7 @@ export function parseDelegateStakeInstruction< stake: getNextAccount(), vote: getNextAccount(), clockSysvar: getNextAccount(), - stakeHistory: getNextAccount(), + stakeHistorySysvar: getNextAccount(), unused: getNextAccount(), stakeAuthority: getNextAccount(), }, diff --git a/clients/js/src/generated/instructions/initialize.ts b/clients/js/src/generated/instructions/initialize.ts index 0e22930a..ba3a0a0a 100644 --- a/clients/js/src/generated/instructions/initialize.ts +++ b/clients/js/src/generated/instructions/initialize.ts @@ -47,9 +47,7 @@ export function getInitializeDiscriminatorBytes() { 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 & @@ -109,10 +107,8 @@ export type InitializeInput< TAccountStake extends string = string, TAccountRentSysvar extends string = string, > = { - /** Uninitialized stake account */ stake: Address; - /** Rent sysvar */ - rentSysvar?: Address; + rentSysvar: Address; arg0: InitializeInstructionDataArgs['arg0']; arg1: InitializeInstructionDataArgs['arg1']; }; @@ -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..7ee23f0e 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[] = [], @@ -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..be7d091f 100644 --- a/clients/js/src/generated/instructions/merge.ts +++ b/clients/js/src/generated/instructions/merge.ts @@ -41,10 +41,8 @@ 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, + TAccountClockSysvar extends string | AccountMeta = string, + TAccountStakeHistorySysvar extends string | AccountMeta = string, TAccountStakeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & @@ -60,9 +58,9 @@ export type MergeInstruction< TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, - TAccountStakeHistory extends string - ? ReadonlyAccount - : TAccountStakeHistory, + TAccountStakeHistorySysvar extends string + ? ReadonlyAccount + : TAccountStakeHistorySysvar, TAccountStakeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta @@ -100,18 +98,13 @@ export type MergeInput< TAccountDestinationStake extends string = string, TAccountSourceStake 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 */ + clockSysvar: Address; + stakeHistorySysvar: Address; stakeAuthority: TransactionSigner; }; @@ -119,7 +112,7 @@ export function getMergeInstruction< TAccountDestinationStake extends string, TAccountSourceStake extends string, TAccountClockSysvar extends string, - TAccountStakeHistory extends string, + TAccountStakeHistorySysvar extends string, TAccountStakeAuthority extends string, TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( @@ -127,7 +120,7 @@ export function getMergeInstruction< TAccountDestinationStake, TAccountSourceStake, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } @@ -136,7 +129,7 @@ export function getMergeInstruction< TAccountDestinationStake, TAccountSourceStake, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountStakeAuthority > { // Program address. @@ -150,7 +143,10 @@ export function getMergeInstruction< }, sourceStake: { value: input.sourceStake ?? 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,19 +154,13 @@ 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.clockSysvar), - getAccountMeta(accounts.stakeHistory), + getAccountMeta(accounts.stakeHistorySysvar), getAccountMeta(accounts.stakeAuthority), ], data: getMergeInstructionDataEncoder().encode({}), @@ -180,7 +170,7 @@ export function getMergeInstruction< TAccountDestinationStake, TAccountSourceStake, TAccountClockSysvar, - TAccountStakeHistory, + TAccountStakeHistorySysvar, TAccountStakeAuthority >); } @@ -191,15 +181,10 @@ export type ParsedMergeInstruction< > = { programAddress: Address; accounts: { - /** Destination stake account */ destinationStake: TAccountMetas[0]; - /** Source stake account */ sourceStake: TAccountMetas[1]; - /** Clock sysvar */ clockSysvar: TAccountMetas[2]; - /** Stake history sysvar */ - stakeHistory: TAccountMetas[3]; - /** Stake authority */ + stakeHistorySysvar: TAccountMetas[3]; stakeAuthority: TAccountMetas[4]; }; data: MergeInstructionData; @@ -229,7 +214,7 @@ export function parseMergeInstruction< destinationStake: getNextAccount(), sourceStake: 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..67282630 100644 --- a/clients/js/src/generated/instructions/moveLamports.ts +++ b/clients/js/src/generated/instructions/moveLamports.ts @@ -101,11 +101,8 @@ 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']; }; @@ -173,11 +170,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 */ stakeAuthority: TAccountMetas[2]; }; data: MoveLamportsInstructionData; diff --git a/clients/js/src/generated/instructions/moveStake.ts b/clients/js/src/generated/instructions/moveStake.ts index e216194e..6d1cbba6 100644 --- a/clients/js/src/generated/instructions/moveStake.ts +++ b/clients/js/src/generated/instructions/moveStake.ts @@ -98,11 +98,8 @@ 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']; }; @@ -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 */ stakeAuthority: TAccountMetas[2]; }; data: MoveStakeInstructionData; diff --git a/clients/js/src/generated/instructions/setLockup.ts b/clients/js/src/generated/instructions/setLockup.ts index 1e082f68..3492f11f 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, 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,6 +29,12 @@ import { } from '@solana/kit'; import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getLockupParamsDecoder, + getLockupParamsEncoder, + type LockupParams, + type LockupParamsArgs, +} from '../types'; export const SET_LOCKUP_DISCRIMINATOR = 6; @@ -68,24 +64,16 @@ export type SetLockupInstruction< export type SetLockupInstructionData = { discriminator: number; - unixTimestamp: Option; - epoch: Option; - custodian: Option
; + lockupArgs: LockupParams; }; -export type SetLockupInstructionDataArgs = { - unixTimestamp: OptionOrNullable; - epoch: OptionOrNullable; - custodian: OptionOrNullable
; -}; +export type SetLockupInstructionDataArgs = { lockupArgs: LockupParamsArgs }; export function getSetLockupInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['unixTimestamp', getOptionEncoder(getI64Encoder())], - ['epoch', getOptionEncoder(getU64Encoder())], - ['custodian', getOptionEncoder(getAddressEncoder())], + ['lockupArgs', getLockupParamsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_DISCRIMINATOR }) ); @@ -94,9 +82,7 @@ export function getSetLockupInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['unixTimestamp', getOptionDecoder(getI64Decoder())], - ['epoch', getOptionDecoder(getU64Decoder())], - ['custodian', getOptionDecoder(getAddressDecoder())], + ['lockupArgs', getLockupParamsDecoder()], ]); } @@ -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']; + lockupArgs: SetLockupInstructionDataArgs['lockupArgs']; }; 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..020e3a9a 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, 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,6 +29,12 @@ import { } from '@solana/kit'; import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getLockupCheckedParamsDecoder, + getLockupCheckedParamsEncoder, + type LockupCheckedParams, + type LockupCheckedParamsArgs, +} from '../types'; export const SET_LOCKUP_CHECKED_DISCRIMINATOR = 12; @@ -78,21 +76,18 @@ export type SetLockupCheckedInstruction< export type SetLockupCheckedInstructionData = { discriminator: number; - unixTimestamp: Option; - epoch: Option; + lockupCheckedArgs: LockupCheckedParams; }; export type SetLockupCheckedInstructionDataArgs = { - unixTimestamp: OptionOrNullable; - epoch: OptionOrNullable; + lockupCheckedArgs: LockupCheckedParamsArgs; }; export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['unixTimestamp', getOptionEncoder(getI64Encoder())], - ['epoch', getOptionEncoder(getU64Encoder())], + ['lockupCheckedArgs', getLockupCheckedParamsEncoder()], ]), (value) => ({ ...value, discriminator: SET_LOCKUP_CHECKED_DISCRIMINATOR }) ); @@ -101,8 +96,7 @@ export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['unixTimestamp', getOptionDecoder(getI64Decoder())], - ['epoch', getOptionDecoder(getU64Decoder())], + ['lockupCheckedArgs', getLockupCheckedParamsDecoder()], ]); } @@ -121,14 +115,10 @@ 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; - unixTimestamp: SetLockupCheckedInstructionDataArgs['unixTimestamp']; - epoch: SetLockupCheckedInstructionDataArgs['epoch']; + lockupCheckedArgs: SetLockupCheckedInstructionDataArgs['lockupCheckedArgs']; }; export function getSetLockupCheckedInstruction< @@ -191,11 +181,8 @@ 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 a01549bf..4a2df973 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; 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()], + ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: SPLIT_DISCRIMINATOR }) ); @@ -79,7 +79,7 @@ export function getSplitInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['args', getU64Decoder()], + ['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..d91dc22e 100644 --- a/clients/js/src/generated/instructions/withdraw.ts +++ b/clients/js/src/generated/instructions/withdraw.ts @@ -43,10 +43,8 @@ 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()], + ['lamports', getU64Encoder()], ]), (value) => ({ ...value, discriminator: WITHDRAW_DISCRIMINATOR }) ); @@ -102,7 +103,7 @@ export function getWithdrawInstructionDataEncoder(): FixedSizeEncoder { return getStructDecoder([ ['discriminator', getU32Decoder()], - ['args', getU64Decoder()], + ['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/types/authorizeCheckedWithSeedParams.ts b/clients/js/src/generated/types/authorizeCheckedWithSeedParams.ts new file mode 100644 index 00000000..2343ed80 --- /dev/null +++ b/clients/js/src/generated/types/authorizeCheckedWithSeedParams.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 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 new file mode 100644 index 00000000..4e0f1209 --- /dev/null +++ b/clients/js/src/generated/types/authorizeWithSeedParams.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 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/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..1ada0996 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 './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'; 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/lockupCheckedParams.ts b/clients/js/src/generated/types/lockupCheckedParams.ts new file mode 100644 index 00000000..8979ebc2 --- /dev/null +++ b/clients/js/src/generated/types/lockupCheckedParams.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 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 new file mode 100644 index 00000000..5936cba9 --- /dev/null +++ b/clients/js/src/generated/types/lockupParams.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 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/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..74ec8f22 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, } @@ -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)] @@ -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, @@ -177,9 +171,7 @@ 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, }; @@ -194,13 +186,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 +199,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, @@ -350,13 +341,11 @@ 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, @@ -365,7 +354,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 +363,6 @@ impl<'a, 'b> AuthorizeCpiBuilder<'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.rs b/clients/rust/src/generated/instructions/authorize_checked.rs index 62476187..a4317be0 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, } @@ -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..8f2843f9 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::AuthorizeCheckedWithSeedParams, 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 + pub lockup_authority: Option, } @@ -94,9 +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 stake_authorize: StakeAuthorize, - pub authority_seed: String, - pub authority_owner: Pubkey, + pub authorize_checked_with_seed_args: AuthorizeCheckedWithSeedParams, } /// Instruction builder for `AuthorizeCheckedWithSeed`. @@ -105,7 +101,7 @@ pub struct AuthorizeCheckedWithSeedInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[signer]` base -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 2. `[]` clock_sysvar /// 3. `[signer]` new_authority /// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] @@ -115,9 +111,7 @@ pub struct AuthorizeCheckedWithSeedBuilder { clock_sysvar: Option, new_authority: Option, lockup_authority: Option, - stake_authorize: Option, - authority_seed: Option, - authority_owner: Option, + authorize_checked_with_seed_args: Option, __remaining_accounts: Vec, } @@ -125,33 +119,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); 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 +149,11 @@ 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 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. @@ -198,25 +179,15 @@ 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.unwrap_or(solana_program::pubkey!( - "SysvarC1ock11111111111111111111111111111111" - )), + 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 + authorize_checked_with_seed_args: self + .authorize_checked_with_seed_args .clone() - .expect("authority_seed is not set"), - authority_owner: self - .authority_owner - .clone() - .expect("authority_owner is not set"), + .expect("authorize_checked_with_seed_args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -225,15 +196,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 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 +211,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 + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeCheckedWithSeedInstructionArgs, @@ -387,26 +357,21 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { clock_sysvar: None, new_authority: None, lockup_authority: None, - stake_authorize: None, - authority_seed: None, - authority_owner: None, + authorize_checked_with_seed_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); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -415,7 +380,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 +389,6 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -435,18 +398,11 @@ 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 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. @@ -491,21 +447,11 @@ 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 + authorize_checked_with_seed_args: self .instruction - .authority_owner + .authorize_checked_with_seed_args .clone() - .expect("authority_owner is not set"), + .expect("authorize_checked_with_seed_args is not set"), }; let instruction = AuthorizeCheckedWithSeedCpi { __program: self.instruction.__program, @@ -542,9 +488,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>>, - stake_authorize: Option, - authority_seed: Option, - authority_owner: 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 86b83f62..d495e2de 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::AuthorizeWithSeedParams, 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 + pub lockup_authority: Option, } @@ -88,10 +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 new_authorized_pubkey: Pubkey, - pub stake_authorize: StakeAuthorize, - pub authority_seed: String, - pub authority_owner: Pubkey, + pub authorize_with_seed_args: AuthorizeWithSeedParams, } /// Instruction builder for `AuthorizeWithSeed`. @@ -100,7 +95,7 @@ pub struct AuthorizeWithSeedInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[signer]` base -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 2. `[]` clock_sysvar /// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeWithSeedBuilder { @@ -108,10 +103,7 @@ pub struct AuthorizeWithSeedBuilder { base: Option, clock_sysvar: Option, lockup_authority: Option, - new_authorized_pubkey: Option, - stake_authorize: Option, - authority_seed: Option, - authority_owner: Option, + authorize_with_seed_args: Option, __remaining_accounts: Vec, } @@ -119,27 +111,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); 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 +136,11 @@ 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 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. @@ -191,28 +166,14 @@ 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.unwrap_or(solana_program::pubkey!( - "SysvarC1ock11111111111111111111111111111111" - )), + 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 + authorize_with_seed_args: self + .authorize_with_seed_args .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"), + .expect("authorize_with_seed_args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -221,13 +182,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 clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, - /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } @@ -235,13 +195,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 + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeWithSeedInstructionArgs, @@ -371,27 +331,21 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { base: None, clock_sysvar: None, lockup_authority: None, - new_authorized_pubkey: None, - stake_authorize: None, - authority_seed: None, - authority_owner: None, + authorize_with_seed_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); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -401,7 +355,6 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { self } /// `[optional account]` - /// Lockup authority #[inline(always)] pub fn lockup_authority( &mut self, @@ -411,23 +364,11 @@ 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 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. @@ -472,26 +413,11 @@ 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 + authorize_with_seed_args: self .instruction - .authority_owner + .authorize_with_seed_args .clone() - .expect("authority_owner is not set"), + .expect("authorize_with_seed_args is not set"), }; let instruction = AuthorizeWithSeedCpi { __program: self.instruction.__program, @@ -522,10 +448,7 @@ 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>>, - new_authorized_pubkey: Option, - stake_authorize: Option, - authority_seed: Option, - authority_owner: 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/deactivate.rs b/clients/rust/src/generated/instructions/deactivate.rs index 468e458b..8cad1dcb 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, } @@ -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..c5e0542f 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, } @@ -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..19e33208 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 stake_history_sysvar: solana_program::pubkey::Pubkey, + pub unused: solana_program::pubkey::Pubkey, - /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, } @@ -45,7 +44,7 @@ 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( @@ -91,8 +90,8 @@ impl Default for DelegateStakeInstructionData { /// /// 0. `[writable]` stake /// 1. `[]` vote -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[]` stake_history +/// 2. `[]` clock_sysvar +/// 3. `[]` stake_history_sysvar /// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug, Default)] @@ -100,7 +99,7 @@ pub struct DelegateStakeBuilder { stake: Option, vote: Option, clock_sysvar: Option, - stake_history: Option, + stake_history_sysvar: Option, unused: 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); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -173,10 +168,10 @@ 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"), + 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"), unused: self.unused.expect("unused 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 stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub unused: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + 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 stake_history_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub unused: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -229,7 +223,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { stake: accounts.stake, vote: accounts.vote, clock_sysvar: accounts.clock_sysvar, - stake_history: accounts.stake_history, + stake_history_sysvar: accounts.stake_history_sysvar, unused: accounts.unused, stake_authority: accounts.stake_authority, } @@ -281,7 +275,7 @@ 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( @@ -311,7 +305,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.clone()); + account_infos.push(self.stake_history_sysvar.clone()); account_infos.push(self.unused.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts @@ -333,7 +327,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { /// 0. `[writable]` stake /// 1. `[]` vote /// 2. `[]` clock_sysvar -/// 3. `[]` stake_history +/// 3. `[]` stake_history_sysvar /// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug)] @@ -348,26 +342,23 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { stake: None, vote: None, clock_sysvar: None, - stake_history: None, + stake_history_sysvar: 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 } - /// 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,16 +367,14 @@ 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( &mut self, @@ -394,7 +383,6 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { self.instruction.unused = Some(unused); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -456,10 +444,10 @@ 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"), @@ -481,7 +469,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: Option<&'b solana_program::account_info::AccountInfo<'a>>, + stake_history_sysvar: 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/clients/rust/src/generated/instructions/initialize.rs b/clients/rust/src/generated/instructions/initialize.rs index 24bc81f5..ccb39c05 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, } @@ -83,7 +82,7 @@ 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, @@ -97,14 +96,11 @@ 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); @@ -142,9 +138,7 @@ 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"), @@ -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, @@ -285,13 +278,11 @@ 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 929046f7..f89f1c10 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, } @@ -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..a38a825b 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 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, } @@ -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( @@ -87,15 +86,15 @@ impl Default for MergeInstructionData { /// /// 0. `[writable]` destination_stake /// 1. `[writable]` source_stake -/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) -/// 3. `[]` stake_history +/// 2. `[]` clock_sysvar +/// 3. `[]` stake_history_sysvar /// 4. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MergeBuilder { destination_stake: Option, source_stake: Option, clock_sysvar: Option, - stake_history: Option, + stake_history_sysvar: Option, stake_authority: Option, __remaining_accounts: Vec, } @@ -104,7 +103,6 @@ impl MergeBuilder { pub fn new() -> Self { Self::default() } - /// Destination stake account #[inline(always)] pub fn destination_stake( &mut self, @@ -113,26 +111,24 @@ impl MergeBuilder { self.destination_stake = Some(destination_stake); 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); 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, @@ -166,10 +162,10 @@ 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.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"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -179,15 +175,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 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 +190,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 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>, } @@ -217,7 +212,7 @@ impl<'a, 'b> MergeCpi<'a, 'b> { destination_stake: accounts.destination_stake, source_stake: accounts.source_stake, clock_sysvar: accounts.clock_sysvar, - stake_history: accounts.stake_history, + stake_history_sysvar: accounts.stake_history_sysvar, stake_authority: accounts.stake_authority, } } @@ -268,7 +263,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( @@ -294,7 +289,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.clone()); + account_infos.push(self.stake_history_sysvar.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -315,7 +310,7 @@ impl<'a, 'b> MergeCpi<'a, 'b> { /// 0. `[writable]` destination_stake /// 1. `[writable]` source_stake /// 2. `[]` clock_sysvar -/// 3. `[]` stake_history +/// 3. `[]` stake_history_sysvar /// 4. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct MergeCpiBuilder<'a, 'b> { @@ -329,13 +324,12 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { destination_stake: None, source_stake: 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( &mut self, @@ -344,7 +338,6 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { self.instruction.destination_stake = Some(destination_stake); self } - /// Source stake account #[inline(always)] pub fn source_stake( &mut self, @@ -353,7 +346,6 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { self.instruction.source_stake = Some(source_stake); self } - /// Clock sysvar #[inline(always)] pub fn clock_sysvar( &mut self, @@ -362,16 +354,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, @@ -439,10 +429,10 @@ impl<'a, 'b> MergeCpiBuilder<'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"), stake_authority: self .instruction @@ -462,7 +452,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: 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/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs index cc30b72c..77fedfa6 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 stake_authority: solana_program::pubkey::Pubkey, } @@ -101,13 +100,11 @@ 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, @@ -116,7 +113,6 @@ impl MoveLamportsBuilder { self.destination_stake = Some(destination_stake); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -167,11 +163,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 stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -179,11 +174,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, @@ -306,7 +301,6 @@ impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { }); Self { instruction } } - /// Active or inactive source stake account #[inline(always)] pub fn source_stake( &mut self, @@ -315,7 +309,6 @@ 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, @@ -324,7 +317,6 @@ 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 c8953253..96ecb598 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 stake_authority: solana_program::pubkey::Pubkey, } @@ -101,13 +100,11 @@ 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, @@ -116,7 +113,6 @@ impl MoveStakeBuilder { self.destination_stake = Some(destination_stake); self } - /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -167,11 +163,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 stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -179,11 +174,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, @@ -306,7 +301,6 @@ impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { }); Self { instruction } } - /// Active source stake account #[inline(always)] pub fn source_stake( &mut self, @@ -315,7 +309,6 @@ 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, @@ -324,7 +317,6 @@ 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 f92de1e9..e339cb24 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::LockupParams, 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, } @@ -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_args: LockupParams, } /// 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_args: 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_args(&mut self, lockup_args: LockupParams) -> &mut Self { + self.lockup_args = Some(lockup_args); 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_args: self.lockup_args.clone().expect("lockup_args 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_args: 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_args(&mut self, lockup_args: LockupParams) -> &mut Self { + self.instruction.lockup_args = Some(lockup_args); self } /// Add an additional account to the instruction. @@ -369,9 +329,11 @@ 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_args: self + .instruction + .lockup_args + .clone() + .expect("lockup_args is not set"), }; let instruction = SetLockupCpi { __program: self.instruction.__program, @@ -393,9 +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>>, - unix_timestamp: Option, - epoch: Option, - custodian: 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 fbfb6125..1b0b4315 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -5,16 +5,18 @@ //! //! -use borsh::{BorshDeserialize, BorshSerialize}; +use { + crate::generated::types::LockupCheckedParams, + 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, } @@ -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_checked_args: LockupCheckedParams, } /// Instruction builder for `SetLockupChecked`. @@ -95,8 +96,7 @@ pub struct SetLockupCheckedBuilder { stake: Option, authority: Option, new_authority: Option, - unix_timestamp: Option, - epoch: Option, + lockup_checked_args: Option, __remaining_accounts: Vec, } @@ -104,20 +104,17 @@ 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, @@ -126,16 +123,9 @@ impl SetLockupCheckedBuilder { self.new_authority = new_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_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. @@ -164,8 +154,10 @@ impl SetLockupCheckedBuilder { new_authority: self.new_authority, }; let args = SetLockupCheckedInstructionArgs { - unix_timestamp: self.unix_timestamp.clone(), - epoch: self.epoch.clone(), + lockup_checked_args: self + .lockup_checked_args + .clone() + .expect("lockup_checked_args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -174,11 +166,10 @@ 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>>, } @@ -186,11 +177,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, @@ -312,19 +303,16 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { stake: None, authority: None, new_authority: None, - unix_timestamp: None, - epoch: None, + lockup_checked_args: 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,7 +322,6 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { self } /// `[optional account]` - /// New lockup authority #[inline(always)] pub fn new_authority( &mut self, @@ -343,16 +330,9 @@ 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: 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); + 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. @@ -397,8 +377,11 @@ 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_checked_args: self + .instruction + .lockup_checked_args + .clone() + .expect("lockup_checked_args is not set"), }; let instruction = SetLockupCheckedCpi { __program: self.instruction.__program, @@ -423,8 +406,7 @@ 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>>, - unix_timestamp: Option, - epoch: Option, + 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/clients/rust/src/generated/instructions/split.rs b/clients/rust/src/generated/instructions/split.rs index e17198a1..348020e6 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, } @@ -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..eceba2a9 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( @@ -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_params.rs b/clients/rust/src/generated/types/authorize_checked_with_seed_params.rs new file mode 100644 index 00000000..70a65233 --- /dev/null +++ b/clients/rust/src/generated/types/authorize_checked_with_seed_params.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 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 new file mode 100644 index 00000000..1d1e2a2e --- /dev/null +++ b/clients/rust/src/generated/types/authorize_with_seed_params.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 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/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_checked_params.rs b/clients/rust/src/generated/types/lockup_checked_params.rs new file mode 100644 index 00000000..6bf3cf6d --- /dev/null +++ b/clients/rust/src/generated/types/lockup_checked_params.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 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 new file mode 100644 index 00000000..c1ec7850 --- /dev/null +++ b/clients/rust/src/generated/types/lockup_params.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 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 41560dee..bf81f076 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_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; 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_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/clients/rust/src/generated/types/unix_timestamp.rs b/clients/rust/src/generated/types/unix_timestamp.rs new file mode 100644 index 00000000..62d0860b --- /dev/null +++ b/clients/rust/src/generated/types/unix_timestamp.rs @@ -0,0 +1,8 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +pub type UnixTimestamp = i64; diff --git a/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 a987f507..30f0df56 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -18,6 +18,8 @@ program-id = "Stake11111111111111111111111111111111111111" [dependencies] borsh = { version = "1.5.7", features = ["derive", "unstable__schema"], optional = true } +codama = "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..251381f3 --- /dev/null +++ b/interface/build.rs @@ -0,0 +1,35 @@ +//! 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..8ad89a0a 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": "lockupParams", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "unixTimestamp", + "type": { + "item": { + "kind": "definedTypeLinkNode", + "name": "unixTimestamp" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "epoch", + "type": { + "item": { + "kind": "definedTypeLinkNode", + "name": "epoch" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "custodian", + "type": { + "item": { + "kind": "publicKeyTypeNode" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + } + ], + "kind": "structTypeNode" } - ], - "args": [ - { - "name": "arg0", - "type": { - "defined": "Authorized" - } - }, - { - "name": "arg1", - "type": { - "defined": "Lockup" - } + }, + { + "kind": "definedTypeNode", + "name": "lockupCheckedParams", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "unixTimestamp", + "type": { + "item": { + "kind": "definedTypeLinkNode", + "name": "unixTimestamp" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "epoch", + "type": { + "item": { + "kind": "definedTypeLinkNode", + "name": "epoch" + }, + "kind": "optionTypeNode", + "prefix": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + } + ], + "kind": "structTypeNode" } - ], - "discriminant": { - "type": "u32", - "value": 0 - } - }, - { - "name": "Authorize", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account to be updated" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake or withdraw authority" - ] - }, - { - "name": "lockupAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "Lockup authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "authorizeWithSeedParams", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "newAuthorizedPubkey", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "stakeAuthorize", + "type": { + "kind": "definedTypeLinkNode", + "name": "stakeAuthorize" + } + }, + { + "kind": "structFieldTypeNode", + "name": "authoritySeed", + "type": { + "kind": "sizePrefixTypeNode", + "prefix": { + "endian": "le", + "format": "u32", + "kind": "numberTypeNode" + }, + "type": { + "encoding": "utf8", + "kind": "stringTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "authorityOwner", + "type": { + "kind": "publicKeyTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [ - { - "name": "arg0", - "type": "publicKey" - }, - { - "name": "arg1", - "type": { - "defined": "StakeAuthorize" - } + }, + { + "kind": "definedTypeNode", + "name": "authorizeCheckedWithSeedParams", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "stakeAuthorize", + "type": { + "kind": "definedTypeLinkNode", + "name": "stakeAuthorize" + } + }, + { + "kind": "structFieldTypeNode", + "name": "authoritySeed", + "type": { + "kind": "sizePrefixTypeNode", + "prefix": { + "endian": "le", + "format": "u32", + "kind": "numberTypeNode" + }, + "type": { + "encoding": "utf8", + "kind": "stringTypeNode" + } + } + }, + { + "kind": "structFieldTypeNode", + "name": "authorityOwner", + "type": { + "kind": "publicKeyTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "discriminant": { - "type": "u32", - "value": 1 - } - }, - { - "name": "DelegateStake", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Initialized stake account to be delegated" - ] - }, - { - "name": "vote", - "isMut": false, - "isSigner": false, - "docs": [ - "Vote account to which this stake will be delegated" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "stakeHistory", - "isMut": false, - "isSigner": false, - "docs": [ - "Stake history sysvar" - ] - }, - { - "name": "unused", - "isMut": false, - "isSigner": false, - "docs": [ - "Unused account, formerly the stake config" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "stakeFlags", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "bits", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 2 - } - }, - { - "name": "Split", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account to be split" - ] - }, - { - "name": "splitStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Uninitialized stake account" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" + }, + { + "kind": "definedTypeNode", + "name": "stakeState", + "type": { + "kind": "enumTypeNode", + "size": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + }, + "variants": [ + { + "kind": "enumEmptyVariantTypeNode", + "name": "uninitialized" + }, + { + "kind": "enumTupleVariantTypeNode", + "name": "initialized", + "tuple": { + "items": [ + { + "kind": "definedTypeLinkNode", + "name": "meta" + } + ], + "kind": "tupleTypeNode" + } + }, + { + "kind": "enumTupleVariantTypeNode", + "name": "stake", + "tuple": { + "items": [ + { + "kind": "definedTypeLinkNode", + "name": "meta" + }, + { + "kind": "definedTypeLinkNode", + "name": "stake" + } + ], + "kind": "tupleTypeNode" + } + }, + { + "kind": "enumEmptyVariantTypeNode", + "name": "rewardsPool" + } ] } - ], - "args": [ - { - "name": "args", - "type": "u64" - } - ], - "discriminant": { - "type": "u32", - "value": 3 - } - }, - { - "name": "Withdraw", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account from which to withdraw" - ] - }, - { - "name": "recipient", - "isMut": true, - "isSigner": false, - "docs": [ - "Recipient account" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "stakeHistory", - "isMut": false, - "isSigner": false, - "docs": [ - "Stake history sysvar" - ] - }, - { - "name": "withdrawAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Withdraw authority" - ] - }, - { - "name": "lockupAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "Lockup authority" + }, + { + "kind": "definedTypeNode", + "name": "stakeStateV2", + "type": { + "kind": "enumTypeNode", + "size": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + }, + "variants": [ + { + "kind": "enumEmptyVariantTypeNode", + "name": "uninitialized" + }, + { + "kind": "enumTupleVariantTypeNode", + "name": "initialized", + "tuple": { + "items": [ + { + "kind": "definedTypeLinkNode", + "name": "meta" + } + ], + "kind": "tupleTypeNode" + } + }, + { + "kind": "enumTupleVariantTypeNode", + "name": "stake", + "tuple": { + "items": [ + { + "kind": "definedTypeLinkNode", + "name": "meta" + }, + { + "kind": "definedTypeLinkNode", + "name": "stake" + }, + { + "kind": "definedTypeLinkNode", + "name": "stakeFlags" + } + ], + "kind": "tupleTypeNode" + } + }, + { + "kind": "enumEmptyVariantTypeNode", + "name": "rewardsPool" + } ] } - ], - "args": [ - { - "name": "args", - "type": "u64" - } - ], - "discriminant": { - "type": "u32", - "value": 4 - } - }, - { - "name": "Deactivate", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Delegated stake account" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" + }, + { + "kind": "definedTypeNode", + "name": "stakeAuthorize", + "type": { + "kind": "enumTypeNode", + "size": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + }, + "variants": [ + { + "kind": "enumEmptyVariantTypeNode", + "name": "staker" + }, + { + "kind": "enumEmptyVariantTypeNode", + "name": "withdrawer" + } ] } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 5 - } - }, - { - "name": "SetLockup", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Initialized stake account" - ] - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "docs": [ - "Lockup authority or withdraw authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "lockup", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "unixTimestamp", + "type": { + "kind": "definedTypeLinkNode", + "name": "unixTimestamp" + } + }, + { + "kind": "structFieldTypeNode", + "name": "epoch", + "type": { + "kind": "definedTypeLinkNode", + "name": "epoch" + } + }, + { + "kind": "structFieldTypeNode", + "name": "custodian", + "type": { + "kind": "publicKeyTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [ - { - "name": "lockupArgs", - "type": { - "defined": "LockupArgs" - } + }, + { + "kind": "definedTypeNode", + "name": "authorized", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "staker", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "withdrawer", + "type": { + "kind": "publicKeyTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "discriminant": { - "type": "u32", - "value": 6 - } - }, - { - "name": "Merge", - "accounts": [ - { - "name": "destinationStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Destination stake account" - ] - }, - { - "name": "sourceStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Source stake account" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "stakeHistory", - "isMut": false, - "isSigner": false, - "docs": [ - "Stake history sysvar" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "meta", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "rentExemptReserve", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "authorized", + "type": { + "kind": "definedTypeLinkNode", + "name": "authorized" + } + }, + { + "kind": "structFieldTypeNode", + "name": "lockup", + "type": { + "kind": "definedTypeLinkNode", + "name": "lockup" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 7 - } - }, - { - "name": "AuthorizeWithSeed", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account to be updated" - ] - }, - { - "name": "base", - "isMut": false, - "isSigner": true, - "docs": [ - "Base key of stake or withdraw authority" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "lockupAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "Lockup authority" - ] + }, + { + "kind": "definedTypeNode", + "name": "delegation", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "voterPubkey", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "stake", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "activationEpoch", + "type": { + "kind": "definedTypeLinkNode", + "name": "epoch" + } + }, + { + "kind": "structFieldTypeNode", + "name": "deactivationEpoch", + "type": { + "kind": "definedTypeLinkNode", + "name": "epoch" + } + }, + { + "kind": "structFieldTypeNode", + "name": "warmupCooldownRate", + "type": { + "endian": "le", + "format": "f64", + "kind": "numberTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "args": [ - { - "name": "authorizeWithSeedArgs", - "type": { - "defined": "AuthorizeWithSeedArgs" - } + }, + { + "kind": "definedTypeNode", + "name": "stake", + "type": { + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "delegation", + "type": { + "kind": "definedTypeLinkNode", + "name": "delegation" + } + }, + { + "kind": "structFieldTypeNode", + "name": "creditsObserved", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + } + ], + "kind": "structTypeNode" } - ], - "discriminant": { - "type": "u32", - "value": 8 } - }, - { - "name": "InitializeChecked", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Uninitialized stake account" - ] - }, - { - "name": "rentSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Rent sysvar" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": false, - "docs": [ - "The stake authority" - ] - }, - { - "name": "withdrawAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "The withdraw authority" - ] - } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 9 + ], + "errors": [ + { + "code": 0, + "kind": "errorNode", + "message": "Not enough credits to redeem", + "name": "noCreditsToRedeem" + }, + { + "code": 1, + "kind": "errorNode", + "message": "Lockup has not yet expired", + "name": "lockupInForce" + }, + { + "code": 2, + "kind": "errorNode", + "message": "Stake already deactivated", + "name": "alreadyDeactivated" + }, + { + "code": 3, + "kind": "errorNode", + "message": "One re-delegation permitted per epoch", + "name": "tooSoonToRedelegate" + }, + { + "code": 4, + "kind": "errorNode", + "message": "Split amount is more than is staked", + "name": "insufficientStake" + }, + { + "code": 5, + "kind": "errorNode", + "message": "Stake account with transient stake cannot be merged", + "name": "mergeTransientStake" + }, + { + "code": 6, + "kind": "errorNode", + "message": "Stake account merge failed due to different authority, lockups or state", + "name": "mergeMismatch" + }, + { + "code": 7, + "kind": "errorNode", + "message": "Custodian address not present", + "name": "custodianMissing" + }, + { + "code": 8, + "kind": "errorNode", + "message": "Custodian signature not present", + "name": "custodianSignatureMissing" + }, + { + "code": 9, + "kind": "errorNode", + "message": "Insufficient voting activity in the reference vote account", + "name": "insufficientReferenceVotes" + }, + { + "code": 10, + "kind": "errorNode", + "message": "Stake account is not delegated to the provided vote account", + "name": "voteAddressMismatch" + }, + { + "code": 11, + "kind": "errorNode", + "message": "Stake account has not been delinquent for the minimum epochs required for deactivation", + "name": "minimumDelinquentEpochsForDeactivationNotMet" + }, + { + "code": 12, + "kind": "errorNode", + "message": "Delegation amount is less than the minimum", + "name": "insufficientDelegation" + }, + { + "code": 13, + "kind": "errorNode", + "message": "Stake account with transient or inactive stake cannot be redelegated", + "name": "redelegateTransientOrInactiveStake" + }, + { + "code": 14, + "kind": "errorNode", + "message": "Stake redelegation to the same vote account is not permitted", + "name": "redelegateToSameVoteAccount" + }, + { + "code": 15, + "kind": "errorNode", + "message": "Redelegated stake must be fully activated before deactivation", + "name": "redelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted" + }, + { + "code": 16, + "kind": "errorNode", + "message": "Stake action is not permitted while the epoch rewards period is active", + "name": "epochRewardsActive" } - }, - { - "name": "AuthorizeChecked", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Stake account to be updated" - ] - }, - { - "name": "clockSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "Clock sysvar" - ] - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "docs": [ - "The stake or withdraw authority" - ] - }, - { - "name": "newAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "The new stake or withdraw authority" - ] - }, - { - "name": "lockupAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "Lockup authority" - ] - } - ], - "args": [ - { - "name": "stakeAuthorize", - "type": { - "defined": "StakeAuthorize" + ], + "instructions": [ + { + "accounts": [ + { + "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": "arg0", + "type": { + "kind": "definedTypeLinkNode", + "name": "authorized" + } + }, + { + "kind": "instructionArgumentNode", + "name": "arg1", + "type": { + "kind": "definedTypeLinkNode", + "name": "lockup" + } } - } - ], - "discriminant": { - "type": "u32", - "value": 11 - } - }, - { - "name": "SetLockupChecked", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Initialized stake account" - ] - }, - { - "name": "authority", - "isMut": false, - "isSigner": true, - "docs": [ - "Lockup authority or withdraw authority" - ] - }, - { - "name": "newAuthority", - "isMut": false, - "isSigner": true, - "isOptional": true, - "docs": [ - "New lockup authority" - ] - } - ], - "args": [ - { - "name": "lockupCheckedArgs", - "type": { - "defined": "LockupCheckedArgs" + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 } - } - ], - "discriminant": { - "type": "u32", - "value": 12 - } - }, - { - "name": "GetMinimumDelegation", - "accounts": [], - "args": [], - "discriminant": { - "type": "u32", - "value": 13 - } - }, - { - "name": "DeactivateDelinquent", - "accounts": [ - { - "name": "stake", - "isMut": true, - "isSigner": false, - "docs": [ - "Delegated stake account" - ] - }, - { - "name": "delinquentVote", - "isMut": false, - "isSigner": false, - "docs": [ - "Delinquent vote account" - ] - }, - { - "name": "referenceVote", - "isMut": false, - "isSigner": false, - "docs": [ - "Reference vote account" - ] - } - ], - "args": [], - "discriminant": { - "type": "u32", - "value": 14 - } - }, - { - "name": "Redelegate", - "accounts": [], - "args": [], - "discriminant": { - "type": "u32", - "value": 15 - } - }, - { - "name": "MoveStake", - "accounts": [ - { - "name": "sourceStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Active source stake account" - ] - }, - { - "name": "destinationStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Active or inactive destination stake account" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" - ] - } - ], - "args": [ - { - "name": "args", - "type": "u64" - } - ], - "discriminant": { - "type": "u32", - "value": 16 - } - }, - { - "name": "MoveLamports", - "accounts": [ - { - "name": "sourceStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Active or inactive source stake account" - ] - }, - { - "name": "destinationStake", - "isMut": true, - "isSigner": false, - "docs": [ - "Mergeable destination stake account" - ] - }, - { - "name": "stakeAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "Stake authority" - ] - } - ], - "args": [ - { - "name": "args", - "type": "u64" - } - ], - "discriminant": { - "type": "u32", - "value": 17 - } - } - ], - "types": [ - { - "name": "LockupArgs", - "type": { - "kind": "struct", - "fields": [ - { - "name": "unixTimestamp", + ], + "kind": "instructionNode", + "name": "initialize" + }, + { + "accounts": [ + { + "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": "arg0", "type": { - "option": { - "defined": "Epoch" - } + "kind": "publicKeyTypeNode" } }, { - "name": "custodian", + "kind": "instructionArgumentNode", + "name": "arg1", "type": { - "option": "publicKey" + "kind": "definedTypeLinkNode", + "name": "stakeAuthorize" } } - ] - } - }, - { - "name": "LockupCheckedArgs", - "type": { - "kind": "struct", - "fields": [ - { - "name": "unixTimestamp", + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "authorize" + }, + { + "accounts": [ + { + "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": "unused" + }, + { + "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" + }, + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "splitStake" }, { - "name": "epoch", + "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" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" }, { - "name": "authoritySeed", - "type": "string" + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeHistorySysvar" }, { - "name": "authorityOwner", - "type": "publicKey" + "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": "lockupArgs", "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": "destinationStake" + }, + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "sourceStake" }, { - "name": "custodian", - "type": "publicKey" + "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" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "base" }, { - "name": "withdrawer", - "type": "publicKey" + "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": "authorizeWithSeedArgs", "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" }, { - "name": "stake", - "type": "u64" + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "authority" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "newAuthority" + }, + { + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "lockupAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 10 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } }, { - "name": "activationEpoch", + "kind": "instructionArgumentNode", + "name": "stakeAuthorize", "type": { - "defined": "Epoch" + "kind": "definedTypeLinkNode", + "name": "stakeAuthorize" } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "authorizeChecked" + }, + { + "accounts": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "stake" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "base" + }, + { + "isSigner": false, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "clockSysvar" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "newAuthority" }, { - "name": "deactivationEpoch", + "isOptional": true, + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "lockupAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 11 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "defined": "Epoch" + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } }, { - "name": "warmupCooldownRate", + "kind": "instructionArgumentNode", + "name": "authorizeCheckedWithSeedArgs", "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": "newAuthority" + } + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 12 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", "type": { - "defined": "Delegation" + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" } }, { - "name": "creditsObserved", - "type": "u64" + "kind": "instructionArgumentNode", + "name": "lockupCheckedArgs", + "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": "sourceStake" }, { - "name": "RewardsPool" + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "destinationStake" + }, + { + "isSigner": true, + "isWritable": false, + "kind": "instructionAccountNode", + "name": "stakeAuthority" } - ] - } - }, - { - "name": "StakeStateV2", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Uninitialized" + ], + "arguments": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 16 + }, + "defaultValueStrategy": "omitted", + "kind": "instructionArgumentNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } }, { - "name": "Initialized", - "fields": [ - { - "defined": "Meta" - } - ] + "kind": "instructionArgumentNode", + "name": "args", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], + "kind": "instructionNode", + "name": "moveStake" + }, + { + "accounts": [ + { + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "sourceStake" }, { - "name": "Stake", - "fields": [ - { - "defined": "Meta" - }, - { - "defined": "Stake" - }, - { - "defined": "StakeFlags" - } - ] + "isSigner": false, + "isWritable": true, + "kind": "instructionAccountNode", + "name": "destinationStake" }, { - "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": "args", + "type": { + "endian": "le", + "format": "u64", + "kind": "numberTypeNode" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 } - ] + ], + "kind": "instructionNode", + "name": "moveLamports" } - } - ], - "metadata": { - "origin": "shank", - "address": "Stake11111111111111111111111111111111111111", - "binaryVersion": "0.4.2", - "libVersion": "0.4.2" - } + ], + "kind": "programNode", + "name": "solanaStakeInterface", + "pdas": [], + "publicKey": "Stake11111111111111111111111111111111111111", + "version": "2.0.1" + }, + "standard": "codama", + "version": "1.0.0" } diff --git a/interface/src/error.rs b/interface/src/error.rs index 29923230..fb6a5354 100644 --- a/interface/src/error.rs +++ b/interface/src/error.rs @@ -1,70 +1,115 @@ 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..74271dc3 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,9 @@ 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 { arg0: Authorized, arg1: Lockup }, /// Authorize a key to manage stake or withdrawal /// @@ -54,7 +57,11 @@ 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 { arg0: Pubkey, arg1: StakeAuthorize }, /// Delegate a stake to a particular vote account /// @@ -68,6 +75,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 = "unused"))] + #[codama(account(name = "stake_authority", signer))] DelegateStake, /// Split `u64` tokens and stake off a stake account into another stake account. @@ -76,7 +89,10 @@ 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 +106,13 @@ 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 +120,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 +133,9 @@ 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_args: LockupArgs }, /// Merge two stake accounts. /// @@ -134,6 +161,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_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))] Merge, /// Authorize a key to manage stake or withdrawal with a derived key @@ -144,7 +176,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 = "base", signer))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "lockup_authority", optional, signer))] + AuthorizeWithSeed { + authorize_with_seed_args: AuthorizeWithSeedArgs, + }, /// Initialize a stake with authorization information /// @@ -156,6 +194,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 +212,12 @@ 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 +231,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 = "base", signer))] + #[codama(account(name = "clock_sysvar"))] + #[codama(account(name = "new_authority", signer))] + #[codama(account(name = "lockup_authority", optional, signer))] + AuthorizeCheckedWithSeed { + authorize_checked_with_seed_args: AuthorizeCheckedWithSeedArgs, + }, /// Set stake lockup /// @@ -198,7 +252,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_authority", optional, signer))] + SetLockupChecked { + lockup_checked_args: LockupCheckedArgs, + }, /// Get the minimum stake delegation, in lamports /// @@ -223,6 +282,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 +308,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 +330,11 @@ 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 = "sourceStake", writable))] + #[codama(account(name = "destinationStake", writable))] + #[codama(account(name = "stake_authority", signer))] + // 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. @@ -282,35 +349,42 @@ pub enum StakeInstruction { /// 2. `[SIGNER]` Stake authority /// /// The `u64` is the portion of available lamports to move - MoveLamports(u64), + #[codama(account(name = "source_stake", writable))] + #[codama(account(name = "destination_stake", writable))] + #[codama(account(name = "stake_authority", signer))] + // 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 = "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)] +#[codama(name = "lockupCheckedParams")] #[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)] +#[codama(name = "authorizeWithSeedParams")] #[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 +392,12 @@ pub struct AuthorizeWithSeedArgs { pub authority_owner: Pubkey, } +#[derive(CodamaType, Debug, PartialEq, Eq, Clone)] +#[codama(name = "authorizeCheckedWithSeedParams")] #[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 +408,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 { + arg0: *authorized, + arg1: *lockup, + }, vec![ AccountMeta::new(*stake_pubkey, false), AccountMeta::new_readonly(RENT_ID, false), @@ -454,7 +532,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 +671,10 @@ pub fn authorize( Instruction::new_with_bincode( ID, - &StakeInstruction::Authorize(*new_authorized_pubkey, stake_authorize), + &StakeInstruction::Authorize { + arg0: *new_authorized_pubkey, + arg1: stake_authorize, + }, account_metas, ) } @@ -619,7 +700,7 @@ pub fn authorize_checked( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeChecked(stake_authorize), + &StakeInstruction::AuthorizeChecked { stake_authorize }, account_metas, ) } @@ -653,7 +734,9 @@ pub fn authorize_with_seed( Instruction::new_with_bincode( ID, - &StakeInstruction::AuthorizeWithSeed(args), + &StakeInstruction::AuthorizeWithSeed { + authorize_with_seed_args: args, + }, account_metas, ) } @@ -687,7 +770,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, ) } @@ -730,7 +815,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 +838,13 @@ 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_args: *lockup, + }, + account_metas, + ) } #[cfg(feature = "bincode")] @@ -776,7 +867,9 @@ pub fn set_lockup_checked( } Instruction::new_with_bincode( ID, - &StakeInstruction::SetLockupChecked(lockup_checked), + &StakeInstruction::SetLockupChecked { + lockup_checked_args: lockup_checked, + }, account_metas, ) } @@ -881,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")] @@ -897,7 +994,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 { args: 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..79be1158 100644 --- a/interface/src/state.rs +++ b/interface/src/state.rs @@ -13,6 +13,7 @@ use { stake_flags::StakeFlags, stake_history::{StakeHistoryEntry, StakeHistoryGetEntry}, }, + codama_macros::{codama, CodamaType}, solana_clock::{Clock, Epoch, UnixTimestamp}, solana_instruction::error::InstructionError, solana_pubkey::Pubkey, @@ -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..5edcc397 100644 --- a/scripts/generate-clients.mts +++ b/scripts/generate-clients.mts @@ -1,16 +1,15 @@ #!/usr/bin/env zx import 'zx/globals'; import * as c from 'codama'; -import { rootNodeFromAnchor } from '@codama/nodes-from-anchor'; import { renderVisitor as renderJavaScriptVisitor } from '@codama/renderers-js'; import { renderVisitor as renderRustVisitor } from '@codama/renderers-rust'; import { getToolchainArgument, workingDirectory } from './utils.mts'; -// Instanciate Codama from the IDL. +// Load the auto-generated IDL from Codama macros const idl = JSON.parse( fs.readFileSync(path.join(workingDirectory, 'interface', 'idl.json'), 'utf-8') ); -const codama = c.createFromRoot(rootNodeFromAnchor(idl)); +const codama = c.createFromRoot(idl); // Rename the program. codama.update( @@ -26,18 +25,56 @@ codama.update( }) ); -// Add missing types from the IDL. +// Rename instruction argument types to avoid collisions with encoder arg types +codama.update( + c.updateDefinedTypesVisitor({ + lockupArgs: { name: 'lockupParams' }, + lockupCheckedArgs: { name: 'lockupCheckedParams' }, + authorizeWithSeedArgs: { name: 'authorizeWithSeedParams' }, + authorizeCheckedWithSeedArgs: { name: 'authorizeCheckedWithSeedParams' }, + }) +); + +// Add type aliases for semantic external types codama.update( c.bottomUpTransformerVisitor([ { - select: '[programNode]stake', + select: '[programNode]', + transform: (node) => { + c.assertIsNode(node, 'programNode'); + return { + ...node, + definedTypes: [ + // Add Epoch type alias + c.definedTypeNode({ + name: 'epoch', + type: c.numberTypeNode('u64'), + }), + // Add UnixTimestamp type alias + c.definedTypeNode({ + name: 'unixTimestamp', + type: c.numberTypeNode('i64'), + }), + ...node.definedTypes, + ], + }; + }, + }, + ]) +); + +// Apply transformations to the IDL +codama.update( + c.bottomUpTransformerVisitor([ + { + select: '[programNode]', transform: (node) => { c.assertIsNode(node, 'programNode'); return { ...node, accounts: [ ...node.accounts, - // stake account + // Stake account wrapper for client convenience c.accountNode({ name: 'stakeStateAccount', data: c.structTypeNode([ @@ -48,125 +85,9 @@ codama.update( ]), }), ], - errors: [ - c.errorNode({ - code: 0, - name: 'NoCreditsToRedeem', - message: 'Not enough credits to redeem', - }), - c.errorNode({ - code: 1, - name: 'LockupInForce', - message: 'Lockup has not yet expired', - }), - c.errorNode({ - code: 2, - name: 'AlreadyDeactivated', - message: 'Stake already deactivated', - }), - c.errorNode({ - code: 3, - name: 'TooSoonToRedelegate', - message: 'One re-delegation permitted per epoch', - }), - c.errorNode({ - code: 4, - name: 'InsufficientStake', - message: 'Split amount is more than is staked', - }), - c.errorNode({ - code: 5, - name: 'MergeTransientStake', - message: 'Stake account with transient stake cannot be merged', - }), - c.errorNode({ - code: 6, - name: 'MergeMismatch', - message: - 'Stake account merge failed due to different authority, lockups or state', - }), - c.errorNode({ - code: 7, - name: 'CustodianMissing', - message: 'Custodian address not present', - }), - c.errorNode({ - code: 8, - name: 'CustodianSignatureMissing', - message: 'Custodian signature not present', - }), - c.errorNode({ - code: 9, - name: 'InsufficientReferenceVotes', - message: - 'Insufficient voting activity in the reference vote account', - }), - c.errorNode({ - code: 10, - name: 'VoteAddressMismatch', - message: - 'Stake account is not delegated to the provided vote account', - }), - c.errorNode({ - code: 11, - name: 'MinimumDelinquentEpochsForDeactivationNotMet', - message: - 'Stake account has not been delinquent for the minimum epochs required for deactivation', - }), - c.errorNode({ - code: 12, - name: 'InsufficientDelegation', - message: 'Delegation amount is less than the minimum', - }), - c.errorNode({ - code: 13, - name: 'RedelegateTransientOrInactiveStake', - message: - 'Stake account with transient or inactive stake cannot be redelegated', - }), - c.errorNode({ - code: 14, - name: 'RedelegateToSameVoteAccount', - message: - 'Stake redelegation to the same vote account is not permitted', - }), - c.errorNode({ - code: 15, - name: 'RedelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted', - message: - 'Redelegated stake must be fully activated before deactivation', - }), - c.errorNode({ - code: 16, - name: 'EpochRewardsActive', - message: - 'Stake action is not permitted while the epoch rewards period is active', - }), - ], }; }, }, - { - // Epoch -> u64 - select: '[definedTypeLinkNode]epoch', - transform: () => { - return c.numberTypeNode('u64'); - }, - }, - { - // UnixTimestamp -> i64 - select: '[definedTypeLinkNode]unixTimestamp', - transform: () => { - return c.numberTypeNode('i64'); - }, - }, - { - // [definedType]f64 -> [numberType]f64 - select: '[definedTypeLinkNode]f64', - transform: () => { - return c.numberTypeNode('f64'); - }, - }, { // enum discriminator -> u32 select: '[definedTypeNode]stakeState.[enumTypeNode]', @@ -191,10 +112,19 @@ codama.update( }, { // Use omitted optional account strategy for all instructions. + // + 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 + ), + }; }, }, ]) @@ -240,3 +170,4 @@ codama.accept( }, }) ); +